From: Fco.J.Ballesteros <nemo@plan9.escet.urjc.es>
To: 9fans@cse.psu.edu
Subject: [9fans] autofs
Date: Tue, 16 Jul 2002 10:58:18 +0200 [thread overview]
Message-ID: <69c0bc11b75703468171eb698a635ec5@plan9.escet.urjc.es> (raw)
[-- Attachment #1: Type: text/plain, Size: 61 bytes --]
I loved the idea so much, that I couldn't wait.
Enjoy.
[-- Attachment #2: autofs --]
[-- Type: text/plain, Size: 433 bytes --]
.TH AUTOFS 4
.SH NAME
autofs \- automatically supply mount points for file systems
.SH SYNOPSIS
.B autofs
[
.I mnt
]
.SH DESCRIPTION
.I Autofs
implements a single directory that creates inner directories on
demand, when referenced. It is intended to supply mount points automatically.
.PP
By default
.I autofs
mounts itself at
.B /n
unless a
.I mnt
mount point is specified.
.SH SOURCE
.B /sys/src/cmd/autofs.c
[-- Attachment #3: autofs.c --]
[-- Type: text/plain, Size: 2774 bytes --]
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <thread.h>
#include <9p.h>
enum {
Qroot = ~0,
};
static void aopen(Req*);
static void aread(Req*);
static void astat(Req*);
static void awstat(Req*);
static char* awalk1(Fid* fid, char *name, Qid *qid);
static void aattach(Req*);
char** names;
int nnames;
Srv asrv = {
.tree = nil,
.attach = aattach,
.auth = nil,
.open = aopen,
.create = nil,
.read = aread,
.write = nil,
.remove = nil,
.flush = nil,
.stat = astat,
.wstat = awstat,
.walk = nil,
.walk1 = awalk1,
.clone = nil,
.destroyfid = nil,
.destroyreq = nil,
.end = nil,
.aux = nil,
.infd = -1,
.outfd = -1,
.nopipe = 0,
.srvfd = -1,
};
static void
usage(void)
{
fprint(2, "usage: %s [mnt]\n", argv0);
exits("usage");
}
static void
aattach(Req* r)
{
Qid q;
q.type = QTDIR;
q.path = Qroot;
q.vers = 0;
r->fid->qid = q;
r->ofcall.qid = q;
respond(r, nil);
}
static void
aopen(Req* r)
{
respond(r, nil);
}
static int
agen(int n, Dir *dir, void* a)
{
if (a == nil || n < 0 || n >= nnames)
return -1;
dir->qid.type = QTDIR;
dir->qid.path = n;
dir->qid.vers = 0;
dir->name = estrdup9p(names[n]);
dir->uid = estrdup9p("sys");
dir->gid = estrdup9p("sys");
dir->mode= 0555|DMDIR;
dir->length= 0;
return 0;
}
static void
aread(Req* r)
{
Qid q;
q = r->fid->qid;
if (q.path < 0 || q.path >= nnames && q.path != Qroot)
respond(r, "bug: bad qid");
if (q.path == Qroot)
dirread9p(r, agen, names);
else
dirread9p(r, agen, nil);
respond(r, nil);
}
static void
astat(Req* r)
{
Qid q;
q = r->fid->qid;
if (q.path < 0 || q.path >= nnames && q.path != Qroot)
respond(r, "bug: bad qid");
r->d.qid = q;
if (q.path == Qroot)
r->d.name = estrdup9p("/");
else
r->d.name = estrdup9p(names[q.path]);
r->d.uid = estrdup9p("sys");
r->d.gid = estrdup9p("sys");
r->d.length= 0;
r->d.mode= 0555|DMDIR;
respond(r, nil);
}
static void
awstat(Req* r)
{
respond(r, "wstat not allowed");
}
static char*
awalk1(Fid* fid, char *name, Qid *qid)
{
int i;
if (fid->qid.path != Qroot)
return "no such name";
for (i = 0; i < nnames; i++)
if (strcmp(name, names[i]) == 0)
break;
if (i == nnames){
if ((nnames % 100) == 0)
names = realloc(names, (nnames+100)*sizeof(char*));
names[nnames++] = strdup(name);
}
qid->path = i;
qid->type = QTDIR;
qid->vers = 0;
fid->qid = *qid;
return nil;
}
void
main(int argc, char* argv[])
{
char* mnt;
ARGBEGIN{
default:
usage();
}ARGEND;
if (argc > 1)
usage();
if (argc == 0)
mnt = "/n";
else
mnt = *argv;
postmountsrv(&asrv, nil, mnt, MREPL);
exits(nil);
}
next reply other threads:[~2002-07-16 8:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-16 8:58 Fco.J.Ballesteros [this message]
2002-07-16 12:23 rog
2002-07-16 11:42 ` Sam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=69c0bc11b75703468171eb698a635ec5@plan9.escet.urjc.es \
--to=nemo@plan9.escet.urjc.es \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).