summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2010-10-05 09:02:37 -0600
committerEric Blake <eblake@redhat.com>2010-10-05 09:07:58 -0600
commitb7459696dca96015688e82c81eaefad756b63ddc (patch)
tree9161b78ce6f91cb170aee4a0f0a3645a390a9dab
parent4c286d341a5443ca9044ac3aca3b69d941f5e531 (diff)
downloadcoreutils-b7459696dca96015688e82c81eaefad756b63ddc.tar.xz
stat: drop %C support when printing file system details
* 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.
-rw-r--r--NEWS8
-rw-r--r--doc/coreutils.texi1
-rw-r--r--src/stat.c13
3 files changed, 11 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index 719ac9c47..22f257ba6 100644
--- a/NEWS
+++ b/NEWS
@@ -76,10 +76,14 @@ GNU coreutils NEWS -*- outline -*-
stat no longer accepts the --context (-Z) option. Initially it was
merely accepted and ignored, for compatibility. Starting two years
ago, with coreutils-7.0, its use evoked a warning. Printing the
- SELinux context can be done with the %C format directive, and the
- default output when no format is specified now automatically
+ SELinux context of a file can be done with the %C format directive,
+ and the default output when no format is specified now automatically
includes %C when context information is available.
+ stat no longer accepts the %C directive when the --file-system
+ option is in effect, since security context is a file attribute
+ rather than a file system attribute.
+
stat now outputs the full sub-second resolution for the atime,
mtime, and ctime values since the Epoch, when using the %X, %Y, and
%Z directives of the --format option. This matches the fact that
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 12f103a12..f4b76309d 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -10679,6 +10679,7 @@ The valid @var{format} directives for files with @option{--format} and
@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 f742f1ed3..fabbc17e1 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\