summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-05-27 09:48:22 +0100
committerRichard Jones <rjones@redhat.com>2010-05-27 09:48:22 +0100
commit6b500f1b8e1ac8d28c485a5591c2833b18cc86e2 (patch)
treeb9d7bf6181bd281ee3d5a78a7cef890b9efc1cc9
parentc1e3cff523d72e8110cbc568a3c280e57c2aabca (diff)
downloadlibguestfs-6b500f1b8e1ac8d28c485a5591c2833b18cc86e2.tar.gz
libguestfs-6b500f1b8e1ac8d28c485a5591c2833b18cc86e2.tar.xz
libguestfs-6b500f1b8e1ac8d28c485a5591c2833b18cc86e2.zip
New API: fallocate64 (replaces fallocate).
guestfs_fallocate takes an integer for the length, effectively limiting it to creating 1GB files. This new call takes an int64_t for the length, but is otherwise identical.
-rw-r--r--daemon/fallocate.c11
-rw-r--r--src/MAX_PROC_NR2
-rwxr-xr-xsrc/generator.ml24
3 files changed, 35 insertions, 2 deletions
diff --git a/daemon/fallocate.c b/daemon/fallocate.c
index 49474307..0c948fff 100644
--- a/daemon/fallocate.c
+++ b/daemon/fallocate.c
@@ -31,6 +31,17 @@
int
do_fallocate (const char *path, int len)
{
+ if (len < 0) {
+ reply_with_error ("length < 0");
+ return -1;
+ }
+
+ return do_fallocate64 (path, len);
+}
+
+int
+do_fallocate64 (const char *path, int64_t len)
+{
int fd;
CHROOT_IN;
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 1f7e0d6e..2197544d 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-251
+252
diff --git a/src/generator.ml b/src/generator.ml
index 6db6aeb8..96a58478 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -3475,7 +3475,7 @@ The C<-f> option removes the link (C<linkname>) if it exists already.");
"\
This command reads the target of a symbolic link.");
- ("fallocate", (RErr, [Pathname "path"; Int "len"]), 169, [],
+ ("fallocate", (RErr, [Pathname "path"; Int "len"]), 169, [DeprecatedBy "fallocate64"],
[InitBasicFS, Always, TestOutputStruct (
[["fallocate"; "/a"; "1000000"];
["stat"; "/a"]], [CompareWithInt ("size", 1_000_000)])],
@@ -4722,6 +4722,28 @@ returned list.
See also C<guestfs_available> and L<guestfs(3)/AVAILABILITY>.");
+ ("fallocate64", (RErr, [Pathname "path"; Int64 "len"]), 252, [],
+ [InitBasicFS, Always, TestOutputStruct (
+ [["fallocate64"; "/a"; "1000000"];
+ ["stat"; "/a"]], [CompareWithInt ("size", 1_000_000)])],
+ "preallocate a file in the guest filesystem",
+ "\
+This command preallocates a file (containing zero bytes) named
+C<path> of size C<len> bytes. If the file exists already, it
+is overwritten.
+
+Note that this call allocates disk blocks for the file.
+To create a sparse file use C<guestfs_truncate_size> instead.
+
+The deprecated call C<guestfs_fallocate> does the same,
+but owing to an oversight it only allowed 30 bit lengths
+to be specified, effectively limiting the maximum size
+of files created through that call to 1GB.
+
+Do not confuse this with the guestfish-specific
+C<alloc> and C<sparse> commands which create
+a file in the host and attach it as a device.");
+
]
let all_functions = non_daemon_functions @ daemon_functions