From: Richard W.M. Jones Date: Wed, 3 Nov 2010 17:37:07 +0000 (+0000) Subject: capitests: Use ftruncate instead of seek + write to create test files. X-Git-Tag: 1.7.1~13 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=162c89ed497212859d748506209ffc1b88763ab2;p=libguestfs.git capitests: Use ftruncate instead of seek + write to create test files. --- diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml index 6f5f59c..325b37c 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);