Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Expose the 'dc' parameter to user programs by extending the mount call.
Browse files Browse the repository at this point in the history
The mount call has another parameter, an int, which is the device character
used to pick a mount device. This works for mount and ramfs,
but it would be nice if someone else could verify it.

Now, go forth, and write new devmnt devices!

Change-Id: I765dd6830f5a26d8a96d5e568fe61871cf7e402c
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
  • Loading branch information
rminnich committed Aug 20, 2015
1 parent 5dd0f89 commit 72777a1
Show file tree
Hide file tree
Showing 52 changed files with 63 additions and 60 deletions.
2 changes: 1 addition & 1 deletion sys/include/libc.h
Expand Up @@ -676,7 +676,7 @@ extern int fauth(int, char*);
extern int fstat(int, uint8_t*, int);
extern int fwstat(int, uint8_t*, int);
extern int fversion(int, int, char*, int);
extern int mount(int, int, char*, int, char*);
extern int mount(int, int, char*, int, char*, int);
extern int unmount(char*, char*);
extern int noted(int);
extern int notify(void(*)(void*, char*));
Expand Down
4 changes: 2 additions & 2 deletions sys/src/9/amd64pv/root/cpu.c
Expand Up @@ -342,7 +342,7 @@ remoteside(int old)
strcpy(buf, VERSION9P);
if(fversion(fd, 64*1024, buf, sizeof buf) < 0)
exits("fversion failed");
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "") < 0)
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "", 'M') < 0)
exits("mount failed");

close(fd);
Expand Down Expand Up @@ -1179,7 +1179,7 @@ lclnoteproc(int netfd)
return;
case 0:
close(pfd[0]);
if(mount(pfd[1], -1, "/dev", MBEFORE, "") < 0)
if(mount(pfd[1], -1, "/dev", MBEFORE, "", 'M') < 0)
fprint(2, "cpu: can't mount note proc: %r\n");
close(pfd[1]);
return;
Expand Down
2 changes: 1 addition & 1 deletion sys/src/9/boot/settime.c
Expand Up @@ -50,7 +50,7 @@ settime(int islocal, int afd, char *rp)
f = open(timeserver, ORDWR);
if(f < 0)
return;
if(mount(f, afd, "/tmp", MREPL, rp) < 0){
if(mount(f, afd, "/tmp", MREPL, rp, 'M') < 0){
warning("settime mount");
close(f);
return;
Expand Down
4 changes: 2 additions & 2 deletions sys/src/9/k10/root/cpu.c
Expand Up @@ -342,7 +342,7 @@ remoteside(int old)
strcpy(buf, VERSION9P);
if(fversion(fd, 64*1024, buf, sizeof buf) < 0)
exits("fversion failed");
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "") < 0)
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "", 'M') < 0)
exits("mount failed");

close(fd);
Expand Down Expand Up @@ -1179,7 +1179,7 @@ lclnoteproc(int netfd)
return;
case 0:
close(pfd[0]);
if(mount(pfd[1], -1, "/dev", MBEFORE, "") < 0)
if(mount(pfd[1], -1, "/dev", MBEFORE, "", 'M') < 0)
fprint(2, "cpu: can't mount note proc: %r\n");
close(pfd[1]);
return;
Expand Down
5 changes: 3 additions & 2 deletions sys/src/9/k10/syscall.c
Expand Up @@ -244,16 +244,17 @@ syscall(int badscallnr, Ureg *ureg)
{
// can only handle 4 args right now.
uintptr_t a0, a1, a2, a3;
uintptr_t a4, a5 = 0;
uintptr_t a4, a5;

a0 = ureg->di;
a1 = ureg->si;
a2 = ureg->dx;
a3 = ureg->r10;
a4 = ureg->r8;
a5 = ureg->r9;
Proc *up = externup();
unsigned int scallnr = (unsigned int) badscallnr;
if (0) iprint("Syscall %d, %lx, %lx, %lx %lx %lx\n", scallnr, a0, a1, a2, a3, a4);
if (0) iprint("Syscall %d, %lx, %lx, %lx %lx %lx %lx\n", scallnr, a0, a1, a2, a3, a4, a5);
char *e;
uintptr_t sp;
int s;
Expand Down
3 changes: 2 additions & 1 deletion sys/src/9/port/sysfile.c
Expand Up @@ -1303,7 +1303,7 @@ sysmount(Ar0* ar0, ...)
{
int afd, fd, flag;
char *aname, *old;
int dc = 'M';
int dc;
va_list list;
va_start(list, ar0);

Expand All @@ -1317,6 +1317,7 @@ sysmount(Ar0* ar0, ...)
old = va_arg(list, char*);
flag = va_arg(list, int);
aname = va_arg(list, char*);
dc = va_arg(list, int);
va_end(list);

ar0->i = bindmount(dc, fd, afd, nil, old, flag, aname);
Expand Down
4 changes: 2 additions & 2 deletions sys/src/9/root/cpu.c
Expand Up @@ -338,7 +338,7 @@ remoteside(int old)
strcpy(buf, VERSION9P);
if(fversion(fd, 64*1024, buf, sizeof buf) < 0)
exits("fversion failed");
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "") < 0)
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "", 'M') < 0)
exits("mount failed");

close(fd);
Expand Down Expand Up @@ -1109,7 +1109,7 @@ lclnoteproc(int netfd)
return;
case 0:
close(pfd[0]);
if(mount(pfd[1], -1, "/dev", MBEFORE, "") < 0)
if(mount(pfd[1], -1, "/dev", MBEFORE, "", 'M') < 0)
fprint(2, "cpu: can't mount note proc: %r\n");
close(pfd[1]);
return;
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/acme/fsys.c
Expand Up @@ -279,7 +279,7 @@ fsysmount(Rune *dir, int ndir, Rune **incl, int nincl)
close(sfd);
m = fsysaddid(dir, ndir, incl, nincl);
sprint(buf, "%d", m->id);
if(mount(cfd, -1, "/mnt/acme", MREPL, buf) < 0){
if(mount(cfd, -1, "/mnt/acme", MREPL, buf, 'M') < 0){
fsysdelid(m);
return nil;
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/auth/factotum/util.c
Expand Up @@ -22,7 +22,7 @@ bindnetcs(void)

if(access("/net/cs", AEXIST) < 0){
if((srvfd = open("#s/cs", ORDWR)) >= 0){
if(mount(srvfd, -1, "/net", MBEFORE, "") >= 0)
if(mount(srvfd, -1, "/net", MBEFORE, "", 'M') >= 0)
return 0;
close(srvfd);
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/auth/keyfs.c
Expand Up @@ -194,7 +194,7 @@ main(int argc, char *argv[])
error("fork");
default:
close(p[1]);
if(mount(p[0], -1, mntpt, MREPL|MCREATE, "") < 0)
if(mount(p[0], -1, mntpt, MREPL|MCREATE, "", 'M') < 0)
error("can't mount: %r");
exits(0);
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/auth/login.c
Expand Up @@ -115,7 +115,7 @@ mountfactotum(char *srvname)
fd = open(srvname, ORDWR);
if(fd < 0)
sysfatal("opening factotum: %r");
mount(fd, -1, "/mnt", MBEFORE, "");
mount(fd, -1, "/mnt", MBEFORE, "", 'M');
close(fd);
}

Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/aux/consolefs.c
Expand Up @@ -381,7 +381,7 @@ fsmount(char *mntpt)
close(srv);
}

mount(pfd[1], -1, mntpt, MBEFORE, "");
mount(pfd[1], -1, mntpt, MBEFORE, "", 'M');
close(pfd[1]);
return fs;
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/aux/searchfs.c
Expand Up @@ -227,7 +227,7 @@ main(int argc, char **argv)
exits(nil);
}

if(mount(p[1], -1, mnt, MREPL, "") < 0){
if(mount(p[1], -1, mnt, MREPL, "", 'M') < 0){
close(p[1]);
fatal("mount failed");
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/aux/statusbar.c
Expand Up @@ -286,7 +286,7 @@ newwin(char *win)
return -1;
}
sprint(spec, "new -r %s", win);
if(mount(srvfd, -1, "/mnt/wsys", 0, spec) == -1){
if(mount(srvfd, -1, "/mnt/wsys", 0, spec, 'M') == -1){
fprint(2, "statusbar: can't mount /mnt/wsys: %r (spec=%s)\n", spec);
return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion sys/src/cmd/cfs/cfs.c
Expand Up @@ -269,7 +269,8 @@ mountinit(char *server, char *mountpoint)
break;
default:
if (noauth)
err = mount(p[1], -1, mountpoint, MREPL|MCREATE, "");
err = mount(p[1], -1, mountpoint, MREPL|MCREATE, "",
'M');
else
err = amount(p[1], mountpoint, MREPL|MCREATE, "");
if (err < 0)
Expand Down
4 changes: 2 additions & 2 deletions sys/src/cmd/cpu.c
Expand Up @@ -400,7 +400,7 @@ remoteside(int old)
strcpy(buf, VERSION9P);
if(fversion(fd, 64*1024, buf, sizeof buf) < 0)
exits("fversion failed");
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "") < 0)
if(mount(fd, -1, "/mnt/term", MCREATE|MREPL, "", 'M') < 0)
exits("mount failed");

close(fd);
Expand Down Expand Up @@ -1166,7 +1166,7 @@ lclnoteproc(int netfd)
return;
case 0:
close(pfd[0]);
if(mount(pfd[1], -1, "/dev", MBEFORE, "") < 0)
if(mount(pfd[1], -1, "/dev", MBEFORE, "", 'M') < 0)
fprint(2, "cpu: can't mount note proc: %r\n");
close(pfd[1]);
return;
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/disk/kfs/9p2.c
Expand Up @@ -65,7 +65,7 @@ fsauth(Chan *chan, Fcall *f, Fcall *r)

if(access("/mnt/factotum", 0) < 0)
if((fd = open("/srv/factotum", ORDWR)) >= 0)
mount(fd, -1, "/mnt", MBEFORE, "");
mount(fd, -1, "/mnt", MBEFORE, "", 'M');

afd = open("/mnt/factotum/rpc", ORDWR);
if(afd < 0){
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/disk/mkfs.c
Expand Up @@ -772,7 +772,7 @@ mountkfs(char *name)
fprint(2, "can't open %q\n", kname);
exits("open /srv/kfs");
}
if(mount(sfd, -1, "/n/kfs", MREPL|MCREATE, "") < 0){
if(mount(sfd, -1, "/n/kfs", MREPL|MCREATE, "", 'M') < 0){
fprint(2, "can't mount kfs on /n/kfs\n");
exits("mount kfs");
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/fossil/9p.c
Expand Up @@ -966,7 +966,7 @@ conIPCheck(Con* con)
if(access("/mnt/ipok/ok", AEXIST) < 0){
/* mount closes the fd on success */
if((fd = open("/srv/ipok", ORDWR)) >= 0
&& mount(fd, -1, "/mnt/ipok", MREPL, "") < 0)
&& mount(fd, -1, "/mnt/ipok", MREPL, "", 'M') < 0)
close(fd);
if(access("/mnt/ipok/ok", AEXIST) < 0){
vtSetError("cannot verify remote address");
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/import.c
Expand Up @@ -244,7 +244,7 @@ main(int argc, char **argv)
post(srvfile, srvpost, fd);
}
procsetname("mount on %s", mntpt);
if(mount(fd, -1, mntpt, mntflags, "") < 0)
if(mount(fd, -1, mntpt, mntflags, "", 'M') < 0)
sysfatal("can't mount %s: %r", argv[1]);
alarm(0);

Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ip/ftpfs/ftpfs.c
Expand Up @@ -195,7 +195,7 @@ main(int argc, char *argv[])
break;
default:
close(p[0]);
if(mount(p[1], -1, mountpoint, MREPL|MCREATE, "") < 0)
if(mount(p[1], -1, mountpoint, MREPL|MCREATE, "", 'M') < 0)
fatal("mount failed: %r");
}
exits(0);
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ip/httpd/netlib_find.c
Expand Up @@ -174,7 +174,7 @@ init800fs(char*name,char*pat)
fd800fs = open(name, ORDWR);
if(fd800fs < 0)
exits("can't connect to 800fs server");
if(mount(fd800fs, -1, "/mnt", MREPL, "") < 0)
if(mount(fd800fs, -1, "/mnt", MREPL, "", 'M') < 0)
exits("can't mount /mnt");
fd800fs = open("/mnt/search", ORDWR);
n = strlen("search=")+strlen(pat)+1;
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ip/httpd/wikipost.c
Expand Up @@ -148,7 +148,7 @@ mountwiki(HConnect *c, char *service)
hfail(c, HNotFound);
exits("failed");
}
if(mount(fd, -1, "/mnt/wiki", MREPL, "") < 0){
if(mount(fd, -1, "/mnt/wiki", MREPL, "", 'M') < 0){
syslog(0, LOG, "%s mount /mnt/wiki failed: %r", hp->remotesys);
hfail(c, HNotFound);
exits("failed");
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ip/imap4d/auth.c
Expand Up @@ -37,7 +37,7 @@ enableForwarding(void)
fd = open("/srv/ratify", ORDWR);
if(fd < 0)
return;
if(!mount(fd, -1, "/mail/ratify", MBEFORE, "")){
if(!mount(fd, -1, "/mail/ratify", MBEFORE, "", 'M')){
close(fd);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/lnfs.c
Expand Up @@ -171,7 +171,7 @@ main(int argc, char *argv[])
break;
default:
close(p[0]); /* don't deadlock if child fails */
if(mount(p[1], -1, defmnt, MREPL|MCREATE, "") < 0)
if(mount(p[1], -1, defmnt, MREPL|MCREATE, "", 'M') < 0)
sysfatal("mount failed: %r");
}
exits(0);
Expand Down
4 changes: 2 additions & 2 deletions sys/src/cmd/mount.c
Expand Up @@ -30,7 +30,7 @@ amount0(int fd, char *mntpt, int flags, char *aname, char *keyspec)
else
fprint(2, "%s: auth_proxy: %r\n", argv0);
}
rv = mount(fd, afd, mntpt, flags, aname);
rv = mount(fd, afd, mntpt, flags, aname, 'M');
if(afd >= 0)
close(afd);
return rv;
Expand Down Expand Up @@ -92,7 +92,7 @@ main(int argc, char *argv[])

notify(catch);
if(noauth)
rv = mount(fd, -1, argv[1], flag, spec);
rv = mount(fd, -1, argv[1], flag, spec, 'M');
else
rv = amount0(fd, argv[1], flag, spec, keyspec);
if(rv < 0){
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ndb/cs.c
Expand Up @@ -334,7 +334,7 @@ mountinit(char *service, char *mntpt)
* put ourselves into the file system
*/
close(p[0]);
if(mount(p[1], -1, mntpt, MAFTER, "") < 0)
if(mount(p[1], -1, mntpt, MAFTER, "", 'M') < 0)
error("mount failed\n");
_exits(0);
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ndb/dns.c
Expand Up @@ -136,7 +136,7 @@ justremount(char *service, char *mntpt)
f = open(service, ORDWR);
if(f < 0)
abort(); /* service */;
while (mount(f, -1, mntpt, MAFTER, "") < 0) {
while (mount(f, -1, mntpt, MAFTER, "", 'M') < 0) {
dnslog("dns mount -a on %s failed: %r", mntpt);
sleep(5000);
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ndb/dnsquery.c
Expand Up @@ -35,7 +35,7 @@ setup(int argc, char **argv)
fd = open(srv, ORDWR);
if(fd < 0)
sysfatal("can't open %s: %r", srv);
if(mount(fd, -1, mtpt, MBEFORE, "") < 0)
if(mount(fd, -1, mtpt, MBEFORE, "", 'M') < 0)
sysfatal("can't mount(%s, %s): %r", srv, mtpt);
fd = open(dns, ORDWR);
if(fd < 0)
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/page/view.c
Expand Up @@ -1016,7 +1016,7 @@ newwin(void)
}
free(srv);
sprint(spec, "new -pid %d", pid);
if(mount(srvfd, -1, "/mnt/wsys", 0, spec) == -1){
if(mount(srvfd, -1, "/mnt/wsys", 0, spec, 'M') == -1){
fprint(2, "page: can't mount /mnt/wsys: %r (spec=%s)\n", spec);
wexits("no mount");
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/plumb/fsys.c
Expand Up @@ -225,7 +225,7 @@ startfsys(void)
procrfork(fsysproc, nil, Stack, RFFDG);

close(p[0]);
if(mount(p[1], -1, "/mnt/plumb", MREPL, "") < 0)
if(mount(p[1], -1, "/mnt/plumb", MREPL, "", 'M') < 0)
error("can't mount /mnt/plumb: %r");
close(p[1]);
}
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ramfs.c
Expand Up @@ -248,7 +248,7 @@ main(int argc, char *argv[])
break;
default:
close(p[0]); /* don't deadlock if child fails */
if(defmnt && mount(p[1], -1, defmnt, MREPL|MCREATE, "") < 0)
if(defmnt && mount(p[1], -1, defmnt, MREPL|MCREATE, "", 'M') < 0)
error("mount failed");
}
exits(0);
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/ratfs/main.c
Expand Up @@ -165,7 +165,7 @@ post(int fd, char *mountpoint)
* another server is already running, so just exit.
*/
f = open(SRVFILE, ORDWR);
if(f >= 0 && mount(f, -1, mountpoint, MREPL|MCREATE, "") >= 0){
if(f >= 0 && mount(f, -1, mountpoint, MREPL|MCREATE, "", 'M') >= 0){
unmount(0, mountpoint);
close(f);
exits(0);
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/rio/fsys.c
Expand Up @@ -243,7 +243,7 @@ filsysmount(Filsys *fs, int id)

close(fs->sfd); /* close server end so mount won't hang if exiting */
sprint(buf, "%d", id);
if(mount(fs->cfd, -1, "/mnt/wsys", MREPL, buf) < 0){
if(mount(fs->cfd, -1, "/mnt/wsys", MREPL, buf, 'M') < 0){
fprint(2, "mount failed: %r\n");
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions sys/src/cmd/scat/header.c
Expand Up @@ -283,7 +283,7 @@ dssmount(int dskno)
/*
* mount nfs jukebox server
*/
if(mount(s1, -1, "/n/njuke", 0, "") < 0) {
if(mount(s1, -1, "/n/njuke", 0, "", 'M') < 0) {
close(s1);
Bprint(&bout, "\"mount /srv/%s /n/juke\" failed: %r\n", JUKEFS);
goto out;
Expand All @@ -309,7 +309,7 @@ dssmount(int dskno)
/*
* mount 9660 server
*/
if(mount(s2, -1, "/n/dss", 0, dssname) < 0) {
if(mount(s2, -1, "/n/dss", 0, dssname, 'M') < 0) {
close(s2);
if(count == 0) {
// do it again so /n/njuke is in 9660's namespace
Expand Down
2 changes: 1 addition & 1 deletion sys/src/cmd/srv.c
Expand Up @@ -206,7 +206,7 @@ main(int argc, char *argv[])
if(domount == 0 || reallymount == 0)
exits(0);

if((!doauth && mount(fd, -1, mtpt, mountflag, "") < 0)
if((!doauth && mount(fd, -1, mtpt, mountflag, "", 'M') < 0)
|| (doauth && amount(fd, mtpt, mountflag, "") < 0)){
err[0] = 0;
errstr(err, sizeof err);
Expand Down

0 comments on commit 72777a1

Please sign in to comment.