#include "version.h"
#include "utils.h"
+static void print_usage(void) __attribute__((noreturn));
static void print_usage(void)
{
fprintf(stderr, "usage: btrfs-zero-log dev\n");
struct btrfs_trans_handle *trans;
int ret;
- if (ac != 2)
+ set_argv0(av);
+ if (check_argc_exact(ac, 2))
print_usage();
radix_tree_init();
if((ret = check_mounted(av[1])) < 0) {
fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret));
- return ret;
+ goto out;
} else if(ret) {
fprintf(stderr, "%s is currently mounted. Aborting.\n", av[1]);
- return -EBUSY;
+ ret = -EBUSY;
+ goto out;
}
- root = open_ctree(av[1], 0, 1);
+ root = open_ctree(av[1], 0, OPEN_CTREE_WRITES | OPEN_CTREE_PARTIAL);
if (root == NULL)
return 1;
trans = btrfs_start_transaction(root, 1);
- btrfs_set_super_log_root(&root->fs_info->super_copy, 0);
- btrfs_set_super_log_root_level(&root->fs_info->super_copy, 0);
+ btrfs_set_super_log_root(root->fs_info->super_copy, 0);
+ btrfs_set_super_log_root_level(root->fs_info->super_copy, 0);
btrfs_commit_transaction(trans, root);
close_ctree(root);
- return ret;
+ printf("Log root zero'ed\n");
+out:
+ return !!ret;
}