Subject: Fwd: Re: bug#29069: info coreutils file permissions: improvements/bug-report

From: kalle <[email-masked]>
Date: Wed, 31 Jan 2018 00:55:31 +0100

I have a patch for chapter 27.3, coreutils texinfo-document.

greetings,
kalle
From b250dcdaba02083a0174d9157c655f0dbb586ef6 Mon Sep 17 00:00:00 2001
From: kalle <[email-masked]>
Date: Wed, 3 Jan 2018 20:56:07 +0100
Subject: [PATCH] changed presentation in 'File permissions' in 'numeric modes'

I described the numeric modes explaining it's octal representation and how it is obtained from the symbolic notation.
---
 doc/perm.texi | 64 ++++++++++++++---------------------------------------------
 1 file changed, 15 insertions(+), 49 deletions(-)

diff --git a/doc/perm.texi b/doc/perm.texi
index c94c483..a514998 100644
--- a/doc/perm.texi
+++ b/doc/perm.texi
@@ -491,59 +491,25 @@ the file to all users.
 @cindex numeric modes
 @cindex file mode bits, numeric
 @cindex octal numbers for file modes
-As an
-alternative to giving a symbolic mode, you can give an octal (base 8)
-number that represents the mode.
-This number is always interpreted in octal; you do not have to add a
-leading @samp{0}, as you do in C.  Mode @samp{0055} is the same as
-mode @samp{55}.  (However, modes of five digits or more, such as
-@samp{00055}, are sometimes special.  @xref{Directory Setuid and Setgid}.)
-
-A numeric mode is usually shorter than the corresponding symbolic
-mode, but it is limited in that normally it cannot take into account the
-previous file mode bits; it can only set them absolutely.
-The set-user-ID and set-group-ID bits of directories are an exception
-to this general limitation.  @xref{Directory Setuid and Setgid}.
-Also, operator numeric modes can take previous file mode bits into
-account.  @xref{Operator Numeric Modes}.
-
-The permissions granted to the user,
-to other users in the file's group,
-and to other users not in the file's group each require three
-bits, which are represented as one octal digit.  The three special
-mode bits also require one bit each, and they are as a group
-represented as another octal digit.  Here is how the bits are arranged,
-starting with the lowest valued bit:
+As an alternative to giving a symbolic mode, you can give an octal (with base 8) number that represents the mode.This number is always interpreted in octal; you do not have to add a leading @samp{0}, as you do in C. Mode @samp{0055} is the same as mode @samp{55}.  Modes of five digits or more, such as @samp{00055}, have a special meaning for directories  @xref{Directory Setuid and Setgid}.)
+
+A numeric mode is usually shorter than the corresponding symbolic mode, but it is limited in that normally it cannot take into account the previous file mode bits; it can only set them absolutely.  The set-user-ID and set-group-ID bits of directories are an exception to this general limitation.   @xref{Directory Setuid and Setgid}.  Also, operator numeric modes can take previous file mode bits into account.  @xref{Operator Numeric Modes}.
+
+The octal notation can be derived from the symbolic one, as an intermediate step transforming it into a binary string (1), which is then easily changed into octal base (2):
+
+(1)For the intermediate step the @samp{r},@samp{w} and @samp{x}-symbols of the symbolic notation are changed out at the corresponding place by a @samp{0} or a @samp{1}, according to whether the bits are clear or set  (this works as long as there are no special mode bits, because every place belongs specifically to one kind of bit), thus transforming e.g. the string @samp{rwxr-xr--} into @samp{111101100}.Then instead of overriding the @samp{x}-bits, the special mode bits are represented by grouping them at the beginning, in the order suid|guid|sticky/restricted_deletion, thus e.g. describing symbolic @samp{rwsr-xr-t} as @samp{101111101101}. 
+
+(2)Every 3 digits can then be grouped together and described as an octal digit, following the logic that three binary digits @samp{abc} are translated into an octal number a*2^2+b*2^1+c*2^0=a*4+b*2+c*1, e.g.:
 
 @example
-Value in  Corresponding
-Mode      Mode Bit
-
-          Other users not in the file's group:
-   1      Execute/search
-   2      Write
-   4      Read
-
-          Other users in the file's group:
-  10      Execute/search
-  20      Write
-  40      Read
-
-          The file's owner:
- 100      Execute/search
- 200      Write
- 400      Read
-
-          Special mode bits:
-1000      Restricted deletion flag or sticky bit
-2000      Set group ID on execution
-4000      Set user ID on execution
+binary	octal
+101	5
+111	7
+011	3
 @end example
 
-For example, numeric mode @samp{4755} corresponds to symbolic mode
-@samp{u=rwxs,go=rx}, and numeric mode @samp{664} corresponds to symbolic mode
-@samp{ug=rw,o=r}.  Numeric mode @samp{0} corresponds to symbolic mode
-@samp{a=}.
+thus transforming the binary @samp{101111101101} from the last example into octal @samp{5755}.
+
 
 @node Operator Numeric Modes
 @section Operator Numeric Modes
-- 
1.9.1