9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Alex Musolino <musolinoa@gmail.com>
To: 9front <9front@9front.org>
Subject: hjfs create patch
Date: Fri, 16 Jun 2017 22:31:32 +0930	[thread overview]
Message-ID: <CAMVULc7ZbGKPAqW6-6R1SH6kAJYxvPC8Qj6x8+hiw8Tu=RYEbQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

Hi all,

According to open(5), when creating a new file, the owner of the file
is the implied user id of the request, the group of the file is the
same as the parent directory.  Hjfs currently does not adhere to the
the latter part; the group of the file ends up being set the same as
the user id.

I've attached a patch to remedy this.  Subjected to light testing it
seems to work.  Perhaps there's a better way, though.

--
Cheers,
Alex Musolino

[-- Attachment #2: hjfs.patch --]
[-- Type: text/x-patch, Size: 784 bytes --]

diff -r df2c352ae695 sys/src/cmd/hjfs/fs2.c
--- a/sys/src/cmd/hjfs/fs2.c	Mon May 01 22:50:16 2017 +0200
+++ b/sys/src/cmd/hjfs/fs2.c	Fri Jun 16 21:58:49 2017 +1000
@@ -100,6 +100,22 @@
 	return p - name < NAMELEN;
 }
 
+static short
+getgid(Dev *d, Loc *l)
+{
+	Buf *b;
+	Dentry *e;
+
+	b = getbuf(d, l->blk, TDENTRY, 0);
+	if(b == nil)
+		return -1;
+	e = getdent(l, b);
+	putbuf(b);
+	if(e == nil)
+		return -1;
+	return e->gid;
+}
+
 int
 chancreat(Chan *ch, char *name, int perm, int mode)
 {
@@ -164,7 +180,8 @@
 	strcpy(d->name, name);
 	d->mtime = time(0);
 	d->atime = d->mtime;
-	d->gid = d->uid = d->muid = ch->uid;
+	d->gid = getgid(ch->fs->d, l->next);
+	d->uid = d->muid = ch->uid;
 	d->mode = DALLOC | perm & 0777;
 	if((d->type & QTEXCL) != 0){
 		qlock(&ch->loc->ex);

             reply	other threads:[~2017-06-16 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-16 13:01 Alex Musolino [this message]
2017-06-17  8:39 ` Alex Musolino

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='CAMVULc7ZbGKPAqW6-6R1SH6kAJYxvPC8Qj6x8+hiw8Tu=RYEbQ@mail.gmail.com' \
    --to=musolinoa@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).