From 676d294c23cf999ac7d192b058476f91242550c0 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Thu, 10 Sep 2009 01:35:48 +0200 Subject: [PATCH] reorder create_path() and node/link creation to be called in a direct sequence --- libudev/libudev-queue-private.c | 4 +--- udev/udev-node.c | 11 +++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/libudev/libudev-queue-private.c b/libudev/libudev-queue-private.c index e0a8738e..d9f7a67d 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 f17c48a7..3685485e 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; -- 2.39.5