On 02/08/2012 08:14 AM, Jérémy Compostella wrote: >> That leads onto the only other possible implementation I suppose. >> I.E. since we don't need to specify skip and skip_bytes together, >> the option value could select between each mode. I.E. >> >> skip=2 => skip 2 blocks, >> skip=2b => skip 1024 blocks, >> skip=2bytes => skip 2 bytes >> >> Hmm, that's not too bad at all really > I do agree, it looks like a very interesting idea indeed. However, I > have two questions: > 1. Why skip=2b => 1024 blocks ?
Because POSIX requires that one. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dd.html For the bs=, cbs=, ibs=, and obs= operands, the application shall supply an expression specifying a size in bytes. The expression, expr, can be: A positive decimal number A positive decimal number followed by k, specifying multiplication by 1024 A positive decimal number followed by b, specifying multiplication by 512 Two or more positive decimal numbers (with or without k or b) separated by x, specifying the product of the indicated values > 2. Do you know if there is a utility function somewhere in coreutils or > gnulib which could help me to parse this ? If such a function exists it > could be able to manage more units (bytes, kbytes, megabytes, ...). If > have to write such a function we have to discuss the possibilities I have to > provide. See how parse_integer() is already using xstrtoumax; it would just be a matter of special-casing 'bytes', differently than 'b', and more like 'x' is special-cased. -- Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
