linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yin Kangkai <kangkai.yin@linux.intel.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH 2/3] udevd: try to create the links only when the target
Date: Fri, 06 Aug 2010 07:26:09 +0000	[thread overview]
Message-ID: <20100806072609.GO29131@kai-debian> (raw)

From 966aab6e1035e607f7c7f4329393bf68c39d49da Mon Sep 17 00:00:00 2001
From: Yin Kangkai <kangkai.yin@intel.com>
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.

Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
---
 udev/udevd.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/udev/udevd.c b/udev/udevd.c
index 6dc9795..61b76f5 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);
+		}
 	}
 }
 
-- 
1.6.5


             reply	other threads:[~2010-08-06  7:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06  7:26 Yin Kangkai [this message]
2010-08-08 18:37 ` [PATCH 2/3] udevd: try to create the links only when the Martin Pitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100806072609.GO29131@kai-debian \
    --to=kangkai.yin@linux.intel.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).