lib9: can change length in dirfwstat, dirwstat; mode in dirwstat (David Swasey)
This commit is contained in:
parent
63a686861c
commit
115dbcecc8
2 changed files with 21 additions and 6 deletions
|
|
@ -48,6 +48,10 @@ dirfwstat(int fd, Dir *dir)
|
||||||
if(futimes(fd, tv) < 0)
|
if(futimes(fd, tv) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
if(~dir->length != 0){
|
||||||
|
if(ftruncate(fd, dir->length) < 0)
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,24 @@
|
||||||
int
|
int
|
||||||
dirwstat(char *file, Dir *dir)
|
dirwstat(char *file, Dir *dir)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
struct utimbuf ub;
|
struct utimbuf ub;
|
||||||
|
|
||||||
/* BUG handle more */
|
/* BUG handle more */
|
||||||
if(~dir->mtime == 0)
|
ret = 0;
|
||||||
return 0;
|
if(~dir->mode != 0){
|
||||||
|
if(chmod(file, dir->mode) < 0)
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
if(~dir->mtime != 0){
|
||||||
ub.actime = dir->mtime;
|
ub.actime = dir->mtime;
|
||||||
ub.modtime = dir->mtime;
|
ub.modtime = dir->mtime;
|
||||||
return utime(file, &ub);
|
if(utime(file, &ub) < 0)
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
if(~dir->length != 0){
|
||||||
|
if(truncate(file, dir->length) < 0)
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue