hmi/console: fix file owner for screenconsole

When boot starts screenconsole, the hostowner is still empty
This commit is contained in:
Giacomo Tesio 2017-11-02 22:52:48 +01:00
parent dcbea5d48d
commit 2f99fb162f
3 changed files with 26 additions and 34 deletions

View File

@ -65,7 +65,7 @@ extern void post(char *srv, int fd);
extern int fsinit(int *, int *);
extern void fsserve(int, char*);
extern void fsserve(int);
extern void passthrough(int, int);

View File

@ -41,7 +41,6 @@ static Status status;
static int rawmode;
static int fspid;
static char *filesowner;
static void *data;
enum {
@ -533,10 +532,33 @@ invalidioreq(Fcall *req)
return "bad read/write count";
return nil;
}
static char*
gethostowner(void)
{
int f, r;
char *res;
res = (char*)malloc(256);
if(res == nil)
sysfatal("out of memory");
f = open("#c/hostowner", OREAD);
if(f < 0)
sysfatal("open(#c/hostowner) %r");
r = read(f, res, 255);
if(r < 0)
sysfatal("read(#c/hostowner)");
res[r] = '\0';
close(f);
return res;
}
static int
fillstat(uint64_t path, Dir *d)
{
struct Qtab *t;
static char *filesowner;
if(filesowner == nil)
filesowner = gethostowner();
memset(d, 0, sizeof(Dir));
d->uid = filesowner;
@ -987,16 +1009,12 @@ fsinit(int *mnt, int *mntdev)
}
/* fsserve is the main loop */
void
fsserve(int connection, char *owner)
fsserve(int connection)
{
int r, w, syncrep;
Fcall rep;
Fcall *req;
if(owner == nil)
sysfatal("owner undefined");
filesowner = strdup(owner);
fspid = getpid();
req = malloc(sizeof(Fcall)+Maxfdata);
if(req == nil)

View File

@ -85,24 +85,6 @@ debug(const char *fmt, ...)
}
/* process management */
static char*
gethostowner(void)
{
int f, r;
char *res;
res = (char*)malloc(256);
if(res == nil)
sysfatal("out of memory");
f = open("#c/hostowner", OREAD);
if(f < 0)
sysfatal("open(#c/hostowner) %r");
r = read(f, res, 255);
if(r < 0)
sysfatal("read(#c/hostowner)");
close(f);
return res;
}
/* start the relevant services
*
* assumes that
@ -116,11 +98,6 @@ int
servecons(StreamFilter inputFilter, StreamFilter outputFilter, int *devmnt)
{
int pid, input, output, fs, mnt;
char *s;
s = gethostowner();
if(s == nil)
sysfatal("cannot read hostowner");
pid = getpid();
@ -142,18 +119,15 @@ servecons(StreamFilter inputFilter, StreamFilter outputFilter, int *devmnt)
close(0);
close(1);
close(mnt);
s = strdup(s);
PROVIDE(fs);
rfork(RFREND);
fsserve(fs, s);
fsserve(fs);
break;
default:
break;
}
WAIT_FOR(fs);
free(s);
s = nil;
close(fs);
/* start output device writer */