diff options
Diffstat (limited to 'udev')
-rw-r--r-- | udev/lib/libudev-device-db-write.c | 2 | ||||
-rw-r--r-- | udev/udev-event.c | 2 | ||||
-rw-r--r-- | udev/udev-node.c | 20 | ||||
-rw-r--r-- | udev/udev-rules.c | 12 | ||||
-rw-r--r-- | udev/udev-util.c | 16 | ||||
-rw-r--r-- | udev/udev.h | 18 | ||||
-rw-r--r-- | udev/udevd.c | 14 |
7 files changed, 40 insertions, 44 deletions
diff --git a/udev/lib/libudev-device-db-write.c b/udev/lib/libudev-device-db-write.c index 17e989310e..34095e5682 100644 --- a/udev/lib/libudev-device-db-write.c +++ b/udev/lib/libudev-device-db-write.c @@ -50,7 +50,7 @@ int udev_device_update_db(struct udev_device *udev_device) devpath_to_db_path(udev, udev_device_get_devpath(udev_device), filename, sizeof(filename)); - create_path(udev, filename); + util_create_path(udev, filename); unlink(filename); udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) diff --git a/udev/udev-event.c b/udev/udev-event.c index 86cb92ea94..54006b5927 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -732,7 +732,7 @@ int udev_event_execute_run(struct udev_event *event) util_strlcpy(program, cmd, sizeof(program)); udev_event_apply_format(event, program, sizeof(program)); envp = udev_device_get_properties_envp(event->dev); - if (run_program(event->udev, program, envp, NULL, 0, NULL) != 0) { + if (util_run_program(event->udev, program, envp, NULL, 0, NULL) != 0) { if (!udev_list_entry_get_flag(list_entry)) err = -1; } diff --git a/udev/udev-node.c b/udev/udev-node.c index c384eb7764..03b8d61fd0 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -53,14 +53,14 @@ static int name_index(struct udev *udev, const char *devpath, const char *name, if (add) { info(udev, "creating index: '%s'\n", filename); - create_path(udev, filename); + util_create_path(udev, filename); fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd > 0) close(fd); } else { info(udev, "removing index: '%s'\n", filename); unlink(filename); - delete_path(udev, filename); + util_delete_path(udev, filename); } return 0; } @@ -288,7 +288,7 @@ static int update_link(struct udev_device *dev, const char *slink, int test) info(udev, "no reference left, remove '%s'\n", slink); if (!test) { unlink(slink); - delete_path(udev, slink); + util_delete_path(udev, slink); } goto out; } @@ -349,7 +349,7 @@ static int update_link(struct udev_device *dev, const char *slink, int test) /* create symlink to the target with the highest priority */ info(udev, "'%s' with target '%s' has the highest priority %i, create it\n", slink, target, priority); if (!test) { - create_path(udev, slink); + util_create_path(udev, slink); node_symlink(udev, target, slink); } out: @@ -400,7 +400,7 @@ int udev_node_add(struct udev_device *dev, mode_t mode, const char *owner, const struct udev_list_entry *list_entry; int err = 0; - create_path(udev, udev_device_get_devnode(dev)); + util_create_path(udev, udev_device_get_devnode(dev)); if (strcmp(owner, "root") == 0) uid = 0; @@ -412,7 +412,7 @@ int udev_node_add(struct udev_device *dev, mode_t mode, const char *owner, const if (endptr[0] == '\0') uid = (uid_t) id; else - uid = lookup_user(udev, owner); + uid = util_lookup_user(udev, owner); } if (strcmp(group, "root") == 0) @@ -425,7 +425,7 @@ int udev_node_add(struct udev_device *dev, mode_t mode, const char *owner, const if (endptr[0] == '\0') gid = (gid_t) id; else - gid = lookup_group(udev, group); + gid = util_lookup_group(udev, group); } info(udev, "creating device node '%s', devnum=%d:%d, mode=%#o, uid=%d, gid=%d\n", @@ -503,7 +503,7 @@ extern int udev_node_remove(struct udev_device *dev, int test) info(udev, "removing device node '%s'\n", devnode); if (!test) - err = unlink_secure(udev, devnode); + err = util_unlink_secure(udev, devnode); if (err) return err; @@ -518,9 +518,9 @@ extern int udev_node_remove(struct udev_device *dev, int test) snprintf(partitionname, sizeof(partitionname), "%s%d", devnode, i); partitionname[sizeof(partitionname)-1] = '\0'; if (!test) - unlink_secure(udev, partitionname); + util_unlink_secure(udev, partitionname); } } - delete_path(udev, devnode); + util_delete_path(udev, devnode); return err; } diff --git a/udev/udev-rules.c b/udev/udev-rules.c index ff61574ac6..cbf3511595 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -290,7 +290,7 @@ static int import_program_into_env(struct udev_device *dev, const char *program) char *line; envp = udev_device_get_properties_envp(dev); - if (run_program(udev, program, envp, result, sizeof(result), &reslen) != 0) + if (util_run_program(udev, program, envp, result, sizeof(result), &reslen) != 0) return -1; line = result; @@ -690,7 +690,7 @@ try_parent: util_strlcpy(program, key_val(rule, &rule->program), sizeof(program)); udev_event_apply_format(event, program, sizeof(program)); envp = udev_device_get_properties_envp(dev); - if (run_program(event->udev, program, envp, result, sizeof(result), NULL) != 0) { + if (util_run_program(event->udev, program, envp, result, sizeof(result), NULL) != 0) { dbg(event->udev, "PROGRAM is false\n"); event->program_result[0] = '\0'; if (rule->program.operation != KEY_OP_NOMATCH) @@ -999,7 +999,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udev_event *event) if (event->tmp_node[0] != '\0') { dbg(event->udev, "removing temporary device node\n"); - unlink_secure(event->udev, event->tmp_node); + util_unlink_secure(event->udev, event->tmp_node); event->tmp_node[0] = '\0'; } return 0; @@ -1541,7 +1541,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena strtoul(value, &endptr, 10); if (endptr[0] != '\0') { char owner[32]; - uid_t uid = lookup_user(rules->udev, value); + uid_t uid = util_lookup_user(rules->udev, value); dbg(rules->udev, "replacing username='%s' by id=%i\n", value, uid); sprintf(owner, "%u", (unsigned int) uid); add_rule_key(rule, &rule->owner, operation, owner); @@ -1560,7 +1560,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena strtoul(value, &endptr, 10); if (endptr[0] != '\0') { char group[32]; - gid_t gid = lookup_group(rules->udev, value); + gid_t gid = util_lookup_group(rules->udev, value); dbg(rules->udev, "replacing groupname='%s' by id=%i\n", value, gid); sprintf(group, "%u", (unsigned int) gid); add_rule_key(rule, &rule->group, operation, group); @@ -1794,7 +1794,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); util_strlcat(filename, "/.udev/rules.d", sizeof(filename)); if (stat(filename, &statbuf) != 0) { - create_path(udev, filename); + util_create_path(udev, filename); udev_selinux_setfscreatecon(udev, filename, S_IFDIR|0755); mkdir(filename, 0755); udev_selinux_resetfscreatecon(udev); diff --git a/udev/udev-util.c b/udev/udev-util.c index d17a151966..d45d444e97 100644 --- a/udev/udev-util.c +++ b/udev/udev-util.c @@ -29,7 +29,7 @@ #include "udev.h" -int create_path(struct udev *udev, const char *path) +int util_create_path(struct udev *udev, const char *path) { char p[UTIL_PATH_SIZE]; char *pos; @@ -49,7 +49,7 @@ int create_path(struct udev *udev, const char *path) if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR) return 0; - if (create_path(udev, p) != 0) + if (util_create_path(udev, p) != 0) return -1; dbg(udev, "mkdir '%s'\n", p); @@ -65,7 +65,7 @@ int create_path(struct udev *udev, const char *path) return -1; } -int delete_path(struct udev *udev, const char *path) +int util_delete_path(struct udev *udev, const char *path) { char p[UTIL_PATH_SIZE]; char *pos; @@ -102,7 +102,7 @@ int delete_path(struct udev *udev, const char *path) /* Reset permissions on the device node, before unlinking it to make sure, * that permisions of possible hard links will be removed too. */ -int unlink_secure(struct udev *udev, const char *filename) +int util_unlink_secure(struct udev *udev, const char *filename) { int retval; @@ -124,7 +124,7 @@ int unlink_secure(struct udev *udev, const char *filename) return retval; } -uid_t lookup_user(struct udev *udev, const char *user) +uid_t util_lookup_user(struct udev *udev, const char *user) { struct passwd *pw; uid_t uid = 0; @@ -142,7 +142,7 @@ uid_t lookup_user(struct udev *udev, const char *user) return uid; } -extern gid_t lookup_group(struct udev *udev, const char *group) +extern gid_t util_lookup_group(struct udev *udev, const char *group) { struct group *gr; gid_t gid = 0; @@ -160,8 +160,8 @@ extern gid_t lookup_group(struct udev *udev, const char *group) return gid; } -int run_program(struct udev *udev, const char *command, char **envp, - char *result, size_t ressize, size_t *reslen) +int util_run_program(struct udev *udev, const char *command, char **envp, + char *result, size_t ressize, size_t *reslen) { int status; int outpipe[2] = {-1, -1}; diff --git a/udev/udev.h b/udev/udev.h index 66ad73ad92..89f6f11edf 100644 --- a/udev/udev.h +++ b/udev/udev.h @@ -33,10 +33,6 @@ #define DEFAULT_FAKE_PARTITIONS_COUNT 15 #define UDEV_EVENT_TIMEOUT 180 -/* linux/include/linux/kobject.h */ -#define UEVENT_BUFFER_SIZE 2048 -#define UEVENT_NUM_ENVP 32 - #define UDEV_CTRL_SOCK_PATH "@" UDEV_PREFIX "/org/kernel/udev/udevd" #define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -109,13 +105,13 @@ extern int udev_node_remove(struct udev_device *dev, int test); extern void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old, int test); /* udev-util.c */ -extern int create_path(struct udev *udev, const char *path); -extern int delete_path(struct udev *udev, const char *path); -extern int unlink_secure(struct udev *udev, const char *filename); -extern uid_t lookup_user(struct udev *udev, const char *user); -extern gid_t lookup_group(struct udev *udev, const char *group); -extern int run_program(struct udev *udev, const char *command, char **envp, - char *result, size_t ressize, size_t *reslen); +extern int util_create_path(struct udev *udev, const char *path); +extern int util_delete_path(struct udev *udev, const char *path); +extern int util_unlink_secure(struct udev *udev, const char *filename); +extern uid_t util_lookup_user(struct udev *udev, const char *user); +extern gid_t util_lookup_group(struct udev *udev, const char *group); +extern int util_run_program(struct udev *udev, const char *command, char **envp, + char *result, size_t ressize, size_t *reslen); /* udev-selinux.c */ #ifndef USE_SELINUX diff --git a/udev/udevd.c b/udev/udevd.c index 4f46b6c1a9..21fd6f82e7 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -109,8 +109,8 @@ static void export_event_state(struct udev_event *event, enum event_state state) switch (state) { case EVENT_QUEUED: if(unlink(filename_failed) == 0) - delete_path(event->udev, filename_failed); - create_path(event->udev, filename); + util_delete_path(event->udev, filename_failed); + util_create_path(event->udev, filename); udev_selinux_setfscreatecon(event->udev, filename, S_IFLNK); symlink(udev_device_get_devpath(event->dev), filename); udev_selinux_resetfscreatecon(event->udev); @@ -131,23 +131,23 @@ static void export_event_state(struct udev_event *event, enum event_state state) udev_device_get_devpath_old(event->dev), udev_device_get_devpath(event->dev)); } else { if (unlink(filename_failed) == 0) - delete_path(event->udev, filename_failed); + util_delete_path(event->udev, filename_failed); } unlink(filename); /* clean up possibly empty queue directory */ if (udev_list_is_empty(&exec_list) && udev_list_is_empty(&running_list)) - delete_path(event->udev, filename); + util_delete_path(event->udev, filename); break; case EVENT_FAILED: /* move failed event to the failed directory */ - create_path(event->udev, filename_failed); + util_create_path(event->udev, filename_failed); rename(filename, filename_failed); /* clean up possibly empty queue directory */ if (udev_list_is_empty(&exec_list) && udev_list_is_empty(&running_list)) - delete_path(event->udev, filename); + util_delete_path(event->udev, filename); break; } @@ -613,7 +613,7 @@ static void export_initial_seqnum(struct udev *udev) } util_strlcpy(filename, udev_get_dev_path(udev), sizeof(filename)); util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); - create_path(udev, filename); + util_create_path(udev, filename); fd = open(filename, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd >= 0) { write(fd, seqnum, len); |