wm: teppich

Download patch

ref: 4695d500412add95b4ca42cbb224bf15bf21873e
parent: a9ee87279fb13fb9e068fbd97475b4deb2295779
author: mkf <mkf@cloud9p.org>
date: Thu Dec 7 13:04:52 EST 2023

[cmd,env,root]fs: use new APIs

--- a/fs/cmdfs.c
+++ b/fs/cmdfs.c
@@ -1,8 +1,6 @@
 #include <u.h>
 #include <libc.h>
 
-#include <mem.h>
-
 #include <vfs.h>
 #include <user.h>
 #include "../cmd/rc.h"
@@ -17,6 +15,7 @@
 	int i = 0;
 	ll_t *ulist, *flist, *t;
 	file_t *f, *root;
+	user_t *u;
 	
 	if(cmdfs->state == READY)
 		return cmdfs;
@@ -27,7 +26,8 @@
 	ulist = malloc(sizeof(ll_t*));
 	flist = malloc(sizeof(ll_t*));
 
-	lladd(ulist, &adam);
+	u = getadam();
+	lladd(ulist, u->name);
 	
 	cmdfs->fid = 1;
 	cmdfs->state = READY;
@@ -42,7 +42,7 @@
 	root->fid = 0;
 	root->size = 0;
 	
-	root->owner = adam.id;
+	root->owner = u->uid;
 	root->perms = 0444; /* u=r, o=r */
 	
 	root->path = "/";
@@ -59,7 +59,7 @@
 		f->fid = cmdfs->fid++;
 		f->size = 0; /* that is a virtual file */
 		
-		f->owner = adam.id;
+		f->owner = u->uid;
 		f->perms = 0555;
 		
 		f->name = cmdtab[i].name;
--- a/fs/envfs.c
+++ b/fs/envfs.c
@@ -6,6 +6,7 @@
 #include <user.h>
 
 static fs_t *envfs;
+static user_t *cuser;
 
 fs_t*
 envfs_init(void)
@@ -14,7 +15,8 @@
 	int i = 0;
 	ll_t *ulist, *flist;
 	file_t *root;
-	
+
+	/* TODO: check if user has changed, if yes. create a new envfs */
 	if(envfs->state == READY)
 		return envfs;
 		
@@ -23,7 +25,8 @@
 	ulist = malloc(sizeof(ll_t*));
 	flist = malloc(sizeof(ll_t*));
 
-	lladd(ulist, &cuser);
+	cuser = getcuser();
+	lladd(ulist, cuser);
 	
 	envfs->fid = 1;
 	envfs->state = READY;
@@ -34,8 +37,8 @@
 	
 	root->fid = 0;
 	root->size = 0;
-	
-	root->owner = cuser.id;
+
+	root->owner = cuser->uid;
 	root->perms = 0444; /* u=r, o=r */
 	
 	root->path = malloc(sizeof(PATH_MAX));
@@ -74,7 +77,7 @@
 	f->path = malloc(sizeof(PATH_MAX));
 	strncpy(f->path, path, strlen(path));
 
-	f->owner = cuser.id;
+	f->owner = cuser->uid;
 
 	/* t now should point to last item in fs->files */
 	lladd(t, f);
--- a/fs/rootfs.c
+++ b/fs/rootfs.c
@@ -15,6 +15,7 @@
 	char* path;
 	ll_t *ulist, *flist, *t;
 	file_t *f, *root;
+	user_t *u;
 
 	if(rootfs->state == READY)
 		return rootfs;
@@ -25,17 +26,17 @@
 	ulist = malloc(sizeof(ll_t*));
 	flist = malloc(sizeof(ll_t*));
 
-	lladd(ulist, &adam);
+	u = getadam();
+	lladd(ulist, u);
 	
 	rootfs->fid = 1;
 	rootfs->state = READY;
-	/* cmdfs.type = INTERFACE; */
 	rootfs->users = ulist;
 	
 	root->fid = 0;
 	root->size = 0;
 
-	root->owner = adam.id;
+	root->owner = u->uid;
 	root->perms = 0444; /* u=r, o=r */
 	
 	root->path = "/";
@@ -57,7 +58,7 @@
 		f->fid = rootfs->fid++;
 		f->size = 0;
 		
-		f->owner = adam.id;
+		f->owner = u->uid;
 		f->perms = 0444;
 
 		f->name = fstab[i].name;