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 /daemon | |
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).
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/fill.c | 28 |
1 files changed, 28 insertions, 0 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; +} |