summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test-file-zero-alloc-speed.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/test-file-zero-alloc-speed.c b/test-file-zero-alloc-speed.c
index dcfc3b1..f5af84d 100644
--- a/test-file-zero-alloc-speed.c
+++ b/test-file-zero-alloc-speed.c
@@ -38,12 +38,13 @@ int pre_test_setup(char *source, char *target, char *fstype,
{
int r;
- r = mount(source, target, fstype, mntflags, mntopts);
- if (r < 0) {
- perror("mount");
- return -1;
+ if (source) {
+ r = mount(source, target, fstype, mntflags, mntopts);
+ if (r < 0) {
+ perror("mount");
+ return -1;
+ }
}
-
unlink(name);
*fd = open(name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
if (*fd < 0) {
@@ -73,10 +74,11 @@ int post_test_cleanup(char *target, int *fd)
if (r < 0)
perror("close");
- r = umount(target);
- if (r < 0)
- perror("unmount");
-
+ if (strcmp(target, ".")) {
+ r = umount(target);
+ if (r < 0)
+ perror("unmount");
+ }
return r;
}
@@ -211,16 +213,22 @@ int main(int argc, char **argv)
unsigned long long filesize;
/* FIXME! use getopt */
- if (argc < 5) {
+ if (argc < 2 || argc > 2 && argc < 5) {
printf("usage: %s <filesize-in-gb> <device> <mountpoint> <fstype> [mntflags] [mntopts]\n",
argv[0]);
return -1;
}
filesize = GB(atol(argv[1]));
- source = argv[2];
- target = argv[3];
- fstype = argv[4];
+ if (argc > 2) {
+ source = argv[2];
+ target = argv[3];
+ fstype = argv[4];
+ } else {
+ source = NULL;
+ target = ".";
+ fstype = "native";
+ }
if (argc > 5)
mntflags = atol(argv[5]);
else