objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
root-tree.o dir-item.o hash.o file-item.o inode-item.o \
inode-map.o \
-
+#
# if you don't have sparse installed, use ls instead
CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
-Wcontext -Wcast-truncate -Wuninitialized -Wshadow -Wundef
all: bit-radix-test tester debug-tree quick-test dir-test tags mkfs.btrfs
mkfs.btrfs: $(objects) mkfs.o
- gcc $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o
+ gcc $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o -luuid
bit-radix-test: $(objects) bit-radix.o
gcc $(CFLAGS) -o bit-radix-test $(objects) bit-radix.o
debug-tree: $(objects) debug-tree.o
- gcc $(CFLAGS) -o debug-tree $(objects) debug-tree.o
+ gcc $(CFLAGS) -o debug-tree $(objects) debug-tree.o -luuid
tester: $(objects) random-test.o
gcc $(CFLAGS) -o tester $(objects) random-test.o
#include <stdio.h>
#include <stdlib.h>
+#include <uuid/uuid.h>
#include "kerncompat.h"
#include "radix-tree.h"
#include "ctree.h"
int main(int ac, char **av) {
struct btrfs_super_block super;
struct btrfs_root *root;
+ char uuidbuf[37];
if (ac != 2) {
fprintf(stderr, "usage: %s device\n", av[0]);
root->fs_info->tree_root->node);
printf("total blocks %Lu\n", btrfs_super_total_blocks(&super));
printf("blocks used %Lu\n", btrfs_super_blocks_used(&super));
+ uuidbuf[36] = '\0';
+ uuid_unparse(super.fsid, uuidbuf);
+ printf("uuid %s\n", uuidbuf);
return 0;
}
if (root->node && btrfs_header_parentid(&buf->node.header) !=
btrfs_header_parentid(&root->node->node.header))
BUG();
+ if (memcmp(root->fs_info->disk_super->fsid, buf->node.header.fsid,
+ sizeof(buf->node.header.fsid)))
+ BUG();
return 0;
}
dirty_tree_block(trans, root, buf);
btrfs_set_header_generation(&buf->node.header,
root->root_key.offset + 1);
+ memcpy(buf->node.header.fsid, root->fs_info->disk_super->fsid,
+ sizeof(buf->node.header.fsid));
return buf;
}
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <uuid/uuid.h>
#include "kerncompat.h"
#include "radix-tree.h"
#include "ctree.h"
btrfs_set_super_blocksize(&super, blocksize);
btrfs_set_super_total_blocks(&super, num_blocks);
btrfs_set_super_blocks_used(&super, start_block + 5);
+ uuid_generate(super.fsid);
block = malloc(blocksize);
memset(block, 0, blocksize);
btrfs_set_header_blocknr(&empty_leaf->header, start_block + 1);
btrfs_set_header_nritems(&empty_leaf->header, 3);
btrfs_set_header_generation(&empty_leaf->header, 0);
+ memcpy(empty_leaf->header.fsid, super.fsid,
+ sizeof(empty_leaf->header.fsid));
/* create the items for the root tree */
btrfs_set_root_blocknr(&root_item, start_block + 2);