commit 14a97f465c31b9e0c707730ca8798dfd4140cb03
parent d7e3a0358ece64c1d797e149c61c16472664b909
Author: sin <sin@2f30.org>
Date: Tue, 7 May 2019 20:56:23 +0100
Reorder bhdr field
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bstorage.c b/bstorage.c
@@ -103,9 +103,9 @@ RB_HEAD(bdcache, bd);
struct sctx {
struct bdcache bdcache; /* cache of block descriptors */
SLIST_HEAD(gchead, bd) gchead; /* list of all blocks with a zero refcount */
- struct bhdr bhdr; /* block header entry */
int fd; /* underlying storage file descriptor */
int rdonly; /* when set to 1, the bssync() operation is a no-op */
+ struct bhdr bhdr; /* block header entry */
};
static int
@@ -330,6 +330,8 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar)
sctx = bctx->sctx;
RB_INIT(&sctx->bdcache);
SLIST_INIT(&sctx->gchead);
+ sctx->fd = fd;
+
bhdr = &sctx->bhdr;
memcpy(bhdr->magic, BHDRMAGIC, NBHDRMAGIC);
bhdr->flags = (VMAJ << VMAJSHIFT) | VMIN;
@@ -359,9 +361,7 @@ bscreat(struct bctx *bctx, char *path, int mode, struct bparam *bpar)
bseterr("invalid encryption type: %s", bpar->ealgo);
return -1;
}
-
bhdr->nbd = 0;
- sctx->fd = fd;
if (packbhdr(fd, bhdr) < 0) {
free(sctx);