diff options
62 files changed, 943 insertions, 329 deletions
diff --git a/.gitignore b/.gitignore index ae9c0fe4ec..e96d00e30c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,23 @@ *.o -*.a -udevd -udevadm -udev_version.h -test-udev - +*.lo +*.la +.libs/ +.deps/ +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +config.h +config.h.in +config.log +config.status +config.guess +config.sub +libtool +ltmain.sh +install-sh +missing +configure +stamp-h1 +depcomp +udev-test-install/ diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000000..855259930e --- /dev/null +++ b/INSTALL @@ -0,0 +1,44 @@ + ./configure + --prefix= + "/usr" - prefix for man pages, include files + --exec-prefix= + "" - the root filesystem, prefix for libs and binaries + --sysconfdir= + "/etc" + --with-libdir-name= + "lib" - directory name for libraries, not a path name + multilib 64bit systems may use "lib64" instead of "lib" + --enable-debug + compile-in verbose debug messages + --disable-logging + disable all logging and compile-out all log strings + --enable-selinux + link against SELInux libraries to set the expected context + for created files + +The installation directories are controlled by $prefix, $exec_prefix +$sysconfdir and $libdir-name. Documentation, development files are +installed below $prefix, binaries are installed below $exec_prefix, +libraries below $exec_prefix/$libdir-name. + +The default configuration for a RPM spec file may look like: + --prefix=%{_prefix} + --exec-prefix="" + --sysconfdir=%{_sysconfdir} + --with-libdir-name=%{_lib} + +The well defined location for scripts and binaries which are called +from rules is /lib/udev/ on all systems and architectures, anything +else is broken. Other packages who use udev, may use the /lib/udev/ +directory to install their rule helper and udev rule files. + +It is recommended to use the /lib/udev/devices/ directory to place +device nodes, directories and symlinks, which are copied to /dev/ +at every bootup. That way, nodes for devices which can not be +detected automatically, or are activated on-demand by opening the +pre-existing device node, will be available. + +Default udev rules and persistent device naming rules are required +by other software that depends on the data udev collects from the +devices, and should therefore be installed by default with every udev +installation. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000000..8152af012d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,41 @@ +SUBDIRS = \ + udev \ + rules \ + extras + +udevconfdir = $(sysconfdir)/udev +udevconf_DATA = \ + udev.conf + +EXTRA_DIST = \ + udev.conf \ + docs \ + autogen.sh + +distclean-local: + rm -f *~ + rm -rf autom4te.cache + rm -f depcomp aclocal.m4 config.h.in configure install-sh + rm -f Makefile.in missing config.guess config.sub ltmain.sh + rm -rf udev-test-install + rm -f udev-$(VERSION).tar.gz udev-$(VERSION).tar.bz2 + +ChangeLog: + @ mv $@ $@.tmp + @ echo "Summary of changes from v$(shell echo $$(($(VERSION) - 1))) to v$(VERSION)" >> $@ + @ echo "============================================" >> $@ + @ echo >> $@ + @ git log --pretty=short $(shell echo $$(($(VERSION) - 1)))..HEAD | git shortlog >> $@ + @ echo >> $@ + @ cat $@ + @ cat $@.tmp >> $@ + @ rm $@.tmp + +test-run: + cd test && ./udev-test.pl + +test-install: + rm -rf $(PWD)/udev-test-install/ + make DESTDIR=$(PWD)/udev-test-install install + tree $(PWD)/udev-test-install/ + @@ -1,3 +1,27 @@ +udev 126 +======== +We use ./configure now. See INSTALL for details. Current +options are: + --prefix= + "/usr" - prefix for man pages, include files + --exec-prefix= + "" - the root filesystem, prefix for libs and binaries + --sysconfdir= + "/etc" + --with-libdir-name= + "lib" - directory name for libraries, not a path name + multilib 64bit systems may use "lib64" instead of "lib" + --enable-debug + compile-in verbose debug messages + --disable-logging + disable all logging and compile-out all log strings + --enable-selinux + link against SELInux libraries to set the expected context + for created files + +No symlinks to udevadm are installed anymore, if still neded, the +package should create them. + udev 125 ======== Bugfixes. @@ -17,19 +17,19 @@ Requirements: (unix domain sockets (CONFIG_UNIX) as a loadable kernel module may work, but it does not make any sense - don't complain if anything goes wrong.) - - The proc filesystem must be mounted on /proc, the sysfs filesystem must - be mounted at /sys. No other locations are supported by udev. + - The proc filesystem must be mounted on /proc/, the sysfs filesystem must + be mounted at /sys/. No other locations are supported by udev. Operation: - Udev creates and removes device nodes in /dev, based on events the kernel + Udev creates and removes device nodes in /dev/, based on events the kernel sends out on device discovery or removal. - - Very early in the boot process, the /dev directory should get a 'tmpfs' + - Very early in the boot process, the /dev/ directory should get a 'tmpfs' filesystem mounted, which is populated from scratch by udev. Created nodes or changed permissions will not survive a reboot, which is intentional. - - The content of /lib/udev/devices directory which contains the nodes, + - The content of /lib/udev/devices/ directory which contains the nodes, symlinks and directories, which are always expected to be in /dev, should be copied over to the tmpfs mounted /dev, to provide the required nodes to initialize udev and continue booting. @@ -48,44 +48,6 @@ Operation: device node with the default kernel name, or the one specified by a matching udev rule. - -Compile Options: - DESTDIR - Prefix of install target, used for package building. - USE_LOG - If set to 'true', udev is able to pass errors or debug information - to syslog. This is very useful to see what udev is doing or not doing. - It is enabled by default, don't expect any useful answer, if you - need to hunt a bug, but you can't enable syslog. - DEBUG - If set to 'true', very verbose debugging messages will be compiled - into the udev binaries. The actual level of debugging is specified - in the udev config file. - USE_SELINUX - If set to 'true', udev will be built with SELinux support - enabled. This is disabled by default. - EXTRAS - list of helper programs in extras/ to build. - make EXTRAS="extras/cdrom_id extras/scsi_id extras/volume_id" - - -Installation: - - The install target intalls the udev binaries in the default locations, - All binaries will be installed in /lib/udev or /sbin. - - - The default location for scripts and binaries that are called from - rules is /lib/udev. Other packages who install udev rules, may use - that directory too. - - - It is recommended to use the /lib/udev/devices/ directory to place - device nodes and symlinks in, which are copied to /dev at every boot. - That way, nodes for broken subsystems or devices which can't be - detected automatically by the kernel, will always be available. - - - Default udev rules and persistent device naming rules are required by other - software that depends on the data udev collects from the devices, - and should be installed by default with every udev installation. - -Please direct any comment/question/concern to the linux-hotplug-devel mailing list at: +Please direct any comment/question/concern to the linux-hotplug mailing list at: linux-hotplug@vger.kernel.org diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000000..b01012eb2e --- /dev/null +++ b/autogen.sh @@ -0,0 +1,57 @@ +#!/bin/sh -e + +(autopoint --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autopoint installed to generate the build system.." + echo + exit 1 +} +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to generate the build system." + echo + exit 1 +} +(libtoolize --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have libtool installed to generate the build system." + echo + exit 1 +} +(autoheader --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoheader installed to generate the build system." + echo + exit 1 +} +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have automake installed to generate the build system." + echo + exit 1 +} + +test -f udev/udevd.c || { + echo "You must run this script in the top-level source directory" + exit 1 +} + +echo " aclocal: $(aclocal --version | head -1)" +aclocal +echo " autoconf: $(autoconf --version | head -1)" +autoconf +echo " libtool: $(automake --version | head -1)" +libtoolize --force +echo " autoheader: $(autoheader --version | head -1)" +autoheader +echo " automake: $(automake --version | head -1)" +automake --add-missing + +if test -z "$@"; then + args="--prefix=/usr --exec-prefix= --sysconfdir=/etc" +else + args=$@ +fi +echo " configure: $args" +echo +./configure $args diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000000..0ec8e204e3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,118 @@ +AC_INIT(udev, + 126, + kay.sievers@vrfy.org) + +AC_PREREQ(2.60) +AC_CONFIG_SRCDIR(udev/udevd.c) +AM_INIT_AUTOMAKE([check-news foreign -Wall 1.9 dist-bzip2]) +AC_GNU_SOURCE +AC_DISABLE_STATIC +AC_SYS_LARGEFILE +AC_PROG_LIBTOOL + +dnl /* libvolume_id version */ +VOLID_LT_CURRENT=0 +VOLID_LT_REVISION=86 +VOLID_LT_AGE=0 +AC_SUBST(VOLID_LT_CURRENT) +AC_SUBST(VOLID_LT_REVISION) +AC_SUBST(VOLID_LT_AGE) + +AC_PATH_PROG([XSLTPROC], [xsltproc]) + +AC_CHECK_LIB(c, inotify_init, + [AC_DEFINE([HAVE_INOTIFY], 1, [inotify available])], + [AC_MSG_WARN([inotify support disabled])]) + +AC_CHECK_LIB(c, strlcpy, + [AC_DEFINE([HAVE_STRLCPY], 1, [strlcpy available])], + []) + +AC_ARG_WITH(udev-prefix, + AS_HELP_STRING([--with-udev-prefix=DIR], [add prefix to internal udev path names]), + [], [with_udev_prefix='${exec_prefix}']) +udev_prefix=$with_udev_prefix +AC_SUBST(udev_prefix) + +AC_ARG_WITH(libdir-name, + AS_HELP_STRING([--with-libdir-name=DIR], [name of the arch lib directory]), + [], [with_libdir_name=lib]) +libdir_name=$with_libdir_name +AC_SUBST(libdir_name) + +AC_ARG_WITH(selinux, + AS_HELP_STRING([--with-selinux], [compile with SELinux support]), + [], with_selinux=no) +if test "x$with_selinux" = xyes; then + LIBS_save=$LIBS + AC_CHECK_LIB(selinux, getprevcon, + [], + AC_MSG_ERROR([SELinux selected but libselinux not found])) + LIBS=$LIBS_save + AC_DEFINE(USE_SELINUX, [1] ,[compile with SELinux support]) + SELINUX_LIBS="-lselinux" +fi +AC_SUBST([SELINUX_LIBS]) +AM_CONDITIONAL(USE_SELINUX, [test "x$with_selinux" = xyes], [compile with SELinux support]) + +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug], [turn on debugging]), + [], enable_debug=no) +if test "x$enable_debug" = "xyes"; then + AC_DEFINE(DEBUG, [1] ,[Compile in debug messages]) + DEBUG_CFLAGS="-DDEBUG" +fi +AC_SUBST(DEBUG_CFLAGS) + +AC_ARG_ENABLE(logging, + AS_HELP_STRING([--disable-logging], [turn off logging/syslog]), + [], enable_logging=yes) +if test "x$enable_logging" != "xno"; then + AC_DEFINE(USE_LOG, [1] ,[Use logging/syslog]) +fi + +AC_CONFIG_HEADERS(config.h) +AC_CONFIG_FILES([ + Makefile + udev/Makefile + rules/Makefile + extras/Makefile + extras/ata_id/Makefile + extras/cdrom_id/Makefile + extras/edd_id/Makefile + extras/path_id/Makefile + extras/firmware/Makefile + extras/collect/Makefile + extras/floppy/Makefile + extras/fstab_import/Makefile + extras/rule_generator/Makefile + extras/scsi_id/Makefile + extras/usb_id/Makefile + extras/volume_id/Makefile + extras/volume_id/lib/Makefile + extras/volume_id/lib/libvolume_id.pc +]) +AC_OUTPUT + +echo " + udev $VERSION + ======== + + prefix: ${prefix} + exec_prefix: ${exec_prefix} + udev_prefix: ${udev_prefix} + libdir_name: ${libdir_name} + datarootdir: ${datarootdir} + mandir: ${mandir} + includedir: ${includedir} + + logging: ${enable_logging} + debug: ${enable_debug} + selinux: ${with_selinux} + + compiler: ${CC} + cflags: ${CFLAGS} + ldflags: ${LDFLAGS} + + xsltproc: ${XSLTPROC} +" diff --git a/extras/Makefile.am b/extras/Makefile.am new file mode 100644 index 0000000000..f72e0b1f5f --- /dev/null +++ b/extras/Makefile.am @@ -0,0 +1,16 @@ +SUBDIRS = \ + ata_id \ + cdrom_id \ + edd_id \ + path_id \ + firmware \ + collect \ + floppy \ + fstab_import \ + rule_generator \ + scsi_id \ + usb_id \ + volume_id + +distclean-local: + rm -f Makefile.in diff --git a/extras/ata_id/Makefile.am b/extras/ata_id/Makefile.am new file mode 100644 index 0000000000..81332dd3f6 --- /dev/null +++ b/extras/ata_id/Makefile.am @@ -0,0 +1,20 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + ata_id + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +ata_id_SOURCES = \ + ata_id.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +dist_man_MANS = \ + ata_id.8 + +distclean-local: + rm -f Makefile.in + diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c index 6d3c2330b4..125c3f3dd7 100644 --- a/extras/ata_id/ata_id.c +++ b/extras/ata_id/ata_id.c @@ -26,7 +26,7 @@ #include <linux/types.h> #include <linux/hdreg.h> -#include "../../udev.h" +#include "../../udev/udev.h" #ifdef USE_LOG void log_message(int priority, const char *format, ...) diff --git a/extras/cdrom_id/Makefile.am b/extras/cdrom_id/Makefile.am new file mode 100644 index 0000000000..88de1379cd --- /dev/null +++ b/extras/cdrom_id/Makefile.am @@ -0,0 +1,24 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + cdrom_id + +udevrulesdir = $(udev_prefix)/lib/udev/rules.d +dist_udevrules_DATA = \ + 60-cdrom_id.rules + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +cdrom_id_SOURCES = \ + cdrom_id.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +dist_man_MANS = \ + cdrom_id.8 + +distclean-local: + rm -f Makefile.in + diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c index a1135665a9..acf7a97e41 100644 --- a/extras/cdrom_id/cdrom_id.c +++ b/extras/cdrom_id/cdrom_id.c @@ -37,7 +37,8 @@ #include <sys/time.h> #include <sys/ioctl.h> #include <linux/cdrom.h> -#include "../../udev.h" + +#include "../../udev/udev.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) diff --git a/extras/collect/Makefile.am b/extras/collect/Makefile.am new file mode 100644 index 0000000000..a92f4aa9f5 --- /dev/null +++ b/extras/collect/Makefile.am @@ -0,0 +1,11 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + collect + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +distclean-local: + rm -f Makefile.in + diff --git a/extras/collect/collect.c b/extras/collect/collect.c index ce49b9f410..14184a5e05 100644 --- a/extras/collect/collect.c +++ b/extras/collect/collect.c @@ -31,9 +31,9 @@ #include <sys/types.h> #include <sys/stat.h> -#include "../../list.h" +#include "../../udev/list.h" -#define TMPFILE "/dev/.udev/collect" +#define TMPFILE UDEV_PREFIX "/dev/.udev/collect" #define BUFSIZE 16 #define UDEV_ALARM_TIMEOUT 180 diff --git a/extras/edd_id/Makefile.am b/extras/edd_id/Makefile.am new file mode 100644 index 0000000000..fa4f18c9fb --- /dev/null +++ b/extras/edd_id/Makefile.am @@ -0,0 +1,24 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + edd_id + +udevrulesdir = $(udev_prefix)/lib/udev/rules.d +dist_udevrules_DATA = \ + 61-persistent-storage-edd.rules + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +edd_id_SOURCES = \ + edd_id.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +dist_man_MANS = \ + edd_id.8 + +distclean-local: + rm -f Makefile.in + diff --git a/extras/edd_id/edd_id.c b/extras/edd_id/edd_id.c index 4a177709a8..9d745c505a 100644 --- a/extras/edd_id/edd_id.c +++ b/extras/edd_id/edd_id.c @@ -23,7 +23,7 @@ #include <dirent.h> #include <stdint.h> -#include "../../udev.h" +#include "../../udev/udev.h" #ifdef USE_LOG void log_message(int priority, const char *format, ...) diff --git a/extras/firmware/Makefile.am b/extras/firmware/Makefile.am new file mode 100644 index 0000000000..0c69de9161 --- /dev/null +++ b/extras/firmware/Makefile.am @@ -0,0 +1,7 @@ +udevhomedir = $(udev_prefix)/lib/udev +dist_udevhome_SCRIPTS = \ + firmware.sh + +distclean-local: + rm -f Makefile.in + diff --git a/extras/floppy/Makefile.am b/extras/floppy/Makefile.am new file mode 100644 index 0000000000..4854d5245b --- /dev/null +++ b/extras/floppy/Makefile.am @@ -0,0 +1,29 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + create_floppy_devices + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +create_floppy_devices_SOURCES = \ + create_floppy_devices.c \ + ../../udev/udev_config.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c \ + ../../udev/udev_utils_file.c +if USE_SELINUX +create_floppy_devices_SOURCES += \ + ../../udev/udev_selinux.c + +create_floppy_devices_LDADD = \ + $(SELINUX_LIBS) +endif + +dist_man_MANS = \ + create_floppy_devices.8 + +distclean-local: + rm -f Makefile.in + diff --git a/extras/floppy/create_floppy_devices.c b/extras/floppy/create_floppy_devices.c index d79a782abf..3e73aa83c3 100644 --- a/extras/floppy/create_floppy_devices.c +++ b/extras/floppy/create_floppy_devices.c @@ -24,8 +24,8 @@ #include <pwd.h> #include <grp.h> -#include "../../udev.h" -#include "../../udev_selinux.h" +#include "../../udev/udev.h" +#include "../../udev/udev_selinux.h" static char *table[] = { "", "d360", "h1200", "u360", "u720", "h360", "h720", diff --git a/extras/fstab_import/Makefile.am b/extras/fstab_import/Makefile.am new file mode 100644 index 0000000000..0ee7efb9ce --- /dev/null +++ b/extras/fstab_import/Makefile.am @@ -0,0 +1,21 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + fstab_import + +udevrulesdir = $(udev_prefix)/lib/udev/rules.d +dist_udevrules_DATA = \ + 79-fstab_import.rules + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +fstab_import_SOURCES = \ + fstab_import.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +distclean-local: + rm -f Makefile.in + diff --git a/extras/fstab_import/fstab_import.c b/extras/fstab_import/fstab_import.c index a8de067b38..2d24cfb38a 100644 --- a/extras/fstab_import/fstab_import.c +++ b/extras/fstab_import/fstab_import.c @@ -24,7 +24,7 @@ #include <mntent.h> #include <sys/stat.h> -#include "../../udev.h" +#include "../../udev/udev.h" static int debug; static char root[PATH_SIZE] = "/dev"; diff --git a/extras/path_id/Makefile.am b/extras/path_id/Makefile.am new file mode 100644 index 0000000000..966a03dfaf --- /dev/null +++ b/extras/path_id/Makefile.am @@ -0,0 +1,10 @@ +udevhomedir = $(udev_prefix)/lib/udev +dist_udevhome_SCRIPTS = \ + path_id + +dist_man_MANS = \ + path_id.8 + +distclean-local: + rm -f Makefile.in + diff --git a/extras/rule_generator/Makefile.am b/extras/rule_generator/Makefile.am new file mode 100644 index 0000000000..1f0248b215 --- /dev/null +++ b/extras/rule_generator/Makefile.am @@ -0,0 +1,16 @@ +udevhomedir = $(udev_prefix)/lib/udev +dist_udevhome_SCRIPTS = \ + write_cd_rules \ + write_net_rules + +dist_udevhome_DATA = \ + rule_generator.functions + +udevrulesdir = $(udev_prefix)/lib/udev/rules.d +dist_udevrules_DATA = \ + 75-cd-aliases-generator.rules \ + 75-persistent-net-generator.rules + +distclean-local: + rm -f Makefile.in + diff --git a/extras/scsi_id/Makefile.am b/extras/scsi_id/Makefile.am new file mode 100644 index 0000000000..7f890b04cf --- /dev/null +++ b/extras/scsi_id/Makefile.am @@ -0,0 +1,27 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + scsi_id + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +scsi_id_SOURCES = \ + scsi_id.c \ + scsi_serial.c \ + scsi.h \ + scsi_id.h \ + bsg.h \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +dist_sysconf_DATA = \ + scsi_id.config + +dist_man_MANS = \ + scsi_id.8 + +distclean-local: + rm -f Makefile.in + diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c index bc942fac58..23bcb9468e 100644 --- a/extras/scsi_id/scsi_id.c +++ b/extras/scsi_id/scsi_id.c @@ -14,6 +14,8 @@ * Free Software Foundation version 2 of the License. */ +#include "config.h" + #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -27,9 +29,8 @@ #include <getopt.h> #include <sys/stat.h> -#include "../../udev.h" +#include "../../udev/udev.h" #include "scsi_id.h" -#include "scsi_id_version.h" static const struct option options[] = { { "device", 1, NULL, 'd' }, @@ -51,7 +52,7 @@ static const char dev_short_options[] = "bgp:"; static int all_good; static int dev_specified; -static char config_file[MAX_PATH_LEN] = SCSI_ID_CONFIG_FILE; +static char config_file[MAX_PATH_LEN] = SYSCONFDIR "/scsi_id.config"; static enum page_code default_page_code; static int sg_version = 4; static int use_stderr; @@ -468,7 +469,7 @@ static int set_options(int argc, char **argv, const char *short_opts, break; case 'V': - printf("%s\n", SCSI_ID_VERSION); + printf("%s\n", VERSION); exit(0); break; diff --git a/extras/scsi_id/scsi_serial.c b/extras/scsi_id/scsi_serial.c index 016075c3ea..104db3d95f 100644 --- a/extras/scsi_id/scsi_serial.c +++ b/extras/scsi_id/scsi_serial.c @@ -30,10 +30,9 @@ /* #include <linux/bsg.h> */ #include "bsg.h" -#include "../../udev.h" +#include "../../udev/udev.h" #include "scsi.h" #include "scsi_id.h" -#include "scsi_id_version.h" /* * A priority based list of id, naa, and binary/ascii for the identifier diff --git a/extras/usb_id/Makefile.am b/extras/usb_id/Makefile.am new file mode 100644 index 0000000000..0de004a228 --- /dev/null +++ b/extras/usb_id/Makefile.am @@ -0,0 +1,18 @@ +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + usb_id + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +usb_id_SOURCES = \ + usb_id.c \ + ../../udev/udev_sysfs.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +distclean-local: + rm -f Makefile.in + diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c index fed6631b90..5b78b975d8 100644 --- a/extras/usb_id/usb_id.c +++ b/extras/usb_id/usb_id.c @@ -20,7 +20,7 @@ #include <errno.h> #include <getopt.h> -#include "../../udev.h" +#include "../../udev/udev.h" #define MAX_PATH_LEN 512 #define MAX_SERIAL_LEN 256 diff --git a/extras/volume_id/Makefile.am b/extras/volume_id/Makefile.am new file mode 100644 index 0000000000..bc1b262f27 --- /dev/null +++ b/extras/volume_id/Makefile.am @@ -0,0 +1,33 @@ +SUBDIRS = \ + lib + +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = \ + vol_id + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +vol_id_SOURCES = \ + vol_id.c \ + ../../udev/udev_sysdeps.c \ + ../../udev/udev_utils.c \ + ../../udev/udev_utils_string.c + +vol_id_LDADD = \ + lib/libvolume_id.la + +dist_man_MANS = \ + vol_id.8 + +EXTRA_DIST = \ + vol_id.xml + +%.7 %.8 : %.xml + $(XSLTPROC) -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< + +distclean-local: + rm -f Makefile.in + rm -f $(dist_man_MANS) + diff --git a/extras/volume_id/lib/Makefile.am b/extras/volume_id/lib/Makefile.am new file mode 100644 index 0000000000..de37f9e8b8 --- /dev/null +++ b/extras/volume_id/lib/Makefile.am @@ -0,0 +1,69 @@ +rootlibdir = $(exec_prefix)/$(libdir_name) +rootlib_LTLIBRARIES = \ + libvolume_id.la + +include_HEADERS =\ + libvolume_id.h + +libvolume_id_la_SOURCES =\ + ext.c \ + fat.c \ + hfs.c \ + highpoint.c \ + isw_raid.c \ + lsi_raid.c \ + via_raid.c \ + silicon_raid.c \ + nvidia_raid.c \ + promise_raid.c \ + adaptec_raid.c \ + jmicron_raid.c \ + ddf_raid.c \ + iso9660.c \ + jfs.c \ + linux_raid.c \ + linux_swap.c \ + lvm.c \ + ntfs.c \ + reiserfs.c \ + udf.c \ + ufs.c \ + xfs.c \ + cramfs.c \ + hpfs.c \ + romfs.c \ + sysv.c \ + minix.c \ + gfs.c \ + luks.c \ + ocfs.c \ + vxfs.c \ + squashfs.c \ + netware.c \ + oracleasm.c \ + volume_id.c \ + util.h \ + util.c + +libvolume_id_la_LDFLAGS = \ + -version-info $(VOLID_LT_CURRENT):$(VOLID_LT_REVISION):$(VOLID_LT_AGE) \ + -export-symbols $(top_srcdir)/extras/volume_id/lib/exported_symbols + +# move devel files to $(prefix)$(libdir_name) if needed +install-data-hook: + rm $(DESTDIR)$(rootlibdir)/libvolume_id.la + if test "$(prefix)" != "$(exec_prefix)"; then \ + rm $(DESTDIR)$(rootlibdir)/libvolume_id.so; \ + mkdir -p $(DESTDIR)$(prefix)/$(libdir_name); \ + ln -sf $(rootlibdir)/libvolume_id.so.$(VOLID_LT_CURRENT).$(VOLID_LT_AGE).$(VOLID_LT_REVISION) \ + $(DESTDIR)$(prefix)/$(libdir_name)/libvolume_id.so; \ + fi + +EXTRA_DIST = \ + exported_symbols + +pkgconfigdir = $(prefix)/$(libdir_name)/pkgconfig +pkgconfig_DATA = libvolume_id.pc + +distclean-local: + rm -f Makefile.in diff --git a/extras/volume_id/lib/exported_symbols b/extras/volume_id/lib/exported_symbols index 05b6e52bc4..55b0265825 100644 --- a/extras/volume_id/lib/exported_symbols +++ b/extras/volume_id/lib/exported_symbols @@ -1,64 +1,55 @@ -{ global: - volume_id_log_fn; - - volume_id_get_label; - volume_id_get_label_raw; - volume_id_get_uuid; - volume_id_get_uuid_raw; - volume_id_get_usage; - volume_id_get_type; - volume_id_get_type_version; - - volume_id_open_fd; - volume_id_close; - volume_id_probe_all; - volume_id_probe_filesystem; - volume_id_probe_raid; - volume_id_all_probers; - volume_id_get_prober_by_type; - volume_id_encode_string; - - volume_id_open_node; - - volume_id_probe_linux_swap; - volume_id_probe_luks; - volume_id_probe_cramfs; - volume_id_probe_ext; - volume_id_probe_vfat; - volume_id_probe_hfs_hfsplus; - volume_id_probe_hpfs; - volume_id_probe_iso9660; - volume_id_probe_jfs; - volume_id_probe_minix; - volume_id_probe_ntfs; - volume_id_probe_ocfs1; - volume_id_probe_ocfs2; - volume_id_probe_reiserfs; - volume_id_probe_romfs; - volume_id_probe_sysv; - volume_id_probe_udf; - volume_id_probe_ufs; - volume_id_probe_vxfs; - volume_id_probe_xfs; - volume_id_probe_squashfs; - volume_id_probe_netware; - volume_id_probe_gfs; - volume_id_probe_gfs2; - - volume_id_probe_linux_raid; - volume_id_probe_lvm1; - volume_id_probe_lvm2; - volume_id_probe_ddf_raid; - volume_id_probe_intel_software_raid; - volume_id_probe_highpoint_37x_raid; - volume_id_probe_highpoint_45x_raid; - volume_id_probe_lsi_mega_raid; - volume_id_probe_nvidia_raid; - volume_id_probe_promise_fasttrack_raid; - volume_id_probe_silicon_medley_raid; - volume_id_probe_via_raid; - volume_id_probe_adaptec_raid; - volume_id_probe_jmicron_raid; -local: - *; -}; +volume_id_log_fn +volume_id_get_label +volume_id_get_label_raw +volume_id_get_uuid +volume_id_get_uuid_raw +volume_id_get_usage +volume_id_get_type +volume_id_get_type_version +volume_id_open_fd +volume_id_close +volume_id_probe_all +volume_id_probe_filesystem +volume_id_probe_raid +volume_id_all_probers +volume_id_get_prober_by_type +volume_id_encode_string +volume_id_open_node +volume_id_probe_linux_swap +volume_id_probe_luks +volume_id_probe_cramfs +volume_id_probe_ext +volume_id_probe_vfat +volume_id_probe_hfs_hfsplus +volume_id_probe_hpfs +volume_id_probe_iso9660 +volume_id_probe_jfs +volume_id_probe_minix +volume_id_probe_ntfs +volume_id_probe_ocfs1 +volume_id_probe_ocfs2 +volume_id_probe_reiserfs +volume_id_probe_romfs +volume_id_probe_sysv +volume_id_probe_udf +volume_id_probe_ufs +volume_id_probe_vxfs +volume_id_probe_xfs +volume_id_probe_squashfs +volume_id_probe_netware +volume_id_probe_gfs +volume_id_probe_gfs2 +volume_id_probe_linux_raid +volume_id_probe_lvm1 +volume_id_probe_lvm2 +volume_id_probe_ddf_raid +volume_id_probe_intel_software_raid +volume_id_probe_highpoint_37x_raid +volume_id_probe_highpoint_45x_raid +volume_id_probe_lsi_mega_raid +volume_id_probe_nvidia_raid +volume_id_probe_promise_fasttrack_raid +volume_id_probe_silicon_medley_raid +volume_id_probe_via_raid +volume_id_probe_adaptec_raid +volume_id_probe_jmicron_raid diff --git a/extras/volume_id/lib/libvolume_id.pc.in b/extras/volume_id/lib/libvolume_id.pc.in new file mode 100644 index 0000000000..5a1e1b77ba --- /dev/null +++ b/extras/volume_id/lib/libvolume_id.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@prefix@ +libdir=@prefix@/@libdir_name@ +includedir=@prefix@/include + +Name: libvolume_id +Description: Library for reading metadata, label, uuid from various filesystems +Version: @VERSION@ +Libs: -L${libdir} -lvolume_id +Cflags: -I${includedir} diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c index 5c4e05d794..60428ab582 100644 --- a/extras/volume_id/vol_id.c +++ b/extras/volume_id/vol_id.c @@ -34,7 +34,7 @@ #include <fcntl.h> #include <sys/ioctl.h> -#include "../../udev.h" +#include "../../udev/udev.h" #include "lib/libvolume_id.h" #define BLKGETSIZE64 _IOR(0x12,114,size_t) diff --git a/rules/Makefile.am b/rules/Makefile.am new file mode 100644 index 0000000000..45a64b725b --- /dev/null +++ b/rules/Makefile.am @@ -0,0 +1,25 @@ +udevrulesdir = $(udev_prefix)/lib/udev/rules.d +dist_udevrules_DATA = \ + rules.d/50-udev-default.rules \ + rules.d/60-persistent-storage.rules \ + rules.d/60-persistent-storage-tape.rules \ + rules.d/60-persistent-input.rules \ + rules.d/60-persistent-v4l.rules \ + rules.d/80-drivers.rules \ + rules.d/95-udev-late.rules + +install-data-local: + -mkdir -p $(DESTDIR)$(sysconfdir)/udev/rules.d + +EXTRA_DIST = \ + packages \ + debian \ + redhat \ + suse \ + gentoo \ + slackware \ + frugalware + + +distclean-local: + rm -f Makefile.in diff --git a/test/udev-test.pl b/test/udev-test.pl index f7f68a1416..ad551dd042 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -22,7 +22,7 @@ use strict; my $PWD = $ENV{PWD}; my $sysfs = "sys/"; -my $udev_bin = "../test-udev"; +my $udev_bin = "../udev/test-udev"; my $udev_root = "udev-root/"; my $udev_conf = "udev-test.conf"; my $udev_rules = "udev-test.rules"; diff --git a/udev/.gitignore b/udev/.gitignore new file mode 100644 index 0000000000..5ce11acc15 --- /dev/null +++ b/udev/.gitignore @@ -0,0 +1,6 @@ +*.o +*.a +udevd +udevadm +test-udev +.deps/ diff --git a/udev/Makefile.am b/udev/Makefile.am new file mode 100644 index 0000000000..6402f231f9 --- /dev/null +++ b/udev/Makefile.am @@ -0,0 +1,115 @@ +sbin_PROGRAMS = \ + udevd \ + udevadm + +noinst_PROGRAMS = \ + test-udev + +AM_CPPFLAGS = \ + -DSYSCONFDIR=\""$(sysconfdir)"\" \ + -DUDEV_PREFIX=\""$(udev_prefix)"\" + +udevd_SOURCES = \ + list.h \ + logging.h \ + udev.h \ + udev_rules.h \ + udev_selinux.h \ + udev_sysdeps.h \ + udevd.h \ + udevd.c \ + udev_config.c \ + udev_db.c \ + udev_device.c \ + udev_node.c \ + udev_rules.c \ + udev_rules_parse.c \ + udev_sysdeps.c \ + udev_sysfs.c \ + udev_utils.c \ + udev_utils_file.c \ + udev_utils_string.c +if USE_SELINUX +udevd_SOURCES += \ + udev_selinux.c + +udevd_LDADD = \ + $(SELINUX_LIBS) +endif + +udevadm_SOURCES = \ + list.h \ + logging.h \ + udev.h \ + udev_rules.h \ + udev_selinux.h \ + udev_sysdeps.h \ + udevadm.c \ + udevinfo.c \ + udevcontrol.c \ + udevtest.c \ + udevmonitor.c \ + udevsettle.c \ + udevtrigger.c \ + udev_config.c \ + udev_db.c \ + udev_device.c \ + udev_node.c \ + udev_rules.c \ + udev_rules_parse.c \ + udev_sysdeps.c \ + udev_sysfs.c \ + udev_utils.c \ + udev_utils_file.c \ + udev_utils_string.c +if USE_SELINUX +udevadm_SOURCES += \ + udev_selinux.c + +udevadm_LDADD = \ + $(SELINUX_LIBS) +endif + +test_udev_SOURCES = \ + list.h \ + logging.h \ + udev.h \ + udev_rules.h \ + udev_selinux.h \ + udev_sysdeps.h \ + test-udev.c \ + udev_config.c \ + udev_db.c \ + udev_device.c \ + udev_node.c \ + udev_rules.c \ + udev_rules_parse.c \ + udev_sysdeps.c \ + udev_sysfs.c \ + udev_utils.c \ + udev_utils_file.c \ + udev_utils_string.c +if USE_SELINUX +test_udev_SOURCES += \ + udev_selinux.c + +test_udev_LDADD = \ + $(SELINUX_LIBS) +endif + +dist_man_MANS = \ + udev.7 \ + udevadm.8 \ + udevd.8 + +EXTRA_DIST = \ + udev.xml \ + udevadm.xml \ + udevd.xml + +%.7 %.8 : %.xml + $(XSLTPROC) -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $< + +distclean-local: + rm -f Makefile.in + rm -f $(dist_man_MANS) diff --git a/udev/logging.h b/udev/logging.h index 6e1d5a20ef..6766ac3efa 100644 --- a/udev/logging.h +++ b/udev/logging.h @@ -22,6 +22,8 @@ #ifndef LOGGING_H #define LOGGING_H +#include "config.h" + #define err(format, arg...) do { } while (0) #define info(format, arg...) do { } while (0) #define dbg(format, arg...) do { } while (0) diff --git a/udev/test-udev.c b/udev/test-udev.c index 4ac2d5a889..591e93058a 100644 --- a/udev/test-udev.c +++ b/udev/test-udev.c @@ -17,6 +17,8 @@ * */ +#include "config.h" + #include <stdio.h> #include <stddef.h> #include <stdlib.h> @@ -71,7 +73,7 @@ int main(int argc, char *argv[], char *envp[]) int retval = -EINVAL; if (argc == 2 && strcmp(argv[1], "-V") == 0) { - printf("%s\n", UDEV_VERSION); + printf("%s\n", VERSION); exit(0); } @@ -93,7 +95,7 @@ int main(int argc, char *argv[], char *envp[]) err("open /dev/null failed: %s\n", strerror(errno)); udev_config_init(); selinux_init(); - dbg("version %s\n", UDEV_VERSION); + dbg("version %s\n", VERSION); /* set signal handlers */ memset(&act, 0x00, sizeof(act)); diff --git a/udev/udev.h b/udev/udev.h index 5ecef4abbd..2648e2aa06 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -26,7 +26,6 @@ #include "list.h" #include "logging.h" #include "udev_sysdeps.h" -#include "udev_version.h" #define COMMENT_CHARACTER '#' #define LINE_SIZE 512 @@ -47,13 +46,6 @@ #define READ_END 0 #define WRITE_END 1 -#define UDEV_ROOT "/dev" -#define DB_DIR ".udev/db" -#define DB_NAME_INDEX_DIR ".udev/names" -#define RULES_LIB_DIR "/lib/udev/rules.d" -#define RULES_DYN_DIR ".udev/rules.d" -#define RULES_ETC_DIR "/etc/udev/rules.d" - struct udev_rules; struct sysfs_device { diff --git a/udev/udev_config.c b/udev/udev_config.c index 55f0361dd2..8a1dac51d2 100644 --- a/udev/udev_config.c +++ b/udev/udev_config.c @@ -164,8 +164,8 @@ void udev_config_init(void) { const char *env; - strcpy(udev_config_filename, UDEV_CONFIG_FILE); - strcpy(udev_root, UDEV_ROOT); + strcpy(udev_config_filename, SYSCONFDIR "/udev/udev.conf"); + strcpy(udev_root, UDEV_PREFIX "/dev"); udev_rules_dir[0] = '\0'; udev_log_priority = LOG_ERR; udev_run = 1; diff --git a/udev/udev_db.c b/udev/udev_db.c index 3348c9a02c..e3f0f7fd58 100644 --- a/udev/udev_db.c +++ b/udev/udev_db.c @@ -40,7 +40,7 @@ static size_t devpath_to_db_path(const char *devpath, char *filename, size_t len /* translate to location of db file */ strlcpy(filename, udev_root, len); - start = strlcat(filename, "/"DB_DIR"/", len); + start = strlcat(filename, "/.udev/db/", len); strlcat(filename, devpath, len); return path_encode(&filename[start], len - start); } @@ -55,7 +55,7 @@ static int name_index(const char *devpath, const char *name, int add) /* directory with device name */ strlcpy(filename, udev_root, sizeof(filename)); - start = strlcat(filename, "/"DB_NAME_INDEX_DIR"/", sizeof(filename)); + start = strlcat(filename, "/.udev/names/", sizeof(filename)); strlcat(filename, name, sizeof(filename)); path_encode(&filename[start], sizeof(filename) - start); /* entry with the devpath */ @@ -86,7 +86,7 @@ int udev_db_get_devices_by_name(const char *name, struct list_head *name_list) int rc = 0; strlcpy(dirname, udev_root, sizeof(dirname)); - start = strlcat(dirname, "/"DB_NAME_INDEX_DIR"/", sizeof(dirname)); + start = strlcat(dirname, "/.udev/names/", sizeof(dirname)); strlcat(dirname, name, sizeof(dirname)); path_encode(&dirname[start], sizeof(dirname) - start); @@ -303,7 +303,7 @@ int udev_db_get_all_entries(struct list_head *name_list) DIR *dir; strlcpy(dbpath, udev_root, sizeof(dbpath)); - strlcat(dbpath, "/"DB_DIR, sizeof(dbpath)); + strlcat(dbpath, "/.udev/db", sizeof(dbpath)); dir = opendir(dbpath); if (dir == NULL) { info("no udev_db available '%s': %s\n", dbpath, strerror(errno)); diff --git a/udev/udev_device.c b/udev/udev_device.c index cf21191ca0..bce5b29986 100644 --- a/udev/udev_device.c +++ b/udev/udev_device.c @@ -24,6 +24,7 @@ #include <fcntl.h> #include <errno.h> #include <ctype.h> +#include <string.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <net/if.h> diff --git a/udev/udev_rules.c b/udev/udev_rules.c index ea850a84c3..693bce261c 100644 --- a/udev/udev_rules.c +++ b/udev/udev_rules.c @@ -174,7 +174,7 @@ static int run_program(const char *command, const char *subsystem, /* allow programs in /lib/udev called without the path */ if (strchr(argv[0], '/') == NULL) { - strlcpy(program, "/lib/udev/", sizeof(program)); + strlcpy(program, UDEV_PREFIX "/lib/udev/", sizeof(program)); strlcat(program, argv[0], sizeof(program)); argv[0] = program; } diff --git a/udev/udev_rules.h b/udev/udev_rules.h index fe0f9dfbb5..9a41ccbdd8 100644 --- a/udev/udev_rules.h +++ b/udev/udev_rules.h @@ -24,7 +24,6 @@ #include "list.h" #define PAIRS_MAX 5 -#define RULESFILE_SUFFIX ".rules" enum key_operation { KEY_OP_UNSET, diff --git a/udev/udev_rules_parse.c b/udev/udev_rules_parse.c index 3ada8b1c7d..273f92f486 100644 --- a/udev/udev_rules_parse.c +++ b/udev/udev_rules_parse.c @@ -451,7 +451,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena /* allow programs in /lib/udev called without the path */ if (strchr(file, '/') == NULL) { - strlcpy(file, "/lib/udev/", sizeof(file)); + strlcpy(file, UDEV_PREFIX "/lib/udev/", sizeof(file)); strlcat(file, value, sizeof(file)); pos = strchr(file, ' '); if (pos) @@ -739,24 +739,24 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names) if (udev_rules_dir[0] != '\0') { /* custom rules location for testing */ - add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX); + add_matching_files(&name_list, udev_rules_dir, ".rules"); } else { /* read default rules */ - add_matching_files(&name_list, RULES_LIB_DIR, RULESFILE_SUFFIX); + add_matching_files(&name_list, UDEV_PREFIX "/lib/udev/rules.d", ".rules"); /* read user/custom rules */ - add_matching_files(&sort_list, RULES_ETC_DIR, RULESFILE_SUFFIX); + add_matching_files(&sort_list, SYSCONFDIR "/udev/rules.d", ".rules"); /* read dynamic/temporary rules */ strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); + strlcat(filename, "/.udev/rules.d", sizeof(filename)); if (stat(filename, &statbuf) != 0) { create_path(filename); selinux_setfscreatecon(filename, NULL, S_IFDIR|0755); mkdir(filename, 0755); selinux_resetfscreatecon(); } - add_matching_files(&sort_list, filename, RULESFILE_SUFFIX); + add_matching_files(&sort_list, filename, ".rules"); /* sort all rules files by basename into list of files */ list_for_each_entry_safe(sort_loop, sort_tmp, &sort_list, node) { diff --git a/udev/udev_selinux.c b/udev/udev_selinux.c index eec950194c..66742e1fec 100644 --- a/udev/udev_selinux.c +++ b/udev/udev_selinux.c @@ -16,6 +16,8 @@ * */ +#include "config.h" + #include <stdlib.h> #include <stdio.h> #include <stddef.h> diff --git a/udev/udev_selinux.h b/udev/udev_selinux.h index 73567d6cfe..fcdd9dbe5f 100644 --- a/udev/udev_selinux.h +++ b/udev/udev_selinux.h @@ -19,20 +19,17 @@ #define _UDEV_SELINUX_H #ifdef USE_SELINUX - extern void selinux_setfilecon(const char *file, const char *devname, unsigned int mode); extern void selinux_setfscreatecon(const char *file, const char *devname, unsigned int mode); extern void selinux_resetfscreatecon(void); extern void selinux_init(void); extern void selinux_exit(void); - #else - static inline void selinux_setfilecon(const char *file, const char *devname, unsigned int mode) {} static inline void selinux_setfscreatecon(const char *file, const char *devname, unsigned int mode) {} static inline void selinux_resetfscreatecon(void) {} static inline void selinux_init(void) {} static inline void selinux_exit(void) {} +#endif -#endif /* USE_SELINUX */ -#endif /* _UDEV_USE_SELINUX */ +#endif diff --git a/udev/udev_sysdeps.c b/udev/udev_sysdeps.c index 9447cca936..ef5b09ef89 100644 --- a/udev/udev_sysdeps.c +++ b/udev/udev_sysdeps.c @@ -1,6 +1,5 @@ /* - * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com> - * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org> + * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -20,14 +19,9 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <ctype.h> -#include <fcntl.h> -#include <errno.h> #include <sys/types.h> -#include "udev.h" - -#ifdef __GLIBC__ +#ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t size) { size_t bytes = 0; @@ -70,4 +64,4 @@ size_t strlcat(char *dst, const char *src, size_t size) *q = '\0'; return bytes; } -#endif /* __GLIBC__ */ +#endif /* HAVE_STRLCPY */ diff --git a/udev/udev_sysdeps.h b/udev/udev_sysdeps.h index d4f03686af..f08053e5f1 100644 --- a/udev/udev_sysdeps.h +++ b/udev/udev_sysdeps.h @@ -1,7 +1,7 @@ /* * wrapping of libc features and kernel interfaces * - * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org> + * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -21,82 +21,17 @@ #ifndef _UDEV_SYSDEPS_H_ #define _UDEV_SYSDEPS_H_ -#include <string.h> -#include <unistd.h> #include <stdint.h> -/* needed until Inotify! syscalls reach glibc */ -#include <sys/syscall.h> -#ifndef __NR_inotify_init -#if defined(__i386__) -# define __NR_inotify_init 291 -# define __NR_inotify_add_watch 292 -# define __NR_inotify_rm_watch 293 -#elif defined(__x86_64__) -# define __NR_inotify_init 253 -# define __NR_inotify_add_watch 254 -# define __NR_inotify_rm_watch 255 -#elif defined(__powerpc__) || defined(__powerpc64__) -# define __NR_inotify_init 275 -# define __NR_inotify_add_watch 276 -# define __NR_inotify_rm_watch 277 -#elif defined (__ia64__) -# define __NR_inotify_init 1277 -# define __NR_inotify_add_watch 1278 -# define __NR_inotify_rm_watch 1279 -#elif defined (__s390__) -# define __NR_inotify_init 284 -# define __NR_inotify_add_watch 285 -# define __NR_inotify_rm_watch 286 -#elif defined (__alpha__) -# define __NR_inotify_init 444 -# define __NR_inotify_add_watch 445 -# define __NR_inotify_rm_watch 446 -#elif defined (__sparc__) || defined (__sparc64__) -# define __NR_inotify_init 151 -# define __NR_inotify_add_watch 152 -# define __NR_inotify_rm_watch 156 -#elif defined (__arm__) -# define __NR_inotify_init __NR_SYSCALL_BASE+316 -# define __NR_inotify_add_watch __NR_SYSCALL_BASE+317 -# define __NR_inotify_rm_watch __NR_SYSCALL_BASE+318 -#elif defined (__sh__) -# define __NR_inotify_init 290 -# define __NR_inotify_add_watch 291 -# define __NR_inotify_rm_watch 292 -#elif defined (__m32r__) -# define __NR_inotify_init 290 -# define __NR_inotify_add_watch 291 -# define __NR_inotify_rm_watch 292 -#elif defined (__hppa__) -# define __NR_inotify_init 269 -# define __NR_inotify_add_watch 270 -# define __NR_inotify_rm_watch 271 -#elif defined (__mips__) -# include <sgidefs.h> -# if _MIPS_SIM == _MIPS_SIM_ABI32 -# define __NR_Linux 4000 -# define __NR_inotify_init (__NR_Linux + 284) -# define __NR_inotify_add_watch (__NR_Linux + 285) -# define __NR_inotify_rm_watch (__NR_Linux + 286) -# elif _MIPS_SIM == _MIPS_SIM_ABI64 -# define __NR_Linux 5000 -# define __NR_inotify_init (__NR_Linux + 243) -# define __NR_inotify_add_watch (__NR_Linux + 244) -# define __NR_inotify_rm_watch (__NR_Linux + 245) -# elif _MIPS_SIM == _MIPS_SIM_NABI32 -# define __NR_Linux 6000 -# define __NR_inotify_init (__NR_Linux + 247) -# define __NR_inotify_add_watch (__NR_Linux + 248) -# define __NR_inotify_rm_watch (__NR_Linux + 249) -# endif +/* needed for our signal handlers to work */ +#undef asmlinkage +#ifdef __i386__ +#define asmlinkage __attribute__((regparm(0))) #else -#warning "inotify unsupported on this architecture!" -#endif -#endif /* __NR_inotify_init */ +#define asmlinkage +#endif /* __i386__ */ -/* dummy if we don't have the syscalls defined */ -#ifndef __NR_inotify_init +#ifndef HAVE_INOTIFY static inline int inotify_init(void) { return -1; @@ -106,67 +41,11 @@ static inline int inotify_add_watch(int fd, const char *name, uint32_t mask) { return -1; } -#else -/* needed until /usr/include/sys/inotify.h is working */ -#ifndef __GLIBC__ -#include <sys/inotify.h> -#else -static inline int inotify_init(void) -{ - return syscall(__NR_inotify_init); -} - -static inline int inotify_add_watch(int fd, const char *name, uint32_t mask) -{ - return syscall(__NR_inotify_add_watch, fd, name, mask); -} -#endif /* __GLIBC__ */ -#endif /* __NR_inotify_init */ - -#ifndef IN_CREATE -#define IN_CREATE 0x00000100 /* Subfile was created */ -#define IN_MOVED_FROM 0x00000040 /* File was moved from X */ -#define IN_MOVED_TO 0x00000080 /* File was moved to Y */ -#define IN_DELETE 0x00000200 /* Subfile was deleted */ -#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */ -#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */ -#endif /* IN_CREATE */ - -/* needed for our signal handlers to work */ -#undef asmlinkage -#ifdef __i386__ -#define asmlinkage __attribute__((regparm(0))) -#else -#define asmlinkage -#endif /* __i386__ */ - -/* headers are broken on some architectures */ -#ifndef __FD_SET -#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) -#endif -#ifndef __FD_CLR -#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) -#endif -#ifndef __FD_ISSET -#define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0) -#endif -#ifndef __FD_ZERO -#define __FD_ZERO(set) ((void) memset ((void*) (set), 0, sizeof (fd_set))) -#endif - -#ifndef NETLINK_KOBJECT_UEVENT -#define NETLINK_KOBJECT_UEVENT 15 -#endif - -#ifndef SO_RCVBUFFORCE -#if defined(__alpha__) || defined(__hppa__) || defined(__sparc__) || defined(__sparc_v9__) -#define SO_RCVBUFFORCE 0x100b -#else -#define SO_RCVBUFFORCE 33 -#endif #endif +#ifndef HAVE_STRLCPY extern size_t strlcpy(char *dst, const char *src, size_t size); extern size_t strlcat(char *dst, const char *src, size_t size); +#endif #endif diff --git a/udev/udev_sysfs.c b/udev/udev_sysfs.c index c4cd4ab75d..91f5997d0c 100644 --- a/udev/udev_sysfs.c +++ b/udev/udev_sysfs.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stddef.h> #include <unistd.h> +#include <string.h> #include <fcntl.h> #include <ctype.h> #include <errno.h> diff --git a/udev/udev_utils.c b/udev/udev_utils.c index 00b67dadc6..9b22de783f 100644 --- a/udev/udev_utils.c +++ b/udev/udev_utils.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stddef.h> #include <unistd.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <ctype.h> diff --git a/udev/udev_utils_file.c b/udev/udev_utils_file.c index a492785af9..3e73c8769e 100644 --- a/udev/udev_utils_file.c +++ b/udev/udev_utils_file.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stddef.h> #include <unistd.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <ctype.h> diff --git a/udev/udev_utils_string.c b/udev/udev_utils_string.c index e3dc137e63..78bfca800c 100644 --- a/udev/udev_utils_string.c +++ b/udev/udev_utils_string.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stddef.h> #include <unistd.h> +#include <string.h> #include <fcntl.h> #include <errno.h> #include <ctype.h> diff --git a/udev/udevadm.c b/udev/udevadm.c index 6e7d7734d2..7adb7c5732 100644 --- a/udev/udevadm.c +++ b/udev/udevadm.c @@ -16,6 +16,8 @@ * */ +#include "config.h" + #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -37,9 +39,9 @@ void log_message(int priority, const char *format, ...) return; va_start(args, format); - if (debug) { + if (debug) vprintf(format, args); - } else + else vsyslog(priority, format, args); va_end(args); } @@ -56,7 +58,7 @@ static const struct command cmds[]; static int version(int argc, char *argv[], char *envp[]) { - printf("%s\n", UDEV_VERSION); + printf("%s\n", VERSION); return 0; } diff --git a/udev/udevcontrol.c b/udev/udevcontrol.c index 4c93b8f464..a02bfc4d65 100644 --- a/udev/udevcontrol.c +++ b/udev/udevcontrol.c @@ -16,6 +16,8 @@ * */ +#include "config.h" + #include <time.h> #include <errno.h> #include <stdio.h> @@ -50,7 +52,7 @@ int udevcontrol(int argc, char *argv[], char *envp[]) udev_log = log_priority(env); logging_init("udevcontrol"); - dbg("version %s\n", UDEV_VERSION); + dbg("version %s\n", VERSION); if (argc < 2) { fprintf(stderr, "missing command\n\n"); diff --git a/udev/udevd.c b/udev/udevd.c index 0827a5ceb3..22d261fccb 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -17,6 +17,8 @@ * */ +#include "config.h" + #include <stddef.h> #include <signal.h> #include <unistd.h> @@ -39,6 +41,9 @@ #include <sys/ioctl.h> #include <linux/types.h> #include <linux/netlink.h> +#ifdef HAVE_INOTIFY +#include <sys/inotify.h> +#endif #include "udev.h" #include "udev_rules.h" @@ -156,12 +161,12 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st size_t start; /* location of queue file */ - snprintf(filename, sizeof(filename), "%s/"EVENT_QUEUE_DIR"/%llu", udev_root, msg->seqnum); + snprintf(filename, sizeof(filename), "%s/.udev/queue/%llu", udev_root, msg->seqnum); /* location of failed file */ strlcpy(filename_failed, udev_root, sizeof(filename_failed)); strlcat(filename_failed, "/", sizeof(filename_failed)); - start = strlcat(filename_failed, EVENT_FAILED_DIR"/", sizeof(filename_failed)); + start = strlcat(filename_failed, ".udev/failed/", sizeof(filename_failed)); strlcat(filename_failed, msg->devpath, sizeof(filename_failed)); path_encode(&filename_failed[start], sizeof(filename_failed) - start); @@ -182,7 +187,7 @@ static void export_event_state(struct udevd_uevent_msg *msg, enum event_state st strlcpy(filename_failed_old, udev_root, sizeof(filename_failed_old)); strlcat(filename_failed_old, "/", sizeof(filename_failed_old)); - start = strlcat(filename_failed_old, EVENT_FAILED_DIR"/", sizeof(filename_failed_old)); + start = strlcat(filename_failed_old, ".udev/failed/", sizeof(filename_failed_old)); strlcat(filename_failed_old, msg->devpath_old, sizeof(filename_failed_old)); path_encode(&filename_failed_old[start], sizeof(filename) - start); @@ -273,7 +278,7 @@ static void msg_queue_insert(struct udevd_uevent_msg *msg) info("seq %llu queued, '%s' '%s'\n", msg->seqnum, msg->action, msg->subsystem); strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename)); + strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd >= 0) { char str[32]; @@ -939,7 +944,7 @@ static void export_initial_seqnum(void) len = 3; } strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename)); + strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); create_path(filename); fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd >= 0) { @@ -971,7 +976,7 @@ int main(int argc, char *argv[], char *envp[]) logging_init("udevd"); udev_config_init(); selinux_init(); - dbg("version %s\n", UDEV_VERSION); + dbg("version %s\n", VERSION); while (1) { option = getopt_long(argc, argv, "dDthV", options, NULL); @@ -994,7 +999,7 @@ int main(int argc, char *argv[], char *envp[]) printf("Usage: udevd [--help] [--daemon] [--debug-trace] [--debug] [--version]\n"); goto exit; case 'V': - printf("%s\n", UDEV_VERSION); + printf("%s\n", VERSION); goto exit; default: goto exit; @@ -1123,7 +1128,7 @@ int main(int argc, char *argv[], char *envp[]) fd = open("/dev/kmsg", O_WRONLY); if (fd > 0) { - const char *str = "<6>udevd version " UDEV_VERSION " started\n"; + const char *str = "<6>udevd version " VERSION " started\n"; write(fd, str, strlen(str)); close(fd); @@ -1148,14 +1153,14 @@ int main(int argc, char *argv[], char *envp[]) } else { char filename[PATH_MAX]; - inotify_add_watch(inotify_fd, RULES_LIB_DIR, + inotify_add_watch(inotify_fd, UDEV_PREFIX "/lib/udev/rules.d", IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); - inotify_add_watch(inotify_fd, RULES_ETC_DIR, + inotify_add_watch(inotify_fd, SYSCONFDIR "/udev/rules.d", IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); /* watch dynamic rules directory */ strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); + strlcat(filename, "/.udev/rules.d", sizeof(filename)); inotify_add_watch(inotify_fd, filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE); } diff --git a/udev/udevd.h b/udev/udevd.h index 9be34cb0cc..1f4d6e417f 100644 --- a/udev/udevd.h +++ b/udev/udevd.h @@ -22,10 +22,6 @@ #define UDEVD_PRIORITY -4 #define UDEV_PRIORITY -2 -#define EVENT_QUEUE_DIR ".udev/queue" -#define EVENT_FAILED_DIR ".udev/failed" -#define EVENT_SEQNUM ".udev/uevent_seqnum" - /* maximum limit of forked childs */ #define UDEVD_MAX_CHILDS 256 /* start to throttle forking if maximum number of running childs in our session is reached */ @@ -35,8 +31,8 @@ #define UEVENT_BUFFER_SIZE 2048 #define UEVENT_NUM_ENVP 32 -#define UDEVD_CTRL_SOCK_PATH "/org/kernel/udev/udevd" -#define UDEVD_CTRL_MAGIC "udevd_" UDEV_VERSION +#define UDEVD_CTRL_SOCK_PATH UDEV_PREFIX "/org/kernel/udev/udevd" +#define UDEVD_CTRL_MAGIC "udevd_" VERSION enum udevd_ctrl_msg_type { UDEVD_CTRL_UNKNOWN, diff --git a/udev/udevinfo.c b/udev/udevinfo.c index b9ee17c4f1..a97f09c3e6 100644 --- a/udev/udevinfo.c +++ b/udev/udevinfo.c @@ -16,6 +16,8 @@ * */ +#include "config.h" + #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -373,10 +375,10 @@ int udevinfo(int argc, char *argv[], char *envp[]) export_prefix = optarg; break; case 1: - printf("%s\n", UDEV_VERSION); + printf("%s\n", VERSION); goto exit; case 'V': - printf("udevinfo, version %s\n", UDEV_VERSION); + printf("udevinfo, version %s\n", VERSION); goto exit; case 'h': printf("Usage: udevadm info OPTIONS\n" diff --git a/udev/udevsettle.c b/udev/udevsettle.c index cb63a66bba..f00a38b4b7 100644 --- a/udev/udevsettle.c +++ b/udev/udevsettle.c @@ -89,7 +89,7 @@ int udevsettle(int argc, char *argv[], char *envp[]) logging_init("udevsettle"); udev_config_init(); - dbg("version %s\n", UDEV_VERSION); + dbg("version %s\n", VERSION); sysfs_init(); while (1) { @@ -113,7 +113,7 @@ int udevsettle(int argc, char *argv[], char *envp[]) } strlcpy(queuename, udev_root, sizeof(queuename)); - strlcat(queuename, "/" EVENT_QUEUE_DIR, sizeof(queuename)); + strlcat(queuename, "/.udev/queue", sizeof(queuename)); loop = timeout * LOOP_PER_SECOND; while (loop--) { @@ -135,7 +135,7 @@ int udevsettle(int argc, char *argv[], char *envp[]) /* read current udev seqnum */ strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/" EVENT_SEQNUM, sizeof(filename)); + strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); fd = open(filename, O_RDONLY); if (fd < 0) goto exit; diff --git a/udev/udevtest.c b/udev/udevtest.c index d5e90b02c6..2b43691f39 100644 --- a/udev/udevtest.c +++ b/udev/udevtest.c @@ -91,7 +91,7 @@ int udevtest(int argc, char *argv[], char *envp[]) {} }; - info("version %s\n", UDEV_VERSION); + info("version %s\n", VERSION); udev_config_init(); if (udev_log_priority < LOG_INFO) { char priority[32]; diff --git a/udev/udevtrigger.c b/udev/udevtrigger.c index d4b10d06ab..d338f82664 100644 --- a/udev/udevtrigger.c +++ b/udev/udevtrigger.c @@ -536,7 +536,7 @@ static void scan_failed(void) struct dirent *dent; strlcpy(base, udev_root, sizeof(base)); - strlcat(base, "/" EVENT_FAILED_DIR, sizeof(base)); + strlcat(base, "/.udev/failed", sizeof(base)); dir = opendir(base); if (dir != NULL) { @@ -582,7 +582,7 @@ int udevtrigger(int argc, char *argv[], char *envp[]) logging_init("udevtrigger"); udev_config_init(); - dbg("version %s\n", UDEV_VERSION); + dbg("version %s\n", VERSION); sysfs_init(); while (1) { |