[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--

From: Stefan Vargyas
Subject: stat: added features: `--files0-from=FILE', `--digest-type=WORD' and `--quoting-style=WORD'
Date: Thu, 22 May 2014 01:44:34 -0700 (PDT)

Dear maintainers,

Since coreutils v8.9 I was using a customized 'stat', which has the additional
features implied by the command line options and by the format sequence shown

  $ stat --help
  Usage: stat [OPTION]... [FILE]...
     or: stat [OPTION]... --files-from=F
  Display file or file system status.
                          when computing file content sums use specified
                          message digest algorithm: md5, sha1, sha224, sha256,
                          sha384 or sha512;  when the option is not specified
                          compute sha1 digests
        --files-from=F    display status of files specified by names in file F;
                            If F is - then read names from standard input
                          use quoting style WORD for file names:
                            literal, locale, shell, shell-always, c, escape
                            c-maybe, clocale;
                          when no option is given, use literal style
  The valid format sequences for files (without --file-system):
    %S   file content digest sum

These features were used as essential composing parts in the following scenario:

  (1)  $ find EXPR -print|sort|stat --files-from=- ... > STAT_SRC
  (1b) $ find EXPR -print0|sort -null|stat --files0-from=- ... > STAT_SRC

  (2)  $ find EXPR -print0|du --files0-from=- ...
  (2b) $ find EXPR -print0|sort -null|du --files0-from=- ...

  (3)  $ mkisofs -exclude-list EXCL -o ISO_FILE ...

  (4)  $ find ISO_LOOP --not type d -print|sort|stat --files-from=- ... > 
  (4b) $ find ISO_LOOP --not type d -print0|sort -null|stat --files0-from=- ... 

  (5)  $ diff -u <(cut out inode column from STAT_SRC) <(cut out inode column 
from STAT_ISO)
       $ wdiff STAT_SRC STAT_ISO

Here EXPR and EXCL are generated based upon a (potentially elaborated) list of
file globbing patterns. Zooming into the details of the 'find|stat' commands
above would show something like:

  $ eval find $(GEN-FIND-EXPR)|sort|stat \
  --printf '%S\t%f\t%a\t%u\t%g\t%h\t%i\t%s\t%W\t%X\t%Y\t%Z\t%n\n' \
  --quoting-style=escape \
  --digest-type=sha1 \
  --files-from=- \
  > files-stat.output \

I used to employ steps (1) through (5): my 'stat' implements '--files-from'. The
(2b) and (4b) alternatives imply a fanciful fitted feature of 'sort': 
options: the program is taking in lines terminated by a NUL char instead of by

Please look into the attached patch files. They implement the features 
above, relative to the latest released source tarball (version 8.22, from 
13, 2013). They apply also to the current Coreutils git repository as well.

The 'files0-from' patch modifies only 'stat.c', while the other, 'files-from' --
two additional parties belonging to 'gnulib':

  $ lsdiff stat-files0-from-digest-type-quoting-style.patch 

  $ lsdiff stat-files-from-digest-type-quoting-style.patch 

There is not much to add but to note that the modifications applied to 'stat.c'
do obey to the general style of the other tools in the Coreutils package. I used
a logic which extends that found in 'md5sum.c' with regards to the computations
of digest sums: see functions 'out_hex_string', 'digest_{regular,symlink}_file'
and 'out_file_digest'. The other changes were applied using a logic very similar
to that in 'du.c' and 'wc.c'. The modifications of source files 'argv-iter.[hc]'
and 'readtokens0.[hc]' were made such that their original behavior be preserved
while adding functionality for reading and tokenizing input separated by a given
delimiter char -- which for 'stat.c' with '--files-from' is the newline char.

Both patch sets pass the regression tests included in package. Note that these
patch sets do not touch neither the documentation nor the regression test code
of the package yet: they are only an initial proposition.


Stefan Vargyas.

Attachment: stat-files0-from-digest-type-quoting-style.patch
Description: Text Data

Attachment: stat-files-from-digest-type-quoting-style.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]