aboutsummaryrefslogtreecommitdiffstats
path: root/btrfs-zero-log.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-05 18:02:08 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-05 18:02:08 +0200
commit47de682c0ee7c8273a0d2038622bdb7edb523fbd (patch)
tree3644f51252a0f2557a9741fe62a97b8d994db6dd /btrfs-zero-log.c
parent567d7569d8dd50c14c28a9808891b2dc757f7628 (diff)
downloadbtrfs-progs-47de682c0ee7c8273a0d2038622bdb7edb523fbd.tar.gz
btrfs-progs-47de682c0ee7c8273a0d2038622bdb7edb523fbd.tar.xz
btrfs-progs-47de682c0ee7c8273a0d2038622bdb7edb523fbd.zip
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 <dsterba@suse.cz>
Diffstat (limited to 'btrfs-zero-log.c')
-rw-r--r--btrfs-zero-log.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c
index cd0cee0..058e9b1 100644
--- a/btrfs-zero-log.c
+++ b/btrfs-zero-log.c
@@ -16,24 +16,18 @@
* Boston, MA 021110-1307, USA.
*/
+#include "kerncompat.h"
+
#include <stdio.h>
-#include <stdlib.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#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;
}