[cs631apue] filemode and blocksize question

Jan Schaumann jschauma at stevens.edu
Fri Sep 30 20:46:10 EDT 2016


bzhang41 <bzhang41 at stevens.edu> wrote:

> When I try the sticky bit, sometimes there will be a `+` char followed 
> bu the 'x' permission. What is that ?

This indicates that there may be filesystem specific extended attributes
associated with the file.  You may also encounter a '@' or a '.' in that
spot  Your version of ls(1) does not need to account for those and you
can ignore them.

You can use the getfacl(1) command to get (some of) the attributes,
depending on the file system.  The fact that the manual page makes no
mention of these is a bug / example of the unfortunately inconsistent
quality of manual page on Linux systems.  The info(1) page for ls(1) in
comparison does include a reference to this:

info coreutils 'ls invocation', /\+

     Following the file mode bits is a single character that specifies
     whether an alternate access method such as an access control list
     applies to the file.  When the character following the file mode
     bits is a space, there is no alternate access method.  When it is
     a printing character, then there is such a method.

     GNU `ls' uses a `.' character to indicate a file with an SELinux
     security context, but no other alternate access method.

     A file with any other combination of alternate access methods is
     marked with a `+' character.

 
> 2) When I try to calculat the block size of the directory, I found the 
> result is different from the
> result by using ls.

The GNU version of ls(1) appears to use a default block size of 1024,
contrary to what it says in the manual page (but which, again, it notes
in the 'info' pages -- see above re that unfortunate discrepancy on
Linux systems).

You can change this behaviour by setting the BLOCKSIZE environment
variable.  If you set BLOCKSIZE=1024, your program should behave as the
Linux ls(1); if you set BLOCKSIZE=512, the Linux ls(1) should have just
like yours.

-Jan


More information about the cs631apue mailing list