diff options
author | Denys Vlasenko | 2016-11-27 23:27:54 +0100 |
---|---|---|
committer | Denys Vlasenko | 2016-11-27 23:27:54 +0100 |
commit | 2c769c69b269f43d8c9ecf4a7f5ce5cce290750a (patch) | |
tree | 1d68a329e6419f721ee5dda0cabeafc16c79834b | |
parent | bff71d3b9d4244abc5182c38d0a98f4913188391 (diff) | |
download | busybox-2c769c69b269f43d8c9ecf4a7f5ce5cce290750a.zip busybox-2c769c69b269f43d8c9ecf4a7f5ce5cce290750a.tar.gz |
makedevs: make special node creation idempotent
When makedevs is called for a second time with the same device file,
it fails because the files already exist and mknod() gives -EEXIST.
Ignore EEXIST errors.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/makedevs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index 6278ee7..c5eeed0 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c @@ -157,8 +157,11 @@ int makedevs_main(int argc, char **argv) /* if mode != S_IFCHR and != S_IFBLK, * third param in mknod() ignored */ - if (mknod(nodname, mode, makedev(Smajor, Sminor))) + if (mknod(nodname, mode, makedev(Smajor, Sminor)) != 0 + && errno != EEXIST + ) { bb_perror_msg("can't create '%s'", nodname); + } /*if (nodname == basedev)*/ /* ex. /dev/hda - to /dev/hda1 ... */ nodname = buf; @@ -279,7 +282,9 @@ int makedevs_main(int argc UNUSED_PARAM, char **argv) for (i = start; i <= start + count; i++) { sprintf(full_name_inc, count ? "%s%u" : "%s", full_name, i); rdev = makedev(major, minor + (i - start) * increment); - if (mknod(full_name_inc, mode, rdev) < 0) { + if (mknod(full_name_inc, mode, rdev) != 0 + && errno != EEXIST + ) { bb_perror_msg("line %d: can't create node %s", linenum, full_name_inc); ret = EXIT_FAILURE; } else if (chown(full_name_inc, uid, gid) < 0) { |