diff options
-rw-r--r-- | biosdevname.spec.fedora | 120 | ||||
-rw-r--r-- | biosdevname.spec.suse | 103 | ||||
-rw-r--r-- | pkg/debian/README.debian | 1 | ||||
-rw-r--r-- | pkg/debian/changelog | 68 | ||||
-rw-r--r-- | pkg/debian/compat | 1 | ||||
-rw-r--r-- | pkg/debian/control | 21 | ||||
-rw-r--r-- | pkg/debian/copyright | 18 | ||||
-rw-r--r-- | pkg/debian/dirs | 5 | ||||
-rw-r--r-- | pkg/debian/docs | 2 | ||||
-rwxr-xr-x | pkg/debian/rules | 96 | ||||
-rw-r--r-- | src/sysfs.c | 68 | ||||
-rw-r--r-- | src/sysfs.h | 2 |
12 files changed, 505 insertions, 0 deletions
diff --git a/biosdevname.spec.fedora b/biosdevname.spec.fedora new file mode 100644 index 0000000..fbf8126 --- /dev/null +++ b/biosdevname.spec.fedora @@ -0,0 +1,120 @@ +Name: biosdevname +Version: 0.3.6 +Release: 1%{?dist} +Summary: Udev helper for naming devices per BIOS names + +Group: System Environment/Base +License: GPLv2 +URL: http://linux.dell.com/files/%{name} +# SMBIOS only exists on these arches. It's also likely that other +# arches don't expect the PCI bus to be sorted breadth-first, or of +# so, there haven't been any comments about that on LKML. +ExclusiveArch: %{ix86} x86_64 ia64 +Source0: http://linux.dell.com/files/%{name}/permalink/%{name}-%{version}.tar.gz +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +BuildRequires: pciutils-devel, zlib-devel +# to figure out how to name the rules file +BuildRequires: udev +# for ownership of /etc/udev/rules.d +Requires: udev + +%description +biosdevname in its simplest form takes a kernel device name as an +argument, and returns the BIOS-given name it "should" be. This is necessary +on systems where the BIOS name for a given device (e.g. the label on +the chassis is "Gb1") doesn't map directly and obviously to the kernel +name (e.g. eth0). + +%prep +%setup -q + +%build +# this is a udev rule, so it needs to live in / rather than /usr +%configure --disable-rpath --prefix=/ --sbindir=/sbin +make %{?_smp_mflags} + + +%install +rm -rf %{buildroot} +make install install-data DESTDIR=%{buildroot} + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%doc COPYING README +/sbin/%{name} +%{_sbindir}/dump_pirq +# hack for either /etc or /lib rules location +/*/udev/rules.d/*.rules +%{_mandir}/man1/%{name}.1* + + +%changelog +* Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.6-1 +- drop biosdevnameS, it's unused and fails to build on F15 + +* Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.5-1 +- install dump_pirq into /usr/sbin +- fix udev rule, skip running if NAME is already set +- move udev rule to /lib/udev/rules.d by default + +* Thu Dec 16 2010 Matt Domsch <mdomsch@fedoraproject.org> - 0.3.4-1 +- drop unnecessary explicit version requirement on udev +- bugfix: start indices at 1 not 0, to match Dell and HP server port designations +- bugfix: don't assign names to unknown devices +- bugfix: don't assign duplicate names + +* Thu Dec 9 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.3-1 +- add back in use of PCI IRQ Routing Table, if info is not provided by + sysfs or SMBIOS + +* Thu Dec 2 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.2-1 +- fix for multi-port cards with bridges +- removal of code for seriously obsolete systems + +* Mon Nov 28 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.1-1 +- remove all policies except 'physical' and 'all_ethN' +- handle SR-IOV devices properly + +* Wed Nov 10 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.0-1 +- add --policy=loms, make it default +- read index and labels from sysfs if available + +* Mon Jul 27 2009 Jordan Hargrave <Jordan_Hargrave@dell.com> 0.2.5-1 +- fix mmap error checking + +* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.4-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Mon Feb 23 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.4-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Tue May 06 2008 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-5 +- use policy=all_names to find breakage + +* Sun Feb 10 2008 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-4 +- rebuild for gcc43 + +* Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-3 +- fix manpage entry in files + +* Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-2 +- rebuild with Requires: udev > 115-3.20070920git + +* Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-1 +- coordinate udev rules usage with udev maintainer +- fix crashes in pcmcia search, in_ethernet(), and incorrect command + line parsing. + +* Mon Aug 27 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.3-1 +- eliminate libbiosdevname.*, pre and post scripts + +* Fri Aug 24 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.2-1 +- ExclusiveArch those arches with SMBIOS and PCI IRQ Routing tables +- eliminate libsysfs dependency, move app to / for use before /usr is mounted. +- build static + +* Mon Aug 20 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.1-1 +- initial release diff --git a/biosdevname.spec.suse b/biosdevname.spec.suse new file mode 100644 index 0000000..ea42dd3 --- /dev/null +++ b/biosdevname.spec.suse @@ -0,0 +1,103 @@ +Name: biosdevname +Version: 0.3.6 +Release: 1%{?dist} +Summary: Udev helper for naming devices per BIOS names + +Group: System Environment/Base +License: GPLv2 +URL: http://linux.dell.com/files/%{name} +# SMBIOS only exists on these arches. It's also likely that other +# arches don't expect the PCI bus to be sorted breadth-first, or of +# so, there haven't been any comments about that on LKML. +ExclusiveArch: %{ix86} x86_64 ia64 +Source0: http://linux.dell.com/files/%{name}/permalink/%{name}-%{version}.tar.gz +BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) +BuildRequires: pciutils-devel, zlib-devel +# to figure out how to name the rules file +BuildRequires: udev +# for ownership of /etc/udev/rules.d +Requires: udev + + +%description +biosdevname in its simplest form takes a kernel device name as an +argument, and returns the BIOS-given name it "should" be. This is necessary +on systems where the BIOS name for a given device (e.g. the label on +the chassis is "Gb1") doesn't map directly and obviously to the kernel +name (e.g. eth0). + +%prep +%setup -q + +%build +# this is a udev rule, so it needs to live in / rather than /usr +%configure --disable-rpath --prefix=/ --sbindir=/sbin +make %{?_smp_mflags} + + +%install +rm -rf %{buildroot} +make install DESTDIR=%{buildroot} + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%doc COPYING README +/sbin/%{name} +%{_sbindir}/dump_pirq +# hack for either /etc or /lib rules location +/*/udev/rules.d/*.rules +%{_mandir}/man1/%{name}.1* + + +%changelog +* Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.6-1 +- drop biosdevnameS, it's unused and fails to build on F15 + +* Tue Jan 25 2011 Matt Domsch <Matt_Domsch@dell.com> - 0.3.5-1 +- install dump_pirq into /usr/sbin +- fix udev rule, skip running if NAME is already set +- move udev rule to /lib/udev/rules.d by default + +* Thu Dec 16 2010 Matt Domsch <mdomsch@fedoraproject.org> - 0.3.4-1 +- drop unnecessary explicit version requirement on udev +- bugfix: start indices at 1 not 0, to match Dell and HP server port designations +- bugfix: don't assign names to unknown devices +- bugfix: don't assign duplicate names + +* Thu Dec 9 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.3-1 +- add back in use of PCI IRQ Routing Table, if info is not provided by + sysfs or SMBIOS + +* Thu Dec 2 2010 Matt Domsch <Matt_Domsch@dell.com> - 0.3.2-1 +- fix for multi-port cards with bridges +- removal of code for seriously obsolete systems + +* Mon Nov 28 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.1-1 +- remove all policies except 'physical' and 'all_ethN' +- handle SR-IOV devices properly + +* Wed Nov 10 2010 Matt Domsch <Matt_Domsch@dell.com> 0.3.0-1 +- add --policy=loms, make it default +- read index and labels from sysfs if available + +* Mon Jul 27 2009 Jordan Hargrave <Jordan_Hargrave@dell.com> 0.2.5-1 +- fix mmap error checking + +* Fri Sep 21 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.4-1 +- coordinate udev rules usage with udev maintainer +- fix crashes in pcmcia search, in_ethernet(), and incorrect command + line parsing. + +* Mon Aug 27 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.3-1 +- eliminate libbiosdevname.*, pre and post scripts + +* Fri Aug 24 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.2-1 +- ExclusiveArch those arches with SMBIOS and PCI IRQ Routing tables +- eliminate libsysfs dependency, move app to / for use before /usr is mounted. +- build static + +* Mon Aug 20 2007 Matt Domsch <Matt_Domsch@dell.com> 0.2.1-1 +- initial release diff --git a/pkg/debian/README.debian b/pkg/debian/README.debian new file mode 100644 index 0000000..a8a5b46 --- /dev/null +++ b/pkg/debian/README.debian @@ -0,0 +1 @@ +When necessary remove /etc/udev/rules.d/z25_persistent-net.rules after installing the package. diff --git a/pkg/debian/changelog b/pkg/debian/changelog new file mode 100644 index 0000000..97d4834 --- /dev/null +++ b/pkg/debian/changelog @@ -0,0 +1,68 @@ +biosdevname (0.3.5) unstable; urgency=low + * drop biosdevnameS, it's unused and fails to build on F15 + + -- Matt Domsch <Matt_Domsch@dell.com> Tue, 25 Jan 2011 14:48:00 -0600 + +biosdevname (0.3.5) unstable; urgency=low + * install dump_pirq into /usr/sbin + * fix udev rule, skip running if NAME is already set + * move udev rule to /lib/udev/rules.d + + -- Matt Domsch <Matt_Domsch@dell.com> Tue, 25 Jan 2011 12:17:00 -0600 + +biosdevname (0.3.4) unstable; urgency=low + * drop unnecessary explicit version requirement on udev + * bugfix: start indices at 1 not 0, to match Dell and HP server port designations + * bugfix: don't assign names to unknown devices + * bugfix: don't assign duplicate names + + -- Matt Domsch <Matt_Domsch@dell.com> Thu, 16 Dec 2010 10:45:00 -0600 + +biosdevname (0.3.3) unstable; urgency=low + + * add back in use of PCI IRQ Routing Table, if info is not provided by + sysfs or SMBIOS + + -- Matt Domsch <Matt_Domsch@dell.com> Thu, 09 Nov 2010 15:31:00 -0600 + + * fix for multi-port cards with bridges + * removal of code for seriously obsolete systems + + -- Matt Domsch <Matt_Domsch@dell.com> Thu, 02 Dec 2010 22:03:00 -0600 + +biosdevname (0.3.1) unstable; urgency=low + + * remove all policies except 'physical' and 'all_ethN' + * handle SR-IOV devices properly + + -- Matt Domsch <Matt_Domsch@dell.com> Mon, 28 Nov 2010 22:05:00 -0600 + +biosdevname (0.3.0) unstable; urgency=low + + * add --policy=loms, use it by default. + * read index and labels from sysfs if available + + -- Matt Domsch <Matt_Domsch@dell.com> Wed, 10 Nov 2010 22:44:23 -0600 + +biosdevname (0.2.4-1) unstable; urgency=low + + * eliminate libsysfs usage, libbiosdevname + * coordinate udev rules usage with udev maintainer + * fix crashes in pcmcia search, in_ethernet(), and incorrect command + line parsing. + + -- Matt Domsch <Matt_Domsch@dell.com> Sat, 21 Sep 2007 10:30:13 -0500 + +biosdevname (0.2.3-1) unstable; urgency=low + + * Initial working release + + -- Matt Domsch <Matt_Domsch@dell.com> Sat, 08 Sep 2007 14:30:13 -0500 + +biosdevname (0.1-1) unstable; urgency=low + + * Initial release. + * bios_dev_name-0.1-usage-and-virtual-device-fix.patch is applied + + -- Rudy Gevaert <Rudy.Gevaert@UGent.be> Wed, 16 May 2007 09:25:13 +0200 + diff --git a/pkg/debian/compat b/pkg/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/pkg/debian/compat @@ -0,0 +1 @@ +5 diff --git a/pkg/debian/control b/pkg/debian/control new file mode 100644 index 0000000..6f7d608 --- /dev/null +++ b/pkg/debian/control @@ -0,0 +1,21 @@ +Source: biosdevname +Section: misc +Priority: optional +Maintainer: Rudy Gevaert <Rudy.Gevaert@UGent.be> +Build-Depends: debhelper (>= 5), autotools-dev, pciutils-dev, pciutils, udev +Standards-Version: 3.7.2 + +Package: biosdevname +Architecture: i386 amd64 ia64 +Depends: ${shlibs:Depends}, udev +Description: biosdevname in its simplest form takes a kernel device name + as an argument, and returns the BIOS-given name it "should" be. + . + This is necessary on systems where the BIOS name for a given device + (e.g. the label on the chassis is "Gb1") doesn't map directly and + obviously to the kernel name (e.g. eth0). + . + This also works as a straight udev rule, which is provided. + . + Home Page: http://linux.dell.com/biosdevname/ + diff --git a/pkg/debian/copyright b/pkg/debian/copyright new file mode 100644 index 0000000..3ecbd9d --- /dev/null +++ b/pkg/debian/copyright @@ -0,0 +1,18 @@ +This package was debianized by Rudy Gevaert <Rudy.Gevaert@UGent.be> on +Wed, 16 May 2007 09:25:13 +0200. + +It was downloaded from http://linux.dell.com/biosdevname/ + +Upstream Author: Matt Domsch <Matt_Domsch@dell.com> + +Copyright: 2006 Dell, Inc + +You are free to distribute this software under the terms of +the GNU General Public License either version 2 of the License. + +On Debian systems, the complete text of the GNU General Public +License can be found in the file `/usr/share/common-licenses/GPL-2'. + +The Debian packaging is (C) 2007, Rudy Gevaert <Rudy.Gevaert@UGent.be> and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. + diff --git a/pkg/debian/dirs b/pkg/debian/dirs new file mode 100644 index 0000000..0aed183 --- /dev/null +++ b/pkg/debian/dirs @@ -0,0 +1,5 @@ +sbin +usr/sbin +lib/udev +etc/udev +usr/share/doc/biosdevname diff --git a/pkg/debian/docs b/pkg/debian/docs new file mode 100644 index 0000000..724e084 --- /dev/null +++ b/pkg/debian/docs @@ -0,0 +1,2 @@ +README +TODO diff --git a/pkg/debian/rules b/pkg/debian/rules new file mode 100755 index 0000000..0183e57 --- /dev/null +++ b/pkg/debian/rules @@ -0,0 +1,96 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +config.status: configure + dh_testdir + # Add here commands to configure the package. + ./configure --disable-rpath --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/ --sbindir=/sbin --mandir=/usr/share/man CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" + + +build: build-stamp + +build-stamp: config.status + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/biosdevname.sgml > biosdevname.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) distclean +ifneq "$(wildcard /usr/share/misc/config.sub)" "" + cp -f /usr/share/misc/config.sub config.sub +endif +ifneq "$(wildcard /usr/share/misc/config.guess)" "" + cp -f /usr/share/misc/config.guess config.guess +endif + + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/biosdevname. + $(MAKE) install DESTDIR=$(CURDIR)/debian/biosdevname + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs ChangeLog + dh_installdocs + dh_installexamples + dh_install + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/src/sysfs.c b/src/sysfs.c new file mode 100644 index 0000000..f2c616e --- /dev/null +++ b/src/sysfs.c @@ -0,0 +1,68 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +/** + * sysfs_path_is_file: Check if the path supplied points to a file + * @path: path to validate + * Returns 0 if path points to file, 1 otherwise + * Copied from sysfsutils-2.1.0 (which is LGPL2.1 or later), relicensed GPLv2 for use here. + */ +int sysfs_path_is_file(const char * path) +{ + struct stat astats; + + if (!path) { + errno = EINVAL; + return 1; + } + if ((lstat(path, &astats)) != 0) { + return 1; + } + if (S_ISREG(astats.st_mode)) + return 0; + + return 1; +} + +int sysfs_read_file(const char * path, char **output) +{ + int ret; + char *result = NULL; + int fd; + unsigned long resultsize = 0; + ssize_t length = 0; + + resultsize = getpagesize(); + result = malloc(resultsize); + if (!result) + return -ENOMEM; + memset(result, 0, resultsize); + + fd = open(path, O_RDONLY); + if (fd < 0) { + ret = fd; + goto free_out; + } + + length = read(fd, result, resultsize-1); + if (length < 0) { + close(fd); + ret = -1; + goto free_out; + } + result[length] = '\0'; + if (result[length-1] == '\n') + result[length-1] = '\0'; + *output = result; + ret = 0; + goto out; +free_out: + free(result); +out: + return ret; +} diff --git a/src/sysfs.h b/src/sysfs.h new file mode 100644 index 0000000..91bfb15 --- /dev/null +++ b/src/sysfs.h @@ -0,0 +1,2 @@ +extern int sysfs_path_is_file(const char *path); +extern int sysfs_read_file(const char *path, char **output); |