annotate toys/pending/stat.c @ 871:8aa07b575cd6

stat: Reindent from 4 to 2 spaces
author Felix Janda <felix.janda@posteo.de>
date Fri, 19 Apr 2013 21:29:36 +0200
parents 7a983e09efad
children 793972c94560
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 * anand.sinha85@gmail.com
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
3 * Copyright 2012 <warior.linux@gmail.com>
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
4
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 USE_STAT(NEWTOY(stat, "LZfc", 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
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
11 Usage: stat [OPTION] FILE...
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
12 display file or file system status
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
13 -Z, --context
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 print the security context information if available
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
15 -f, --file-system
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
16 display file system status instead of file status
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
17 -c --format=FORMAT
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
18 use the specified FORMAT instead of the default; output a newline after each use of FORMAT
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
19 --help display this help and exit
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
20 The valid format sequences for files (without --file-system):
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
21 %a Access rights in octal
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
22 %A Access rights in human readable form
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
23 %b Number of blocks allocated (see
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
24 %B The size in bytes of each block reported by
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
25 %d Device number in decimal
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
26 %D Device number in hex
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
27 %f Raw mode in hex
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
28 %F File type
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
29 %G Group name of owner
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
30 %h Number of hard links
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
31 %i Inode number
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
32 %n File name
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
33 %N Quoted file name with dereference if symbolic link
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
34 %o I/O block size
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
35 %s Total size, in bytes
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
36 %t Major device type in hex
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
37 %T Minor device type in hex
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
38 %u User ID of owner
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
39 %U User name of owner
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
40 %x Time of last access
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
41 %X Time of last access as seconds since Epoch
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
42 %y Time of last modification
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
43 %Y Time of last modification as seconds since Epoch
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
44 %z Time of last change
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
45 %Z Time of last change as seconds since Epoch
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
46 */
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 #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
49 #include "toys.h"
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
50
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
51 #define SIZE_DATE_TIME_STAT 36
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
52 #define access_string(x, s, i) if((x&7) & 1) \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
53 s[9 - i * 3] = 'x'; \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
54 else \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
55 s[9 - i * 3] = '-'; \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
56 if(((x&7) >> 1) & 1) \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
57 s[9 - (i * 3 + 1)] = 'w'; \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
58 else \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
59 s[9 - (i * 3 + 1)] = '-'; \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 if(((x&7) >> 2) & 1) \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 s[9 - (i * 3 + 2)] = 'r'; \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
62 else \
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
63 s[9 - (i * 3 + 2)] = '-';
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
64
811
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
65 static char *check_type_file(mode_t, size_t);
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
66 static char *get_access_str(unsigned long, mode_t);
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
67 static char *date_stat_format(time_t );
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
68 inline void print_stat_format(char *, int);
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
69
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
70 GLOBALS(
811
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
71 char *access_str;
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
72 char *file_type;
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
73 struct passwd *user_name;
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
74 struct group *group_name;
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
75 struct tm *time_toy;
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
76 struct stat *toystat;
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
77 struct statfs *toystatfs;
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
78 int toy_obj_file_arg;
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
79 )
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
80
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
81
811
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
82 static void do_stat(const char * file_name)
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
83 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
84 TT.toystat = xmalloc(sizeof(struct stat));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
85 if (stat(file_name, TT.toystat) < 0) perror_msg("stat: '%s'", file_name);
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
86 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
87
811
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
88 static void do_statfs(const char * file_name)
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
89 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
90 TT.toystatfs = xmalloc(sizeof(struct statfs));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
91 if (statfs(file_name, TT.toystatfs) < 0)
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
92 perror_msg("statfs: '%s'", file_name);
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
93 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
94
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
95 static char * check_type_file(mode_t mode, size_t size)
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
96 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
97 if (S_ISREG(mode)) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
98 if (size) return "regular file";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
99 return "regular empty file";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
100 }
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
101 if (S_ISDIR(mode)) return "directory";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
102 if (S_ISCHR(mode)) return "character device";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
103 if (S_ISBLK(mode)) return "block device";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
104 if (S_ISFIFO(mode)) return "FIFO (named pipe)";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
105 if (S_ISLNK(mode)) return "symbolic link";
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
106 if (S_ISSOCK(mode)) return "socket";
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
107 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
108
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
109 static char * get_access_str(unsigned long pernission, mode_t mode)
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
110 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
111 static char access_string[10];
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
112 int i;
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
113
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
114 if (S_ISDIR(mode)) access_string[0] = 'd';
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
115 else access_string[0] = '-';
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
116 for (i = 0; i < 3; i++)
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
117 access_string(pernission >> (i * 3) & 7, access_string, i);
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
118
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
119 access_string[10] = '\0';
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
120 return access_string;
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
121 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
122
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
123 static char * date_stat_format(time_t time)
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
124 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
125 static char buf[SIZE_DATE_TIME_STAT];
811
7a983e09efad Call stat "stat" instead of "st" in menuconfig. Use xmalloc() instead of malloc.
Rob Landley <rob@landley.net>
parents: 810
diff changeset
126
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
127 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S.000000000", localtime(&time));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
128 return buf;
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
129 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
130
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
131 inline void print_stat_format(char *format, int flag)
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
132 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
133 format++;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
134 switch (*format) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
135 case 'a':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
136 if (flag) xprintf("%lu\n", TT.toystatfs->f_bavail);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
137 else xprintf("%04lo\n",TT.toystat->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
138 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
139 case 'A':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
140 xprintf("%s\n",TT.access_str);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
141 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
142 case 'b':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
143 if (flag) xprintf("%lu\n", TT.toystatfs->f_blocks);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
144 else xprintf("%llu\n", TT.toystat->st_blocks);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
145 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
146 case 'B':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
147 xprintf("%lu\n", TT.toystat->st_blksize);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
148 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
149 case 'c':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
150 if (flag) xprintf("%lu\n", TT.toystatfs->f_files);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
151 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
152 case 'C':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
153 xprintf("Currently feature is not supported\n");
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
154 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
155 case 'd':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
156 if (flag) xprintf("%lu\n", TT.toystatfs->f_ffree);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
157 else xprintf("%ldd\n", TT.toystat->st_dev);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
158 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
159 case 'D':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
160 xprintf("%llxh\n", TT.toystat->st_dev);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
161 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
162 case 'f':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
163 if (flag) xprintf("%lu\n", TT.toystatfs->f_bfree);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
164 else xprintf("%lx\n", TT.toystat->st_mode);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
165 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
166 case 'F':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
167 xprintf("%s\n", TT.file_type);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
168 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
169 case 'g':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
170 xprintf("%lu\n", TT.toystat->st_uid);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
171 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
172 case 'G':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
173 xprintf("%8s\n", TT.user_name->pw_name);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
174 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
175 case 'h':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
176 xprintf("%lu\n", TT.toystat->st_nlink);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
177 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
178 case 'i':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
179 if (flag)
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
180 xprintf("%d%d\n", TT.toystatfs->f_fsid.__val[0], TT.toystatfs->f_fsid.__val[1]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
181 else xprintf("%llu\n", TT.toystat->st_ino);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
182 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
183 case 'l':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
184 if (flag) xprintf("need to implement\n");
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
185 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
186 case 'n':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
187 xprintf("%s\n", toys.optargs[TT.toy_obj_file_arg]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
188 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
189 case 'N':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
190 xprintf("`%s\n'", toys.optargs[TT.toy_obj_file_arg]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
191 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
192 case 'o':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
193 xprintf("%lu\n", TT.toystat->st_blksize);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
194 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
195 case 's':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
196 if (flag) xprintf("%d\n", TT.toystatfs->f_frsize);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
197 else xprintf("%llu\n", TT.toystat->st_size);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
198 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
199 case 'S':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
200 if (flag) xprintf("%d\n", TT.toystatfs->f_bsize);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
201 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
202 case 't':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
203 if (flag) xprintf("%lx\n", TT.toystatfs->f_type);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
204 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
205 case 'T':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
206 if (flag) xprintf("Needs to be implemented\n");
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
207 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
208 case 'u':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
209 xprintf("%lu\n", TT.toystat->st_uid);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
210 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
211 case 'U':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
212 xprintf("%8s\n", TT.user_name->pw_name);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
213 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
214 case 'x':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
215 xprintf("%s\n", date_stat_format(TT.toystat->st_atime));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
216 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
217 case 'X':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
218 xprintf("%llu\n", TT.toystat->st_atime);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
219 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
220 case 'y':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
221 xprintf("%s\n", date_stat_format(TT.toystat->st_mtime));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
222 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
223 case 'Y':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
224 xprintf("%llu\n", TT.toystat->st_mtime);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
225 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
226 case 'z':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
227 xprintf("%s\n", date_stat_format(TT.toystat->st_ctime));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
228 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
229 case 'Z':
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
230 xprintf("%llu\n", TT.toystat->st_ctime);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
231 default:
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
232 xprintf("%c\n", *format);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
233 break;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
234 }
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
235 exit(0);
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
236 }
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
237
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
238 void stat_main(void)
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
239 {
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
240 int stat_flag_Z = 0, stat_flag_f = 0, stat_flag_c = 0, stat_format = 0;
810
874d2e646f2d Fix whitespace in submitted stat command.
Rob Landley <rob@landley.net>
parents: 747
diff changeset
241
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
242 if (toys.optargs) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
243 if (toys.optflags & 1) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
244 stat_flag_c = 1;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
245 TT.toy_obj_file_arg = 1;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
246 stat_format = 1;
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
247 }
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
248 if (toys.optflags & (1 << 1)) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
249 stat_flag_f = 1;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
250 do_statfs(toys.optargs[TT.toy_obj_file_arg]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
251 } else do_stat(toys.optargs[TT.toy_obj_file_arg]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
252 if (toys.optflags & (1 << 2)) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
253 stat_flag_Z = 1;
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
254 xprintf("SELinux feature has not been implemented so far..\n");
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
255 }
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
256 }
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
257 // function to check the type/mode of file
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
258 if (!stat_flag_f) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
259 TT.file_type = check_type_file(TT.toystat->st_mode, TT.toystat->st_size);
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
260 // check user and group name
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
261 TT.user_name = getpwuid(TT.toystat->st_uid);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
262 TT.group_name = getgrgid(TT.toystat->st_gid);
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
263 // function to get access in human readable format
871
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
264 TT.access_str = get_access_str((TT.toystat->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)), TT.toystat->st_mode);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
265 TT.time_toy = gmtime(&(TT.toystat->st_atime));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
266 }
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
267 if (!(stat_flag_f |stat_flag_Z)) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
268 if (stat_format) print_stat_format(toys.optargs[0], stat_flag_f);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
269 xprintf(" File: `%s'\n", toys.optargs[TT.toy_obj_file_arg]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
270 xprintf(" Size: %llu\t Blocks: %llu\t IO Blocks: %lu\t", TT.toystat->st_size, TT.toystat->st_blocks, TT.toystat->st_blksize);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
271 xprintf("%s\n", TT.file_type);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
272 xprintf("Device: %llxh\t Inode: %llu\t Links: %lu\n", TT.toystat->st_dev, TT.toystat->st_ino, TT.toystat->st_nlink);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
273 xprintf("Access: (%04lo/%s)\tUid: (%lu/%8s)\tGid: (%lu/%8s)\n", (TT.toystat->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)), TT.access_str, TT.toystat->st_uid, TT.user_name->pw_name, TT.toystat->st_gid, TT.group_name->gr_name);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
274 xprintf("Access: %s\nModify: %s\nChange: %s\n", date_stat_format(TT.toystat->st_atime), date_stat_format(TT.toystat->st_mtime), date_stat_format(TT.toystat->st_ctime));
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
275 } else if (stat_flag_f) {
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
276 // implementation of statfs -f, file system
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
277 if (stat_format) print_stat_format(toys.optargs[0], stat_flag_f);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
278 xprintf(" File: \"%s\"\n", toys.optargs[TT.toy_obj_file_arg]);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
279 xprintf(" ID: %d%d Namelen: %ld Type: %lx\n", TT.toystatfs->f_fsid.__val[0], TT.toystatfs->f_fsid.__val[1], TT.toystatfs->f_namelen, TT.toystatfs->f_type);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
280 xprintf("Block Size: %d Fundamental block size: %d\n", TT.toystatfs->f_bsize, TT.toystatfs->f_frsize);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
281 xprintf("Blocks: Total: %lu\t", TT.toystatfs->f_blocks);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
282 xprintf("Free: %lu\t", TT.toystatfs->f_bfree);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
283 xprintf("Available: %lu\n", TT.toystatfs->f_bavail);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
284 xprintf("Inodes: Total: %lu\t", TT.toystatfs->f_files);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
285 xprintf("\tFree: %d\n", TT.toystatfs->f_ffree);
8aa07b575cd6 stat: Reindent from 4 to 2 spaces
Felix Janda <felix.janda@posteo.de>
parents: 811
diff changeset
286 }
747
68d6c1ce7bba Add stat submission to new "pending" directory, along with infrastructure to support pending.
Rob Landley <rob@landley.net>
parents:
diff changeset
287 }