xref: /csrg-svn/sys/stand.att/ls.c (revision 23231)
1*23231Smckusick /*
2*23231Smckusick  * Copyright (c) 1982 Regents of the University of California.
3*23231Smckusick  * All rights reserved.  The Berkeley software License Agreement
4*23231Smckusick  * specifies the terms and conditions for redistribution.
5*23231Smckusick  *
6*23231Smckusick  *	@(#)ls.c	6.2 (Berkeley) 06/08/85
7*23231Smckusick  */
8320Sbill 
9320Sbill #include "../h/param.h"
10320Sbill #include "../h/inode.h"
11320Sbill #include "../h/ino.h"
12320Sbill #include "../h/dir.h"
13320Sbill #include "saio.h"
14320Sbill 
15320Sbill char line[100];
16320Sbill 
17320Sbill main()
18320Sbill {
19320Sbill 	int i;
20320Sbill 
21320Sbill 	printf("ls\n");
22320Sbill 	do  {
23320Sbill 		printf(": "); gets(line);
24320Sbill 		i = open(line, 0);
25320Sbill 	} while (i < 0);
26320Sbill 
27320Sbill 	ls(i);
28320Sbill }
29320Sbill 
30320Sbill ls(io)
31320Sbill register io;
32320Sbill {
33320Sbill 	struct direct d;
34320Sbill 	register i;
35320Sbill 
36320Sbill 	while (read(io, (char *)&d, sizeof d) == sizeof d) {
37320Sbill 		if (d.d_ino == 0)
38320Sbill 			continue;
39320Sbill 		printf("%d\t", d.d_ino);
40320Sbill 		for (i=0; i<DIRSIZ; i++) {
41320Sbill 			if (d.d_name[i] == 0)
42320Sbill 				break;
43320Sbill 			printf("%c", d.d_name[i]);
44320Sbill 		}
45320Sbill 		printf("\n");
46320Sbill 	}
47320Sbill }
48