chiark / gitweb /
remove device node, when type block/char has changed
authorKay Sievers <kay.sievers@suse.de>
Sat, 18 Jun 2005 08:57:10 +0000 (10:57 +0200)
committerKay Sievers <kay.sievers@suse.de>
Sat, 18 Jun 2005 08:57:10 +0000 (10:57 +0200)
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
README
udev_add.c

diff --git a/README b/README
index 54cee659a833206953dc521f7ff8f59d4996a673..a2ce9c7d367137853fcb242daa6a9ccde7dfb381 100644 (file)
--- a/README
+++ b/README
@@ -10,8 +10,7 @@ To use:
 
 - Your 2.6 kernel must have had CONFIG_HOTPLUG enabled when it was built.
 
 
 - Your 2.6 kernel must have had CONFIG_HOTPLUG enabled when it was built.
 
-- Make sure sysfs is mounted.  udev will figure out where sysfs is mounted, but
-  the traditional place for it is at /sys.  You can mount it by hand by running:
+- Make sure sysfs is mounted at /sys. You can mount it by running:
        mount -t sysfs none /sys
 
 - Make sure you have the latest version of the linux-hotplug scripts.  They are
        mount -t sysfs none /sys
 
 - Make sure you have the latest version of the linux-hotplug scripts.  They are
index 2081e503c7d33d8eb5f0cee4cbd0f09684665ef3..89af96570f1ce7b17f3e28eae61e37e5c2319ce5 100644 (file)
@@ -52,12 +52,23 @@ int udev_make_node(struct udevice *udev, const char *file, dev_t devt, mode_t mo
        struct stat stats;
        int retval = 0;
 
        struct stat stats;
        int retval = 0;
 
+       switch (udev->type) {
+       case DEV_BLOCK:
+               mode |= S_IFBLK;
+               break;
+       case DEV_CLASS:
+               mode |= S_IFCHR;
+               break;
+       default:
+               dbg("unknown node type %c\n", udev->type);
+               return -EINVAL;
+       }
+
        if (stat(file, &stats) != 0)
                goto create;
 
        /* preserve node with already correct numbers, to not change the inode number */
        if (stat(file, &stats) != 0)
                goto create;
 
        /* preserve node with already correct numbers, to not change the inode number */
-       if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) &&
-           (stats.st_rdev == devt)) {
+       if ((stats.st_mode & S_IFMT) == (mode & S_IFMT) && (stats.st_rdev == devt)) {
                info("preserve file '%s', cause it has correct dev_t", file);
                selinux_setfilecon(file, udev->kernel_name, stats.st_mode);
                goto perms;
                info("preserve file '%s', cause it has correct dev_t", file);
                selinux_setfilecon(file, udev->kernel_name, stats.st_mode);
                goto perms;
@@ -69,18 +80,6 @@ int udev_make_node(struct udevice *udev, const char *file, dev_t devt, mode_t mo
                dbg("already present file '%s' unlinked", file);
 
 create:
                dbg("already present file '%s' unlinked", file);
 
 create:
-       switch (udev->type) {
-       case DEV_BLOCK:
-               mode |= S_IFBLK;
-               break;
-       case DEV_CLASS:
-               mode |= S_IFCHR;
-               break;
-       default:
-               dbg("unknown node type %c\n", udev->type);
-               return -EINVAL;
-       }
-
        selinux_setfscreatecon(file, udev->kernel_name, mode);
        retval = mknod(file, mode, devt);
        selinux_resetfscreatecon();
        selinux_setfscreatecon(file, udev->kernel_name, mode);
        retval = mknod(file, mode, devt);
        selinux_resetfscreatecon();