1 /* $NetBSD: tls.c,v 1.2 2006/06/24 05:12:13 mrg Exp $ */
4 * Copyright (c) 1995 Gordon W. Ross
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/types.h>
38 void show_long(char *fname
);
47 /* If given an arg, just cd there first. */
55 fprintf(stderr
, "extra args ignored\n");
63 while ((d
= readdir(dfp
)) != NULL
)
70 /* XXX - This is system dependent... */
71 char ifmt_name
[16] = {
73 'P', /* 1: fifo (pipe) */
74 'C', /* 2: chr device */
78 'B', /* 6: blk device */
86 'W', /* E: whiteout */
99 if (lstat(fname
, &st
)) {
103 ifmt
= (st
.st_mode
>> 12) & 15;
104 ifmt_c
= ifmt_name
[ifmt
];
108 printf("%6d ", st
.st_ino
);
112 printf("%c:", ifmt_c
);
113 printf("%04o ", st
.st_mode
& 07777);
115 /* nlinks, uid, gid */
116 printf("%2d ", st
.st_nlink
);
117 printf("%4d ", st
.st_uid
);
118 printf("%4d ", st
.st_gid
);
120 /* size or major/minor */
121 if ((ifmt_c
== 'B') || (ifmt_c
== 'C')) {
122 printf("%2d, ", major(st
.st_rdev
));
123 printf("%3d ", minor(st
.st_rdev
));
125 printf("%7d ", (int) st
.st_size
);
129 date
= ctime(&st
.st_mtime
);
130 date
+= 4; /* skip day-of-week */
131 date
[12] = '\0'; /* to the minute */
141 n
= readlink(fname
, linkto
, sizeof(linkto
)-1);
147 printf(" -> %s", linkto
);