diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-08-17 15:50:51 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-17 16:08:14 +0100 |
commit | 07eb7021638140c4dfc2b5b99bbb4c129d21e03f (patch) | |
tree | 72daa6c34db0da8d30b2e4e13c10aa55243bd647 | |
parent | 6952505694bfd8dda20e4e18b5f8b76b97db82a4 (diff) | |
download | libguestfs-07eb7021638140c4dfc2b5b99bbb4c129d21e03f.tar.gz libguestfs-07eb7021638140c4dfc2b5b99bbb4c129d21e03f.tar.xz libguestfs-07eb7021638140c4dfc2b5b99bbb4c129d21e03f.zip |
New API: fill-dir: Fill a directory with files (for testing).
-rw-r--r-- | daemon/fill.c | 28 | ||||
-rw-r--r-- | generator/generator_actions.ml | 11 | ||||
-rw-r--r-- | src/MAX_PROC_NR | 2 |
3 files changed, 40 insertions, 1 deletions
diff --git a/daemon/fill.c b/daemon/fill.c index 9ea00ab3..a9a3aa78 100644 --- a/daemon/fill.c +++ b/daemon/fill.c @@ -123,3 +123,31 @@ do_fill_pattern (const char *pattern, int len, const char *path) return 0; } + +int +do_fill_dir (const char *dir, int n) +{ + size_t len = strlen (dir); + char filename[len+10]; + int fd; + int i; + + for (i = 0; i < n; ++i) { + snprintf (filename, len+10, "%s/%08d", dir, i); + + CHROOT_IN; + fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666); + CHROOT_OUT; + + if (fd == -1) { + reply_with_perror ("create: %s", filename); + return -1; + } + if (close (fd) == -1) { + reply_with_perror ("close: %s", filename); + return -1; + } + } + + return 0; +} diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index e7cfb6da..1b10b04a 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -9436,6 +9436,17 @@ In the output file, the filenames are separated by C<\\0> characters. C<.> and C<..> are not returned. The filenames are not sorted." }; + { defaults with + name = "fill_dir"; + style = RErr, [Pathname "dir"; Int "nr"], []; + proc_nr = Some 348; + shortdesc = "fill a directory with empty files"; + longdesc = "\ +This function, useful for testing filesystems, creates C<nr> +empty files in the directory C<dir> with names C<00000000> +through C<nr-1> (ie. each file name is 8 digits long padded +with zeroes)." }; + ] (* Non-API meta-commands available only in guestfish. diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 538ad4bc..71627d71 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -347 +348 |