diff options
Diffstat (limited to 'udev')
-rw-r--r-- | udev/.gitignore | 6 | ||||
-rw-r--r-- | udev/Makefile.am | 115 | ||||
-rw-r--r-- | udev/logging.h | 2 | ||||
-rw-r--r-- | udev/test-udev.c | 6 | ||||
-rw-r--r-- | udev/udev.h | 8 | ||||
-rw-r--r-- | udev/udev_config.c | 4 | ||||
-rw-r--r-- | udev/udev_db.c | 8 | ||||
-rw-r--r-- | udev/udev_device.c | 1 | ||||
-rw-r--r-- | udev/udev_rules.c | 2 | ||||
-rw-r--r-- | udev/udev_rules.h | 1 | ||||
-rw-r--r-- | udev/udev_rules_parse.c | 12 | ||||
-rw-r--r-- | udev/udev_selinux.c | 2 | ||||
-rw-r--r-- | udev/udev_selinux.h | 7 | ||||
-rw-r--r-- | udev/udev_sysdeps.c | 12 | ||||
-rw-r--r-- | udev/udev_sysdeps.h | 141 | ||||
-rw-r--r-- | udev/udev_sysfs.c | 1 | ||||
-rw-r--r-- | udev/udev_utils.c | 1 | ||||
-rw-r--r-- | udev/udev_utils_file.c | 1 | ||||
-rw-r--r-- | udev/udev_utils_string.c | 1 | ||||
-rw-r--r-- | udev/udevadm.c | 8 | ||||
-rw-r--r-- | udev/udevcontrol.c | 4 | ||||
-rw-r--r-- | udev/udevd.c | 27 | ||||
-rw-r--r-- | udev/udevd.h | 8 | ||||
-rw-r--r-- | udev/udevinfo.c | 6 | ||||
-rw-r--r-- | udev/udevsettle.c | 6 | ||||
-rw-r--r-- | udev/udevtest.c | 2 | ||||
-rw-r--r-- | udev/udevtrigger.c | 4 |
27 files changed, 198 insertions, 198 deletions
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) { |