[Ocfs2-tools-devel] [PATCH V2] debugfs.ocfs2: Fix a bug in process_open_args()
piaojun
piaojun at huawei.com
Tue May 5 21:44:25 PDT 2015
Hi Junxiao,
This patch is based on V1 and used to fix the bug in V1.
Thanks
Piao
在 2015/5/6 11:44, Junxiao Bi 写道:
> Hi Piaojun,
>
> Is this V2 patch based on V1? This is not the right way to post V2. You
> should include all the stuff in V2 and drop V1.
>
> Thanks,
> Junxiao.
>
> On 05/06/2015 10:25 AM, piaojun wrote:
>> 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().
>>
>> Signed-off-by: Jun Piao <piaojun at huawei.com>
>> Reviewed-by: Alex Chen <alex.chen at huawei.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"
>>
>
>
> .
>
More information about the Ocfs2-tools-devel
mailing list