From 47de682c0ee7c8273a0d2038622bdb7edb523fbd Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 5 Jun 2015 18:02:08 +0200 Subject: btrfs-progs: cleanup and deprecate btrfs-zero-log Sync with the 'rescue zero-log' code, add a warning about deprecation. Signed-off-by: David Sterba --- btrfs-zero-log.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'btrfs-zero-log.c') diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c index cd0cee01..058e9b19 100644 --- a/btrfs-zero-log.c +++ b/btrfs-zero-log.c @@ -16,24 +16,18 @@ * Boston, MA 021110-1307, USA. */ +#include "kerncompat.h" + #include -#include #include -#include -#include -#include "kerncompat.h" #include "ctree.h" #include "disk-io.h" -#include "print-tree.h" #include "transaction.h" -#include "list.h" #include "utils.h" -static void print_usage(void) __attribute__((noreturn)); -static void print_usage(void) +__attribute__((noreturn)) static void print_usage(void) { fprintf(stderr, "usage: btrfs-zero-log dev\n"); - fprintf(stderr, "%s\n", PACKAGE_STRING); exit(1); } @@ -41,6 +35,7 @@ int main(int ac, char **av) { struct btrfs_root *root; struct btrfs_trans_handle *trans; + struct btrfs_super_block *sb; int ret; set_argv0(av); @@ -49,26 +44,33 @@ int main(int ac, char **av) radix_tree_init(); - if((ret = check_mounted(av[1])) < 0) { - fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret)); + printf("WARNING: this utility is deprecated, please use 'btrfs rescue zero-log'\n\n"); + + if ((ret = check_mounted(av[1])) < 0) { + fprintf(stderr, "ERROR: could not check mount status: %s\n", strerror(-ret)); goto out; - } else if(ret) { - fprintf(stderr, "%s is currently mounted. Aborting.\n", av[1]); + } else if (ret) { + fprintf(stderr, "ERROR: %s is currently mounted\n", av[1]); ret = -EBUSY; goto out; } root = open_ctree(av[1], 0, OPEN_CTREE_WRITES | OPEN_CTREE_PARTIAL); - - if (root == NULL) + if (!root) { + fprintf(stderr, "ERROR: cannot open ctree\n"); return 1; + } + sb = root->fs_info->super_copy; + printf("Clearing log on %s, previous log_root %llu, level %u\n", + av[1], + (unsigned long long)btrfs_super_log_root(sb), + (unsigned)btrfs_super_log_root_level(sb)); 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_commit_transaction(trans, root); close_ctree(root); - printf("Log root zero'ed\n"); out: return !!ret; } -- cgit v1.2.3