shithub: riscv

Download patch

ref: 63f1fc07eb77a5443d693b902dd2b74b56f95057
parent: 6dc133ad99486167343885af1860d4e85a0f946c
author: cinap_lenrek <[email protected]>
date: Sun Jan 13 03:49:31 EST 2013

hjfs: dont mask permission bits for "create" console command

--- a/sys/src/cmd/hjfs/cons.c
+++ b/sys/src/cmd/hjfs/cons.c
@@ -148,7 +148,7 @@
 		return -1;
 	if(name2uid(fsmain, argv[3], &gid) < 0)
 		return -1;
-	ch = chanattach(fsmain, 0);
+	ch = chanattach(fsmain, CHFNOPERM);
 	if(ch == nil)
 		return -1;
 	ch->uid = uid;
--- a/sys/src/cmd/hjfs/fs2.c
+++ b/sys/src/cmd/hjfs/fs2.c
@@ -132,17 +132,19 @@
 		werrstr(Enotadir);
 		goto error;
 	}
-	if((ch->flags & CHFNOPERM) == 0)
+	if((ch->flags & CHFNOPERM) == 0){
 		if(!permcheck(ch->fs, d, ch->uid, OWRITE)){
 			werrstr(Eperm);
 			goto error;
 		}
+		if(isdir)
+			perm &= ~0777 | d->mode & 0777;
+		else
+			perm &= ~0666 | d->mode & 0666;
+	}
 	if(newentry(ch->fs, ch->loc, b, name, &f, 0) <= 0)
 		goto error;
-	if(isdir)
-		perm &= ~0777 | d->mode & 0777;
-	else
-		perm &= ~0666 | d->mode & 0666;
+
 	f.type = perm >> 24;
 	if(newqid(ch->fs, &f.path) < 0)
 		goto error;