* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
static char copyright
[] =
"@(#) Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n";
static char sccsid
[] = "@(#)ls.c 8.1 (Berkeley) %G%";
#include <sys/ttychars.h>
if ((fd
= getfile("ls", 0)) == -1)
if ((ip
->di_mode
& IFMT
) != IFDIR
) {
printf("ls: not a directory\n");
printf("ls: zero length directory\n");
if (buf
[0] == CTRL('d') && buf
[1] == 0)
} while ((fd
= open(buf
, mode
)) < 0);
typedef struct direct DP
;
printf("\ninode\tname\n");
while ((size
= read(fd
, dirbuf
, DIRBLKSIZ
)) == DIRBLKSIZ
)
for (dp
= dirbuf
; (dp
< (dirbuf
+ size
)) &&
(dp
+ ((DP
*)dp
)->d_reclen
) < (dirbuf
+ size
);
dp
+= ((DP
*)dp
)->d_reclen
) {
if (((DP
*)dp
)->d_ino
== 0)
if (((DP
*)dp
)->d_namlen
> MAXNAMLEN
+1) {
printf("Corrupt file name length! Run fsck soon!\n");
printf("%d\t%s\n", ((DP
*)dp
)->d_ino
,