Newer
Older
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fs.h"
char buf[512];
for(i = 0; (i < DIRSIZ) && (n[i] != '\0') ; i++) {
} else {
fd = open(".", 0);
if(fd < 0){
printf(2, "ls: cannot open .\n");
exit();
}
case T_FILE:
pname(argv[1]);
printf(1, "%d %d %d\n", st.st_type, st.st_ino, st.st_size);
break;
case T_DIR:
sz = st.st_size;
for(off = 0; off < sz; off += sizeof(struct dirent)) {
if(read(fd, &dirent, sizeof(struct dirent)) != sizeof(struct dirent)) {
printf(1, "ls: read error\n");
break;
// xxx prepend to name the pathname supplied to ls (e.g. .. in ls ..)
printf(1, "stat: failed %s\n", dirent.name);
continue;
}
pname(dirent.name);
printf(1, "%d %d %d\n", st.st_type, dirent.inum, st.st_size);