summaryrefslogtreecommitdiff
path: root/libnandfs/writeblock.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /libnandfs/writeblock.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'libnandfs/writeblock.c')
-rw-r--r--libnandfs/writeblock.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/libnandfs/writeblock.c b/libnandfs/writeblock.c
new file mode 100644
index 00000000..0e4b9c3d
--- /dev/null
+++ b/libnandfs/writeblock.c
@@ -0,0 +1,47 @@
+#include "lib9.h"
+#include "logfs.h"
+#include "nandfs.h"
+#include "local.h"
+
+char *
+nandfswriteblock(Nandfs *nandfs, void *buf, uchar tag, ulong path, int xcount, long *data, long block)
+{
+ int p;
+ char *errmsg;
+
+ ulong opath = nandfsgetpath(nandfs, block);
+ ulong writepath = (~opath | path) & NandfsPathMask;
+ uchar writetag = ~nandfsgettag(nandfs, block) | tag;
+ int ppb = 1 << nandfs->ll.l2pagesperblock;
+
+ for (p = 0; p < ppb; p++) {
+ ulong wp;
+ if (p > 0 && p <= 2 + xcount) {
+ switch (p) {
+ case 1:
+ wp = (~opath | nandfsgetbaseblock(nandfs)) & NandfsPathMask;
+ break;
+ case 2:
+ wp = (~opath | nandfs->ll.blocks) & NandfsPathMask;
+ break;
+ default:
+ wp = (~opath | data[p - 3]) & NandfsPathMask;
+ break;
+ }
+ }
+ else
+ wp = writepath;
+ errmsg = nandfsupdatepage(nandfs, buf, wp, writetag, block, p);
+ if (errmsg)
+ return errmsg;
+#ifdef LOGFSTEST
+ if (logfstest.partialupdate && p > 0) {
+ print("skipping pageupdate\n");
+ break;
+ }
+#endif
+ buf = (uchar *)buf + NandfsPageSize;
+ }
+
+ return nil;
+}