Skip to contentSkip to conversation

makedevs: Do not return error if the fifo exisits

PATCH Superseded Saul Wold 4 participants 4 messages Oct 1, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Saul Wold

author
#0 lore raw

PATCH 1/1 makedevs: Do not return error if the fifo exisits

This ensures that makedevs will not cause image creation failures when it encounters a pipe (fifo) that exists from a previous image. The other file/device creation code either ignore this error or check for file type.

[YOCTO #5288]

---
 meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c +1 -1
index 5d2c45b..7b0487f 100644
@@ -274,7 +274,7 @@ 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))
+	if (mknod(path, mode, 0) && errno != EEXIST)
 		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",
Signature · 1 line
1.7.10.4
#1 lore raw

meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c static void add_new_file(char *name, char *path, unsigned long uid, · line 278

Quoted 6 lines · Saul Wold

static void add_new_fifo(char *name, char *path, unsigned long uid,

meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c +1 -1
 				  unsigned long gid, unsigned long mode)
 {
-	if (mknod(path, mode, 0))
+	if (mknod(path, mode, 0) && errno != EEXIST)
 		error_msg_and_die("%s: file can not be created with mknod!", path);

Will this do the right thing if the mode has changed from the old to the new versions?

p.

#2 lore raw
Quoted 10 lines · Phil Blundell
Quoted 6 lines · Saul Wold

static void add_new_fifo(char *name, char *path, unsigned long uid,
unsigned long gid, unsigned long mode)
{

meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c +1 -1
-	if (mknod(path, mode, 0))
+	if (mknod(path, mode, 0) && errno != EEXIST)
		error_msg_and_die("%s: file can not be created with mknod!", path);

Will this do the right thing if the mode has changed from the old to the new versions?

and it wont catch dangling symlinks anymore

Quoted 8 lines

p.

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#3 lore raw
In reply to Saul Wold
Quoted 18 lines · Saul Wold

This ensures that makedevs will not cause image creation failures when it encounters a pipe (fifo) that exists from a previous image. The other file/device creation code either ignore this error or check for file type.

[YOCTO #5288]

---
  meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c +0 -0
index 5d2c45b..7b0487f 100644

meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c static void add_new_file(char *name, char *path, unsigned long uid, · line 280

Quoted 8 lines
meta/recipes-devtools/makedevs/makedevs-1.0.0/makedevs.c +1 -1
@@ -274,7 +274,7 @@ 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))
+	if (mknod(path, mode, 0) && errno != EEXIST)
  		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",

Ya, I'm happy with this. It avoids recreating it if it exists.. no error.

No idea if a warning is reasonable in this case, but I'm happy with the change.

--Mark