9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] drawterm: kern/devfs-posix: fscreate does not respect parent dir's perm
@ 2023-01-03 22:29 Xiao-Yong Jin
  2023-01-06 14:21 ` cinap_lenrek
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Xiao-Yong Jin @ 2023-01-03 22:29 UTC (permalink / raw)
  To: 9front

Under posix drawterm, creating new file or dir under /mnt/term
always ends up having perm bits 0666 or 0777.  The patch below
includes the parent dir's perm in fscreate.  It also fix the
uid/gid the same as the parent dir.

diff --git a/kern/devfs-posix.c b/kern/devfs-posix.c
index 31eca3c..c715072 100644
--- a/kern/devfs-posix.c
+++ b/kern/devfs-posix.c
@@ -244,8 +244,9 @@ fscreate(Chan *c, char *name, int mode, ulong perm)
                  fd = open(path, 0);
                if(fd >= 0) {
+                       perm &= uif->mode & 0777;
                        chmod(path, perm & 0777);
-                       chown(path, uif->uid, uif->uid);
+                       chown(path, uif->uid, uif->gid);
                }
                close(fd);
  @@ -260,7 +261,8 @@ fscreate(Chan *c, char *name, int mode, ulong perm)
                                close(fd);
                                fd = open(path, m);
                        }
-                       chmod(path, perm & 0777);
+                       perm &= uif->mode & 0666;
+                       chmod(path, perm & 0666);
                        chown(path, uif->uid, uif->gid);
                }
                if(fd < 0)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-06 18:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 22:29 [9front] drawterm: kern/devfs-posix: fscreate does not respect parent dir's perm Xiao-Yong Jin
2023-01-06 14:21 ` cinap_lenrek
2023-01-06 14:44 ` cinap_lenrek
2023-01-06 15:30   ` Xiao-Yong Jin
2023-01-06 15:40 ` cinap_lenrek
2023-01-06 18:20 ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).