new tool
[hband-tools.git] / compiled-tools / coreutils / chmod-cheap.patch
blobc9f905b63b638737f75448be2db6caa6bb1b0810
1 commit 15825b454249350131afe43a08020450f0e6b3c9
2 Author: bAndie91 <bandie9100@gmail.com>
3 Date: Tue May 24 10:03:40 2016 +0200
5 --cheap option
7 diff --git a/src/chmod.c b/src/chmod.c
8 index ba94410..5d60f23 100644
9 --- a/src/chmod.c
10 +++ b/src/chmod.c
11 @@ -436,7 +436,7 @@ main (int argc, char **argv)
13 atexit (close_stdout);
15 - recurse = force_silent = diagnose_surprises = false;
16 + recurse = force_silent = diagnose_surprises = cheap_ops = false;
18 while ((c = getopt_long (argc, argv,
19 ("RcfvCr::w::x::X::s::t::u::g::o::a::,::+::=::"
21 commit f31b8eef23c435f3ef429a3791cd06bd3fd1b9fc
22 Author: bAndie91 <bandie9100@gmail.com>
23 Date: Tue May 24 10:00:30 2016 +0200
25 --cheap option
27 diff --git a/src/chmod.c b/src/chmod.c
28 index 3ea66eb..ba94410 100644
29 --- a/src/chmod.c
30 +++ b/src/chmod.c
31 @@ -67,6 +67,9 @@ static mode_t umask_value;
32 /* If true, change the modes of directories recursively. */
33 static bool recurse;
35 +/* Cheap operations - do chmod(1) only if new mode would differ from old one */
36 +static bool cheap_ops;
38 /* If true, force silence (suppress most of error messages). */
39 static bool force_silent;
41 @@ -101,6 +104,7 @@ static struct option const long_options[] =
42 {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
43 {"silent", no_argument, NULL, 'f'},
44 {"verbose", no_argument, NULL, 'v'},
45 + {"cheap", no_argument, NULL, 'C'},
46 {GETOPT_HELP_OPTION_DECL},
47 {GETOPT_VERSION_OPTION_DECL},
48 {NULL, 0, NULL, 0}
49 @@ -269,7 +273,7 @@ process_file (FTS *fts, FTSENT *ent)
51 if (! S_ISLNK (old_mode))
53 - if (chmodat (fts->fts_cwd_fd, file, new_mode) == 0)
54 + if ((cheap_ops && (old_mode & CHMOD_MODE_BITS) == (new_mode & CHMOD_MODE_BITS)) || chmodat (fts->fts_cwd_fd, file, new_mode) == 0)
55 chmod_succeeded = true;
56 else
58 @@ -396,6 +400,9 @@ With --reference, change the mode of each FILE to that of RFILE.\n\
59 fputs (_("\
60 -R, --recursive change files and directories recursively\n\
61 "), stdout);
62 + fputs (_("\
63 + -C, --cheap do not chmod unless new mode differs from old one\n\
64 +"), stdout);
65 fputs (HELP_OPTION_DESCRIPTION, stdout);
66 fputs (VERSION_OPTION_DESCRIPTION, stdout);
67 fputs (_("\
68 @@ -432,7 +439,7 @@ main (int argc, char **argv)
69 recurse = force_silent = diagnose_surprises = false;
71 while ((c = getopt_long (argc, argv,
72 - ("Rcfvr::w::x::X::s::t::u::g::o::a::,::+::=::"
73 + ("RcfvCr::w::x::X::s::t::u::g::o::a::,::+::=::"
74 "0::1::2::3::4::5::6::7::"),
75 long_options, NULL))
76 != -1)
77 @@ -501,6 +508,9 @@ main (int argc, char **argv)
78 case 'v':
79 verbosity = V_high;
80 break;
81 + case 'C':
82 + cheap_ops = true;
83 + break;
84 case_GETOPT_HELP_CHAR;
85 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
86 default: