chiark / gitweb /
[PATCH] add ACTION to udev object to expose it to the whole process
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Fri, 12 Nov 2004 05:17:35 +0000 (06:17 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 05:24:10 +0000 (22:24 -0700)
udev.c
udev.h
udev_lib.c
udev_lib.h
udevstart.c
udevtest.c

diff --git a/udev.c b/udev.c
index b54896669b72baddf579a6af0897592a1431af50..480a1cdca224e595ff171898affaf9e2858bb54f 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -94,9 +94,9 @@ int main(int argc, char *argv[], char *envp[])
        if (strstr(argv[0], "udevstart") || (argv[1] != NULL && strstr(argv[1], "udevstart"))) {
                act_type = UDEVSTART;
        } else {
-               const char *action = get_action();
-               const char *devpath = get_devpath();
-               const char *subsystem = get_subsystem(main_argv[1]);
+               const char *action = getenv("ACTION");
+               const char *devpath = getenv("DEVPATH");
+               const char *subsystem = argv[1];
 
                if (!action) {
                        dbg("no action?");
@@ -128,7 +128,7 @@ int main(int argc, char *argv[], char *envp[])
                        goto exit;
                }
 
-               udev_set_values(&udev, devpath, subsystem);
+               udev_set_values(&udev, devpath, subsystem, action);
 
                /* skip blacklisted subsystems */
                if (udev.type != 'n' && subsystem_expect_no_dev(subsystem)) {
diff --git a/udev.h b/udev.h
index 1cf4ad7eae988893029ed7d784c3aa7b144fdcbe..3f9f2c8612019e27f99c6849d72ab4a8778e916c 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -30,8 +30,8 @@
 #define COMMENT_CHARACTER              '#'
 
 #define NAME_SIZE                      256
-#define OWNER_SIZE                     30
-#define GROUP_SIZE                     30
+#define OWNER_SIZE                     32
+#define GROUP_SIZE                     32
 #define MODE_SIZE                      8
 
 #define ACTION_SIZE                    32
@@ -44,6 +44,7 @@
 struct udevice {
        char devpath[DEVPATH_SIZE];
        char subsystem[SUBSYSTEM_SIZE];
+       char action[ACTION_SIZE];
        char name[NAME_SIZE];
        char owner[OWNER_SIZE];
        char group[GROUP_SIZE];
index 7fb45f0b5fb6b6549de364d3a6357e30abb518e2..951d36b1d7fb50c746a78d048c27d649c74763fb 100644 (file)
 #include "list.h"
 
 
-char *get_action(void)
-{
-       char *action;
-
-       action = getenv("ACTION");
-       if (action != NULL && strlen(action) > ACTION_SIZE)
-               action[ACTION_SIZE-1] = '\0';
-
-       return action;
-}
-
-char *get_devpath(void)
-{
-       char *devpath;
-
-       devpath = getenv("DEVPATH");
-       if (devpath != NULL && strlen(devpath) > DEVPATH_SIZE)
-               devpath[DEVPATH_SIZE-1] = '\0';
-
-       return devpath;
-}
-
-char *get_devname(void)
-{
-       char *devname;
-
-       devname = getenv("DEVNAME");
-       if (devname != NULL && strlen(devname) > NAME_SIZE)
-               devname[NAME_SIZE-1] = '\0';
-
-       return devname;
-}
-
-char *get_seqnum(void)
-{
-       char *seqnum;
-
-       seqnum = getenv("SEQNUM");
-
-       return seqnum;
-}
-
-char *get_subsystem(char *subsystem)
-{
-       if (subsystem != NULL && strlen(subsystem) > SUBSYSTEM_SIZE)
-               subsystem[SUBSYSTEM_SIZE-1] = '\0';
-
-       return subsystem;
-}
-
 #define BLOCK_PATH             "/block/"
 #define CLASS_PATH             "/class/"
 #define NET_PATH               "/class/net/"
@@ -112,11 +62,13 @@ char get_device_type(const char *path, const char *subsystem)
        return '\0';
 }
 
-void udev_set_values(struct udevice *udev, const char* devpath, const char *subsystem)
+void udev_set_values(struct udevice *udev, const char* devpath,
+                    const char *subsystem, const char* action)
 {
        memset(udev, 0x00, sizeof(struct udevice));
        strfieldcpy(udev->devpath, devpath);
        strfieldcpy(udev->subsystem, subsystem);
+       strfieldcpy(udev->action, action);
        udev->type = get_device_type(devpath, subsystem);
 }
 
index 94649b645f351a035d2b96119ba8802e83c5a89e..30d839461ac626991153617cef4772f06680c204 100644 (file)
@@ -76,13 +76,9 @@ do { \
 # define asmlinkage    /* nothing */
 #endif
 
-extern char *get_action(void);
-extern char *get_devpath(void);
-extern char *get_devname(void);
-extern char *get_seqnum(void);
-extern char *get_subsystem(char *subsystem);
 extern char get_device_type(const char *path, const char *subsystem);
-extern void udev_set_values(struct udevice *udev, const char* devpath, const char *subsystem);
+extern void udev_set_values(struct udevice *udev, const char* devpath,
+                           const char *subsystem, const char* action);
 extern int create_path(const char *path);
 extern int file_map(const char *filename, char **buf, size_t *bufsize);
 extern void file_unmap(char *buf, size_t bufsize);
index fd490f0791688ea8b0d4bd5d045f1431546e62c1..e05680aa93d051859c46f8508901b655358376e8 100644 (file)
@@ -110,7 +110,7 @@ static int add_device(char *devpath, char *subsystem)
                return -ENODEV;
        }
 
-       udev_set_values(&udev, devpath, subsystem);
+       udev_set_values(&udev, devpath, subsystem, "add");
        udev_add_device(&udev, class_dev);
 
        /* run scripts */
index 8af2120fb16856485036eb467e634b4d927ceedb..e67af0df673fb05dd3378afb056f95f79f7dd697 100644 (file)
@@ -103,7 +103,7 @@ int main(int argc, char *argv[], char *envp[])
                subsystem = argv[2];
 
        /* fill in values and test_run flag*/
-       udev_set_values(&udev, devpath, subsystem);
+       udev_set_values(&udev, devpath, subsystem, "add");
 
        /* open the device */
        snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, udev.devpath);