chiark / gitweb /
[PATCH] udev: mode should be mode_t
authorrml@tech9.net <rml@tech9.net>
Mon, 20 Oct 2003 04:56:21 +0000 (21:56 -0700)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:01:41 +0000 (21:01 -0700)
Unix file modes should be stored in a mode_t, not a standard type.  At
the moment it is actually unsigned, in fact, not a signed integer.

Attached patch does an s/int mode/mode_t mode/ and cleans up the
results.

namedev.c
udev-add.c
udev.h
udevdb.c
udevdb.h

index 6f69959346713a0ef9e2a1f0e90d5ddad80fa383..ac05fd88e4d4e4cc31ddd2dbc44a40164cffab7c 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -446,7 +446,8 @@ static int namedev_init_permissions(void)
                dev.attr.mode = strtol(temp, NULL, 8);
 
                dbg_parse("name = %s, owner = %s, group = %s, mode = %#o",
-                               dev.attr.name, dev.attr.owner, dev.attr.group, dev.attr.mode);
+                               dev.attr.name, dev.attr.owner, dev.attr.group,
+                               dev.attr.mode);
                retval = add_dev(&dev);
                if (retval) {
                        dbg("add_dev returned with error %d", retval);
@@ -459,7 +460,7 @@ exit:
        return retval;
 }      
 
-static int get_default_mode(struct sysfs_class_device *class_dev)
+static mode_t get_default_mode(struct sysfs_class_device *class_dev)
 {
        /* just default everyone to rw for the world! */
        return 0666;
@@ -544,7 +545,7 @@ static int get_attr(struct sysfs_class_device *class_dev, struct device_attr *at
        int retval = 0;
        int found;
 
-       attr->mode = -1;
+       attr->mode = 0;
        if (class_dev->sysdevice) {
                dbg_parse("class_dev->sysdevice->directory->path = '%s'", class_dev->sysdevice->directory->path);
                dbg_parse("class_dev->sysdevice->bus_id = '%s'", class_dev->sysdevice->bus_id);
@@ -751,9 +752,10 @@ label_found:
                }       
        }
        strcpy(attr->name, class_dev->name);
-       
+
 done:
-       if (attr->mode == -1) { 
+       /* mode was never set above */
+       if (!attr->mode) {
                attr->mode = get_default_mode(class_dev);
                attr->owner[0] = 0x00;
                attr->group[0] = 0x00;
index 05f2aa3e9dc414598eb81e18d81089c164828fa2..d158c41b1d54adbc138a28d9ea098f1e855c9a95 100644 (file)
@@ -71,7 +71,7 @@ exit:
 /*
  * We also want to add some permissions here, and possibly some symlinks
  */
-static int create_node(char *name, char type, int major, int minor, int mode)
+static int create_node(char *name, char type, int major, int minor, mode_t mode)
 {
        char filename[255];
        int retval = 0;
@@ -94,7 +94,7 @@ static int create_node(char *name, char type, int major, int minor, int mode)
        }
 
        dbg("mknod(%s, %#o, %u, %u)", filename, mode, major, minor);
-       retval = mknod(filename,mode,makedev(major,minor));
+       retval = mknod(filename, mode, makedev(major, minor));
        if (retval)
                dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
                    filename, mode, major, minor, strerror(errno));
diff --git a/udev.h b/udev.h
index 33cb89af5542ef6684971cc6e90c0514325e85b1..af575c2b174bddbf7ec11bb748c84e2660b9eccb 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -59,7 +59,7 @@ struct device_attr {
        char name[NAME_SIZE];
        char owner[OWNER_SIZE];
        char group[GROUP_SIZE];
-       int mode;
+       mode_t mode;
 };
 
 extern int udev_add_device(char *device, char *subsystem);
index fa26de46d5956f4051da42741f1d413a5c5a0e40..678ddd960340764bb8a94f7025ebb4bf29e8d00d 100644 (file)
--- a/udevdb.c
+++ b/udevdb.c
@@ -73,7 +73,7 @@ struct namedb_record {
        char type;
        int major;
        int minor;
-       int mode;
+       mode_t mode;
 };
 
 /**
index 8e72eded0217ee3c26145ba38b96f4af32237948..656613b593242a1a53cc930eaf017a004252e922 100644 (file)
--- a/udevdb.h
+++ b/udevdb.h
@@ -25,7 +25,7 @@ struct udevice {
        char type;
        int major;
        int minor;
-       int mode;
+       mode_t mode;
 };
 
 /* Function Prototypes */