projects
/
platform
/
upstream
/
btrfs-progs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
btrfs-progs: fsck-tests: Introduce test case with keyed data backref with the extent...
[platform/upstream/btrfs-progs.git]
/
btrfs-zero-log.c
diff --git
a/btrfs-zero-log.c
b/btrfs-zero-log.c
index
31ec215
..
2fce59e
100644
(file)
--- a/
btrfs-zero-log.c
+++ b/
btrfs-zero-log.c
@@
-16,55
+16,59
@@
* Boston, MA 021110-1307, USA.
*/
* Boston, MA 021110-1307, USA.
*/
-#
define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+#
include "kerncompat.h"
+
#include <stdio.h>
#include <stdio.h>
-#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include "kerncompat.h"
#include "ctree.h"
#include "disk-io.h"
#include "ctree.h"
#include "disk-io.h"
-#include "print-tree.h"
#include "transaction.h"
#include "transaction.h"
-#include "list.h"
-#include "version.h"
#include "utils.h"
#include "utils.h"
+#include "help.h"
-static void print_usage(void)
+
__attribute__((noreturn))
static void print_usage(void)
{
{
- fprintf(stderr, "usage: btrfs-zero-log dev\n");
- fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+ printf("usage: btrfs-zero-log dev\n");
exit(1);
}
exit(1);
}
-int main(int a
c, char **a
v)
+int main(int a
rgc, char **arg
v)
{
struct btrfs_root *root;
struct btrfs_trans_handle *trans;
{
struct btrfs_root *root;
struct btrfs_trans_handle *trans;
+ struct btrfs_super_block *sb;
int ret;
int ret;
- if (ac != 2)
+ set_argv0(argv);
+ if (check_argc_exact(argc - optind, 1))
print_usage();
radix_tree_init();
print_usage();
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(argv[optind])) < 0) {
+ fprintf(stderr, "ERROR: could not check mount status: %s\n", strerror(-ret));
goto out;
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", argv[optind
]);
ret = -EBUSY;
goto out;
}
ret = -EBUSY;
goto out;
}
- root = open_ctree(a
v[1], 0, 1
);
-
- if (root == NULL)
+ root = open_ctree(a
rgv[optind], 0, OPEN_CTREE_WRITES | OPEN_CTREE_PARTIAL
);
+ if (!root) {
+ fprintf(stderr, "ERROR: cannot open ctree\n");
return 1;
return 1;
+ }
+ sb = root->fs_info->super_copy;
+ printf("Clearing log on %s, previous log_root %llu, level %u\n",
+ argv[optind],
+ (unsigned long long)btrfs_super_log_root(sb),
+ (unsigned)btrfs_super_log_root_level(sb));
trans = btrfs_start_transaction(root, 1);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
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);
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);