Plan 9 from Bell Labs’s /usr/web/sources/contrib/alltom/sitefs/sitefs.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include<u.h>
#include<libc.h>
#include<auth.h> /* required by lib9p */
#include<thread.h>
#include<fcall.h> /* required by lib9p */
#include<9p.h>

char *srcdir;

static void
fsattach(Req *r) {
	r->fid->qid = (Qid){0, 0, QTDIR};
	r->ofcall.qid = r->fid->qid;
	respond(r, nil);
}

static void
fscreate(Req *r) {
}

static void
fsread(Req *r) {
}

static char *
fswalk1(Fid *fid, char *name, Qid *qid) {
	return nil;
}

static char *
fsclone(Fid *fid, Fid *newfid) {
	return nil;
}

static void
fsstat(Req *r) {
}

static void
fsremove(Req *r) {
}

static void
freefid(Fid *fid) {
}

static Srv sfs = {
	.attach = fsattach,
	.create = fscreate,
	.remove = fsremove,
	.read = fsread,
	.write = nil,
	.walk1 = fswalk1,
	.clone = fsclone,
	.stat = fsstat,
	.destroyfid = freefid,
};

static void
usage(void) {
	fprint(2, "usage: %s -c srcdir [-D] [-s srv] [-m mnt]\n", argv0);
	fprint(2, "	srcdir: directory with source files\n");
	threadexitsall("usage");
}

void
threadmain(int argc, char **argv) {
	char *mnt;
	char *srv;

	srv = nil;
	mnt = "/mnt/sitefs";
	srcdir = nil;
	ARGBEGIN{
	case 'D':
		chatty9p++;
		break;
	case 's':
		srv = EARGF(usage());
		break;
	case 'm':
		mnt = EARGF(usage());
		break;
	case 'c':
		srcdir = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND;

	if(argc != 0 || srcdir == nil)
		usage();

	threadpostmountsrv(&sfs, srv, mnt, MREPL|MCREATE);
	threadexits(nil);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].