diff options
author | rsc <devnull@localhost> | 2005-01-13 04:49:19 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-13 04:49:19 +0000 |
commit | c8b6342d3c2a167dec16931815926e9e4387e7ef (patch) | |
tree | 80d3ec6ea074462b30639168113def880476dad6 /src/cmd/rm.c | |
parent | 741f510ce758f77ed5193256fb693a09a7daecce (diff) | |
download | plan9port-c8b6342d3c2a167dec16931815926e9e4387e7ef.tar.gz plan9port-c8b6342d3c2a167dec16931815926e9e4387e7ef.tar.bz2 plan9port-c8b6342d3c2a167dec16931815926e9e4387e7ef.zip |
Many small edits.
Diffstat (limited to 'src/cmd/rm.c')
-rw-r--r-- | src/cmd/rm.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cmd/rm.c b/src/cmd/rm.c index e76fdb0a..f71fe989 100644 --- a/src/cmd/rm.c +++ b/src/cmd/rm.c @@ -1,4 +1,5 @@ #include <u.h> +#include <sys/stat.h> #include <libc.h> #define rmdir p9rmdir @@ -16,6 +17,13 @@ err(char *f) } } +int +issymlink(char *name) +{ + struct stat s; + return lstat(name, &s) >= 0 && S_ISLNK(s.st_mode); +} + /* * f is a non-empty directory. Remove its contents and then it. */ @@ -48,7 +56,7 @@ rmdir(char *f) ndir = 0; for(i=0; i<n; i++){ snprint(name, nname, "%s/%s", f, dirbuf[i].name); - if(remove(name) != -1) + if(remove(name) != -1 || issymlink(name)) dirbuf[i].qid.type = QTFILE; /* so we won't recurse */ else{ if(dirbuf[i].qid.type & QTDIR) |