Re: [PATCH] mount: make the --offset option support hex number

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 25, 2010 at 1:50 PM, Américo Wang <xiyou.wangcong@xxxxxxxxx> wrote:
> On Thu, Mar 25, 2010 at 1:19 PM, Liu Aleaxander <aleaxander@xxxxxxxxx> wrote:
>> --- a/mount/lomount.c
>> +++ b/mount/lomount.c
>> @@ -1015,8 +1015,14 @@ main(int argc, char **argv) {
>>                        usage();
>>        }
>>
>> -       if (offset && sscanf(offset, "%llu", &off) != 1)
>> -               usage();
>> +       if (offset) {
>> +               char *end;
>> +               off = strtoull(offset, &end, 0);
>> +               if (*end) {
>> +                       fprintf(stderr, _("%s is not a valid
>> number\n"), offset);
>> +                       return -1;
>> +               }
>> +       }
>
> Sorry, this is still not right. Please refer strtoul(2), you need
> to check if end == offset.
>
Hi,

You mean do it by this:

if (end == offset) {
       then_error();
}

If so, I don't think so this can handle the case like the following one:
/sbin/losetup -o 0x7e00fdjfkk /dev/loop0 disk.img

Thanks!


-- 
regards
Liu Aleaxander
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux