9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Xiao-Yong Jin <meta.jxy@gmail.com>
To: 9front@9front.org
Subject: [9front] drawterm: kern/devfs-posix: fscreate does not respect parent dir's perm
Date: Tue, 3 Jan 2023 16:29:54 -0600	[thread overview]
Message-ID: <22E420E1-6595-48D5-ABE5-7800430C142B@gmail.com> (raw)

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)


             reply	other threads:[~2023-01-03 22:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 22:29 Xiao-Yong Jin [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22E420E1-6595-48D5-ABE5-7800430C142B@gmail.com \
    --to=meta.jxy@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).