libplumb: search for plumber only at /mnt/plumb, and don't try to mount $plumbsrv if the search fails
This commit is contained in:
parent
9a1e762dcc
commit
1259fe5c38
|
@ -5,37 +5,16 @@
|
||||||
int
|
int
|
||||||
plumbopen(char *name, int omode)
|
plumbopen(char *name, int omode)
|
||||||
{
|
{
|
||||||
int fd, f;
|
int fd;
|
||||||
char *s, *plumber;
|
|
||||||
char buf[128], err[ERRMAX];
|
char buf[128], err[ERRMAX];
|
||||||
|
|
||||||
if(name[0] == '/')
|
if(name[0] == '/')
|
||||||
return open(name, omode);
|
return open(name, omode);
|
||||||
|
|
||||||
/* find elusive plumber */
|
|
||||||
if(access("/mnt/plumb/send", AWRITE) >= 0)
|
|
||||||
plumber = "/mnt/plumb";
|
|
||||||
else if(access("/mnt/term/mnt/plumb/send", AWRITE) >= 0)
|
|
||||||
plumber = "/mnt/term/mnt/plumb";
|
|
||||||
else{
|
|
||||||
/* last resort: try mounting service */
|
|
||||||
plumber = "/mnt/plumb";
|
|
||||||
s = getenv("plumbsrv");
|
|
||||||
if(s == nil)
|
|
||||||
return -1;
|
|
||||||
f = open(s, ORDWR);
|
|
||||||
free(s);
|
|
||||||
if(f < 0)
|
|
||||||
return -1;
|
|
||||||
if(mount(f, -1, "/mnt/plumb", MREPL, "") < 0){
|
|
||||||
close(f);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(access("/mnt/plumb/send", AWRITE) < 0)
|
if(access("/mnt/plumb/send", AWRITE) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
snprint(buf, sizeof buf, "%s/%s", plumber, name);
|
snprint(buf, sizeof buf, "/mnt/plumb/%s", name);
|
||||||
fd = open(buf, omode);
|
fd = open(buf, omode);
|
||||||
if(fd >= 0)
|
if(fd >= 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
Loading…
Reference in a new issue