chiark / gitweb /
[PATCH] fix special file mode mask for temporary device node
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Thu, 10 Feb 2005 18:46:50 +0000 (19:46 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:33:50 +0000 (23:33 -0700)
test/udev-test.pl
udev_add.c

index 992fc00..1b1ee90 100644 (file)
@@ -1068,7 +1068,7 @@ EOF
                devpath         => "/block/sda",
                exp_name        => "sda",
                conf            => <<EOF
-BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="%N"
+BUS="scsi", KERNEL="sda", PROGRAM="/usr/bin/test -b %N" NAME="%N"
 EOF
        },
        {
index c566571..be62e13 100644 (file)
@@ -89,6 +89,22 @@ int udev_make_node(struct udevice *udev, const char *file, int major, int minor,
                dbg("already present file '%s' unlinked", file);
 
 create:
+       switch (udev->type) {
+       case 'b':
+               mode |= S_IFBLK;
+               break;
+       case 'c':
+       case 'u':
+               mode |= S_IFCHR;
+               break;
+       case 'p':
+               mode |= S_IFIFO;
+               break;
+       default:
+               dbg("unknown node type %c\n", udev->type);
+               return -EINVAL;
+       }
+
        selinux_setfscreatecon(file, udev->kernel_name, mode);
        retval = mknod(file, mode, makedev(major, minor));
        if (retval != 0) {
@@ -131,24 +147,8 @@ static int create_node(struct udevice *udev, struct sysfs_class_device *class_de
        snprintf(filename, NAME_SIZE, "%s/%s", udev_root, udev->name);
        filename[NAME_SIZE-1] = '\0';
 
-       switch (udev->type) {
-       case 'b':
-               udev->mode |= S_IFBLK;
-               break;
-       case 'c':
-       case 'u':
-               udev->mode |= S_IFCHR;
-               break;
-       case 'p':
-               udev->mode |= S_IFIFO;
-               break;
-       default:
-               dbg("unknown node type %c\n", udev->type);
-               return -EINVAL;
-       }
-
        /* create parent directories if needed */
-       if (strrchr(udev->name, '/'))
+       if (strchr(udev->name, '/'))
                create_path(filename);
 
        if (udev->owner[0] != '\0') {