ref: 9b76881a8e11c44aae5dfd447e1cd1bc074ec9f3
dir: /config.c/
#include "all.h" /* assuming that the config will not be more than a block */ void initconfig(u64 dblkno) { Iobuf *buf; char cfg[Ddatasize]; buf = getmetachk(dblkno, Breadonly, Tdentry, Qpconfig); if(buf == nil) panic("cannot find config file in %llud block\n", dblkno); memcpy(cfg, buf->cur->buf, buf->cur->size); putbuf(buf, 0); parseconfig(cfg, &config); } u16 configstr(s8 *buf, u16 nbuf) { u16 n; n = (u16)snprint(buf, nbuf, "disksize %llud\n" "nblocks %llud\n" "backup config %llud to %llud\n" "backup super %llud to %llud\n" "backup root %llud to %llud\n" "service %s\n", config.size, config.nblocks, config.config.srcbno, config.config.dest[0], config.super.srcbno, config.super.dest[0], config.root.srcbno, config.root.dest[0], config.service); if(n == nbuf) panic("config needs more blocks"); return n; } void writeconfig(u64 bno) { Iobuf *buf; s32 n; buf = getmetachk(bno, Bwritable, Tdentry, Qpconfig); if(buf == nil) panic("cannot write config"); n = configstr(buf->new->buf, Ddatasize); buf->new->size = n; putbuf(buf, 1); }