summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-11-03 17:37:07 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-11-03 17:44:30 +0000
commit162c89ed497212859d748506209ffc1b88763ab2 (patch)
tree2f6de6561b42bb0294da8707838ffc59e17290c7
parentec0fe45e48fa4621fc6fa0f5bcc44f184068c86f (diff)
downloadlibguestfs-162c89ed497212859d748506209ffc1b88763ab2.tar.gz
libguestfs-162c89ed497212859d748506209ffc1b88763ab2.tar.xz
libguestfs-162c89ed497212859d748506209ffc1b88763ab2.zip
capitests: Use ftruncate instead of seek + write to create test files.
-rw-r--r--generator/generator_capitests.ml30
1 files changed, 6 insertions, 24 deletions
diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml
index 6f5f59c7..325b37c5 100644
--- a/generator/generator_capitests.ml
+++ b/generator/generator_capitests.ml
@@ -181,14 +181,8 @@ int main (int argc, char *argv[])
perror (filename);
exit (EXIT_FAILURE);
}
- if (lseek (fd, %d, SEEK_SET) == -1) {
- perror (\"lseek\");
- close (fd);
- unlink (filename);
- exit (EXIT_FAILURE);
- }
- if (write (fd, &c, 1) == -1) {
- perror (\"write\");
+ if (ftruncate (fd, %d) == -1) {
+ perror (\"ftruncate\");
close (fd);
unlink (filename);
exit (EXIT_FAILURE);
@@ -209,14 +203,8 @@ int main (int argc, char *argv[])
perror (filename);
exit (EXIT_FAILURE);
}
- if (lseek (fd, %d, SEEK_SET) == -1) {
- perror (\"lseek\");
- close (fd);
- unlink (filename);
- exit (EXIT_FAILURE);
- }
- if (write (fd, &c, 1) == -1) {
- perror (\"write\");
+ if (ftruncate (fd, %d) == -1) {
+ perror (\"ftruncate\");
close (fd);
unlink (filename);
exit (EXIT_FAILURE);
@@ -237,14 +225,8 @@ int main (int argc, char *argv[])
perror (filename);
exit (EXIT_FAILURE);
}
- if (lseek (fd, %d, SEEK_SET) == -1) {
- perror (\"lseek\");
- close (fd);
- unlink (filename);
- exit (EXIT_FAILURE);
- }
- if (write (fd, &c, 1) == -1) {
- perror (\"write\");
+ if (ftruncate (fd, %d) == -1) {
+ perror (\"ftruncate\");
close (fd);
unlink (filename);
exit (EXIT_FAILURE);