shithub: gefs

Download patch

ref: a289e5c5a595ae8e3283c1b5a616fcc5068715a4
parent: 7f5ba9667e001b1eaf01d53f2d483bce7688d53e
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Apr 27 22:18:39 EDT 2023

pack: add flags field to xdir

we'll want it for features like small file opt,
unix symlinks, and other similar stuff.

--- a/dat.h
+++ b/dat.h
@@ -174,7 +174,7 @@
  * and refcount blocks.
  *
  * The superblock has this layout:
- *	version[8]	always "gefs0002"
+ *	version[8]	always "gefsNNNNN"
  *	blksz[4]	block size in bytes
  *	bufsz[4]	portion of leaf nodes
  *			allocated to buffers,
@@ -525,6 +525,7 @@
 
 struct Xdir {
 	/* file data */
+	uvlong	flag;	/* storage flags */
 	Qid	qid;	/* unique id from server */
 	ulong	mode;	/* permissions */
 	vlong	atime;	/* last read time: nsec */
--- a/pack.c
+++ b/pack.c
@@ -203,6 +203,7 @@
 
 	err = 0;
 	e = p + sz;
+	p = pack64(&err, p, e, d->flag);
 	p = pack64(&err, p, e, d->qid.path);
 	p = pack32(&err, p, e, d->qid.vers);
 	p = pack8(&err, p, e, d->qid.type);
@@ -236,6 +237,7 @@
 
 	v = kv->v;
 	ev = v + kv->nv;
+	v = unpack64(&err, v, ev, &d->flag);
 	v = unpack64(&err, v, ev, &d->qid.path);
 	v = unpack32(&err, v, ev, &d->qid.vers);
 	v = unpack8(&err, v, ev, &d->qid.type);
@@ -522,7 +524,7 @@
 packarena(char *p, int sz, Arena *a, Fshdr *fi)
 {
 	assert(sz == Blksz);
-	memcpy(p, "gefs0003", 8);	p += 8;
+	memcpy(p, "gefs0004", 8);	p += 8;
 	PACK32(p, Blksz);		p += 4;
 	PACK32(p, Bufspc);		p += 4;
 	PACK32(p, fi->snap.ht);		p += 4;
@@ -545,7 +547,7 @@
 	assert(sz == Blksz);
 	memset(a, 0, sizeof(*a));
 	memset(fi, 0, sizeof(*fi));
-	if(memcmp(p, "gefs0003", 8) != 0){
+	if(memcmp(p, "gefs0004", 8) != 0){
 		werrstr("wrong block header %.8s\n", p);
 		return nil;
 	}