]> err.no Git - systemd/commitdiff
prefix udev-util.c functions with util_*
authorKay Sievers <kay.sievers@vrfy.org>
Sat, 18 Oct 2008 18:12:55 +0000 (20:12 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Sat, 18 Oct 2008 18:12:55 +0000 (20:12 +0200)
extras/floppy/create_floppy_devices.c
udev/lib/libudev-device-db-write.c
udev/udev-event.c
udev/udev-node.c
udev/udev-rules.c
udev/udev-util.c
udev/udev.h
udev/udevd.c

index 6c5b3b4800c91cae5be8752bdf9f173f7d44ae08..f5069f722065b2aa56fb2bb9bcd5c8eb550a7282 100644 (file)
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
 
        logging_init("create_floppy_devices");
        udev_set_log_fn(udev, log_fn);
-       selinux_init(udev);
+       udev_selinux_init(udev);
 
        while ((c = getopt(argc, argv, "cudm:U:G:M:t:")) != -1) {
                switch (c) {
@@ -79,10 +79,10 @@ int main(int argc, char **argv)
                        print_nodes = 1;
                        break;
                case 'U':
-                       uid = lookup_user(udev, optarg);
+                       uid = util_lookup_user(udev, optarg);
                        break;
                case 'G':
-                       gid = lookup_group(udev, optarg);
+                       gid = util_lookup_group(udev, optarg);
                        break;
                case 'M':
                        mode = strtol(optarg, NULL, 0);
@@ -162,7 +162,7 @@ int main(int argc, char **argv)
                i++;
        }
 
-       selinux_exit(udev);
+       udev_selinux_exit(udev);
        udev_unref(udev);
 exit:
        return 0;
index 17e989310e34b4f444c7590505d9a697063b7947..34095e5682303c08dd102ffe4287971a79e8301d 100644 (file)
@@ -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))
index 86cb92ea949f66cf8fe9239863f25f7da284b36f..54006b59270c4477e8b4b8c521fbed8420bf4053 100644 (file)
@@ -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;
                        }
index c384eb7764771eb04a3874e9f9caac395927fc2a..03b8d61fd0d411552c793e4ec87ea7bf2d46beb4 100644 (file)
@@ -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;
 }
index ff61574ac6af274be6dce29174b80ca0f276bdba..cbf351159579b08eb1f058f20b35a868aa8650df 100644 (file)
@@ -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);
index d17a151966d6aeded44865a3638f6c1c983edbc2..d45d444e979229e8613b69c062ad2d7dca4e8d9c 100644 (file)
@@ -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};
index 66ad73ad92dac868b522b802b78df21a320f9526..89f6f11edfd1b1262b5dae3f42f46dbb028b590b 100644 (file)
 #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
index 4f46b6c1a9cf9ac13dfd824fb57c17953fe36e8d..21fd6f82e7355acbad3d0c3074d39783dd23791b 100644 (file)
@@ -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);