9front - general discussion about 9front
 help / color / mirror / Atom feed
* hjfs create patch
@ 2017-06-16 13:01 Alex Musolino
  2017-06-17  8:39 ` Alex Musolino
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Musolino @ 2017-06-16 13:01 UTC (permalink / raw)
  To: 9front

[-- 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);

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

* Re: hjfs create patch
  2017-06-16 13:01 hjfs create patch Alex Musolino
@ 2017-06-17  8:39 ` Alex Musolino
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Musolino @ 2017-06-17  8:39 UTC (permalink / raw)
  To: 9front

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

Please ignore the previous patch.  It doesn't need to be so
complicated.  New patch attached.

--
Cheers,
Alex Musolino

[-- Attachment #2: hjfs.patch --]
[-- Type: text/x-patch, Size: 709 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	Sat Jun 17 18:38:40 2017 +1000
@@ -108,6 +108,7 @@
 	int isdir;
 	Loc *l;
 	FLoc f;
+	short pgid;
 
 	b = nil;
 	l = nil;
@@ -150,6 +151,7 @@
 	l = getloc(ch->fs, f, ch->loc);
 	modified(ch, d);
 	b->op |= BDELWRI;
+	pgid = d->gid;
 	putbuf(b);
 	b = nil;
 	if(willmodify(ch->fs, l, ch->flags & CHFNOLOCK) < 0)
@@ -164,7 +166,8 @@
 	strcpy(d->name, name);
 	d->mtime = time(0);
 	d->atime = d->mtime;
-	d->gid = d->uid = d->muid = ch->uid;
+	d->gid = pgid;
+	d->uid = d->muid = ch->uid;
 	d->mode = DALLOC | perm & 0777;
 	if((d->type & QTEXCL) != 0){
 		qlock(&ch->loc->ex);

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

end of thread, other threads:[~2017-06-17  8:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-16 13:01 hjfs create patch Alex Musolino
2017-06-17  8:39 ` Alex Musolino

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).