summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorYin Kangkai <kangkai.yin@intel.com>2010-08-05 16:17:00 +0800
committerMartin Pitt <martin.pitt@ubuntu.com>2010-08-08 20:35:46 +0200
commit08f11597f2618d46b23f0e747a41a0ee960bcf1b (patch)
tree910a9cd7760491a283ee1c375a8857cc2492ab53 /udev
parent40929a0222bbc82459c6418b03d51790ca65d74b (diff)
udevd: create static device links only when the target exists
For example, not all systems have PROC_KCORE enabled. Avoid a broken symbolic link in those cases. Signed-off-by: Yin Kangkai <kangkai.yin@intel.com> Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
Diffstat (limited to 'udev')
-rw-r--r--udev/udevd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/udev/udevd.c b/udev/udevd.c
index 6dc97955d6..61b76f5c3e 100644
--- a/udev/udevd.c
+++ b/udev/udevd.c
@@ -900,10 +900,14 @@ static void static_dev_create_links(struct udev *udev, DIR *dir)
unsigned int i;
for (i = 0; i < ARRAY_SIZE(stdlinks); i++) {
- udev_selinux_setfscreateconat(udev, dirfd(dir), stdlinks[i].link, S_IFLNK);
- if (symlinkat(stdlinks[i].target, dirfd(dir), stdlinks[i].link) < 0 && errno == EEXIST)
- utimensat(dirfd(dir), stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW);
- udev_selinux_resetfscreatecon(udev);
+ struct stat sb;
+
+ if (stat(stdlinks[i].target, &sb) == 0) {
+ udev_selinux_setfscreateconat(udev, dirfd(dir), stdlinks[i].link, S_IFLNK);
+ if (symlinkat(stdlinks[i].target, dirfd(dir), stdlinks[i].link) < 0 && errno == EEXIST)
+ utimensat(dirfd(dir), stdlinks[i].link, NULL, AT_SYMLINK_NOFOLLOW);
+ udev_selinux_resetfscreatecon(udev);
+ }
}
}