diff options
author | Kay Sievers <kay.sievers@suse.de> | 2005-06-18 10:57:10 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@suse.de> | 2005-06-18 10:57:10 +0200 |
commit | 57663b364beda200ec189c889e7d9c9fede37c9a (patch) | |
tree | 9596b3a13dd6c23f346c737ba53d61da8103934f /udev_add.c | |
parent | e33d1515e2d22fe8f872556dd649e0db3b601057 (diff) |
remove device node, when type block/char has changed
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Diffstat (limited to 'udev_add.c')
-rw-r--r-- | udev_add.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/udev_add.c b/udev_add.c index 2081e503c7..89af96570f 100644 --- a/udev_add.c +++ b/udev_add.c @@ -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; + 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 (((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; @@ -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: - 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(); |