Skip to contentSkip to conversation

udevd: try to create the links only when the target

PATCH Applied Yin Kangkai 2 participants 2 messages Aug 6, 2010 – Aug 8, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 udevd: try to create the links only when the target

From 966aab6e1035e607f7c7f4329393bf68c39d49da Mon Sep 17 00:00:00 2001
From: Yin Kangkai <[email protected]>
Date: Thu, 5 Aug 2010 16:17:00 +0800
Subject: [PATCH 2/3] udevd: try to create the links only when the target exists

For example, not all the systems have the PROC_KCORE enalbed but a broken symbol link be created in spite of that.

---
 udev/udevd.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
udev/udevd.c +8 -4
index 6dc9795..61b76f5 100644
@@ -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);
+		}
 	}
 }
 
Signature · 1 line
1.6.5
Applied
#1 lore raw

Re: [PATCH 2/3] udevd: try to create the links only when the

Hello Yin,

Yin Kangkai [2010-08-06 15:26 +0800]:

Quoted 1 line

udevd: try to create the links only when the target exists

Thanks! Applied with some typo fixes and a clarified description.

Martin

Signature · 2 lines
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)