forked from pool/ocfs2-tools
74 lines
1.9 KiB
Diff
74 lines
1.9 KiB
Diff
|
From 41057a7eef9da9d77cde46d336a7f8a19564d7f8 Mon Sep 17 00:00:00 2001
|
||
|
From: piaojun <piaojun@huawei.com>
|
||
|
Date: Wed, 6 May 2015 10:25:10 +0800
|
||
|
Subject: [PATCH 2/2] debugfs.ocfs2: Fix a bug in process_open_args()
|
||
|
|
||
|
In process_open_args(), 'dev' get the wrong value because getopt() will
|
||
|
change the value of args[1]. This problem will cause failure in
|
||
|
debugfs.ocfs2. ocfs2. So we should assign 'dev' before getopt().
|
||
|
|
||
|
This fix fixes the bug introduced in 9693851641bfcd0f2bab226e9f03d9ab05cb7edf
|
||
|
|
||
|
Signed-off-by: Jun Piao <piaojun@huawei.com>
|
||
|
Reviewed-by: Alex Chen <alex.chen@huawei.com>
|
||
|
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
|
||
|
Reported-by: Gang He <ghe@suse.com>
|
||
|
---
|
||
|
debugfs.ocfs2/commands.c | 20 +++++++++++++-------
|
||
|
1 file changed, 13 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/debugfs.ocfs2/commands.c b/debugfs.ocfs2/commands.c
|
||
|
index 1b0b2d9..6da396a 100644
|
||
|
--- a/debugfs.ocfs2/commands.c
|
||
|
+++ b/debugfs.ocfs2/commands.c
|
||
|
@@ -534,6 +534,7 @@ static int process_open_args(char **args,
|
||
|
int num, argc, c;
|
||
|
|
||
|
for (argc = 0; (args[argc]); ++argc);
|
||
|
+ dev = strdup(args[1]);
|
||
|
optind = 0;
|
||
|
while ((c = getopt(argc, args, "is:")) != EOF) {
|
||
|
switch (c) {
|
||
|
@@ -544,26 +545,31 @@ static int process_open_args(char **args,
|
||
|
s = strtoul(optarg, &ptr, 0);
|
||
|
break;
|
||
|
default:
|
||
|
- return 1;
|
||
|
+ ret = 1;
|
||
|
+ goto bail;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- if (!s)
|
||
|
- return 0;
|
||
|
+ if (!s) {
|
||
|
+ ret = 0;
|
||
|
+ goto bail;
|
||
|
+ }
|
||
|
|
||
|
num = ocfs2_get_backup_super_offsets(NULL, byte_off,
|
||
|
ARRAY_SIZE(byte_off));
|
||
|
- if (!num)
|
||
|
- return -1;
|
||
|
+ if (!num) {
|
||
|
+ ret = -1;
|
||
|
+ goto bail;
|
||
|
+ }
|
||
|
|
||
|
if (s < 1 || s > num) {
|
||
|
fprintf(stderr, "Backup super block is outside of valid range"
|
||
|
"(between 1 and %d)\n", num);
|
||
|
- return -1;
|
||
|
+ ret = -1;
|
||
|
+ goto bail;
|
||
|
}
|
||
|
|
||
|
- dev = strdup(args[1]);
|
||
|
ret = get_blocksize(dev, byte_off[s-1], &blksize, s);
|
||
|
if (ret) {
|
||
|
com_err(args[0],ret, "Can't get the blocksize from the device"
|
||
|
--
|
||
|
2.1.2
|
||
|
|