summaryrefslogtreecommitdiff
path: root/ls.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2016-08-25 09:13:00 -0400
committerFrans Kaashoek <[email protected]>2016-08-25 09:13:00 -0400
commit7894fcd21732dd2ddfbb9beca52d037a62ed11f4 (patch)
treeeabcfc4f08613dcf7c35e58d9425f02c4c65224f /ls.c
parent6de6a3c952dc8786619bd052e26e6bc1c97be2e6 (diff)
downloadxv6-labs-7894fcd21732dd2ddfbb9beca52d037a62ed11f4.tar.gz
xv6-labs-7894fcd21732dd2ddfbb9beca52d037a62ed11f4.tar.bz2
xv6-labs-7894fcd21732dd2ddfbb9beca52d037a62ed11f4.zip
Remove trailing white space with:
for f in *.{h,c}; do sed -i .sed 's/[[:blank:]]*$//' $f; done (Thanks to Nicolás Wolovick)
Diffstat (limited to 'ls.c')
-rw-r--r--ls.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ls.c b/ls.c
index b6ddd7f..2862913 100644
--- a/ls.c
+++ b/ls.c
@@ -8,12 +8,12 @@ fmtname(char *path)
{
static char buf[DIRSIZ+1];
char *p;
-
+
// Find first character after last slash.
for(p=path+strlen(path); p >= path && *p != '/'; p--)
;
p++;
-
+
// Return blank-padded name.
if(strlen(p) >= DIRSIZ)
return p;
@@ -29,23 +29,23 @@ ls(char *path)
int fd;
struct dirent de;
struct stat st;
-
+
if((fd = open(path, 0)) < 0){
printf(2, "ls: cannot open %s\n", path);
return;
}
-
+
if(fstat(fd, &st) < 0){
printf(2, "ls: cannot stat %s\n", path);
close(fd);
return;
}
-
+
switch(st.type){
case T_FILE:
printf(1, "%s %d %d %d\n", fmtname(path), st.type, st.ino, st.size);
break;
-
+
case T_DIR:
if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
printf(1, "ls: path too long\n");