diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-06-21 09:00:35 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2007-06-21 09:00:35 +0200 |
commit | 678484af64d322816dd8007030b136200dd038e3 (patch) | |
tree | 923f740d058f36fb465bc4d800e22f33a3ca1ac3 /udev_node.c | |
parent | e54f0b4ad2f10ecfefe01d607c43f086e9e889fe (diff) |
do not try to create existing file
Diffstat (limited to 'udev_node.c')
-rw-r--r-- | udev_node.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/udev_node.c b/udev_node.c index 8c0287405c..9e09e58ba8 100644 --- a/udev_node.c +++ b/udev_node.c @@ -46,21 +46,20 @@ int udev_node_mknod(struct udevice *udev, const char *file, dev_t devt, mode_t m else mode |= S_IFCHR; - /* preserve node with already correct numbers, to prevent changing the inode number */ if (lstat(file, &stats) == 0) { if ((stats.st_mode & S_IFMT) == (mode & S_IFMT) && (stats.st_rdev == devt)) { info("preserve file '%s', because it has correct dev_t", file); selinux_setfilecon(file, udev->dev->kernel, stats.st_mode); goto perms; } + } else { + selinux_setfscreatecon(file, udev->dev->kernel, mode); + retval = mknod(file, mode, devt); + selinux_resetfscreatecon(); + if (retval == 0) + goto perms; } - selinux_setfscreatecon(file, udev->dev->kernel, mode); - retval = mknod(file, mode, devt); - selinux_resetfscreatecon(); - if (retval == 0) - goto perms; - info("atomically replace '%s'", file); strlcpy(file_tmp, file, sizeof(file_tmp)); strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp)); @@ -151,15 +150,15 @@ static int node_symlink(const char *node, const char *slink) } } } + } else { + info("creating symlink '%s' to '%s'", slink, target); + selinux_setfscreatecon(slink, NULL, S_IFLNK); + retval = symlink(target, slink); + selinux_resetfscreatecon(); + if (retval == 0) + goto exit; } - info("creating symlink '%s' to '%s'", slink, target); - selinux_setfscreatecon(slink, NULL, S_IFLNK); - retval = symlink(target, slink); - selinux_resetfscreatecon(); - if (retval == 0) - goto exit; - info("atomically replace '%s'", slink); strlcpy(slink_tmp, slink, sizeof(slink_tmp)); strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp)); |