aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-01-21 01:22:12 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-01-21 01:22:12 +0100
commit4609f477c7e043a4f6147dfe6e86b775da2ef784 (patch)
treec4e51b6214438008026cd22744e57d3cb1cb27ba /util-linux
parent31dc8603eedc0140c798c9af3404a35ea190af2c (diff)
downloadbusybox-w32-4609f477c7e043a4f6147dfe6e86b775da2ef784.tar.gz
busybox-w32-4609f477c7e043a4f6147dfe6e86b775da2ef784.tar.bz2
busybox-w32-4609f477c7e043a4f6147dfe6e86b775da2ef784.zip
mdev: fix mode of dir1 in =dir1/dir2/file rule
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/mdev.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 79871d30e..75de14ff1 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -429,6 +429,18 @@ static const struct rule *next_rule(void)
429 429
430#endif 430#endif
431 431
432static void mkdir_recursive(char *name)
433{
434 /* if name has many levels ("dir1/dir2"),
435 * bb_make_directory() will create dir1 according to umask,
436 * not according to its "mode" parameter.
437 * Since we run with umask=0, need to temporarily switch it.
438 */
439 umask(022); /* "dir1" (if any) will be 0755 too */
440 bb_make_directory(name, 0755, FILEUTILS_RECUR);
441 umask(0);
442}
443
432/* Builds an alias path. 444/* Builds an alias path.
433 * This function potentionally reallocates the alias parameter. 445 * This function potentionally reallocates the alias parameter.
434 * Only used for ENABLE_FEATURE_MDEV_RENAME 446 * Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -442,7 +454,7 @@ static char *build_alias(char *alias, const char *device_name)
442 dest = strrchr(alias, '/'); 454 dest = strrchr(alias, '/');
443 if (dest) { /* ">bar/[baz]" ? */ 455 if (dest) { /* ">bar/[baz]" ? */
444 *dest = '\0'; /* mkdir bar */ 456 *dest = '\0'; /* mkdir bar */
445 bb_make_directory(alias, 0755, FILEUTILS_RECUR); 457 mkdir_recursive(alias);
446 *dest = '/'; 458 *dest = '/';
447 if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */ 459 if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
448 dest = alias; 460 dest = alias;
@@ -641,7 +653,7 @@ static void make_device(char *device_name, char *path, int operation)
641 char *slash = strrchr(node_name, '/'); 653 char *slash = strrchr(node_name, '/');
642 if (slash) { 654 if (slash) {
643 *slash = '\0'; 655 *slash = '\0';
644 bb_make_directory(node_name, 0755, FILEUTILS_RECUR); 656 mkdir_recursive(node_name);
645 *slash = '/'; 657 *slash = '/';
646 } 658 }
647 if (G.verbose) 659 if (G.verbose)