From adefe14e308a0f8cf73f9c60693a3dbbded157b9 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 13 Apr 2009 23:58:33 +0100 Subject: [PATCH] Generated files for file(1) command. --- daemon/actions.h | 1 + daemon/stubs.c | 30 +++++ fish/cmds.c | 24 ++++ guestfish-actions.pod | 12 ++ guestfs-actions.pod | 16 +++ ocaml/guestfs.ml | 1 + ocaml/guestfs.mli | 3 + ocaml/guestfs_c_actions.c | 24 ++++ perl/Guestfs.xs | 16 +++ perl/lib/Sys/Guestfs.pm | 10 ++ python/guestfs-py.c | 26 ++++ python/guestfs.py | 3 + src/guestfs-actions.c | 74 ++++++++++++ src/guestfs-actions.h | 1 + src/guestfs_protocol.c | 20 ++++ src/guestfs_protocol.h | 17 ++- src/guestfs_protocol.x | 9 ++ tests.c | 293 ++++++++++++++++++++++++++++++++++++++-------- 18 files changed, 532 insertions(+), 48 deletions(-) diff --git a/daemon/actions.h b/daemon/actions.h index 2a9d3d1..d53729b 100644 --- a/daemon/actions.h +++ b/daemon/actions.h @@ -69,3 +69,4 @@ extern int do_umount (const char *pathordevice); extern char **do_mounts (void); extern int do_umount_all (void); extern int do_lvm_remove_all (void); +extern char *do_file (const char *path); diff --git a/daemon/stubs.c b/daemon/stubs.c index 4540ca5..af0f14c 100644 --- a/daemon/stubs.c +++ b/daemon/stubs.c @@ -1137,6 +1137,33 @@ static void lvm_remove_all_stub (XDR *xdr_in) done: ; } +static void file_stub (XDR *xdr_in) +{ + char *r; + struct guestfs_file_args args; + const char *path; + + memset (&args, 0, sizeof args); + + if (!xdr_guestfs_file_args (xdr_in, &args)) { + reply_with_error ("%s: daemon failed to decode procedure arguments", "file"); + return; + } + path = args.path; + + r = do_file (path); + if (r == NULL) + /* do_file has already called reply_with_error */ + goto done; + + struct guestfs_file_ret ret; + ret.description = r; + reply ((xdrproc_t) &xdr_guestfs_file_ret, (char *) &ret); + free (r); +done: + xdr_free ((xdrproc_t) xdr_guestfs_file_args, (char *) &args); +} + void dispatch_incoming_message (XDR *xdr_in) { switch (proc_nr) { @@ -1284,6 +1311,9 @@ void dispatch_incoming_message (XDR *xdr_in) case GUESTFS_PROC_LVM_REMOVE_ALL: lvm_remove_all_stub (xdr_in); break; + case GUESTFS_PROC_FILE: + file_stub (xdr_in); + break; default: reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr); } diff --git a/fish/cmds.c b/fish/cmds.c index 2ffd78b..1fb8b9d 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -51,6 +51,7 @@ void list_commands (void) printf ("%-20s %s\n", "chown", "change file owner and group"); printf ("%-20s %s\n", "config", "add qemu parameters"); printf ("%-20s %s\n", "exists", "test if file or directory exists"); + printf ("%-20s %s\n", "file", "determine file type"); printf ("%-20s %s\n", "get-autosync", "get autosync mode"); printf ("%-20s %s\n", "get-path", "get the search path"); printf ("%-20s %s\n", "get-verbose", "get verbose mode"); @@ -272,6 +273,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "lvm_remove_all") == 0 || strcasecmp (cmd, "lvm-remove-all") == 0) pod2text ("lvm-remove-all - remove all LVM LVs, VGs and PVs", " lvm-remove-all\n\nThis command removes all LVM logical volumes, volume groups\nand physical volumes.\n\nB."); else + if (strcasecmp (cmd, "file") == 0) + pod2text ("file - determine file type", " file \n\nThis call uses the standard L command to determine\nthe type or contents of the file. This also works on devices,\nfor example to find out whether a partition contains a filesystem.\n\nThe exact command which runs is C. Note in\nparticular that the filename is not prepended to the output\n(the C<-b> option)."); + else display_builtin_command (cmd); } @@ -1277,6 +1281,23 @@ static int run_lvm_remove_all (const char *cmd, int argc, char *argv[]) return r; } +static int run_file (const char *cmd, int argc, char *argv[]) +{ + char *r; + const char *path; + if (argc != 1) { + fprintf (stderr, "%s should have 1 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + path = argv[0]; + r = guestfs_file (g, path); + if (r == NULL) return -1; + printf ("%s\n", r); + free (r); + return 0; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -1456,6 +1477,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "lvm_remove_all") == 0 || strcasecmp (cmd, "lvm-remove-all") == 0) return run_lvm_remove_all (cmd, argc, argv); else + if (strcasecmp (cmd, "file") == 0) + return run_file (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/guestfish-actions.pod b/guestfish-actions.pod index 50ecfec..606c5b9 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -236,6 +236,18 @@ This returns C if and only if there is a file, directory See also C, C, C. +=head2 file + + file path + +This call uses the standard L command to determine +the type or contents of the file. This also works on devices, +for example to find out whether a partition contains a filesystem. + +The exact command which runs is C. Note in +particular that the filename is not prepended to the output +(the C<-b> option). + =head2 get-autosync get-autosync diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 310db2e..32c6d67 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -312,6 +312,22 @@ See also C, C, C. This function returns a C truth value on success or -1 on error. +=head2 guestfs_file + + char *guestfs_file (guestfs_h *handle, + const char *path); + +This call uses the standard L command to determine +the type or contents of the file. This also works on devices, +for example to find out whether a partition contains a filesystem. + +The exact command which runs is C. Note in +particular that the filename is not prepended to the output +(the C<-b> option). + +This function returns a string or NULL on error. +I. + =head2 guestfs_get_autosync int guestfs_get_autosync (guestfs_h *handle); diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 58f99dc..5330794 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -145,3 +145,4 @@ external umount : t -> string -> unit = "ocaml_guestfs_umount" external mounts : t -> string array = "ocaml_guestfs_mounts" external umount_all : t -> unit = "ocaml_guestfs_umount_all" external lvm_remove_all : t -> unit = "ocaml_guestfs_lvm_remove_all" +external file : t -> string -> string = "ocaml_guestfs_file" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index aaed946..e3cee18 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -274,3 +274,6 @@ val umount_all : t -> unit val lvm_remove_all : t -> unit (** remove all LVM LVs, VGs and PVs *) +val file : t -> string -> string +(** determine file type *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 6b1a9f6..decb838 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -1665,3 +1665,27 @@ ocaml_guestfs_lvm_remove_all (value gv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_file (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("file: used handle after closing it"); + + const char *path = String_val (pathv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_file (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "file"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + diff --git a/perl/Guestfs.xs b/perl/Guestfs.xs index 580b743..14a9225 100644 --- a/perl/Guestfs.xs +++ b/perl/Guestfs.xs @@ -914,3 +914,19 @@ lvm_remove_all (g) croak ("lvm_remove_all: %s", guestfs_last_error (g)); } +SV * +file (g, path) + guestfs_h *g; + char *path; +PREINIT: + char *description; + CODE: + description = guestfs_file (g, path); + if (description == NULL) { + croak ("file: %s", guestfs_last_error (g)); + } + RETVAL = newSVpv (description, 0); + free (description); + OUTPUT: + RETVAL + diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index c708a29..9d050b4 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -289,6 +289,16 @@ This returns C if and only if there is a file, directory See also C<$h-Eis_file>, C<$h-Eis_dir>, C<$h-Estat>. +=item $description = $h->file ($path); + +This call uses the standard L command to determine +the type or contents of the file. This also works on devices, +for example to find out whether a partition contains a filesystem. + +The exact command which runs is C. Note in +particular that the filename is not prepended to the output +(the C<-b> option). + =item $autosync = $h->get_autosync (); Get the autosync flag. diff --git a/python/guestfs-py.c b/python/guestfs-py.c index 9d2738c..d3d6999 100644 --- a/python/guestfs-py.c +++ b/python/guestfs-py.c @@ -1806,6 +1806,31 @@ py_guestfs_lvm_remove_all (PyObject *self, PyObject *args) return py_r; } +static PyObject * +py_guestfs_file (PyObject *self, PyObject *args) +{ + PyObject *py_g; + guestfs_h *g; + PyObject *py_r; + char *r; + const char *path; + + if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_file", + &py_g, &path)) + return NULL; + g = get_handle (py_g); + + r = guestfs_file (g, path); + if (r == NULL) { + PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g)); + return NULL; + } + + py_r = PyString_FromString (r); + free (r); + return py_r; +} + static PyMethodDef methods[] = { { (char *) "create", py_guestfs_create, METH_VARARGS, NULL }, { (char *) "close", py_guestfs_close, METH_VARARGS, NULL }, @@ -1869,6 +1894,7 @@ static PyMethodDef methods[] = { { (char *) "mounts", py_guestfs_mounts, METH_VARARGS, NULL }, { (char *) "umount_all", py_guestfs_umount_all, METH_VARARGS, NULL }, { (char *) "lvm_remove_all", py_guestfs_lvm_remove_all, METH_VARARGS, NULL }, + { (char *) "file", py_guestfs_file, METH_VARARGS, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/python/guestfs.py b/python/guestfs.py index 864b361..d4cd46d 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -207,3 +207,6 @@ class GuestFS: def lvm_remove_all (self): return libguestfsmod.lvm_remove_all (self._o) + def file (self, path): + return libguestfsmod.file (self._o, path) + diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c index 669ca76..4b6b982 100644 --- a/src/guestfs-actions.c +++ b/src/guestfs-actions.c @@ -3471,3 +3471,77 @@ int guestfs_lvm_remove_all (guestfs_h *g) return 0; } +struct file_rv { + int cb_done; /* flag to indicate callback was called */ + struct guestfs_message_header hdr; + struct guestfs_message_error err; + struct guestfs_file_ret ret; +}; + +static void file_cb (guestfs_h *g, void *data, XDR *xdr) +{ + struct file_rv *rv = (struct file_rv *) data; + + if (!xdr_guestfs_message_header (xdr, &rv->hdr)) { + error (g, "guestfs_file: failed to parse reply header"); + return; + } + if (rv->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &rv->err)) { + error (g, "guestfs_file: failed to parse reply error"); + return; + } + goto done; + } + if (!xdr_guestfs_file_ret (xdr, &rv->ret)) { + error (g, "guestfs_file: failed to parse reply"); + return; + } + done: + rv->cb_done = 1; + main_loop.main_loop_quit (g); +} + +char *guestfs_file (guestfs_h *g, + const char *path) +{ + struct guestfs_file_args args; + struct file_rv rv; + int serial; + + if (g->state != READY) { + error (g, "guestfs_file called from the wrong state, %d != READY", + g->state); + return NULL; + } + + memset (&rv, 0, sizeof rv); + + args.path = (char *) path; + serial = dispatch (g, GUESTFS_PROC_FILE, + (xdrproc_t) xdr_guestfs_file_args, (char *) &args); + if (serial == -1) + return NULL; + + rv.cb_done = 0; + g->reply_cb_internal = file_cb; + g->reply_cb_internal_data = &rv; + main_loop.main_loop_run (g); + g->reply_cb_internal = NULL; + g->reply_cb_internal_data = NULL; + if (!rv.cb_done) { + error (g, "guestfs_file failed, see earlier error messages"); + return NULL; + } + + if (check_reply_header (g, &rv.hdr, GUESTFS_PROC_FILE, serial) == -1) + return NULL; + + if (rv.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", rv.err.error); + return NULL; + } + + return rv.ret.description; /* caller will free */ +} + diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index d40ef15..7373964 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -79,3 +79,4 @@ extern int guestfs_umount (guestfs_h *handle, const char *pathordevice); extern char **guestfs_mounts (guestfs_h *handle); extern int guestfs_umount_all (guestfs_h *handle); extern int guestfs_lvm_remove_all (guestfs_h *handle); +extern char *guestfs_file (guestfs_h *handle, const char *path); diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c index 8e86812..82b227c 100644 --- a/src/guestfs_protocol.c +++ b/src/guestfs_protocol.c @@ -827,6 +827,26 @@ xdr_guestfs_mounts_ret (XDR *xdrs, guestfs_mounts_ret *objp) } bool_t +xdr_guestfs_file_args (XDR *xdrs, guestfs_file_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->path, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_file_ret (XDR *xdrs, guestfs_file_ret *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->description, ~0)) + return FALSE; + return TRUE; +} + +bool_t xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp) { register int32_t *buf; diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h index fedd007..339f069 100644 --- a/src/guestfs_protocol.h +++ b/src/guestfs_protocol.h @@ -426,6 +426,16 @@ struct guestfs_mounts_ret { }; typedef struct guestfs_mounts_ret guestfs_mounts_ret; +struct guestfs_file_args { + char *path; +}; +typedef struct guestfs_file_args guestfs_file_args; + +struct guestfs_file_ret { + char *description; +}; +typedef struct guestfs_file_ret guestfs_file_ret; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -475,7 +485,8 @@ enum guestfs_procedure { GUESTFS_PROC_MOUNTS = 46, GUESTFS_PROC_UMOUNT_ALL = 47, GUESTFS_PROC_LVM_REMOVE_ALL = 48, - GUESTFS_PROC_dummy = 48 + 1, + GUESTFS_PROC_FILE = 49, + GUESTFS_PROC_dummy = 49 + 1, }; typedef enum guestfs_procedure guestfs_procedure; #define GUESTFS_MESSAGE_MAX 4194304 @@ -575,6 +586,8 @@ extern bool_t xdr_guestfs_sfdisk_args (XDR *, guestfs_sfdisk_args*); extern bool_t xdr_guestfs_write_file_args (XDR *, guestfs_write_file_args*); extern bool_t xdr_guestfs_umount_args (XDR *, guestfs_umount_args*); extern bool_t xdr_guestfs_mounts_ret (XDR *, guestfs_mounts_ret*); +extern bool_t xdr_guestfs_file_args (XDR *, guestfs_file_args*); +extern bool_t xdr_guestfs_file_ret (XDR *, guestfs_file_ret*); extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*); extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*); extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*); @@ -644,6 +657,8 @@ extern bool_t xdr_guestfs_sfdisk_args (); extern bool_t xdr_guestfs_write_file_args (); extern bool_t xdr_guestfs_umount_args (); extern bool_t xdr_guestfs_mounts_ret (); +extern bool_t xdr_guestfs_file_args (); +extern bool_t xdr_guestfs_file_ret (); extern bool_t xdr_guestfs_procedure (); extern bool_t xdr_guestfs_message_direction (); extern bool_t xdr_guestfs_message_status (); diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x index c547d0b..d133bb5 100644 --- a/src/guestfs_protocol.x +++ b/src/guestfs_protocol.x @@ -328,6 +328,14 @@ struct guestfs_mounts_ret { str devices<>; }; +struct guestfs_file_args { + string path<>; +}; + +struct guestfs_file_ret { + string description<>; +}; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -377,6 +385,7 @@ enum guestfs_procedure { GUESTFS_PROC_MOUNTS = 46, GUESTFS_PROC_UMOUNT_ALL = 47, GUESTFS_PROC_LVM_REMOVE_ALL = 48, + GUESTFS_PROC_FILE = 49, GUESTFS_PROC_dummy }; diff --git a/tests.c b/tests.c index ebb5857..b59192c 100644 --- a/tests.c +++ b/tests.c @@ -3603,6 +3603,190 @@ static int test_umount_all_0 (void) return 0; } +static int test_file_0 (void) +{ + /* InitBasicFS for file (0): create ext2 on /dev/sda1 */ + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char *lines[] = { + ",", + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mkfs (g, "ext2", "/dev/sda1"); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mount (g, "/dev/sda1", "/"); + if (r == -1) + return -1; + } + /* TestOutput for file (0) */ + { + int r; + suppress_error = 0; + r = guestfs_touch (g, "/new"); + if (r == -1) + return -1; + } + { + char *r; + suppress_error = 0; + r = guestfs_file (g, "/new"); + if (r == NULL) + return -1; + if (strcmp (r, "empty") != 0) { + fprintf (stderr, "test_file_0: expected \"empty\" but got \"%s\"\n", r); + return -1; + } + free (r); + } + return 0; +} + +static int test_file_1 (void) +{ + /* InitBasicFS for file (1): create ext2 on /dev/sda1 */ + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char *lines[] = { + ",", + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mkfs (g, "ext2", "/dev/sda1"); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mount (g, "/dev/sda1", "/"); + if (r == -1) + return -1; + } + /* TestOutput for file (1) */ + { + int r; + suppress_error = 0; + r = guestfs_write_file (g, "/new", "some content\n", 0); + if (r == -1) + return -1; + } + { + char *r; + suppress_error = 0; + r = guestfs_file (g, "/new"); + if (r == NULL) + return -1; + if (strcmp (r, "ASCII text") != 0) { + fprintf (stderr, "test_file_1: expected \"ASCII text\" but got \"%s\"\n", r); + return -1; + } + free (r); + } + return 0; +} + +static int test_file_2 (void) +{ + /* InitBasicFS for file (2): create ext2 on /dev/sda1 */ + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char *lines[] = { + ",", + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mkfs (g, "ext2", "/dev/sda1"); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_mount (g, "/dev/sda1", "/"); + if (r == -1) + return -1; + } + /* TestLastFail for file (2) */ + { + char *r; + suppress_error = 1; + r = guestfs_file (g, "/nofile"); + if (r != NULL) + return -1; + free (r); + } + return 0; +} + int main (int argc, char *argv[]) { char c = 0; @@ -3716,236 +3900,251 @@ int main (int argc, char *argv[]) exit (1); } - printf (" 1/ 46 test_mount_0\n"); + printf (" 1/ 49 test_mount_0\n"); if (test_mount_0 () == -1) { printf ("test_mount_0 FAILED\n"); failed++; } - printf (" 2/ 46 test_sync_0\n"); + printf (" 2/ 49 test_sync_0\n"); if (test_sync_0 () == -1) { printf ("test_sync_0 FAILED\n"); failed++; } - printf (" 3/ 46 test_touch_0\n"); + printf (" 3/ 49 test_touch_0\n"); if (test_touch_0 () == -1) { printf ("test_touch_0 FAILED\n"); failed++; } - printf (" 4/ 46 test_cat_0\n"); + printf (" 4/ 49 test_cat_0\n"); if (test_cat_0 () == -1) { printf ("test_cat_0 FAILED\n"); failed++; } - printf (" 5/ 46 test_ls_0\n"); + printf (" 5/ 49 test_ls_0\n"); if (test_ls_0 () == -1) { printf ("test_ls_0 FAILED\n"); failed++; } - printf (" 6/ 46 test_list_devices_0\n"); + printf (" 6/ 49 test_list_devices_0\n"); if (test_list_devices_0 () == -1) { printf ("test_list_devices_0 FAILED\n"); failed++; } - printf (" 7/ 46 test_list_partitions_0\n"); + printf (" 7/ 49 test_list_partitions_0\n"); if (test_list_partitions_0 () == -1) { printf ("test_list_partitions_0 FAILED\n"); failed++; } - printf (" 8/ 46 test_list_partitions_1\n"); + printf (" 8/ 49 test_list_partitions_1\n"); if (test_list_partitions_1 () == -1) { printf ("test_list_partitions_1 FAILED\n"); failed++; } - printf (" 9/ 46 test_pvs_0\n"); + printf (" 9/ 49 test_pvs_0\n"); if (test_pvs_0 () == -1) { printf ("test_pvs_0 FAILED\n"); failed++; } - printf (" 10/ 46 test_pvs_1\n"); + printf (" 10/ 49 test_pvs_1\n"); if (test_pvs_1 () == -1) { printf ("test_pvs_1 FAILED\n"); failed++; } - printf (" 11/ 46 test_vgs_0\n"); + printf (" 11/ 49 test_vgs_0\n"); if (test_vgs_0 () == -1) { printf ("test_vgs_0 FAILED\n"); failed++; } - printf (" 12/ 46 test_vgs_1\n"); + printf (" 12/ 49 test_vgs_1\n"); if (test_vgs_1 () == -1) { printf ("test_vgs_1 FAILED\n"); failed++; } - printf (" 13/ 46 test_lvs_0\n"); + printf (" 13/ 49 test_lvs_0\n"); if (test_lvs_0 () == -1) { printf ("test_lvs_0 FAILED\n"); failed++; } - printf (" 14/ 46 test_lvs_1\n"); + printf (" 14/ 49 test_lvs_1\n"); if (test_lvs_1 () == -1) { printf ("test_lvs_1 FAILED\n"); failed++; } - printf (" 15/ 46 test_pvs_full_0\n"); + printf (" 15/ 49 test_pvs_full_0\n"); if (test_pvs_full_0 () == -1) { printf ("test_pvs_full_0 FAILED\n"); failed++; } - printf (" 16/ 46 test_vgs_full_0\n"); + printf (" 16/ 49 test_vgs_full_0\n"); if (test_vgs_full_0 () == -1) { printf ("test_vgs_full_0 FAILED\n"); failed++; } - printf (" 17/ 46 test_lvs_full_0\n"); + printf (" 17/ 49 test_lvs_full_0\n"); if (test_lvs_full_0 () == -1) { printf ("test_lvs_full_0 FAILED\n"); failed++; } - printf (" 18/ 46 test_read_lines_0\n"); + printf (" 18/ 49 test_read_lines_0\n"); if (test_read_lines_0 () == -1) { printf ("test_read_lines_0 FAILED\n"); failed++; } - printf (" 19/ 46 test_read_lines_1\n"); + printf (" 19/ 49 test_read_lines_1\n"); if (test_read_lines_1 () == -1) { printf ("test_read_lines_1 FAILED\n"); failed++; } - printf (" 20/ 46 test_rm_0\n"); + printf (" 20/ 49 test_rm_0\n"); if (test_rm_0 () == -1) { printf ("test_rm_0 FAILED\n"); failed++; } - printf (" 21/ 46 test_rm_1\n"); + printf (" 21/ 49 test_rm_1\n"); if (test_rm_1 () == -1) { printf ("test_rm_1 FAILED\n"); failed++; } - printf (" 22/ 46 test_rm_2\n"); + printf (" 22/ 49 test_rm_2\n"); if (test_rm_2 () == -1) { printf ("test_rm_2 FAILED\n"); failed++; } - printf (" 23/ 46 test_rmdir_0\n"); + printf (" 23/ 49 test_rmdir_0\n"); if (test_rmdir_0 () == -1) { printf ("test_rmdir_0 FAILED\n"); failed++; } - printf (" 24/ 46 test_rmdir_1\n"); + printf (" 24/ 49 test_rmdir_1\n"); if (test_rmdir_1 () == -1) { printf ("test_rmdir_1 FAILED\n"); failed++; } - printf (" 25/ 46 test_rmdir_2\n"); + printf (" 25/ 49 test_rmdir_2\n"); if (test_rmdir_2 () == -1) { printf ("test_rmdir_2 FAILED\n"); failed++; } - printf (" 26/ 46 test_rm_rf_0\n"); + printf (" 26/ 49 test_rm_rf_0\n"); if (test_rm_rf_0 () == -1) { printf ("test_rm_rf_0 FAILED\n"); failed++; } - printf (" 27/ 46 test_mkdir_0\n"); + printf (" 27/ 49 test_mkdir_0\n"); if (test_mkdir_0 () == -1) { printf ("test_mkdir_0 FAILED\n"); failed++; } - printf (" 28/ 46 test_mkdir_1\n"); + printf (" 28/ 49 test_mkdir_1\n"); if (test_mkdir_1 () == -1) { printf ("test_mkdir_1 FAILED\n"); failed++; } - printf (" 29/ 46 test_mkdir_p_0\n"); + printf (" 29/ 49 test_mkdir_p_0\n"); if (test_mkdir_p_0 () == -1) { printf ("test_mkdir_p_0 FAILED\n"); failed++; } - printf (" 30/ 46 test_mkdir_p_1\n"); + printf (" 30/ 49 test_mkdir_p_1\n"); if (test_mkdir_p_1 () == -1) { printf ("test_mkdir_p_1 FAILED\n"); failed++; } - printf (" 31/ 46 test_mkdir_p_2\n"); + printf (" 31/ 49 test_mkdir_p_2\n"); if (test_mkdir_p_2 () == -1) { printf ("test_mkdir_p_2 FAILED\n"); failed++; } - printf (" 32/ 46 test_exists_0\n"); + printf (" 32/ 49 test_exists_0\n"); if (test_exists_0 () == -1) { printf ("test_exists_0 FAILED\n"); failed++; } - printf (" 33/ 46 test_exists_1\n"); + printf (" 33/ 49 test_exists_1\n"); if (test_exists_1 () == -1) { printf ("test_exists_1 FAILED\n"); failed++; } - printf (" 34/ 46 test_is_file_0\n"); + printf (" 34/ 49 test_is_file_0\n"); if (test_is_file_0 () == -1) { printf ("test_is_file_0 FAILED\n"); failed++; } - printf (" 35/ 46 test_is_file_1\n"); + printf (" 35/ 49 test_is_file_1\n"); if (test_is_file_1 () == -1) { printf ("test_is_file_1 FAILED\n"); failed++; } - printf (" 36/ 46 test_is_dir_0\n"); + printf (" 36/ 49 test_is_dir_0\n"); if (test_is_dir_0 () == -1) { printf ("test_is_dir_0 FAILED\n"); failed++; } - printf (" 37/ 46 test_is_dir_1\n"); + printf (" 37/ 49 test_is_dir_1\n"); if (test_is_dir_1 () == -1) { printf ("test_is_dir_1 FAILED\n"); failed++; } - printf (" 38/ 46 test_pvcreate_0\n"); + printf (" 38/ 49 test_pvcreate_0\n"); if (test_pvcreate_0 () == -1) { printf ("test_pvcreate_0 FAILED\n"); failed++; } - printf (" 39/ 46 test_vgcreate_0\n"); + printf (" 39/ 49 test_vgcreate_0\n"); if (test_vgcreate_0 () == -1) { printf ("test_vgcreate_0 FAILED\n"); failed++; } - printf (" 40/ 46 test_lvcreate_0\n"); + printf (" 40/ 49 test_lvcreate_0\n"); if (test_lvcreate_0 () == -1) { printf ("test_lvcreate_0 FAILED\n"); failed++; } - printf (" 41/ 46 test_mkfs_0\n"); + printf (" 41/ 49 test_mkfs_0\n"); if (test_mkfs_0 () == -1) { printf ("test_mkfs_0 FAILED\n"); failed++; } - printf (" 42/ 46 test_write_file_0\n"); + printf (" 42/ 49 test_write_file_0\n"); if (test_write_file_0 () == -1) { printf ("test_write_file_0 FAILED\n"); failed++; } - printf (" 43/ 46 test_umount_0\n"); + printf (" 43/ 49 test_umount_0\n"); if (test_umount_0 () == -1) { printf ("test_umount_0 FAILED\n"); failed++; } - printf (" 44/ 46 test_umount_1\n"); + printf (" 44/ 49 test_umount_1\n"); if (test_umount_1 () == -1) { printf ("test_umount_1 FAILED\n"); failed++; } - printf (" 45/ 46 test_mounts_0\n"); + printf (" 45/ 49 test_mounts_0\n"); if (test_mounts_0 () == -1) { printf ("test_mounts_0 FAILED\n"); failed++; } - printf (" 46/ 46 test_umount_all_0\n"); + printf (" 46/ 49 test_umount_all_0\n"); if (test_umount_all_0 () == -1) { printf ("test_umount_all_0 FAILED\n"); failed++; } + printf (" 47/ 49 test_file_0\n"); + if (test_file_0 () == -1) { + printf ("test_file_0 FAILED\n"); + failed++; + } + printf (" 48/ 49 test_file_1\n"); + if (test_file_1 () == -1) { + printf ("test_file_1 FAILED\n"); + failed++; + } + printf (" 49/ 49 test_file_2\n"); + if (test_file_2 () == -1) { + printf ("test_file_2 FAILED\n"); + failed++; + } guestfs_close (g); snprintf (buf, sizeof buf, "%s/test1.img", srcdir); @@ -3956,7 +4155,7 @@ int main (int argc, char *argv[]) unlink (buf); if (failed > 0) { - printf ("***** %d / 46 tests FAILED *****\n", failed); + printf ("***** %d / 49 tests FAILED *****\n", failed); exit (1); } -- 1.8.3.1