coreutils
[Top][All Lists]
Advanced

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

[coreutils] [PATCH] stat: drop %C support when printing file system deta


From: Eric Blake
Subject: [coreutils] [PATCH] stat: drop %C support when printing file system details
Date: Tue, 5 Oct 2010 09:06:17 -0600

* src/stat.c (print_statfs, usage): Drop %C, since it applies to
files, not file systems.
(out_file_context): Match style of other out_* functions.
(print_stat): Update caller.
* doc/coreutils.texi (stat invocation): Document %C.
* NEWS: Document the change.
---

How does this look?

I went to remove documentation of %C from -f, and to my surprise,
it had been an undocumented addition!

 doc/coreutils.texi |    1 +
 src/stat.c         |   13 ++++---------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 12f103a..f4b7630 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -10679,6 +10679,7 @@ stat invocation
 @item %A - Access rights in human readable form
 @item %b - Number of blocks allocated (see @samp{%B})
 @item %B - The size in bytes of each block reported by @samp{%b}
+@item %C - The SELinux security context of a file, if available
 @item %d - Device number in decimal
 @item %D - Device number in hex
 @item %f - Raw mode in hex
diff --git a/src/stat.c b/src/stat.c
index f742f1e..fabbc17 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -513,11 +513,10 @@ out_uint_x (char *pformat, size_t prefix_len, uintmax_t 
arg)
   printf (pformat, arg);
 }

-/* Very specialized function (modifies FORMAT), just so as to avoid
-   duplicating this code between both print_statfs and print_stat.
-   Return zero upon success, nonzero upon failure.  */
+/* Print the context information of FILENAME, and return true iff the
+   context could not be obtained.  */
 static bool ATTRIBUTE_WARN_UNUSED_RESULT
-out_file_context (char const *filename, char *pformat, size_t prefix_len)
+out_file_context (char *pformat, size_t prefix_len, char const *filename)
 {
   char *scontext;
   bool fail = false;
@@ -617,9 +616,6 @@ print_statfs (char *pformat, size_t prefix_len, char m, 
char const *filename,
     case 'd':
       out_int (pformat, prefix_len, statfsbuf->f_ffree);
       break;
-    case 'C':
-      fail |= out_file_context (filename, pformat, prefix_len);
-      break;
     default:
       fputc ('?', stdout);
       break;
@@ -846,7 +842,7 @@ print_stat (char *pformat, size_t prefix_len, char m,
       out_string (pformat, prefix_len, epoch_time (get_stat_ctime (statbuf)));
       break;
     case 'C':
-      fail |= out_file_context (filename, pformat, prefix_len);
+      fail |= out_file_context (pformat, prefix_len, filename);
       break;
     default:
       fputc ('?', stdout);
@@ -1238,7 +1234,6 @@ Valid format sequences for file systems:\n\
   %c   Total file nodes in file system\n\
   %d   Free file nodes in file system\n\
   %f   Free blocks in file system\n\
-  %C   SELinux security context string\n\
 "), stdout);
       fputs (_("\
   %i   File System ID in hex\n\
-- 
1.7.2.3




reply via email to

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