[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] new chmod flag: R = r for files, rx for dirs
From: |
vda |
Subject: |
[PATCH] new chmod flag: R = r for files, rx for dirs |
Date: |
Tue, 20 Nov 2001 14:16:23 +0000 |
This is a result of discussion on lkml on usefulness of x bit on dirs.
It adds new flag to chmod:
chmod -R a+R dir
R=(r for files, rx for dirs)
Without this flag, in order to achieve functionality of above command
one needs to write ridiculously long script.
chmod manpage is not updated (I don't know manpage syntax)
Contact me: address@hidden if you have any comments.
diff -u --recursive fileutils-4.1-1-old/ChangeLog
fileutils-4.1-1-new/ChangeLog
--- fileutils-4.1-1-old/ChangeLog Sun Apr 29 11:33:43 2001
+++ fileutils-4.1-1-new/ChangeLog Tue Nov 20 13:48:11 2001
@@ -1,3 +1,7 @@
+2001-11-20 Denis Vlasenko <address@hidden>
+
+ * chmod.c: added R flag: r for files, rx for dirs
+
2001-04-29 Jim Meyering <address@hidden>
* Version 4.1.
diff -u --recursive fileutils-4.1-1-old/lib/modechange.c
fileutils-4.1-1-new/lib/modechange.c
--- fileutils-4.1-1-old/lib/modechange.c Sun Jan 7 09:20:33 2001
+++ fileutils-4.1-1-new/lib/modechange.c Tue Nov 20 13:58:45 2001
@@ -312,6 +312,12 @@
change->value |= ((S_IWUSR | S_IWGRP | S_IWOTH)
& affected_masked);
break;
+ case 'R':
+ change->flags |= MODE_X_IF_DIR;
+ change->value |= ((S_IRUSR | S_IRGRP | S_IROTH
+ | S_IXUSR | S_IXGRP | S_IXOTH)
+ & affected_masked);
+ break;
case 'X':
change->flags |= MODE_X_IF_ANY_X;
/* Fall through. */
@@ -437,6 +443,12 @@
else
{
value = changes->value;
+ /* If `R', do not affect the execute bits if the file is not a
+ directory. */
+ if ((changes->flags & MODE_X_IF_DIR)
+ && !S_ISDIR (oldmode))
+ /* Clear the execute bits. */
+ value &= ~ (S_IXUSR | S_IXGRP | S_IXOTH);
/* If `X', do not affect the execute bits if the file is not a
directory and no execute bits are already set. */
if ((changes->flags & MODE_X_IF_ANY_X)
diff -u --recursive fileutils-4.1-1-old/lib/modechange.h
fileutils-4.1-1-new/lib/modechange.h
--- fileutils-4.1-1-old/lib/modechange.h Mon Aug 7 17:01:58 2000
+++ fileutils-4.1-1-new/lib/modechange.h Tue Nov 20 13:46:15 2001
@@ -26,14 +26,15 @@
# include <sys/types.h>
+/* Affect the execute bits only if the file is a directory. */
+# define MODE_X_IF_DIR 01
/* Affect the execute bits only if at least one execute bit is set already,
or if the file is a directory. */
-# define MODE_X_IF_ANY_X 01
-
+# define MODE_X_IF_ANY_X 02
/* If set, copy some existing permissions for u, g, or o onto the other two.
Which of u, g, or o is copied is determined by which bits are set in the
`value' field. */
-# define MODE_COPY_EXISTING 02
+# define MODE_COPY_EXISTING 04
struct mode_change
{
- [PATCH] new chmod flag: R = r for files, rx for dirs,
vda <=