Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/root/sys/src/cmd/disk/mkfsconf.c

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


#include <u.h>
#include <libc.h>

/* WARNING.  must keep in sync with your fs */

enum
{
	RBUFSIZE		= 8192,
};

enum
{
	Tnone		= 0,
	Tsuper,			/* the super block */
	Tdirold,
	Tind1old,
	Tind2old,
	Tfile,			/* file contents */
	Tfree,			/* in free list */
	Tbuck,			/* cache fs bucket */
	Tvirgo,			/* fake worm virgin bits */
	Tcache,			/* cw cache things */
	Tconfig,		/* configuration block */
	/* Tdir & indirect blocks are last to allow for greater depth */
	Tdir,			/* directory contents */
	Tind1,			/* points to blocks */
	Tind2,			/* points to Tind1 */
	Tind3,			/* points to Tind2 */
	Tind4,			/* points to Tind3 */
	Maxtind,
	MAXTAG,

	Tmaxind = Maxtind - 1,
};

#define	BUFSIZE		(RBUFSIZE-sizeof(Tag))

typedef	struct	Tag	Tag;
typedef	struct	Iobuf	Iobuf;
typedef		uvlong	Off;

struct	Tag
{
	short	pad;		/* make tag end at a long boundary */
	short	tag;
	Off	path;
};

struct	Iobuf
{
	char	iobuf[RBUFSIZE];	/* only active while locked */
	int	flags;
};

void
settag(Iobuf *p, int tag)
{
	Tag *t;

	t = (Tag*)(p->iobuf+BUFSIZE);
	t->tag = tag;
	t->path = 0;
}

void
usage(void)
{
	fprint(2, "usage: mkfsconf < config\n");
	exits("usage");
}

void
main(int argc, char **argv)
{
	Iobuf p;

	ARGBEGIN{
	default:
		usage();
	}ARGEND
	if(argc)
		usage();

	memset(&p, 0, sizeof p);
	read(0, p.iobuf, BUFSIZE);
	settag(&p, Tconfig);
	write(1, p.iobuf, RBUFSIZE);
	exits("");
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.