Plan 9 from Bell Labs’s /usr/web/sources/contrib/blstuart/θfs/dat.h

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


/*
 * Copyright (c) 2013, Coraid, Inc.
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Coraid nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL CORAID BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

enum {
//	BlkSize = 65536,
	BlkSize = 32768,
	NPerBlk = BlkSize / sizeof(uvlong),

	BlobQuan = 64,	/* must be a power of 2 */

	TFile = 0,
	TObject,
	TLun,

	Magicθ = 0x4207abcddcba0742LL,

	FSClean = 1,

	MTnone = 0,		/* must be 0 */
	MTint = 1,
	MTistring = 2,
	MTstring = 3,
	MTblob = 4,
};

typedef struct Blob Blob;
typedef struct GMeta GMeta;
typedef union MVal MVal;
typedef struct PQMap PQMap;
typedef struct Super Super;

#pragma pack on
struct Blob {
	short len;
	union {
		uvlong next;
		char data[1];
	};
};

union MVal {
	uvlong val;
	char str[8];
};

struct GMeta {
	uvlong next;
	uchar type;
	char name[15];
	MVal m;
};

struct PQMap {
	uvlong qpath;
	ushort plen;
	char pname[1];
};
#pragma pack off

struct Super {
	uvlong magic;
	uvlong version;
	uvlong qgen;
	uvlong nblk;
	uvlong nfreemap;
	uvlong freemap;
	uvlong state;
	uvlong firstdat;
	uvlong nfree;
	uvlong firstlun;
	uvlong nmeta;
	uvlong firstmeta;
	uvlong ffmeta;
	uvlong nblob;
	uvlong firstblob;
	uvlong ffblob;
	uvlong lfblob;
	uvlong nht;
	uvlong nhashblk;
	uvlong snaptime;
};

/* aoe.c */
extern void haltaoe(void);
extern void initaoe(void);
extern void rmtarget(int, int);
extern void starttarget(int, int, uvlong);

/* cache.c */
extern int brelease(uvlong);
extern void *cbclean(uvlong);
extern void *cbread(uvlong);
extern void cbwrite(uvlong);
extern int ccanfree(uvlong);
extern int cread(void *, int, uvlong);
extern void csync(void);
extern int cwrite(void *, int, uvlong);
extern void haltcache(void);
extern void initcache(char *, int);
extern char *prcstat(void);
extern void resetcache(void);

/* cons.c */
extern void docons(void *);
extern void initcons(int);

extern int allow;
extern int rootallow;

/* free.c */
extern uvlong allocblock(void);
extern void freeblock(uvlong);
extern void haltfree(void);
extern void initfree(void);

/* fs.c */
extern void halt9p(void);
extern void θstart(Srv *);

extern char *ddir, *dname;
extern uvlong starttime;
extern int doatimes;
extern int shutdown;

/* hash.c */
extern void fixpaths(int);
extern uvlong p2q(int, char *, int);
extern char *prhstat(void);
extern uvlong q2m(int, uvlong, int);
extern void rehashpath(uvlong, char *, char *);
extern void rmp(char *);
extern void rmq(uvlong, uvlong);
extern void setqhash(uvlong, uvlong);
extern void showphash(int, char *);

/* meta.c */
extern void blockuse(int, uvlong);
extern void checkalloc(int);
extern void fixfamilies(int);
extern void freedata(uvlong);
extern void *getblob(int, uvlong, int *);
extern int getmeta(int, uvlong, char *, MVal *);
extern int getmetaint(int, uvlong, char *, uvlong *);
extern char *getmetastr(int, uvlong, char *);
extern uvlong locate(int, uvlong, uvlong, int);
extern void mpred(int, uvlong);
extern void mprint(int, uvlong);
extern void prmeta(int, uvlong);
extern char *prmstat(void);
extern void reammeta(int);
extern void recovermeta(int);
extern void resetmeta(void);
extern uvlong rmmeta(uvlong, uvlong);
extern void rmmlist(uvlong);
extern uvlong setblob(void *, int, uvlong);
extern uvlong setmeta(uvlong, char *, char *, uvlong, int);
extern uvlong setmetaint(uvlong, char *, char *, uvlong);
extern uvlong setmetablob(uvlong, char *, char *, uchar *, int, uvlong);
extern uvlong setmetastr(uvlong, char *, char *, char *, uvlong);
extern void setmstruct(uvlong, uvlong, char *, int, uvlong);

/* nfs.c */
extern void haltnfs(void);
extern void initnfs(void);

extern int debugnfs;

/* super.c */
extern void loadsuper(void);
extern char *prsuper(void);
extern void ream(char *);
extern void savesuper(void);

extern Super super;

/* uid.c */
extern void dumpusers(int);
extern int gname2id(char *, char *);
extern char *id2gname(char *, int);
extern char *id2uname(char *, int);
extern int ingroup(char *, char *);
extern void inituid(void);
extern int isleader(char *, char *);
extern int uname2id(char *, char *);

/* util.c */
extern void *θmalloc(ulong);
extern long θpread(int, uvlong, void *, long, uvlong);
extern long θpwrite(uvlong, void *, long, uvlong, int);
extern void rmdlist(uvlong, uvlong);
extern long spread(int, void *, long, uvlong);

/* platform specific */
extern void conspost(int [], int []);
extern uvlong devsize(char *);

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.