-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfperms.c
53 lines (51 loc) · 900 Bytes
/
rfperms.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <libc.h>
int
main(int argc, char *argv[])
{
int perms;
if(argc < 2){
printf(2, "usage: %s [file]\n", argv[0]);
exit();
}
perms = rfperms(argv[1]);
if(perms == -1){
printf(2, "error: %r\n");
exit();
}
printf(1, "%s (user=", argv[1]);
if((perms&U_READ) == U_READ)
printf(1, "r");
else
printf(1, "-");
if((perms&U_WRITE) == U_WRITE)
printf(1, "w");
else
printf(1, "-");
if((perms&U_EXEC) == U_EXEC)
printf(1, "x");
else
printf(1, "-");
if((perms&U_HIDDEN) == U_HIDDEN)
printf(1, "h");
else
printf(1, "-");
printf(1, ", world=");
if((perms&U_READ) == U_READ)
printf(1, "r");
else
printf(1, "-");
if((perms&U_WRITE) == U_WRITE)
printf(1, "w");
else
printf(1, "-");
if((perms&U_EXEC) == U_EXEC)
printf(1, "x");
else
printf(1, "-");
if((perms&U_HIDDEN) == U_HIDDEN)
printf(1, "h");
else
printf(1, "-");
printf(1,")\n");
exit();
}