diff options
author | kaashoek <kaashoek> | 2006-08-14 03:00:13 +0000 |
---|---|---|
committer | kaashoek <kaashoek> | 2006-08-14 03:00:13 +0000 |
commit | d15f0d1033a7da6448966d9626ec2776781e4188 (patch) | |
tree | 21760376e140e637d48cb3a246b76f62650a454e /ls.c | |
parent | e4bcd2a3a919ef040d2a577a1025f286c3b57168 (diff) | |
download | xv6-labs-d15f0d1033a7da6448966d9626ec2776781e4188.tar.gz xv6-labs-d15f0d1033a7da6448966d9626ec2776781e4188.tar.bz2 xv6-labs-d15f0d1033a7da6448966d9626ec2776781e4188.zip |
start on mkdir
stat
Diffstat (limited to 'ls.c')
-rw-r--r-- | ls.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -4,7 +4,7 @@ #include "fs.h" char buf[512]; -struct stat stat; +struct stat st; struct dirent dirent; int @@ -23,20 +23,26 @@ main(int argc, char *argv[]) printf(2, "ls: cannot open .\n"); exit(); } - if (fstat(fd, &stat) < 0) { + if (fstat(fd, &st) < 0) { printf(2, "ls: cannot open .\n"); exit(); } - if (stat.st_type != T_DIR) { + if (st.st_type != T_DIR) { printf(2, "ls: . is not a dir\n"); } - for(off = 0; off < stat.st_size; off += sizeof(struct dirent)) { + cprintf("size %d\n", st.st_size); + for(off = 0; off < st.st_size; off += sizeof(struct dirent)) { if (read(fd, &dirent, sizeof(struct dirent)) != sizeof(struct dirent)) { printf(2, "ls: read error\n"); exit(); } - if (dirent.inum != 0) - printf(1, "%s\n", dirent.name); + if (dirent.inum != 0) { + + if (stat (dirent.name, &st) < 0) + printf(2, "stat: failed\n"); + + printf(1, "%s t %d\n", dirent.name, st.st_type); + } } close(fd); |