Blame


1 fd04aace 2003-11-23 devnull #include <u.h>
2 fd04aace 2003-11-23 devnull #include <libc.h>
3 fd04aace 2003-11-23 devnull
4 fd04aace 2003-11-23 devnull static char *modes[] =
5 fd04aace 2003-11-23 devnull {
6 fd04aace 2003-11-23 devnull "---",
7 fd04aace 2003-11-23 devnull "--x",
8 fd04aace 2003-11-23 devnull "-w-",
9 fd04aace 2003-11-23 devnull "-wx",
10 fd04aace 2003-11-23 devnull "r--",
11 fd04aace 2003-11-23 devnull "r-x",
12 fd04aace 2003-11-23 devnull "rw-",
13 fd04aace 2003-11-23 devnull "rwx",
14 fd04aace 2003-11-23 devnull };
15 fd04aace 2003-11-23 devnull
16 fd04aace 2003-11-23 devnull static void
17 fd04aace 2003-11-23 devnull rwx(long m, char *s)
18 fd04aace 2003-11-23 devnull {
19 fd04aace 2003-11-23 devnull strncpy(s, modes[m], 3);
20 fd04aace 2003-11-23 devnull }
21 fd04aace 2003-11-23 devnull
22 fd04aace 2003-11-23 devnull int
23 fd04aace 2003-11-23 devnull dirmodefmt(Fmt *f)
24 fd04aace 2003-11-23 devnull {
25 fd04aace 2003-11-23 devnull static char buf[16];
26 fd04aace 2003-11-23 devnull ulong m;
27 fd04aace 2003-11-23 devnull
28 fd04aace 2003-11-23 devnull m = va_arg(f->args, ulong);
29 fd04aace 2003-11-23 devnull
30 fd04aace 2003-11-23 devnull if(m & DMDIR)
31 fd04aace 2003-11-23 devnull buf[0]='d';
32 fd04aace 2003-11-23 devnull else if(m & DMAPPEND)
33 fd04aace 2003-11-23 devnull buf[0]='a';
34 fd04aace 2003-11-23 devnull else if(m & DMAUTH)
35 fd04aace 2003-11-23 devnull buf[0]='A';
36 8a750906 2005-02-08 devnull else if(m & DMDEVICE)
37 8a750906 2005-02-08 devnull buf[0] = 'D';
38 8a750906 2005-02-08 devnull else if(m & DMSOCKET)
39 8a750906 2005-02-08 devnull buf[0] = 'S';
40 8a750906 2005-02-08 devnull else if(m & DMNAMEDPIPE)
41 8a750906 2005-02-08 devnull buf[0] = 'P';
42 fd04aace 2003-11-23 devnull else
43 fd04aace 2003-11-23 devnull buf[0]='-';
44 98660df2 2005-02-21 devnull
45 98660df2 2005-02-21 devnull /*
46 98660df2 2005-02-21 devnull * It's a little weird to have DMSYMLINK conflict with DMEXCL
47 98660df2 2005-02-21 devnull * here, but since you can have symlinks to any of the above
48 98660df2 2005-02-21 devnull * things, this is a better display. Especially since we don't do
49 98660df2 2005-02-21 devnull * DMEXCL on any of the supported systems.
50 98660df2 2005-02-21 devnull */
51 fd04aace 2003-11-23 devnull if(m & DMEXCL)
52 fd04aace 2003-11-23 devnull buf[1]='l';
53 98660df2 2005-02-21 devnull else if(m & DMSYMLINK)
54 98660df2 2005-02-21 devnull buf[1] = 'L';
55 fd04aace 2003-11-23 devnull else
56 fd04aace 2003-11-23 devnull buf[1]='-';
57 fd04aace 2003-11-23 devnull rwx((m>>6)&7, buf+2);
58 fd04aace 2003-11-23 devnull rwx((m>>3)&7, buf+5);
59 fd04aace 2003-11-23 devnull rwx((m>>0)&7, buf+8);
60 fd04aace 2003-11-23 devnull buf[11] = 0;
61 fd04aace 2003-11-23 devnull return fmtstrcpy(f, buf);
62 fd04aace 2003-11-23 devnull }