diff options
author | kaashoek <kaashoek> | 2006-08-14 14:13:52 +0000 |
---|---|---|
committer | kaashoek <kaashoek> | 2006-08-14 14:13:52 +0000 |
commit | bdb66433031ca96f2fd127995186623cd10c45b3 (patch) | |
tree | 037ffd2021f27718fba32c27cacd9ca52682b613 /ls.c | |
parent | d15f0d1033a7da6448966d9626ec2776781e4188 (diff) | |
download | xv6-labs-bdb66433031ca96f2fd127995186623cd10c45b3.tar.gz xv6-labs-bdb66433031ca96f2fd127995186623cd10c45b3.tar.bz2 xv6-labs-bdb66433031ca96f2fd127995186623cd10c45b3.zip |
set size for directories correctly in wdir and mkfs
mkdir
ls shows stat info for each dir entry
Diffstat (limited to 'ls.c')
-rw-r--r-- | ls.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -12,6 +12,7 @@ main(int argc, char *argv[]) { int fd; uint off; + uint sz; if(argc > 1){ puts("Usage: ls\n"); @@ -30,18 +31,19 @@ main(int argc, char *argv[]) if (st.st_type != T_DIR) { printf(2, "ls: . is not a dir\n"); } - cprintf("size %d\n", st.st_size); - for(off = 0; off < st.st_size; off += sizeof(struct dirent)) { + sz = st.st_size; + for(off = 0; off < sz; off += sizeof(struct dirent)) { if (read(fd, &dirent, sizeof(struct dirent)) != sizeof(struct dirent)) { - printf(2, "ls: read error\n"); - exit(); + printf(1, "ls: read error\n"); + break; } 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); + if (stat (dirent.name, &st) < 0) { + printf(1, "stat: failed\n"); + break; + } + printf(1, "%s t %d ino %d sz %d\n", dirent.name, st.st_type, + dirent.inum, st.st_size); } } close(fd); |