annotate toys/pending/stat.c @ 917:b2697351ce6d

Stat cleanup. Move ftname out of GLOBALS into 'F' handler. Make 'i' zero pad output (zeroes in middle of ID can get lost).
author Rob Landley <rob@landley.net>
date Sun, 02 Jun 2013 00:52:14 -0500
parents b92cb3cc9696
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
1 /* stat.c : display file or file system status
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
2 * Copyright 2012 <warior.linux@gmail.com>
917
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
3 * Copyright 2013 <anand.sinha85@gmail.com>
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
4
886
6bb5c8ace240 stat: Remove unimplemented options and clean up help text
Felix Janda <felix.janda@posteo.de>
parents: 885
diff changeset
5 USE_STAT(NEWTOY(stat, "c:f", TOYFLAG_BIN))
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
6
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 config STAT
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
8 bool stat
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
9 default n
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
10 help
886
6bb5c8ace240 stat: Remove unimplemented options and clean up help text
Felix Janda <felix.janda@posteo.de>
parents: 885
diff changeset
11 usage: stat [-f] [-c FORMAT] FILE...
6bb5c8ace240 stat: Remove unimplemented options and clean up help text
Felix Janda <felix.janda@posteo.de>
parents: 885
diff changeset
12
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
13 Display status of files or filesystems.
886
6bb5c8ace240 stat: Remove unimplemented options and clean up help text
Felix Janda <felix.janda@posteo.de>
parents: 885
diff changeset
14
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
15 -f display filesystem status instead of file status
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
16 -c Output specified FORMAT string instead of default
886
6bb5c8ace240 stat: Remove unimplemented options and clean up help text
Felix Janda <felix.janda@posteo.de>
parents: 885
diff changeset
17
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
18 The valid format escape sequences for files:
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
19 %a Access bits (octal) |%A Access bits (flags)|%b Blocks allocated
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
20 %B Bytes per block |%d Device ID (dec) |%D Device ID (hex)
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
21 %f All mode bits (hex) |%F File type |%g Group ID
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
22 %G Group name |%h Hard links |%i Inode
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
23 %n Filename |%N Long filename |%o I/O block size
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
24 %s Size (bytes) |%u User ID |%U User name
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
25 %x Access time |%X Access unix time |%y File write time
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
26 %Y File write unix time|%z Dir change time |%Z Dir change unix time
886
6bb5c8ace240 stat: Remove unimplemented options and clean up help text
Felix Janda <felix.janda@posteo.de>
parents: 885
diff changeset
27
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
28 The valid format escape sequences for filesystems:
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
29 %a Available blocks |%b Total blocks |%c Total inodes
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
30 %d Free inodes |%f Free blocks |%i File system ID
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
31 %l Max filename length |%n File name |%s Fragment size
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
32 %S Best transfer size |%t File system type
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
33 */
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
34
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
35 #define FOR_stat
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
36 #include "toys.h"
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
37
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
38 GLOBALS(
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
39 char *fmt;
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
40
914
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
41 union {
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
42 struct stat st;
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
43 struct statfs sf;
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
44 } stat;
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
45 struct passwd *user_name;
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
46 struct group *group_name;
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
47 )
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
48
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
49
914
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
50 // Note: the atime, mtime, and ctime fields in struct stat are the start
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
51 // of embedded struct timespec, but posix won't let them use that
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
52 // struct definition for legacy/namespace reasons.
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
53
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
54 static void date_stat_format(struct timespec *ts)
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
55 {
914
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
56 strftime(toybuf, sizeof(toybuf), "%Y-%m-%d %H:%M:%S",
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
57 localtime(&(ts->tv_sec)));
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
58 xprintf("%s.%09d", toybuf, ts->tv_nsec);
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
60
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
61 static void print_stat(char type)
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
62 {
914
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
63 struct stat *stat = (struct stat *)&TT.stat;
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
64
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
65 if (type == 'a') xprintf("%04lo", stat->st_mode & ~S_IFMT);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
66 else if (type == 'A') {
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
67 char str[11];
914
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
68
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
69 mode_to_string(stat->st_mode, str);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
70 xprintf("%s", str);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
71 } else if (type == 'b') xprintf("%llu", stat->st_blocks);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
72 else if (type == 'B') xprintf("%lu", stat->st_blksize);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
73 else if (type == 'd') xprintf("%ldd", stat->st_dev);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
74 else if (type == 'D') xprintf("%llxh", stat->st_dev);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
75 else if (type == 'f') xprintf("%lx", stat->st_mode);
917
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
76 else if (type == 'F') {
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
77 char *t = "character device\0directory\0block device\0" \
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
78 "regular file\0symbolic link\0socket\0FIFO (named pipe)";
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
79 int i, filetype = stat->st_mode & S_IFMT;
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
80
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
81 for (i = 1; filetype != (i*8192) && i < 7; i++) t += strlen(t)+1;
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
82 if (!stat->st_size && filetype == S_IFREG) t = "regular empty file";
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
83 xprintf("%s", t);
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
84 } else if (type == 'g') xprintf("%lu", stat->st_gid);
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
85 else if (type == 'G') xprintf("%8s", TT.user_name->pw_name);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
86 else if (type == 'h') xprintf("%lu", stat->st_nlink);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
87 else if (type == 'i') xprintf("%llu", stat->st_ino);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
88 else if (type == 'N') {
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
89 xprintf("`%s'", *toys.optargs);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
90 if (S_ISLNK(stat->st_mode))
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
91 if (0<readlink(*toys.optargs, toybuf, sizeof(toybuf)))
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
92 xprintf(" -> `%s'", toybuf);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
93 } else if (type == 'o') xprintf("%lu", stat->st_blksize);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
94 else if (type == 's') xprintf("%llu", stat->st_size);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
95 else if (type == 'u') xprintf("%lu", stat->st_uid);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
96 else if (type == 'U') xprintf("%8s", TT.user_name->pw_name);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
97 else if (type == 'x') date_stat_format((void *)&stat->st_atime);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
98 else if (type == 'X') xprintf("%llu", (long long)stat->st_atime);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
99 else if (type == 'y') date_stat_format((void *)&stat->st_mtime);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
100 else if (type == 'Y') xprintf("%llu", (long long)stat->st_mtime);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
101 else if (type == 'z') date_stat_format((void *)&stat->st_ctime);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
102 else if (type == 'Z') xprintf("%llu", (long long)stat->st_ctime);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
103 else xprintf("?");
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
104 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
105
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
106 static void print_statfs(char type) {
914
91d15ead5602 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 912
diff changeset
107 struct statfs *statfs = (struct statfs *)&TT.stat;
912
f4f5132d5ac7 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 911
diff changeset
108
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
109 if (type == 'a') xprintf("%lu", statfs->f_bavail);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
110 else if (type == 'b') xprintf("%lu", statfs->f_blocks);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
111 else if (type == 'c') xprintf("%lu", statfs->f_files);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
112 else if (type == 'd') xprintf("%lu", statfs->f_ffree);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
113 else if (type == 'f') xprintf("%lu", statfs->f_bfree);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
114 else if (type == 'l') xprintf("%ld", statfs->f_namelen);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
115 else if (type == 't') xprintf("%lx", statfs->f_type);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
116 else if (type == 'i')
917
b2697351ce6d Stat cleanup.
Rob Landley <rob@landley.net>
parents: 916
diff changeset
117 xprintf("%08x%08x", statfs->f_fsid.__val[0], statfs->f_fsid.__val[1]);
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
118 else if (type == 's') xprintf("%d", statfs->f_frsize);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
119 else if (type == 'S') xprintf("%d", statfs->f_bsize);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
120 else xprintf("?");
910
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
121 }
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
122
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
123 void stat_main(void)
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
124 {
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
125 int flagf = toys.optflags & FLAG_f;
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
126 char *format = flagf
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
127 ? " File: \"%n\"\n ID: %i Namelen: %l Type: %t\n"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
128 "Block Size: %s Fundamental block size: %S\n"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
129 "Blocks: Total: %b\tFree: %f\tAvailable: %a\n"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
130 "Inodes: Total: %c\tFree: %d"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
131 : " File: %N\n Size: %s\t Blocks: %b\t IO Blocks: %B\t%F\n"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
132 "Device: %D\t Inode: %i\t Links: %h\n"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
133 "Access: (%a/%A)\tUid: (%u/%U)\tGid: (%g/%G)\n"
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
134 "Access: %x\nModify: %y\nChange: %z";
872
793972c94560 stat cleanup
Felix Janda <felix.janda@posteo.de>
parents: 871
diff changeset
135
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
136 if (toys.optflags & FLAG_c) format = TT.fmt;
910
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
137
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
138 for (; *toys.optargs; toys.optargs++) {
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
139 char *f;
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
140
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
141 if (flagf && !statfs(*toys.optargs, (void *)&TT.stat));
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
142 else if (!flagf && !lstat(*toys.optargs, (void *)&TT.stat)) {
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
143 struct stat *stat = (struct stat*)&TT.stat;
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
144
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
145 // check user and group name
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
146 TT.user_name = getpwuid(stat->st_uid);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
147 TT.group_name = getgrgid(stat->st_gid);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
148 } else {
910
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
149 perror_msg("'%s'", *toys.optargs);
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
150 continue;
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
151 }
916
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
152
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
153 for (f = format; *f; f++) {
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
154 if (*f != '%') putchar(*f);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
155 else {
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
156 if (*++f == 'n') xprintf("%s", *toys.optargs);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
157 else if (flagf) print_statfs(*f);
b92cb3cc9696 Stat cleanup.
Rob Landley <rob@landley.net>
parents: 914
diff changeset
158 else print_stat(*f);
911
accabaaac666 stat: Separate stat and statfs
Felix Janda <felix.janda@posteo.de>
parents: 910
diff changeset
159 }
accabaaac666 stat: Separate stat and statfs
Felix Janda <felix.janda@posteo.de>
parents: 910
diff changeset
160 }
accabaaac666 stat: Separate stat and statfs
Felix Janda <felix.janda@posteo.de>
parents: 910
diff changeset
161 xputc('\n');
910
1b77a81859f6 stat: Add support for stat'ing multiple files
Felix Janda <felix.janda@posteo.de>
parents: 886
diff changeset
162 }
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
163 }