Plan 9 from Bell Labs’s /usr/web/sources/contrib/cinap_lenrek/ktags.c

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


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

typedef uvlong	Off;
typedef struct Tag Tag;
typedef struct Fbuf Fbuf;
typedef struct Super1 Super1;
typedef struct Superb Superb;

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

enum {
	RBUFSIZE = 8*1024,
	BUFSIZE = RBUFSIZE-sizeof(Tag),
};

struct	Super1
{
	Off	fstart;
	Off	fsize;
	Off	tfree;
	Off	qidgen;		/* generator for unique ids */
	/*
	 * Stuff for WWC device
	 */
	Off	cwraddr;	/* cfs root addr */
	Off	roraddr;	/* dump root addr */
	Off	last;		/* last super block addr */
	Off	next;		/* next super block addr */
};

enum {
	FEPERBUF = (BUFSIZE-sizeof(Super1)-sizeof(Off)) / sizeof(Off),
};

struct	Fbuf
{
	Off	nfree;
	Off	free[FEPERBUF];
};

struct	Superb
{
	Fbuf	fbuf;
	Super1;
};

uchar buf[RBUFSIZE];
Off start = 0;

void
main(void)
{
	Tag *t;
	Superb *s;

	t = (Tag*)(buf+BUFSIZE);
	s = (Superb*)buf;
	start = seek(0, start*RBUFSIZE, 0) / RBUFSIZE;
	for(;;){
		if(read(0, buf, RBUFSIZE) != RBUFSIZE){
			fprint(2, "read: %r\n");
			exits("read");
		}
		//print("%llud %d %llud\n", start, t->tag, t->path);
		if(t->tag == 1 && t->path == 2){
			print("%llud "
				"fstart %llud fsize %llud "
				"cwraddr %llud roraddr %llud "
				"last %llud next %llud\n",
				start,
				s->fstart, s->fsize, 
				s->cwraddr,
				s->roraddr,
				s->last, s->next);
		}
		start++;
	}
}

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.