From: Pádraig Brady
Date: Fri, 22 Jun 2012 10:17:38 +0000 (+0100)
Subject: maint: refactor common mode bits used to create files
X-Git-Tag: v8.18~48
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30a604e631291b80b9812e03e0f325489ae0d77e;p=thirdparty%2Fcoreutils.git
maint: refactor common mode bits used to create files
* src/system.h (MODE_RW_UGO): The new refactored define (666).
* src/mkfifo.c: Use the new define.
* src/mknod.c: Likewise.
* src/split.c: Likewise.
* src/system.h: Likewise.
* src/touch.c: Likewise.
* src/truncate.c: Likewise.
Suggested-by: Jim Meyering
---
diff --git a/src/dd.c b/src/dd.c
index 163d514c09..d93733683c 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -2211,7 +2211,7 @@ main (int argc, char **argv)
}
else
{
- mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
+ mode_t perms = MODE_RW_UGO;
int opts
= (output_flags
| (conversions_mask & C_NOCREAT ? 0 : O_CREAT)
diff --git a/src/mkfifo.c b/src/mkfifo.c
index e5c871d144..e524c44c9c 100644
--- a/src/mkfifo.c
+++ b/src/mkfifo.c
@@ -114,7 +114,7 @@ main (int argc, char **argv)
_("failed to set default file creation context to %s"),
quote (scontext));
- newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ newmode = MODE_RW_UGO;
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
diff --git a/src/mknod.c b/src/mknod.c
index 3a6d695af2..dc158b4405 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -120,7 +120,7 @@ main (int argc, char **argv)
}
}
- newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
+ newmode = MODE_RW_UGO;
if (specified_mode)
{
struct mode_change *change = mode_compile (specified_mode);
diff --git a/src/split.c b/src/split.c
index 53ee2719d0..46d2511ae1 100644
--- a/src/split.c
+++ b/src/split.c
@@ -362,8 +362,7 @@ create (const char *name)
{
if (verbose)
fprintf (stdout, _("creating file %s\n"), quote (name));
- return open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
- (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
+ return open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, MODE_RW_UGO);
}
else
{
diff --git a/src/system.h b/src/system.h
index 06f09cba6d..5e3b3cbdeb 100644
--- a/src/system.h
+++ b/src/system.h
@@ -30,6 +30,9 @@ you must include