]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
[PATCH] remove typedef for call_foreach_file() handler function
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Fri, 4 Mar 2005 20:33:57 +0000 (21:33 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:39:48 +0000 (23:39 -0700)
namedev_parse.c
udev.h
udev_db.h
udev_multiplex.c
udev_utils.c
udev_utils.h

index ed38db4b142267e6f617cff36af0482c4306058a..e360565950c71768975891c8264f76e21031e3b7 100644 (file)
@@ -98,7 +98,7 @@ static char *get_key_attribute(char *str)
        return NULL;
 }
 
-static int namedev_parse(const char *filename, void *data)
+static int namedev_parse(struct udevice *udev, const char *filename)
 {
        char line[LINE_SIZE];
        char *bufline;
@@ -354,9 +354,9 @@ int namedev_init(void)
                return -1;
 
        if ((stats.st_mode & S_IFMT) != S_IFDIR)
-               retval = namedev_parse(udev_rules_filename, NULL);
+               retval = namedev_parse(NULL, udev_rules_filename);
        else
-               retval = call_foreach_file(namedev_parse, udev_rules_filename, RULEFILE_SUFFIX, NULL);
+               retval = call_foreach_file(namedev_parse, NULL, udev_rules_filename, RULEFILE_SUFFIX);
 
        return retval;
 }
@@ -364,8 +364,9 @@ int namedev_init(void)
 void namedev_close(void)
 {
        struct config_device *dev;
+       struct config_device *temp_dev;
 
-       list_for_each_entry(dev, &config_device_list, node) {
+       list_for_each_entry_safe(dev, temp_dev, &config_device_list, node) {
                list_del(&dev->node);
                free(dev);
        }
diff --git a/udev.h b/udev.h
index ddcfa81c8eee1b95ad02d77257bf6fd2c1fe334f..f1236194d6367d3ac9b48b05b324090de2223181 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -4,6 +4,7 @@
  * Userspace devfs
  *
  * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003-2005 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
index 6a0647f2007b50767de88e7d5e256b0d75a48ed8..2fce06be729e252d047dcce5cfa15e9b3eada6ac 100644 (file)
--- a/udev_db.h
+++ b/udev_db.h
@@ -28,7 +28,7 @@
 extern int udev_db_add_device(struct udevice *dev);
 extern int udev_db_delete_device(struct udevice *dev);
 
-extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *devpath);
+extern int udev_db_get_device_by_devpath(struct udevice *udev, const char *devpath);
 extern int udev_db_get_device_by_name(struct udevice *udev, const char *name);
 extern int udev_db_call_foreach(int (*handler_function)(struct udevice *udev));
 
index 3a484068ff76a849e806d251245ecbde4192acbe..6d7852dbc040e8e2783f866797528810bdb84b8a 100644 (file)
 #include "udev_utils.h"
 #include "logging.h"
 
-static int run_program(const char *filename, void *data)
+static int run_program(struct udevice *udev, const char *filename)
 {
        pid_t pid;
        int fd;
-       struct udevice *udev = data;
 
        dbg("running %s", filename);
 
@@ -89,7 +88,7 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c
                        if (strcmp(devname, udev->subsystem) != 0) {
                                snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname);
                                dirname[PATH_MAX-1] = '\0';
-                               call_foreach_file(run_program, dirname, suffix, udev);
+                               call_foreach_file(run_program, udev, dirname, suffix);
                        }
 
                        temp[0] = '/';
@@ -101,16 +100,16 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c
        if (udev->name[0] != '\0') {
                snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->name);
                dirname[PATH_MAX-1] = '\0';
-               call_foreach_file(run_program, dirname, suffix, udev);
+               call_foreach_file(run_program, udev, dirname, suffix);
        }
 
        if (udev->subsystem[0] != '\0') {
                snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->subsystem);
                dirname[PATH_MAX-1] = '\0';
-               call_foreach_file(run_program, dirname, suffix, udev);
+               call_foreach_file(run_program, udev, dirname, suffix);
        }
 
        snprintf(dirname, PATH_MAX, "%s/default", basedir);
        dirname[PATH_MAX-1] = '\0';
-       call_foreach_file(run_program, dirname, suffix, udev);
+       call_foreach_file(run_program, udev, dirname, suffix);
 }
index f2534dd331d3ade1d9da474949cdc39e44b02e4d..cfa4ab51b352b56de6b7aad1c59a7eecba547eae 100644 (file)
@@ -259,13 +259,7 @@ void no_trailing_slash(char *path)
                path[--len] = '\0';
 }
 
-struct name_entry {
-       struct list_head node;
-       char name[NAME_SIZE];
-};
-
-/* sort files in lexical order */
-static int name_list_add(struct list_head *name_list, const char *name, int sort)
+int name_list_add(struct list_head *name_list, const char *name, int sort)
 {
        struct name_entry *loop_name;
        struct name_entry *new_name;
@@ -288,11 +282,13 @@ static int name_list_add(struct list_head *name_list, const char *name, int sort
 
        strfieldcpy(new_name->name, name);
        list_add_tail(&new_name->node, &loop_name->node);
+
        return 0;
 }
 
 /* calls function for every file found in specified directory */
-int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix, void *data)
+int call_foreach_file(int (*handler_function)(struct udevice *udev, const char *string),
+                     struct udevice *udev, const char *dirname, const char *suffix)
 {
        struct dirent *ent;
        DIR *dir;
@@ -335,7 +331,7 @@ int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix,
                snprintf(filename, NAME_SIZE, "%s/%s", dirname, loop_file->name);
                filename[NAME_SIZE-1] = '\0';
 
-               fnct(filename, data);
+               handler_function(udev, filename);
 
                list_del(&loop_file->node);
                free(loop_file);
index 268c2075de9b9286274676d7378d2d49efe38924..1ab4752cd3ca14ed66aeacd8acd72ab051ed0d7c 100644 (file)
@@ -76,6 +76,11 @@ do { \
 # define asmlinkage    /* nothing */
 #endif
 
+struct name_entry {
+       struct list_head node;
+       char name[NAME_SIZE];
+};
+
 extern int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem);
 extern int kernel_release_satisfactory(unsigned int version, unsigned int patchlevel, unsigned int sublevel);
 extern int create_path(const char *path);
@@ -85,8 +90,7 @@ extern int file_map(const char *filename, char **buf, size_t *bufsize);
 extern void file_unmap(char *buf, size_t bufsize);
 extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur);
 extern void no_trailing_slash(char *path);
-typedef int (*file_fnct_t)(const char *filename, void *data);
-extern int  call_foreach_file(file_fnct_t fnct, const char *dirname,
-                             const char *suffix, void *data);
-
+extern int name_list_add(struct list_head *name_list, const char *name, int sort);
+extern int call_foreach_file(int (*handler_function)(struct udevice *udev, const char *string),
+                            struct udevice *udev, const char *dirname, const char *suffix);
 #endif