~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to src/stat.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* stat.c -- display file or file system status
2
 
   Copyright (C) 2001-2011 Free Software Foundation, Inc.
 
2
   Copyright (C) 2001-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software: you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
30
30
 
31
31
#include <stddef.h>
32
32
#include <stdio.h>
 
33
#include <stdalign.h>
33
34
#include <sys/types.h>
34
35
#include <pwd.h>
35
36
#include <grp.h>
57
58
 
58
59
#include "system.h"
59
60
 
60
 
#include "alignof.h"
61
61
#include "areadlink.h"
62
62
#include "error.h"
63
63
#include "file-type.h"
126
126
# else
127
127
#  define STRUCT_STATVFS struct statfs
128
128
#  define STRUCT_STATXFS_F_FSID_IS_INTEGER STRUCT_STATFS_F_FSID_IS_INTEGER
129
 
#  define STATFS_FRSIZE(S) 0
 
129
#  if HAVE_STRUCT_STATFS_F_FRSIZE
 
130
#   define STATFS_FRSIZE(S) ((S)->f_frsize)
 
131
#  else
 
132
#   define STATFS_FRSIZE(S) 0
 
133
#  endif
130
134
# endif
131
135
#endif
132
136
 
232
236
      /* Also compare with the list in "man 2 statfs" using the
233
237
         fs-magic-compare make target.  */
234
238
 
235
 
      /* IMPORTANT NOTE: Each of the following `case S_MAGIC_...:'
 
239
      /* IMPORTANT NOTE: Each of the following 'case S_MAGIC_...:'
236
240
         statements must be followed by a hexadecimal constant in
237
241
         a comment.  The S_MAGIC_... name and constant are automatically
238
242
         combined to produce the #define directives in fs.h.  */
239
243
 
240
 
    case S_MAGIC_ADFS: /* 0xADF5 */
 
244
    case S_MAGIC_ADFS: /* 0xADF5 local */
241
245
      return "adfs";
242
 
    case S_MAGIC_AFFS: /* 0xADFF */
 
246
    case S_MAGIC_AFFS: /* 0xADFF local */
243
247
      return "affs";
244
 
    case S_MAGIC_AFS: /* 0x5346414F */
 
248
    case S_MAGIC_AFS: /* 0x5346414F remote */
245
249
      return "afs";
246
 
    case S_MAGIC_ANON_INODE_FS: /* 0x09041934 */
 
250
    case S_MAGIC_ANON_INODE_FS: /* 0x09041934 local */
247
251
      return "anon-inode FS";
248
 
    case S_MAGIC_AUTOFS: /* 0x0187 */
 
252
    case S_MAGIC_AUFS: /* 0x61756673 remote */
 
253
      /* FIXME: change syntax or add an optional attribute like "inotify:no".
 
254
         The above is labeled as "remote" so that tail always uses polling,
 
255
         but this isn't really a remote file system type.  */
 
256
      return "aufs";
 
257
    case S_MAGIC_AUTOFS: /* 0x0187 local */
249
258
      return "autofs";
250
 
    case S_MAGIC_BEFS: /* 0x42465331 */
 
259
    case S_MAGIC_BEFS: /* 0x42465331 local */
251
260
      return "befs";
252
 
    case S_MAGIC_BFS: /* 0x1BADFACE */
 
261
    case S_MAGIC_BDEVFS: /* 0x62646576 local */
 
262
      return "bdevfs";
 
263
    case S_MAGIC_BFS: /* 0x1BADFACE local */
253
264
      return "bfs";
254
 
    case S_MAGIC_BINFMT_MISC: /* 0x42494E4D */
 
265
    case S_MAGIC_BINFMTFS: /* 0x42494E4D local */
255
266
      return "binfmt_misc";
256
 
    case S_MAGIC_BTRFS: /* 0x9123683E */
 
267
    case S_MAGIC_BTRFS: /* 0x9123683E local */
257
268
      return "btrfs";
258
 
    case S_MAGIC_CGROUP: /* 0x0027E0EB */
 
269
    case S_MAGIC_CGROUP: /* 0x0027E0EB local */
259
270
      return "cgroupfs";
260
 
    case S_MAGIC_CIFS: /* 0xFF534D42 */
 
271
    case S_MAGIC_CIFS: /* 0xFF534D42 remote */
261
272
      return "cifs";
262
 
    case S_MAGIC_CODA: /* 0x73757245 */
 
273
    case S_MAGIC_CODA: /* 0x73757245 remote */
263
274
      return "coda";
264
 
    case S_MAGIC_COH: /* 0x012FF7B7 */
 
275
    case S_MAGIC_COH: /* 0x012FF7B7 local */
265
276
      return "coh";
266
 
    case S_MAGIC_CRAMFS: /* 0x28CD3D45 */
 
277
    case S_MAGIC_CRAMFS: /* 0x28CD3D45 local */
267
278
      return "cramfs";
268
 
    case S_MAGIC_CRAMFS_WEND: /* 0x453DCD28 */
 
279
    case S_MAGIC_CRAMFS_WEND: /* 0x453DCD28 local */
269
280
      return "cramfs-wend";
270
 
    case S_MAGIC_DEBUGFS: /* 0x64626720 */
 
281
    case S_MAGIC_DEBUGFS: /* 0x64626720 local */
271
282
      return "debugfs";
272
 
    case S_MAGIC_DEVFS: /* 0x1373 */
 
283
    case S_MAGIC_DEVFS: /* 0x1373 local */
273
284
      return "devfs";
274
 
    case S_MAGIC_DEVPTS: /* 0x1CD1 */
 
285
    case S_MAGIC_DEVPTS: /* 0x1CD1 local */
275
286
      return "devpts";
276
 
    case S_MAGIC_ECRYPTFS: /* 0xF15F */
 
287
    case S_MAGIC_ECRYPTFS: /* 0xF15F local */
277
288
      return "ecryptfs";
278
 
    case S_MAGIC_EFS: /* 0x00414A53 */
 
289
    case S_MAGIC_EFS: /* 0x00414A53 local */
279
290
      return "efs";
280
 
    case S_MAGIC_EXT: /* 0x137D */
 
291
    case S_MAGIC_EXT: /* 0x137D local */
281
292
      return "ext";
282
 
    case S_MAGIC_EXT2: /* 0xEF53 */
 
293
    case S_MAGIC_EXT2: /* 0xEF53 local */
283
294
      return "ext2/ext3";
284
 
    case S_MAGIC_EXT2_OLD: /* 0xEF51 */
 
295
    case S_MAGIC_EXT2_OLD: /* 0xEF51 local */
285
296
      return "ext2";
286
 
    case S_MAGIC_FAT: /* 0x4006 */
 
297
    case S_MAGIC_FAT: /* 0x4006 local */
287
298
      return "fat";
288
 
    case S_MAGIC_FUSEBLK: /* 0x65735546 */
 
299
    case S_MAGIC_FHGFS: /* 0x19830326 remote */
 
300
      return "fhgfs";
 
301
    case S_MAGIC_FUSEBLK: /* 0x65735546 remote */
289
302
      return "fuseblk";
290
 
    case S_MAGIC_FUSECTL: /* 0x65735543 */
 
303
    case S_MAGIC_FUSECTL: /* 0x65735543 remote */
291
304
      return "fusectl";
292
 
    case S_MAGIC_FUTEXFS: /* 0x0BAD1DEA */
 
305
    case S_MAGIC_FUTEXFS: /* 0x0BAD1DEA local */
293
306
      return "futexfs";
294
 
    case S_MAGIC_GFS: /* 0x1161970 */
 
307
    case S_MAGIC_GFS: /* 0x1161970 remote */
295
308
      return "gfs/gfs2";
296
 
    case S_MAGIC_GPFS: /* 0x47504653 */
 
309
    case S_MAGIC_GPFS: /* 0x47504653 remote */
297
310
      return "gpfs";
298
 
    case S_MAGIC_HFS: /* 0x4244 */
 
311
    case S_MAGIC_HFS: /* 0x4244 local */
299
312
      return "hfs";
300
 
    case S_MAGIC_HPFS: /* 0xF995E849 */
 
313
    case S_MAGIC_HPFS: /* 0xF995E849 local */
301
314
      return "hpfs";
302
 
    case S_MAGIC_HUGETLBFS: /* 0x958458F6 */
 
315
    case S_MAGIC_HUGETLBFS: /* 0x958458F6 local */
303
316
      return "hugetlbfs";
304
 
    case S_MAGIC_INOTIFYFS: /* 0x2BAD1DEA */
 
317
    case S_MAGIC_MTD_INODE_FS: /* 0x11307854 local */
 
318
      return "inodefs";
 
319
    case S_MAGIC_INOTIFYFS: /* 0x2BAD1DEA local */
305
320
      return "inotifyfs";
306
 
    case S_MAGIC_ISOFS: /* 0x9660 */
307
 
      return "isofs";
308
 
    case S_MAGIC_ISOFS_R_WIN: /* 0x4004 */
309
 
      return "isofs";
310
 
    case S_MAGIC_ISOFS_WIN: /* 0x4000 */
311
 
      return "isofs";
312
 
    case S_MAGIC_JFFS: /* 0x07C0 */
 
321
    case S_MAGIC_ISOFS: /* 0x9660 local */
 
322
      return "isofs";
 
323
    case S_MAGIC_ISOFS_R_WIN: /* 0x4004 local */
 
324
      return "isofs";
 
325
    case S_MAGIC_ISOFS_WIN: /* 0x4000 local */
 
326
      return "isofs";
 
327
    case S_MAGIC_JFFS: /* 0x07C0 local */
313
328
      return "jffs";
314
 
    case S_MAGIC_JFFS2: /* 0x72B6 */
 
329
    case S_MAGIC_JFFS2: /* 0x72B6 local */
315
330
      return "jffs2";
316
 
    case S_MAGIC_JFS: /* 0x3153464A */
 
331
    case S_MAGIC_JFS: /* 0x3153464A local */
317
332
      return "jfs";
318
 
    case S_MAGIC_KAFS: /* 0x6B414653 */
 
333
    case S_MAGIC_KAFS: /* 0x6B414653 remote */
319
334
      return "k-afs";
320
 
    case S_MAGIC_LUSTRE: /* 0x0BD00BD0 */
 
335
    case S_MAGIC_LUSTRE: /* 0x0BD00BD0 remote */
321
336
      return "lustre";
322
 
    case S_MAGIC_MINIX: /* 0x137F */
 
337
    case S_MAGIC_MINIX: /* 0x137F local */
323
338
      return "minix";
324
 
    case S_MAGIC_MINIX_30: /* 0x138F */
 
339
    case S_MAGIC_MINIX_30: /* 0x138F local */
325
340
      return "minix (30 char.)";
326
 
    case S_MAGIC_MINIX_V2: /* 0x2468 */
 
341
    case S_MAGIC_MINIX_V2: /* 0x2468 local */
327
342
      return "minix v2";
328
 
    case S_MAGIC_MINIX_V2_30: /* 0x2478 */
 
343
    case S_MAGIC_MINIX_V2_30: /* 0x2478 local */
329
344
      return "minix v2 (30 char.)";
330
 
    case S_MAGIC_MINIX_V3: /* 0x4D5A */
 
345
    case S_MAGIC_MINIX_V3: /* 0x4D5A local */
331
346
      return "minix3";
332
 
    case S_MAGIC_MQUEUE: /* 0x19800202 */
 
347
    case S_MAGIC_MQUEUE: /* 0x19800202 local */
333
348
      return "mqueue";
334
 
    case S_MAGIC_MSDOS: /* 0x4D44 */
 
349
    case S_MAGIC_MSDOS: /* 0x4D44 local */
335
350
      return "msdos";
336
 
    case S_MAGIC_NCP: /* 0x564C */
 
351
    case S_MAGIC_NCP: /* 0x564C remote */
337
352
      return "novell";
338
 
    case S_MAGIC_NFS: /* 0x6969 */
 
353
    case S_MAGIC_NFS: /* 0x6969 remote */
339
354
      return "nfs";
340
 
    case S_MAGIC_NFSD: /* 0x6E667364 */
 
355
    case S_MAGIC_NFSD: /* 0x6E667364 remote */
341
356
      return "nfsd";
342
 
    case S_MAGIC_NILFS: /* 0x3434 */
 
357
    case S_MAGIC_NILFS: /* 0x3434 local */
343
358
      return "nilfs";
344
 
    case S_MAGIC_NTFS: /* 0x5346544E */
 
359
    case S_MAGIC_NTFS: /* 0x5346544E local */
345
360
      return "ntfs";
346
 
    case S_MAGIC_OPENPROM: /* 0x9FA1 */
 
361
    case S_MAGIC_OPENPROM: /* 0x9FA1 local */
347
362
      return "openprom";
348
 
    case S_MAGIC_OCFS2: /* 0x7461636f */
 
363
    case S_MAGIC_OCFS2: /* 0x7461636f remote */
349
364
      return "ocfs2";
350
 
    case S_MAGIC_PROC: /* 0x9FA0 */
 
365
    case S_MAGIC_PANFS: /* 0xAAD7AAEA remote */
 
366
      return "panfs";
 
367
    case S_MAGIC_PIPEFS: /* 0x50495045 remote */
 
368
      /* FIXME: change syntax or add an optional attribute like "inotify:no".
 
369
         The above is labeled as "remote" so that tail always uses polling,
 
370
         but this isn't really a remote file system type.  */
 
371
      return "pipefs";
 
372
    case S_MAGIC_PROC: /* 0x9FA0 local */
351
373
      return "proc";
352
 
    case S_MAGIC_PSTOREFS: /* 0x6165676C */
 
374
    case S_MAGIC_PSTOREFS: /* 0x6165676C local */
353
375
      return "pstorefs";
354
 
    case S_MAGIC_QNX4: /* 0x002F */
 
376
    case S_MAGIC_QNX4: /* 0x002F local */
355
377
      return "qnx4";
356
 
    case S_MAGIC_RAMFS: /* 0x858458F6 */
 
378
    case S_MAGIC_QNX6: /* 0x68191122 local */
 
379
      return "qnx6";
 
380
    case S_MAGIC_RAMFS: /* 0x858458F6 local */
357
381
      return "ramfs";
358
 
    case S_MAGIC_REISERFS: /* 0x52654973 */
 
382
    case S_MAGIC_REISERFS: /* 0x52654973 local */
359
383
      return "reiserfs";
360
 
    case S_MAGIC_ROMFS: /* 0x7275 */
 
384
    case S_MAGIC_ROMFS: /* 0x7275 local */
361
385
      return "romfs";
362
 
    case S_MAGIC_RPC_PIPEFS: /* 0x67596969 */
 
386
    case S_MAGIC_RPC_PIPEFS: /* 0x67596969 local */
363
387
      return "rpc_pipefs";
364
 
    case S_MAGIC_SECURITYFS: /* 0x73636673 */
 
388
    case S_MAGIC_SECURITYFS: /* 0x73636673 local */
365
389
      return "securityfs";
366
 
    case S_MAGIC_SELINUX: /* 0xF97CFF8C */
 
390
    case S_MAGIC_SELINUX: /* 0xF97CFF8C local */
367
391
      return "selinux";
368
 
    case S_MAGIC_SMB: /* 0x517B */
 
392
    case S_MAGIC_SMB: /* 0x517B remote */
369
393
      return "smb";
370
 
    case S_MAGIC_SOCKFS: /* 0x534F434B */
 
394
    case S_MAGIC_SOCKFS: /* 0x534F434B local */
371
395
      return "sockfs";
372
 
    case S_MAGIC_SQUASHFS: /* 0x73717368 */
 
396
    case S_MAGIC_SQUASHFS: /* 0x73717368 local */
373
397
      return "squashfs";
374
 
    case S_MAGIC_SYSFS: /* 0x62656572 */
 
398
    case S_MAGIC_SYSFS: /* 0x62656572 local */
375
399
      return "sysfs";
376
 
    case S_MAGIC_SYSV2: /* 0x012FF7B6 */
 
400
    case S_MAGIC_SYSV2: /* 0x012FF7B6 local */
377
401
      return "sysv2";
378
 
    case S_MAGIC_SYSV4: /* 0x012FF7B5 */
 
402
    case S_MAGIC_SYSV4: /* 0x012FF7B5 local */
379
403
      return "sysv4";
380
 
    case S_MAGIC_TMPFS: /* 0x01021994 */
 
404
    case S_MAGIC_TMPFS: /* 0x01021994 local */
381
405
      return "tmpfs";
382
 
    case S_MAGIC_UDF: /* 0x15013346 */
 
406
    case S_MAGIC_UDF: /* 0x15013346 local */
383
407
      return "udf";
384
 
    case S_MAGIC_UFS: /* 0x00011954 */
385
 
      return "ufs";
386
 
    case S_MAGIC_UFS_BYTESWAPPED: /* 0x54190100 */
387
 
      return "ufs";
388
 
    case S_MAGIC_USBDEVFS: /* 0x9FA2 */
 
408
    case S_MAGIC_UFS: /* 0x00011954 local */
 
409
      return "ufs";
 
410
    case S_MAGIC_UFS_BYTESWAPPED: /* 0x54190100 local */
 
411
      return "ufs";
 
412
    case S_MAGIC_USBDEVFS: /* 0x9FA2 local */
389
413
      return "usbdevfs";
390
 
    case S_MAGIC_V9FS: /* 0x01021997 */
 
414
    case S_MAGIC_V9FS: /* 0x01021997 local */
391
415
      return "v9fs";
392
 
    case S_MAGIC_VXFS: /* 0xA501FCF5 */
 
416
    case S_MAGIC_VMHGFS: /* 0xBACBACBC remote */
 
417
      return "vmhgfs";
 
418
    case S_MAGIC_VXFS: /* 0xA501FCF5 local */
393
419
      return "vxfs";
394
 
    case S_MAGIC_XENFS: /* 0xABBA1974 */
 
420
    case S_MAGIC_VZFS: /* 0x565A4653 local */
 
421
      return "vzfs";
 
422
    case S_MAGIC_XENFS: /* 0xABBA1974 local */
395
423
      return "xenfs";
396
 
    case S_MAGIC_XENIX: /* 0x012FF7B4 */
 
424
    case S_MAGIC_XENIX: /* 0x012FF7B4 local */
397
425
      return "xenix";
398
 
    case S_MAGIC_XFS: /* 0x58465342 */
 
426
    case S_MAGIC_XFS: /* 0x58465342 local */
399
427
      return "xfs";
400
 
    case S_MAGIC_XIAFS: /* 0x012FD16D */
 
428
    case S_MAGIC_XIAFS: /* 0x012FD16D local */
401
429
      return "xia";
 
430
    case S_MAGIC_ZFS: /* 0x2FC12FC1 local */
 
431
      return "zfs";
402
432
 
403
433
# elif __GNU__
404
434
    case FSTYPE_UFS:
550
580
/* Output the number of seconds since the Epoch, using a format that
551
581
   acts like printf's %f format.  */
552
582
static void
553
 
out_epoch_sec (char *pformat, size_t prefix_len, struct stat const *statbuf,
 
583
out_epoch_sec (char *pformat, size_t prefix_len,
 
584
               struct stat const *statbuf ATTRIBUTE_UNUSED,
554
585
               struct timespec arg)
555
586
{
556
587
  char *dot = memchr (pformat, '.', prefix_len);
946
977
      out_uint_x (pformat, prefix_len, minor (statbuf->st_rdev));
947
978
      break;
948
979
    case 's':
949
 
      out_uint (pformat, prefix_len, statbuf->st_size);
 
980
      out_int (pformat, prefix_len, statbuf->st_size);
950
981
      break;
951
982
    case 'B':
952
983
      out_uint (pformat, prefix_len, ST_NBLOCKSIZE);
1033
1064
    case '\\':
1034
1065
      break;
1035
1066
    default:
1036
 
      error (0, 0, _("warning: unrecognized escape `\\%c'"), c);
 
1067
      error (0, 0, _("warning: unrecognized escape '\\%c'"), c);
1037
1068
      break;
1038
1069
    }
1039
1070
  putchar (c);
1050
1081
{
1051
1082
  bool fail = false;
1052
1083
 
1053
 
  /* Add 2 to accommodate our conversion of the stat `%s' format string
1054
 
     to the longer printf `%llu' one.  */
 
1084
  /* Add 2 to accommodate our conversion of the stat '%s' format string
 
1085
     to the longer printf '%llu' one.  */
1055
1086
  enum
1056
1087
    {
1057
1088
      MAX_ADDITIONAL_BYTES =
1159
1190
 
1160
1191
/* Stat the file system and print what we find.  */
1161
1192
static bool ATTRIBUTE_WARN_UNUSED_RESULT
1162
 
do_statfs (char const *filename, bool terse, char const *format)
 
1193
do_statfs (char const *filename, char const *format)
1163
1194
{
1164
1195
  STRUCT_STATVFS statfsbuf;
1165
1196
 
1183
1214
 
1184
1215
/* stat the file and print what we find */
1185
1216
static bool ATTRIBUTE_WARN_UNUSED_RESULT
1186
 
do_stat (char const *filename, bool terse, char const *format,
 
1217
do_stat (char const *filename, char const *format,
1187
1218
         char const *format2)
1188
1219
{
1189
1220
  struct stat statbuf;
1228
1259
        {
1229
1260
          /* TRANSLATORS: This string uses format specifiers from
1230
1261
             'stat --help' with --file-system, and NOT from printf.  */
1231
 
          format = xstrdup (_("\
1232
 
  File: \"%n\"\n\
1233
 
    ID: %-8i Namelen: %-7l Type: %T\n\
1234
 
Block size: %-10s Fundamental block size: %S\n\
1235
 
Blocks: Total: %-10b Free: %-10f Available: %a\n\
1236
 
Inodes: Total: %-10c Free: %d\n\
1237
 
"));
 
1262
          format = xstrdup (_("  File: \"%n\"\n"
 
1263
                              "    ID: %-8i Namelen: %-7l Type: %T\n"
 
1264
                              "Block size: %-10s Fundamental block size: %S\n"
 
1265
                              "Blocks: Total: %-10b Free: %-10f Available: %a\n"
 
1266
                              "Inodes: Total: %-10c Free: %d\n"));
1238
1267
        }
1239
1268
    }
1240
1269
  else /* ! fs */
1264
1293
              /* TRANSLATORS: This string uses format specifiers from
1265
1294
                 'stat --help' without --file-system, and NOT from printf.  */
1266
1295
              format = xasprintf ("%s%s", format, _("\
1267
 
Device: %Dh/%dd\tInode: %-10i  Links: %-5h Device type: %t,%T\n\
 
1296
" "Device: %Dh/%dd\tInode: %-10i  Links: %-5h Device type: %t,%T\n\
1268
1297
"));
1269
1298
            }
1270
1299
          else
1272
1301
              /* TRANSLATORS: This string uses format specifiers from
1273
1302
                 'stat --help' without --file-system, and NOT from printf.  */
1274
1303
              format = xasprintf ("%s%s", format, _("\
1275
 
Device: %Dh/%dd\tInode: %-10i  Links: %h\n\
 
1304
" "Device: %Dh/%dd\tInode: %-10i  Links: %h\n\
1276
1305
"));
1277
1306
            }
1278
1307
          free (temp);
1281
1310
          /* TRANSLATORS: This string uses format specifiers from
1282
1311
             'stat --help' without --file-system, and NOT from printf.  */
1283
1312
          format = xasprintf ("%s%s", format, _("\
1284
 
Access: (%04a/%10.10A)  Uid: (%5u/%8U)   Gid: (%5g/%8G)\n\
 
1313
" "Access: (%04a/%10.10A)  Uid: (%5u/%8U)   Gid: (%5g/%8G)\n\
1285
1314
"));
1286
1315
          free (temp);
1287
1316
 
1290
1319
              temp = format;
1291
1320
              /* TRANSLATORS: This string uses format specifiers from
1292
1321
                 'stat --help' without --file-system, and NOT from printf.  */
1293
 
              format = xasprintf ("%s%s", format, _("\
1294
 
Context: %C\n\
1295
 
"));
 
1322
              format = xasprintf ("%s%s", format, _("Context: %C\n"));
1296
1323
              free (temp);
1297
1324
            }
1298
1325
 
1299
1326
          temp = format;
1300
1327
          /* TRANSLATORS: This string uses format specifiers from
1301
1328
             'stat --help' without --file-system, and NOT from printf.  */
1302
 
          format = xasprintf ("%s%s", format, _("\
1303
 
Access: %x\n\
1304
 
Modify: %y\n\
1305
 
Change: %z\n\
1306
 
 Birth: %w\n\
1307
 
"));
 
1329
          format = xasprintf ("%s%s", format,
 
1330
                              _("Access: %x\n"
 
1331
                                "Modify: %y\n"
 
1332
                                "Change: %z\n"
 
1333
                                " Birth: %w\n"));
1308
1334
          free (temp);
1309
1335
        }
1310
1336
    }
1315
1341
usage (int status)
1316
1342
{
1317
1343
  if (status != EXIT_SUCCESS)
1318
 
    fprintf (stderr, _("Try `%s --help' for more information.\n"),
1319
 
             program_name);
 
1344
    emit_try_help ();
1320
1345
  else
1321
1346
    {
1322
1347
      printf (_("Usage: %s [OPTION]... FILE...\n"), program_name);
1340
1365
      fputs (_("\n\
1341
1366
The valid format sequences for files (without --file-system):\n\
1342
1367
\n\
1343
 
  %a   Access rights in octal\n\
1344
 
  %A   Access rights in human readable form\n\
1345
 
  %b   Number of blocks allocated (see %B)\n\
1346
 
  %B   The size in bytes of each block reported by %b\n\
 
1368
  %a   access rights in octal\n\
 
1369
  %A   access rights in human readable form\n\
 
1370
  %b   number of blocks allocated (see %B)\n\
 
1371
  %B   the size in bytes of each block reported by %b\n\
1347
1372
  %C   SELinux security context string\n\
1348
1373
"), stdout);
1349
1374
      fputs (_("\
1350
 
  %d   Device number in decimal\n\
1351
 
  %D   Device number in hex\n\
1352
 
  %f   Raw mode in hex\n\
1353
 
  %F   File type\n\
1354
 
  %g   Group ID of owner\n\
1355
 
  %G   Group name of owner\n\
1356
 
"), stdout);
1357
 
      fputs (_("\
1358
 
  %h   Number of hard links\n\
1359
 
  %i   Inode number\n\
1360
 
  %m   Mount point\n\
1361
 
  %n   File name\n\
1362
 
  %N   Quoted file name with dereference if symbolic link\n\
1363
 
  %o   I/O block size\n\
1364
 
  %s   Total size, in bytes\n\
1365
 
  %t   Major device type in hex\n\
1366
 
  %T   Minor device type in hex\n\
1367
 
"), stdout);
1368
 
      fputs (_("\
1369
 
  %u   User ID of owner\n\
1370
 
  %U   User name of owner\n\
1371
 
  %w   Time of file birth, human-readable; - if unknown\n\
1372
 
  %W   Time of file birth, seconds since Epoch; 0 if unknown\n\
1373
 
  %x   Time of last access, human-readable\n\
1374
 
  %X   Time of last access, seconds since Epoch\n\
1375
 
  %y   Time of last modification, human-readable\n\
1376
 
  %Y   Time of last modification, seconds since Epoch\n\
1377
 
  %z   Time of last change, human-readable\n\
1378
 
  %Z   Time of last change, seconds since Epoch\n\
 
1375
  %d   device number in decimal\n\
 
1376
  %D   device number in hex\n\
 
1377
  %f   raw mode in hex\n\
 
1378
  %F   file type\n\
 
1379
  %g   group ID of owner\n\
 
1380
  %G   group name of owner\n\
 
1381
"), stdout);
 
1382
      fputs (_("\
 
1383
  %h   number of hard links\n\
 
1384
  %i   inode number\n\
 
1385
  %m   mount point\n\
 
1386
  %n   file name\n\
 
1387
  %N   quoted file name with dereference if symbolic link\n\
 
1388
  %o   optimal I/O transfer size hint\n\
 
1389
  %s   total size, in bytes\n\
 
1390
  %t   major device type in hex\n\
 
1391
  %T   minor device type in hex\n\
 
1392
"), stdout);
 
1393
      fputs (_("\
 
1394
  %u   user ID of owner\n\
 
1395
  %U   user name of owner\n\
 
1396
  %w   time of file birth, human-readable; - if unknown\n\
 
1397
  %W   time of file birth, seconds since Epoch; 0 if unknown\n\
 
1398
  %x   time of last access, human-readable\n\
 
1399
  %X   time of last access, seconds since Epoch\n\
 
1400
  %y   time of last modification, human-readable\n\
 
1401
  %Y   time of last modification, seconds since Epoch\n\
 
1402
  %z   time of last change, human-readable\n\
 
1403
  %Z   time of last change, seconds since Epoch\n\
1379
1404
\n\
1380
1405
"), stdout);
1381
1406
 
1382
1407
      fputs (_("\
1383
1408
Valid format sequences for file systems:\n\
1384
1409
\n\
1385
 
  %a   Free blocks available to non-superuser\n\
1386
 
  %b   Total data blocks in file system\n\
1387
 
  %c   Total file nodes in file system\n\
1388
 
  %d   Free file nodes in file system\n\
1389
 
  %f   Free blocks in file system\n\
 
1410
  %a   free blocks available to non-superuser\n\
 
1411
  %b   total data blocks in file system\n\
 
1412
  %c   total file nodes in file system\n\
 
1413
  %d   free file nodes in file system\n\
 
1414
  %f   free blocks in file system\n\
1390
1415
"), stdout);
1391
1416
      fputs (_("\
1392
 
  %i   File System ID in hex\n\
1393
 
  %l   Maximum length of filenames\n\
1394
 
  %n   File name\n\
1395
 
  %s   Block size (for faster transfers)\n\
1396
 
  %S   Fundamental block size (for block counts)\n\
1397
 
  %t   Type in hex\n\
1398
 
  %T   Type in human readable form\n\
 
1417
  %i   file system ID in hex\n\
 
1418
  %l   maximum length of filenames\n\
 
1419
  %n   file name\n\
 
1420
  %s   block size (for faster transfers)\n\
 
1421
  %S   fundamental block size (for block counts)\n\
 
1422
  %t   file system type in hex\n\
 
1423
  %T   file system type in human readable form\n\
1399
1424
"), stdout);
1400
1425
      printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
1401
1426
      emit_ancillary_info ();
1479
1504
 
1480
1505
  for (i = optind; i < argc; i++)
1481
1506
    ok &= (fs
1482
 
           ? do_statfs (argv[i], terse, format)
1483
 
           : do_stat (argv[i], terse, format, format2));
 
1507
           ? do_statfs (argv[i], format)
 
1508
           : do_stat (argv[i], format, format2));
1484
1509
 
1485
1510
  exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
1486
1511
}