summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-09-10 01:35:48 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-09-10 01:35:48 +0200
commit676d294c23cf999ac7d192b058476f91242550c0 (patch)
treebb635c76017bcaecc437593cd8d19cc19a6b5b78
parentc26e3f69010573710110d98b8f75bcd1ea5fdac5 (diff)
reorder create_path() and node/link creation to be called in a direct sequence
-rw-r--r--libudev/libudev-queue-private.c4
-rw-r--r--udev/udev-node.c11
2 files changed, 6 insertions, 9 deletions
diff --git a/libudev/libudev-queue-private.c b/libudev/libudev-queue-private.c
index e0a8738e0e..d9f7a67d18 100644
--- a/libudev/libudev-queue-private.c
+++ b/libudev/libudev-queue-private.c
@@ -407,10 +407,8 @@ static void update_failed(struct udev_queue_export *udev_queue_export,
switch (state) {
case DEVICE_FAILED:
/* record event in the failed directory */
- if (udev_queue_export->failed_count == 0)
- util_create_path(udev, filename);
udev_queue_export->failed_count++;
-
+ util_create_path(udev, filename);
udev_selinux_setfscreatecon(udev, filename, S_IFLNK);
symlink(udev_device_get_devpath(udev_device), filename);
udev_selinux_resetfscreatecon(udev);
diff --git a/udev/udev-node.c b/udev/udev-node.c
index f17c48a7b4..3685485eb1 100644
--- a/udev/udev-node.c
+++ b/udev/udev-node.c
@@ -77,6 +77,7 @@ int udev_node_mknod(struct udev_device *dev, const char *file, dev_t devnum, mod
}
} else {
info(udev, "mknod(%s, %#o, (%u,%u))\n", file, mode, major(devnum), minor(devnum));
+ util_create_path(udev, file);
udev_selinux_setfscreatecon(udev, file, mode);
err = mknod(file, mode, devnum);
udev_selinux_resetfscreatecon(udev);
@@ -174,6 +175,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink)
}
} else {
info(udev, "creating symlink '%s' to '%s'\n", slink, target);
+ util_create_path(udev, slink);
udev_selinux_setfscreatecon(udev, slink, S_IFLNK);
err = symlink(target, slink);
udev_selinux_resetfscreatecon(udev);
@@ -184,6 +186,7 @@ static int node_symlink(struct udev *udev, const char *node, const char *slink)
info(udev, "atomically replace '%s'\n", slink);
util_strscpyl(slink_tmp, sizeof(slink_tmp), slink, TMP_FILE_EXT, NULL);
unlink(slink_tmp);
+ util_create_path(udev, slink);
udev_selinux_setfscreatecon(udev, slink, S_IFLNK);
err = symlink(target, slink_tmp);
udev_selinux_resetfscreatecon(udev);
@@ -293,7 +296,6 @@ static void link_update(struct udev_device *dev, const char *slink, bool add)
unlink(slink);
util_delete_path(udev, slink);
} else {
- util_create_path(udev, slink);
info(udev, "creating link '%s' to '%s'\n", slink, target);
node_symlink(udev, target, slink);
}
@@ -348,7 +350,6 @@ int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)),
mode, uid, gid);
- util_create_path(udev, udev_device_get_devnode(dev));
if (udev_node_mknod(dev, NULL, makedev(0,0), mode, uid, gid) != 0) {
err = -1;
goto exit;
@@ -373,13 +374,11 @@ int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
/* create/update symlinks, add symlinks to name index */
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev)) {
- if (udev_list_entry_get_flag(list_entry)) {
+ if (udev_list_entry_get_flag(list_entry))
/* simple unmanaged link name */
- util_create_path(udev, udev_list_entry_get_name(list_entry));
node_symlink(udev, udev_device_get_devnode(dev), udev_list_entry_get_name(list_entry));
- } else {
+ else
link_update(dev, udev_list_entry_get_name(list_entry), 1);
- }
}
exit:
return err;