summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2003-04-10 11:02:32 -0700
committerGreg KH <gregkh@suse.de>2005-04-26 21:00:44 -0700
commit3f4967a1fbb4270b0577cca7d6a6d43a880875a5 (patch)
treefe1641f0a059da6cf18d20a1dbfc1de394a71df0
parent85511f02466297b7dca07c3fe5491230f3f06d14 (diff)
[PATCH] restructure code to be able to actually get remove_node() to work.
-rw-r--r--udev.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/udev.c b/udev.c
index 971ac10809..4bb41a8696 100644
--- a/udev.c
+++ b/udev.c
@@ -183,21 +183,43 @@ static int create_node(char *name, char type, int major, int minor, int mode)
return retval;
}
-static int remove_node(char *name)
+static int add_node(char *device, char type)
{
- return 0;
-}
+ char *name;
+ int major;
+ int minor;
+ int mode;
+ int retval = -EINVAL;
-static int do_it(char *action, char *name, char type, int major, int minor, int mode)
-{
- if (strcmp(action, "add") == 0)
- return create_node(name, type, major, minor, mode);
+ retval = get_major_minor(device, &major, &minor);
+ if (retval) {
+ dbg ("get_major_minor failed");
+ goto exit;
+ }
- if (strcmp(action, "remove") == 0)
- return remove_node(name);
+ name = get_name(device, major, minor);
+ if (name == NULL) {
+ dbg ("get_name failed");
+ retval = -ENODEV;
+ goto exit;
+ }
- dbg("Unknown action: %s", action);
- return -EINVAL;
+ mode = get_mode(name, device, major, minor);
+ if (mode < 0) {
+ dbg ("get_mode failed");
+ retval = -EINVAL;
+ goto exit;
+ }
+
+ return create_node(name, type, major, minor, mode);
+
+exit:
+ return retval;
+}
+
+static int remove_node(char *device)
+{
+ return 0;
}
int main(int argc, char *argv[])
@@ -205,11 +227,7 @@ int main(int argc, char *argv[])
char *subsystem;
char *action;
char *device;
- char *name;
char type;
- int major;
- int minor;
- int mode;
int retval = -EINVAL;
if (argc != 2) {
@@ -237,31 +255,14 @@ int main(int argc, char *argv[])
}
dbg("looking at %s", device);
- retval = get_major_minor(device, &major, &minor);
- if (retval) {
- dbg ("get_major_minor failed");
- goto exit;
- }
-
- name = get_name(device, major, minor);
- if (name == NULL) {
- dbg ("get_name failed");
- retval = -ENODEV;
- goto exit;
- }
+ if (strcmp(action, "add") == 0)
+ return add_node(device, type);
- mode = get_mode(name, device, major, minor);
- if (mode < 0) {
- dbg ("get_mode failed");
- retval = -EINVAL;
- goto exit;
- }
+ if (strcmp(action, "remove") == 0)
+ return remove_node(device);
- retval = do_it(action, name, type, major, minor, mode);
- if (retval) {
- dbg ("do_it failed");
- goto exit;
- }
+ dbg("Unknown action: %s", action);
+ return -EINVAL;
retval = 0;
exit: