Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2] makedevs: Do not return error if the fifo exisits
Date: Tue,  1 Oct 2013 12:15:45 -0700	[thread overview]
Message-ID: <1380654945-17787-1-git-send-email-sgw@linux.intel.com> (raw)

This ensures that makedevs will not cause image creation failures
when it encounters a pipe (fifo) that exists from a previous image.
This handles mode changes and it will correctly fail for dangling
symlinks.

[YOCTO #5288]

Signed-off-by: Saul Wold <sgw@linux.intel.com>

makedev

Signed-off-by: Saul Wold <sgw@linux.intel.com>

makedev

Signed-off-by: Saul Wold <sgw@linux.intel.com>
---
 .../makedevs/makedevs-1.0.0/makedevs.c                 |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
index 5d2c45b..53700c6 100644
--- a/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
+++ b/meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c
@@ -274,8 +274,20 @@ static void add_new_file(char *name, char *path, unsigned long uid,
 static void add_new_fifo(char *name, char *path, unsigned long uid,
 				  unsigned long gid, unsigned long mode)
 {
-	if (mknod(path, mode, 0))
-		error_msg_and_die("%s: file can not be created with mknod!", path);
+	int status;
+	struct stat sb;
+
+	memset(&sb, 0, sizeof(struct stat));
+	status = stat(path, &sb);
+
+
+	/* Update the mode if we exist and are a fifo already */
+	if (status >= 0 && S_ISFIFO(sb.st_mode)) {
+		chmod(path, mode);
+	} else {
+		if (mknod(path, mode, 0))
+			error_msg_and_die("%s: file can not be created with mknod!", path);
+	}
 	chown(path, uid, gid);
 //	printf("File: %s %s  UID: %ld  GID: %ld  MODE: %04lo\n",
 //			path, name, gid, uid, mode);
-- 
1.7.10.4



             reply	other threads:[~2013-10-01 19:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 19:15 Saul Wold [this message]
2013-10-01 19:49 ` [PATCH v2] makedevs: Do not return error if the fifo exisits Phil Blundell
2013-10-01 19:58   ` Saul Wold
2013-10-01 20:07     ` Phil Blundell
2013-10-01 20:34       ` Saul Wold

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=1380654945-17787-1-git-send-email-sgw@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.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