diff options
author | Russ Cox <rsc@swtch.com> | 2008-12-06 16:05:41 -0800 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-12-06 16:05:41 -0800 |
commit | 115dbcecc8d35d12b54d17dc1cba39089ad37b5f (patch) | |
tree | b9f773189319859b525d9e4a099919297f30cb1c /src/lib9 | |
parent | 63a686861c04660c55e353e76d7760b1b038d047 (diff) | |
download | plan9port-115dbcecc8d35d12b54d17dc1cba39089ad37b5f.tar.gz plan9port-115dbcecc8d35d12b54d17dc1cba39089ad37b5f.tar.bz2 plan9port-115dbcecc8d35d12b54d17dc1cba39089ad37b5f.zip |
lib9: can change length in dirfwstat, dirwstat; mode in dirwstat (David Swasey)
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/dirfwstat.c | 4 | ||||
-rw-r--r-- | src/lib9/dirwstat.c | 23 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/lib9/dirfwstat.c b/src/lib9/dirfwstat.c index 01eab590..95e18444 100644 --- a/src/lib9/dirfwstat.c +++ b/src/lib9/dirfwstat.c @@ -48,6 +48,10 @@ dirfwstat(int fd, Dir *dir) if(futimes(fd, tv) < 0) ret = -1; } + if(~dir->length != 0){ + if(ftruncate(fd, dir->length) < 0) + ret = -1; + } return ret; } diff --git a/src/lib9/dirwstat.c b/src/lib9/dirwstat.c index 396158dc..0b81d900 100644 --- a/src/lib9/dirwstat.c +++ b/src/lib9/dirwstat.c @@ -7,13 +7,24 @@ int dirwstat(char *file, Dir *dir) { + int ret; struct utimbuf ub; /* BUG handle more */ - if(~dir->mtime == 0) - return 0; - - ub.actime = dir->mtime; - ub.modtime = dir->mtime; - return utime(file, &ub); + ret = 0; + if(~dir->mode != 0){ + if(chmod(file, dir->mode) < 0) + ret = -1; + } + if(~dir->mtime != 0){ + ub.actime = dir->mtime; + ub.modtime = dir->mtime; + if(utime(file, &ub) < 0) + ret = -1; + } + if(~dir->length != 0){ + if(truncate(file, dir->length) < 0) + ret = -1; + } + return ret; } |