kern/devfs-posix: fix chmod after rename (thanks Cinap)

R=rsc
http://codereview.appspot.com/6401047
This commit is contained in:
Russ Cox 2012-07-14 08:15:02 -04:00
parent b229620082
commit 6af132daa2
1 changed files with 8 additions and 7 deletions

View File

@ -425,6 +425,14 @@ fswstat(Chan *c, uchar *buf, int n)
uif = c->aux; uif = c->aux;
fspath(c, 0, old);
if(~d.mode != 0 && (int)(d.mode&0777) != (int)(stbuf.st_mode&0777)) {
if(chmod(old, d.mode&0777) < 0)
error(strerror(errno));
uif->mode &= ~0777;
uif->mode |= d.mode&0777;
}
if(d.name[0] && strcmp(d.name, lastelem(c)) != 0) { if(d.name[0] && strcmp(d.name, lastelem(c)) != 0) {
fspath(c, 0, old); fspath(c, 0, old);
strcpy(new, old); strcpy(new, old);
@ -434,13 +442,6 @@ fswstat(Chan *c, uchar *buf, int n)
error(strerror(errno)); error(strerror(errno));
} }
fspath(c, 0, old);
if(~d.mode != 0 && (int)(d.mode&0777) != (int)(stbuf.st_mode&0777)) {
if(chmod(old, d.mode&0777) < 0)
error(strerror(errno));
uif->mode &= ~0777;
uif->mode |= d.mode&0777;
}
/* /*
p = name2pass(gid, d.gid); p = name2pass(gid, d.gid);
if(p == 0) if(p == 0)