* [PATCH] punch-alternating: add some options
@ 2017-05-04 15:16 Eric Sandeen
2017-05-04 15:49 ` Darrick J. Wong
2017-05-04 17:31 ` [PATCH V2] " Eric Sandeen
0 siblings, 2 replies; 8+ messages in thread
From: Eric Sandeen @ 2017-05-04 15:16 UTC (permalink / raw)
To: fstests
I didn't end up using this, but somebody else might find
it useful, so sending it.
This change lets us specify punch patterns other than
literally every other block.
i.e. punch-alternating with no options will do:
...HDHDHDHDHDHD...
-i 4 -s 2 will do:
...DDHHDDHHDDHH...
or -i 3 -s 1 will do:
...DDHDDHDDHDDH...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
index 4148622..0c7a7ff 100644
--- a/src/punch-alternating.c
+++ b/src/punch-alternating.c
@@ -11,6 +11,14 @@
#include <string.h>
#include "global.h"
+void usage(char *cmd)
+{
+ printf("Usage: %s [-i interval] [-s size] file\n", cmd);
+ printf("Punches every other block in the file by default,\n");
+ printf("or 'size' blocks every 'interval' blocks with options.\n");
+ exit(1);
+}
+
int main(int argc, char *argv[])
{
struct stat s;
@@ -21,14 +29,27 @@ int main(int argc, char *argv[])
off_t sz;
int mode;
int error;
+ int c;
+ int size = 1; /* punch $SIZE blocks ... */
+ int interval = 2; /* every $INTERVAL blocks */
+
+ if (argc < 2)
+ usage(argv[0]);
- if (argc != 2) {
- printf("Usage: %s file\n", argv[0]);
- printf("Punches every other block in the file.\n");
- return 1;
+ while ((c = getopt(argc, argv, "i:s:")) != EOF) {
+ switch (c) {
+ case 'i':
+ interval = atoi(optarg);
+ break;
+ case 's':
+ size = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ }
}
- fd = open(argv[1], O_WRONLY);
+ fd = open(argv[optind], O_WRONLY);
if (fd < 0)
goto err;
@@ -44,8 +65,8 @@ int main(int argc, char *argv[])
blksz = sf.f_bsize;
mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
- for (offset = 0; offset < sz; offset += blksz * 2) {
- error = fallocate(fd, mode, offset, blksz);
+ for (offset = 0; offset < sz; offset += blksz * interval) {
+ error = fallocate(fd, mode, offset, blksz * size);
if (error)
goto err;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] punch-alternating: add some options
2017-05-04 15:16 [PATCH] punch-alternating: add some options Eric Sandeen
@ 2017-05-04 15:49 ` Darrick J. Wong
2017-05-04 17:13 ` Eric Sandeen
2017-05-04 17:31 ` [PATCH V2] " Eric Sandeen
1 sibling, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2017-05-04 15:49 UTC (permalink / raw)
To: Eric Sandeen; +Cc: fstests
On Thu, May 04, 2017 at 10:16:54AM -0500, Eric Sandeen wrote:
> I didn't end up using this, but somebody else might find
> it useful, so sending it.
>
> This change lets us specify punch patterns other than
> literally every other block.
>
> i.e. punch-alternating with no options will do:
>
> ...HDHDHDHDHDHD...
>
> -i 4 -s 2 will do:
>
> ...DDHHDDHHDDHH...
>
> or -i 3 -s 1 will do:
>
> ...DDHDDHDDHDDH...
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> index 4148622..0c7a7ff 100644
> --- a/src/punch-alternating.c
> +++ b/src/punch-alternating.c
> @@ -11,6 +11,14 @@
> #include <string.h>
> #include "global.h"
>
> +void usage(char *cmd)
> +{
> + printf("Usage: %s [-i interval] [-s size] file\n", cmd);
> + printf("Punches every other block in the file by default,\n");
> + printf("or 'size' blocks every 'interval' blocks with options.\n");
> + exit(1);
> +}
> +
> int main(int argc, char *argv[])
> {
> struct stat s;
> @@ -21,14 +29,27 @@ int main(int argc, char *argv[])
> off_t sz;
> int mode;
> int error;
> + int c;
> + int size = 1; /* punch $SIZE blocks ... */
> + int interval = 2; /* every $INTERVAL blocks */
> +
> + if (argc < 2)
> + usage(argv[0]);
I think you want a (optind == argc - 1) check after the getopt to
preserve the "only one file at a time" semantics... or an optind loop to
process a bunch of files.
> - if (argc != 2) {
> - printf("Usage: %s file\n", argv[0]);
> - printf("Punches every other block in the file.\n");
> - return 1;
> + while ((c = getopt(argc, argv, "i:s:")) != EOF) {
> + switch (c) {
> + case 'i':
> + interval = atoi(optarg);
> + break;
> + case 's':
> + size = atoi(optarg);
> + break;
> + default:
> + usage(argv[0]);
> + }
> }
Is it valid to -i 0 -s -5 here? :)
--D
> - fd = open(argv[1], O_WRONLY);
> + fd = open(argv[optind], O_WRONLY);
> if (fd < 0)
> goto err;
>
> @@ -44,8 +65,8 @@ int main(int argc, char *argv[])
> blksz = sf.f_bsize;
>
> mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
> - for (offset = 0; offset < sz; offset += blksz * 2) {
> - error = fallocate(fd, mode, offset, blksz);
> + for (offset = 0; offset < sz; offset += blksz * interval) {
> + error = fallocate(fd, mode, offset, blksz * size);
> if (error)
> goto err;
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] punch-alternating: add some options
2017-05-04 15:49 ` Darrick J. Wong
@ 2017-05-04 17:13 ` Eric Sandeen
0 siblings, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2017-05-04 17:13 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: fstests
On 5/4/17 10:49 AM, Darrick J. Wong wrote:
> On Thu, May 04, 2017 at 10:16:54AM -0500, Eric Sandeen wrote:
>> I didn't end up using this, but somebody else might find
>> it useful, so sending it.
>>
>> This change lets us specify punch patterns other than
>> literally every other block.
>>
>> i.e. punch-alternating with no options will do:
>>
>> ...HDHDHDHDHDHD...
>>
>> -i 4 -s 2 will do:
>>
>> ...DDHHDDHHDDHH...
>>
>> or -i 3 -s 1 will do:
>>
>> ...DDHDDHDDHDDH...
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> diff --git a/src/punch-alternating.c b/src/punch-alternating.c
>> index 4148622..0c7a7ff 100644
>> --- a/src/punch-alternating.c
>> +++ b/src/punch-alternating.c
>> @@ -11,6 +11,14 @@
>> #include <string.h>
>> #include "global.h"
>>
>> +void usage(char *cmd)
>> +{
>> + printf("Usage: %s [-i interval] [-s size] file\n", cmd);
>> + printf("Punches every other block in the file by default,\n");
>> + printf("or 'size' blocks every 'interval' blocks with options.\n");
>> + exit(1);
>> +}
>> +
>> int main(int argc, char *argv[])
>> {
>> struct stat s;
>> @@ -21,14 +29,27 @@ int main(int argc, char *argv[])
>> off_t sz;
>> int mode;
>> int error;
>> + int c;
>> + int size = 1; /* punch $SIZE blocks ... */
>> + int interval = 2; /* every $INTERVAL blocks */
>> +
>> + if (argc < 2)
>> + usage(argv[0]);
>
> I think you want a (optind == argc - 1) check after the getopt to
> preserve the "only one file at a time" semantics... or an optind loop to
> process a bunch of files.
Hm, ok. getopt is not my favorite.
>> - if (argc != 2) {
>> - printf("Usage: %s file\n", argv[0]);
>> - printf("Punches every other block in the file.\n");
>> - return 1;
>> + while ((c = getopt(argc, argv, "i:s:")) != EOF) {
>> + switch (c) {
>> + case 'i':
>> + interval = atoi(optarg);
>> + break;
>> + case 's':
>> + size = atoi(optarg);
>> + break;
>> + default:
>> + usage(argv[0]);
>> + }
>> }
>
> Is it valid to -i 0 -s -5 here? :)
Sure! you'll just have to ctrl-C it. ;)
-Eric
> --D
>
>> - fd = open(argv[1], O_WRONLY);
>> + fd = open(argv[optind], O_WRONLY);
>> if (fd < 0)
>> goto err;
>>
>> @@ -44,8 +65,8 @@ int main(int argc, char *argv[])
>> blksz = sf.f_bsize;
>>
>> mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
>> - for (offset = 0; offset < sz; offset += blksz * 2) {
>> - error = fallocate(fd, mode, offset, blksz);
>> + for (offset = 0; offset < sz; offset += blksz * interval) {
>> + error = fallocate(fd, mode, offset, blksz * size);
>> if (error)
>> goto err;
>> }
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe fstests" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH V2] punch-alternating: add some options
2017-05-04 15:16 [PATCH] punch-alternating: add some options Eric Sandeen
2017-05-04 15:49 ` Darrick J. Wong
@ 2017-05-04 17:31 ` Eric Sandeen
2017-05-04 18:25 ` [PATCH V3] " Eric Sandeen
1 sibling, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2017-05-04 17:31 UTC (permalink / raw)
To: Eric Sandeen, fstests
I didn't end up using this, but somebody else might find
it useful, so sending it.
This change lets us specify punch patterns other than
literally every other block.
i.e. punch-alternating with no options will do:
...HDHDHDHDHDHD...
-i 4 -s 2 will do:
...DDHHDDHHDDHH...
or -i 3 -s 1 will do:
...DDHDDHDDHDDH...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
V2: don't allow interval of zero, or extra arguments
other than the filename after the parsed options.
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
index 4148622..3503ded 100644
--- a/src/punch-alternating.c
+++ b/src/punch-alternating.c
@@ -11,6 +11,14 @@
#include <string.h>
#include "global.h"
+void usage(char *cmd)
+{
+ printf("Usage: %s [-i interval] [-s size] file\n", cmd);
+ printf("Punches every other block in the file by default,\n");
+ printf("or 'size' blocks every 'interval' blocks with options.\n");
+ exit(1);
+}
+
int main(int argc, char *argv[])
{
struct stat s;
@@ -21,14 +29,32 @@ int main(int argc, char *argv[])
off_t sz;
int mode;
int error;
+ int c;
+ int size = 1; /* punch $SIZE blocks ... */
+ int interval = 2; /* every $INTERVAL blocks */
- if (argc != 2) {
- printf("Usage: %s file\n", argv[0]);
- printf("Punches every other block in the file.\n");
- return 1;
+ while ((c = getopt(argc, argv, "i:s:")) != EOF) {
+ switch (c) {
+ case 'i':
+ interval = atoi(optarg);
+ break;
+ case 's':
+ size = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ }
}
- fd = open(argv[1], O_WRONLY);
+ if (!interval) {
+ printf("Please specify an interval > 0\n");
+ usage(argv[0]);
+ }
+
+ if (optind != argc - 1)
+ usage(argv[0]);
+
+ fd = open(argv[optind], O_WRONLY);
if (fd < 0)
goto err;
@@ -44,8 +70,8 @@ int main(int argc, char *argv[])
blksz = sf.f_bsize;
mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
- for (offset = 0; offset < sz; offset += blksz * 2) {
- error = fallocate(fd, mode, offset, blksz);
+ for (offset = 0; offset < sz; offset += blksz * interval) {
+ error = fallocate(fd, mode, offset, blksz * size);
if (error)
goto err;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH V3] punch-alternating: add some options
2017-05-04 17:31 ` [PATCH V2] " Eric Sandeen
@ 2017-05-04 18:25 ` Eric Sandeen
2017-05-05 4:32 ` Eryu Guan
0 siblings, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2017-05-04 18:25 UTC (permalink / raw)
To: Eric Sandeen, fstests
I didn't end up using this, but somebody else might find
it useful, so sending it.
This change lets us specify punch patterns other than
literally every other block.
i.e. punch-alternating with no options will do:
...HDHDHDHDHDHD...
-i 4 -s 2 will do:
...DDHHDDHHDDHH...
or -i 3 -s 1 will do:
...DDHDDHDDHDDH...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
V2: don't allow interval of zero, or extra arguments
other than the filename after the parsed options.
V3: Ok, don't allow negative intervals or sizes, either.
diff --git a/src/punch-alternating.c b/src/punch-alternating.c
index 4148622..11aa65c 100644
--- a/src/punch-alternating.c
+++ b/src/punch-alternating.c
@@ -11,6 +11,14 @@
#include <string.h>
#include "global.h"
+void usage(char *cmd)
+{
+ printf("Usage: %s [-i interval] [-s size] file\n", cmd);
+ printf("Punches every other block in the file by default,\n");
+ printf("or 'size' blocks every 'interval' blocks with options.\n");
+ exit(1);
+}
+
int main(int argc, char *argv[])
{
struct stat s;
@@ -21,14 +29,37 @@ int main(int argc, char *argv[])
off_t sz;
int mode;
int error;
+ int c;
+ int size = 1; /* punch $SIZE blocks ... */
+ int interval = 2; /* every $INTERVAL blocks */
+
+ while ((c = getopt(argc, argv, "i:s:")) != EOF) {
+ switch (c) {
+ case 'i':
+ interval = atoi(optarg);
+ break;
+ case 's':
+ size = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ }
+ }
+
+ if (interval <= 0) {
+ printf("interval must be > 0\n");
+ usage(argv[0]);
+ }
- if (argc != 2) {
- printf("Usage: %s file\n", argv[0]);
- printf("Punches every other block in the file.\n");
- return 1;
+ if (size < 0) {
+ printf("size must be >= 0\n");
+ usage(argv[0]);
}
- fd = open(argv[1], O_WRONLY);
+ if (optind != argc - 1)
+ usage(argv[0]);
+
+ fd = open(argv[optind], O_WRONLY);
if (fd < 0)
goto err;
@@ -44,8 +75,8 @@ int main(int argc, char *argv[])
blksz = sf.f_bsize;
mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
- for (offset = 0; offset < sz; offset += blksz * 2) {
- error = fallocate(fd, mode, offset, blksz);
+ for (offset = 0; offset < sz; offset += blksz * interval) {
+ error = fallocate(fd, mode, offset, blksz * size);
if (error)
goto err;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V3] punch-alternating: add some options
2017-05-04 18:25 ` [PATCH V3] " Eric Sandeen
@ 2017-05-05 4:32 ` Eryu Guan
2017-05-05 5:21 ` Darrick J. Wong
2017-05-05 13:19 ` Eric Sandeen
0 siblings, 2 replies; 8+ messages in thread
From: Eryu Guan @ 2017-05-05 4:32 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Eric Sandeen, fstests
On Thu, May 04, 2017 at 01:25:05PM -0500, Eric Sandeen wrote:
> I didn't end up using this, but somebody else might find
> it useful, so sending it.
>
> This change lets us specify punch patterns other than
> literally every other block.
>
> i.e. punch-alternating with no options will do:
>
> ...HDHDHDHDHDHD...
>
> -i 4 -s 2 will do:
>
> ...DDHHDDHHDDHH...
>
> or -i 3 -s 1 will do:
>
> ...DDHDDHDDHDDH...
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> V2: don't allow interval of zero, or extra arguments
> other than the filename after the parsed options.
>
> V3: Ok, don't allow negative intervals or sizes, either.
>
>
>
> diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> index 4148622..11aa65c 100644
> --- a/src/punch-alternating.c
> +++ b/src/punch-alternating.c
> @@ -11,6 +11,14 @@
> #include <string.h>
> #include "global.h"
>
> +void usage(char *cmd)
> +{
> + printf("Usage: %s [-i interval] [-s size] file\n", cmd);
> + printf("Punches every other block in the file by default,\n");
> + printf("or 'size' blocks every 'interval' blocks with options.\n");
> + exit(1);
> +}
> +
> int main(int argc, char *argv[])
> {
> struct stat s;
> @@ -21,14 +29,37 @@ int main(int argc, char *argv[])
> off_t sz;
> int mode;
> int error;
> + int c;
> + int size = 1; /* punch $SIZE blocks ... */
> + int interval = 2; /* every $INTERVAL blocks */
> +
> + while ((c = getopt(argc, argv, "i:s:")) != EOF) {
> + switch (c) {
> + case 'i':
> + interval = atoi(optarg);
> + break;
> + case 's':
> + size = atoi(optarg);
> + break;
> + default:
> + usage(argv[0]);
> + }
> + }
> +
> + if (interval <= 0) {
> + printf("interval must be > 0\n");
> + usage(argv[0]);
> + }
>
> - if (argc != 2) {
> - printf("Usage: %s file\n", argv[0]);
> - printf("Punches every other block in the file.\n");
> - return 1;
> + if (size < 0) {
> + printf("size must be >= 0\n");
> + usage(argv[0]);
Can size be 0? Seems not, otherwise we call fallocate with zero length.
I got this error if I use "-s 0"
$ ./src/punch-alternating -s 0 -i 8 testfile
-s: Invalid argument
And the "-s" part indicates that the perror call in 'err' label should
be updated too, i.e. argv[1] => argv[optind]
They're simple enough to be fixed at commit time, if you think they're
sane fixes :)
Thanks,
Eryu
> }
>
> - fd = open(argv[1], O_WRONLY);
> + if (optind != argc - 1)
> + usage(argv[0]);
> +
> + fd = open(argv[optind], O_WRONLY);
> if (fd < 0)
> goto err;
>
> @@ -44,8 +75,8 @@ int main(int argc, char *argv[])
> blksz = sf.f_bsize;
>
> mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
> - for (offset = 0; offset < sz; offset += blksz * 2) {
> - error = fallocate(fd, mode, offset, blksz);
> + for (offset = 0; offset < sz; offset += blksz * interval) {
> + error = fallocate(fd, mode, offset, blksz * size);
> if (error)
> goto err;
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V3] punch-alternating: add some options
2017-05-05 4:32 ` Eryu Guan
@ 2017-05-05 5:21 ` Darrick J. Wong
2017-05-05 13:19 ` Eric Sandeen
1 sibling, 0 replies; 8+ messages in thread
From: Darrick J. Wong @ 2017-05-05 5:21 UTC (permalink / raw)
To: Eryu Guan; +Cc: Eric Sandeen, Eric Sandeen, fstests
On Fri, May 05, 2017 at 12:32:34PM +0800, Eryu Guan wrote:
> On Thu, May 04, 2017 at 01:25:05PM -0500, Eric Sandeen wrote:
> > I didn't end up using this, but somebody else might find
> > it useful, so sending it.
> >
> > This change lets us specify punch patterns other than
> > literally every other block.
> >
> > i.e. punch-alternating with no options will do:
> >
> > ...HDHDHDHDHDHD...
> >
> > -i 4 -s 2 will do:
> >
> > ...DDHHDDHHDDHH...
> >
> > or -i 3 -s 1 will do:
> >
> > ...DDHDDHDDHDDH...
> >
> > Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> > ---
> >
> > V2: don't allow interval of zero, or extra arguments
> > other than the filename after the parsed options.
> >
> > V3: Ok, don't allow negative intervals or sizes, either.
> >
> >
> >
> > diff --git a/src/punch-alternating.c b/src/punch-alternating.c
> > index 4148622..11aa65c 100644
> > --- a/src/punch-alternating.c
> > +++ b/src/punch-alternating.c
> > @@ -11,6 +11,14 @@
> > #include <string.h>
> > #include "global.h"
> >
> > +void usage(char *cmd)
> > +{
> > + printf("Usage: %s [-i interval] [-s size] file\n", cmd);
> > + printf("Punches every other block in the file by default,\n");
> > + printf("or 'size' blocks every 'interval' blocks with options.\n");
> > + exit(1);
> > +}
> > +
> > int main(int argc, char *argv[])
> > {
> > struct stat s;
> > @@ -21,14 +29,37 @@ int main(int argc, char *argv[])
> > off_t sz;
> > int mode;
> > int error;
> > + int c;
> > + int size = 1; /* punch $SIZE blocks ... */
> > + int interval = 2; /* every $INTERVAL blocks */
> > +
> > + while ((c = getopt(argc, argv, "i:s:")) != EOF) {
> > + switch (c) {
> > + case 'i':
> > + interval = atoi(optarg);
> > + break;
> > + case 's':
> > + size = atoi(optarg);
> > + break;
> > + default:
> > + usage(argv[0]);
> > + }
> > + }
> > +
> > + if (interval <= 0) {
> > + printf("interval must be > 0\n");
> > + usage(argv[0]);
> > + }
> >
> > - if (argc != 2) {
> > - printf("Usage: %s file\n", argv[0]);
> > - printf("Punches every other block in the file.\n");
> > - return 1;
> > + if (size < 0) {
> > + printf("size must be >= 0\n");
> > + usage(argv[0]);
>
> Can size be 0? Seems not, otherwise we call fallocate with zero length.
> I got this error if I use "-s 0"
>
> $ ./src/punch-alternating -s 0 -i 8 testfile
> -s: Invalid argument
LOL!
The "perror(argv[1])" in the error clause needs to be updated too.
--D
> And the "-s" part indicates that the perror call in 'err' label should
> be updated too, i.e. argv[1] => argv[optind]
>
> They're simple enough to be fixed at commit time, if you think they're
> sane fixes :)
>
> Thanks,
> Eryu
>
> > }
> >
> > - fd = open(argv[1], O_WRONLY);
> > + if (optind != argc - 1)
> > + usage(argv[0]);
> > +
> > + fd = open(argv[optind], O_WRONLY);
> > if (fd < 0)
> > goto err;
> >
> > @@ -44,8 +75,8 @@ int main(int argc, char *argv[])
> > blksz = sf.f_bsize;
> >
> > mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
> > - for (offset = 0; offset < sz; offset += blksz * 2) {
> > - error = fallocate(fd, mode, offset, blksz);
> > + for (offset = 0; offset < sz; offset += blksz * interval) {
> > + error = fallocate(fd, mode, offset, blksz * size);
> > if (error)
> > goto err;
> > }
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V3] punch-alternating: add some options
2017-05-05 4:32 ` Eryu Guan
2017-05-05 5:21 ` Darrick J. Wong
@ 2017-05-05 13:19 ` Eric Sandeen
1 sibling, 0 replies; 8+ messages in thread
From: Eric Sandeen @ 2017-05-05 13:19 UTC (permalink / raw)
To: Eryu Guan; +Cc: Eric Sandeen, fstests
On 5/4/17 11:32 PM, Eryu Guan wrote:
> On Thu, May 04, 2017 at 01:25:05PM -0500, Eric Sandeen wrote:
...
>> - if (argc != 2) {
>> - printf("Usage: %s file\n", argv[0]);
>> - printf("Punches every other block in the file.\n");
>> - return 1;
>> + if (size < 0) {
>> + printf("size must be >= 0\n");
>> + usage(argv[0]);
>
> Can size be 0? Seems not, otherwise we call fallocate with zero length.
> I got this error if I use "-s 0"
>
> $ ./src/punch-alternating -s 0 -i 8 testfile
> -s: Invalid argument
>
> And the "-s" part indicates that the perror call in 'err' label should
> be updated too, i.e. argv[1] => argv[optind]
>
> They're simple enough to be fixed at commit time, if you think they're
> sane fixes :)
Sigh, yes please. I'm apparently now unable to write or test the simplest
code. :/
-Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-05-05 13:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-04 15:16 [PATCH] punch-alternating: add some options Eric Sandeen
2017-05-04 15:49 ` Darrick J. Wong
2017-05-04 17:13 ` Eric Sandeen
2017-05-04 17:31 ` [PATCH V2] " Eric Sandeen
2017-05-04 18:25 ` [PATCH V3] " Eric Sandeen
2017-05-05 4:32 ` Eryu Guan
2017-05-05 5:21 ` Darrick J. Wong
2017-05-05 13:19 ` Eric Sandeen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.