shithub: drawterm-fdroid

Download patch

ref: 6af132daa2d80608eeb817b461235af278f6aea8
parent: b2296200820c15871d0b848553d31280875ed126
author: Russ Cox <rsc@swtch.com>
date: Sat Jul 14 04:15:02 EDT 2012

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

R=rsc
http://codereview.appspot.com/6401047

--- a/kern/devfs-posix.c
+++ b/kern/devfs-posix.c
@@ -425,6 +425,14 @@
 
 	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) {
 		fspath(c, 0, old);
 		strcpy(new, old);
@@ -434,13 +442,6 @@
 			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);
 	if(p == 0)