Implement 'strings' and 'hexdump' commands.
[libguestfs.git] / perl / Guestfs.xs
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #include "EXTERN.h"
23 #include "perl.h"
24 #include "XSUB.h"
25
26 #include <guestfs.h>
27
28 #ifndef PRId64
29 #define PRId64 "lld"
30 #endif
31
32 static SV *
33 my_newSVll(long long val) {
34 #ifdef USE_64_BIT_ALL
35   return newSViv(val);
36 #else
37   char buf[100];
38   int len;
39   len = snprintf(buf, 100, "%" PRId64, val);
40   return newSVpv(buf, len);
41 #endif
42 }
43
44 #ifndef PRIu64
45 #define PRIu64 "llu"
46 #endif
47
48 static SV *
49 my_newSVull(unsigned long long val) {
50 #ifdef USE_64_BIT_ALL
51   return newSVuv(val);
52 #else
53   char buf[100];
54   int len;
55   len = snprintf(buf, 100, "%" PRIu64, val);
56   return newSVpv(buf, len);
57 #endif
58 }
59
60 /* http://www.perlmonks.org/?node_id=680842 */
61 static char **
62 XS_unpack_charPtrPtr (SV *arg) {
63   char **ret;
64   AV *av;
65   I32 i;
66
67   if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV)
68     croak ("array reference expected");
69
70   av = (AV *)SvRV (arg);
71   ret = malloc (av_len (av) + 1 + 1);
72   if (!ret)
73     croak ("malloc failed");
74
75   for (i = 0; i <= av_len (av); i++) {
76     SV **elem = av_fetch (av, i, 0);
77
78     if (!elem || !*elem)
79       croak ("missing element in list");
80
81     ret[i] = SvPV_nolen (*elem);
82   }
83
84   ret[i] = NULL;
85
86   return ret;
87 }
88
89 MODULE = Sys::Guestfs  PACKAGE = Sys::Guestfs
90
91 PROTOTYPES: ENABLE
92
93 guestfs_h *
94 _create ()
95    CODE:
96       RETVAL = guestfs_create ();
97       if (!RETVAL)
98         croak ("could not create guestfs handle");
99       guestfs_set_error_handler (RETVAL, NULL, NULL);
100  OUTPUT:
101       RETVAL
102
103 void
104 DESTROY (g)
105       guestfs_h *g;
106  PPCODE:
107       guestfs_close (g);
108
109 void
110 launch (g)
111       guestfs_h *g;
112 PREINIT:
113       int r;
114  PPCODE:
115       r = guestfs_launch (g);
116       if (r == -1)
117         croak ("launch: %s", guestfs_last_error (g));
118
119 void
120 wait_ready (g)
121       guestfs_h *g;
122 PREINIT:
123       int r;
124  PPCODE:
125       r = guestfs_wait_ready (g);
126       if (r == -1)
127         croak ("wait_ready: %s", guestfs_last_error (g));
128
129 void
130 kill_subprocess (g)
131       guestfs_h *g;
132 PREINIT:
133       int r;
134  PPCODE:
135       r = guestfs_kill_subprocess (g);
136       if (r == -1)
137         croak ("kill_subprocess: %s", guestfs_last_error (g));
138
139 void
140 add_drive (g, filename)
141       guestfs_h *g;
142       char *filename;
143 PREINIT:
144       int r;
145  PPCODE:
146       r = guestfs_add_drive (g, filename);
147       if (r == -1)
148         croak ("add_drive: %s", guestfs_last_error (g));
149
150 void
151 add_cdrom (g, filename)
152       guestfs_h *g;
153       char *filename;
154 PREINIT:
155       int r;
156  PPCODE:
157       r = guestfs_add_cdrom (g, filename);
158       if (r == -1)
159         croak ("add_cdrom: %s", guestfs_last_error (g));
160
161 void
162 config (g, qemuparam, qemuvalue)
163       guestfs_h *g;
164       char *qemuparam;
165       char *qemuvalue;
166 PREINIT:
167       int r;
168  PPCODE:
169       r = guestfs_config (g, qemuparam, qemuvalue);
170       if (r == -1)
171         croak ("config: %s", guestfs_last_error (g));
172
173 void
174 set_qemu (g, qemu)
175       guestfs_h *g;
176       char *qemu;
177 PREINIT:
178       int r;
179  PPCODE:
180       r = guestfs_set_qemu (g, qemu);
181       if (r == -1)
182         croak ("set_qemu: %s", guestfs_last_error (g));
183
184 SV *
185 get_qemu (g)
186       guestfs_h *g;
187 PREINIT:
188       const char *qemu;
189    CODE:
190       qemu = guestfs_get_qemu (g);
191       if (qemu == NULL)
192         croak ("get_qemu: %s", guestfs_last_error (g));
193       RETVAL = newSVpv (qemu, 0);
194  OUTPUT:
195       RETVAL
196
197 void
198 set_path (g, path)
199       guestfs_h *g;
200       char *path;
201 PREINIT:
202       int r;
203  PPCODE:
204       r = guestfs_set_path (g, path);
205       if (r == -1)
206         croak ("set_path: %s", guestfs_last_error (g));
207
208 SV *
209 get_path (g)
210       guestfs_h *g;
211 PREINIT:
212       const char *path;
213    CODE:
214       path = guestfs_get_path (g);
215       if (path == NULL)
216         croak ("get_path: %s", guestfs_last_error (g));
217       RETVAL = newSVpv (path, 0);
218  OUTPUT:
219       RETVAL
220
221 void
222 set_autosync (g, autosync)
223       guestfs_h *g;
224       int autosync;
225 PREINIT:
226       int r;
227  PPCODE:
228       r = guestfs_set_autosync (g, autosync);
229       if (r == -1)
230         croak ("set_autosync: %s", guestfs_last_error (g));
231
232 SV *
233 get_autosync (g)
234       guestfs_h *g;
235 PREINIT:
236       int autosync;
237    CODE:
238       autosync = guestfs_get_autosync (g);
239       if (autosync == -1)
240         croak ("get_autosync: %s", guestfs_last_error (g));
241       RETVAL = newSViv (autosync);
242  OUTPUT:
243       RETVAL
244
245 void
246 set_verbose (g, verbose)
247       guestfs_h *g;
248       int verbose;
249 PREINIT:
250       int r;
251  PPCODE:
252       r = guestfs_set_verbose (g, verbose);
253       if (r == -1)
254         croak ("set_verbose: %s", guestfs_last_error (g));
255
256 SV *
257 get_verbose (g)
258       guestfs_h *g;
259 PREINIT:
260       int verbose;
261    CODE:
262       verbose = guestfs_get_verbose (g);
263       if (verbose == -1)
264         croak ("get_verbose: %s", guestfs_last_error (g));
265       RETVAL = newSViv (verbose);
266  OUTPUT:
267       RETVAL
268
269 SV *
270 is_ready (g)
271       guestfs_h *g;
272 PREINIT:
273       int ready;
274    CODE:
275       ready = guestfs_is_ready (g);
276       if (ready == -1)
277         croak ("is_ready: %s", guestfs_last_error (g));
278       RETVAL = newSViv (ready);
279  OUTPUT:
280       RETVAL
281
282 SV *
283 is_config (g)
284       guestfs_h *g;
285 PREINIT:
286       int config;
287    CODE:
288       config = guestfs_is_config (g);
289       if (config == -1)
290         croak ("is_config: %s", guestfs_last_error (g));
291       RETVAL = newSViv (config);
292  OUTPUT:
293       RETVAL
294
295 SV *
296 is_launching (g)
297       guestfs_h *g;
298 PREINIT:
299       int launching;
300    CODE:
301       launching = guestfs_is_launching (g);
302       if (launching == -1)
303         croak ("is_launching: %s", guestfs_last_error (g));
304       RETVAL = newSViv (launching);
305  OUTPUT:
306       RETVAL
307
308 SV *
309 is_busy (g)
310       guestfs_h *g;
311 PREINIT:
312       int busy;
313    CODE:
314       busy = guestfs_is_busy (g);
315       if (busy == -1)
316         croak ("is_busy: %s", guestfs_last_error (g));
317       RETVAL = newSViv (busy);
318  OUTPUT:
319       RETVAL
320
321 SV *
322 get_state (g)
323       guestfs_h *g;
324 PREINIT:
325       int state;
326    CODE:
327       state = guestfs_get_state (g);
328       if (state == -1)
329         croak ("get_state: %s", guestfs_last_error (g));
330       RETVAL = newSViv (state);
331  OUTPUT:
332       RETVAL
333
334 void
335 set_busy (g)
336       guestfs_h *g;
337 PREINIT:
338       int r;
339  PPCODE:
340       r = guestfs_set_busy (g);
341       if (r == -1)
342         croak ("set_busy: %s", guestfs_last_error (g));
343
344 void
345 set_ready (g)
346       guestfs_h *g;
347 PREINIT:
348       int r;
349  PPCODE:
350       r = guestfs_set_ready (g);
351       if (r == -1)
352         croak ("set_ready: %s", guestfs_last_error (g));
353
354 void
355 mount (g, device, mountpoint)
356       guestfs_h *g;
357       char *device;
358       char *mountpoint;
359 PREINIT:
360       int r;
361  PPCODE:
362       r = guestfs_mount (g, device, mountpoint);
363       if (r == -1)
364         croak ("mount: %s", guestfs_last_error (g));
365
366 void
367 sync (g)
368       guestfs_h *g;
369 PREINIT:
370       int r;
371  PPCODE:
372       r = guestfs_sync (g);
373       if (r == -1)
374         croak ("sync: %s", guestfs_last_error (g));
375
376 void
377 touch (g, path)
378       guestfs_h *g;
379       char *path;
380 PREINIT:
381       int r;
382  PPCODE:
383       r = guestfs_touch (g, path);
384       if (r == -1)
385         croak ("touch: %s", guestfs_last_error (g));
386
387 SV *
388 cat (g, path)
389       guestfs_h *g;
390       char *path;
391 PREINIT:
392       char *content;
393    CODE:
394       content = guestfs_cat (g, path);
395       if (content == NULL)
396         croak ("cat: %s", guestfs_last_error (g));
397       RETVAL = newSVpv (content, 0);
398       free (content);
399  OUTPUT:
400       RETVAL
401
402 SV *
403 ll (g, directory)
404       guestfs_h *g;
405       char *directory;
406 PREINIT:
407       char *listing;
408    CODE:
409       listing = guestfs_ll (g, directory);
410       if (listing == NULL)
411         croak ("ll: %s", guestfs_last_error (g));
412       RETVAL = newSVpv (listing, 0);
413       free (listing);
414  OUTPUT:
415       RETVAL
416
417 void
418 ls (g, directory)
419       guestfs_h *g;
420       char *directory;
421 PREINIT:
422       char **listing;
423       int i, n;
424  PPCODE:
425       listing = guestfs_ls (g, directory);
426       if (listing == NULL)
427         croak ("ls: %s", guestfs_last_error (g));
428       for (n = 0; listing[n] != NULL; ++n) /**/;
429       EXTEND (SP, n);
430       for (i = 0; i < n; ++i) {
431         PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
432         free (listing[i]);
433       }
434       free (listing);
435
436 void
437 list_devices (g)
438       guestfs_h *g;
439 PREINIT:
440       char **devices;
441       int i, n;
442  PPCODE:
443       devices = guestfs_list_devices (g);
444       if (devices == NULL)
445         croak ("list_devices: %s", guestfs_last_error (g));
446       for (n = 0; devices[n] != NULL; ++n) /**/;
447       EXTEND (SP, n);
448       for (i = 0; i < n; ++i) {
449         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
450         free (devices[i]);
451       }
452       free (devices);
453
454 void
455 list_partitions (g)
456       guestfs_h *g;
457 PREINIT:
458       char **partitions;
459       int i, n;
460  PPCODE:
461       partitions = guestfs_list_partitions (g);
462       if (partitions == NULL)
463         croak ("list_partitions: %s", guestfs_last_error (g));
464       for (n = 0; partitions[n] != NULL; ++n) /**/;
465       EXTEND (SP, n);
466       for (i = 0; i < n; ++i) {
467         PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
468         free (partitions[i]);
469       }
470       free (partitions);
471
472 void
473 pvs (g)
474       guestfs_h *g;
475 PREINIT:
476       char **physvols;
477       int i, n;
478  PPCODE:
479       physvols = guestfs_pvs (g);
480       if (physvols == NULL)
481         croak ("pvs: %s", guestfs_last_error (g));
482       for (n = 0; physvols[n] != NULL; ++n) /**/;
483       EXTEND (SP, n);
484       for (i = 0; i < n; ++i) {
485         PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
486         free (physvols[i]);
487       }
488       free (physvols);
489
490 void
491 vgs (g)
492       guestfs_h *g;
493 PREINIT:
494       char **volgroups;
495       int i, n;
496  PPCODE:
497       volgroups = guestfs_vgs (g);
498       if (volgroups == NULL)
499         croak ("vgs: %s", guestfs_last_error (g));
500       for (n = 0; volgroups[n] != NULL; ++n) /**/;
501       EXTEND (SP, n);
502       for (i = 0; i < n; ++i) {
503         PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
504         free (volgroups[i]);
505       }
506       free (volgroups);
507
508 void
509 lvs (g)
510       guestfs_h *g;
511 PREINIT:
512       char **logvols;
513       int i, n;
514  PPCODE:
515       logvols = guestfs_lvs (g);
516       if (logvols == NULL)
517         croak ("lvs: %s", guestfs_last_error (g));
518       for (n = 0; logvols[n] != NULL; ++n) /**/;
519       EXTEND (SP, n);
520       for (i = 0; i < n; ++i) {
521         PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
522         free (logvols[i]);
523       }
524       free (logvols);
525
526 void
527 pvs_full (g)
528       guestfs_h *g;
529 PREINIT:
530       struct guestfs_lvm_pv_list *physvols;
531       int i;
532       HV *hv;
533  PPCODE:
534       physvols = guestfs_pvs_full (g);
535       if (physvols == NULL)
536         croak ("pvs_full: %s", guestfs_last_error (g));
537       EXTEND (SP, physvols->len);
538       for (i = 0; i < physvols->len; ++i) {
539         hv = newHV ();
540         (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
541         (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
542         (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
543         (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
544         (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
545         (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
546         (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
547         (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
548         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
549         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
550         (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
551         (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
552         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
553         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
554         PUSHs (sv_2mortal ((SV *) hv));
555       }
556       guestfs_free_lvm_pv_list (physvols);
557
558 void
559 vgs_full (g)
560       guestfs_h *g;
561 PREINIT:
562       struct guestfs_lvm_vg_list *volgroups;
563       int i;
564       HV *hv;
565  PPCODE:
566       volgroups = guestfs_vgs_full (g);
567       if (volgroups == NULL)
568         croak ("vgs_full: %s", guestfs_last_error (g));
569       EXTEND (SP, volgroups->len);
570       for (i = 0; i < volgroups->len; ++i) {
571         hv = newHV ();
572         (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
573         (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
574         (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
575         (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
576         (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
577         (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
578         (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
579         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
580         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
581         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
582         (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
583         (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
584         (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
585         (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
586         (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
587         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
588         (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
589         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
590         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
591         PUSHs (sv_2mortal ((SV *) hv));
592       }
593       guestfs_free_lvm_vg_list (volgroups);
594
595 void
596 lvs_full (g)
597       guestfs_h *g;
598 PREINIT:
599       struct guestfs_lvm_lv_list *logvols;
600       int i;
601       HV *hv;
602  PPCODE:
603       logvols = guestfs_lvs_full (g);
604       if (logvols == NULL)
605         croak ("lvs_full: %s", guestfs_last_error (g));
606       EXTEND (SP, logvols->len);
607       for (i = 0; i < logvols->len; ++i) {
608         hv = newHV ();
609         (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
610         (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
611         (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
612         (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
613         (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
614         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
615         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
616         (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
617         (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
618         (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
619         (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
620         (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
621         (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
622         (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
623         (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
624         (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
625         PUSHs (sv_2mortal ((SV *) hv));
626       }
627       guestfs_free_lvm_lv_list (logvols);
628
629 void
630 read_lines (g, path)
631       guestfs_h *g;
632       char *path;
633 PREINIT:
634       char **lines;
635       int i, n;
636  PPCODE:
637       lines = guestfs_read_lines (g, path);
638       if (lines == NULL)
639         croak ("read_lines: %s", guestfs_last_error (g));
640       for (n = 0; lines[n] != NULL; ++n) /**/;
641       EXTEND (SP, n);
642       for (i = 0; i < n; ++i) {
643         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
644         free (lines[i]);
645       }
646       free (lines);
647
648 void
649 aug_init (g, root, flags)
650       guestfs_h *g;
651       char *root;
652       int flags;
653 PREINIT:
654       int r;
655  PPCODE:
656       r = guestfs_aug_init (g, root, flags);
657       if (r == -1)
658         croak ("aug_init: %s", guestfs_last_error (g));
659
660 void
661 aug_close (g)
662       guestfs_h *g;
663 PREINIT:
664       int r;
665  PPCODE:
666       r = guestfs_aug_close (g);
667       if (r == -1)
668         croak ("aug_close: %s", guestfs_last_error (g));
669
670 SV *
671 aug_defvar (g, name, expr)
672       guestfs_h *g;
673       char *name;
674       char *expr;
675 PREINIT:
676       int nrnodes;
677    CODE:
678       nrnodes = guestfs_aug_defvar (g, name, expr);
679       if (nrnodes == -1)
680         croak ("aug_defvar: %s", guestfs_last_error (g));
681       RETVAL = newSViv (nrnodes);
682  OUTPUT:
683       RETVAL
684
685 void
686 aug_defnode (g, name, expr, val)
687       guestfs_h *g;
688       char *name;
689       char *expr;
690       char *val;
691 PREINIT:
692       struct guestfs_int_bool *r;
693  PPCODE:
694       r = guestfs_aug_defnode (g, name, expr, val);
695       if (r == NULL)
696         croak ("aug_defnode: %s", guestfs_last_error (g));
697       EXTEND (SP, 2);
698       PUSHs (sv_2mortal (newSViv (r->i)));
699       PUSHs (sv_2mortal (newSViv (r->b)));
700       guestfs_free_int_bool (r);
701
702 SV *
703 aug_get (g, path)
704       guestfs_h *g;
705       char *path;
706 PREINIT:
707       char *val;
708    CODE:
709       val = guestfs_aug_get (g, path);
710       if (val == NULL)
711         croak ("aug_get: %s", guestfs_last_error (g));
712       RETVAL = newSVpv (val, 0);
713       free (val);
714  OUTPUT:
715       RETVAL
716
717 void
718 aug_set (g, path, val)
719       guestfs_h *g;
720       char *path;
721       char *val;
722 PREINIT:
723       int r;
724  PPCODE:
725       r = guestfs_aug_set (g, path, val);
726       if (r == -1)
727         croak ("aug_set: %s", guestfs_last_error (g));
728
729 void
730 aug_insert (g, path, label, before)
731       guestfs_h *g;
732       char *path;
733       char *label;
734       int before;
735 PREINIT:
736       int r;
737  PPCODE:
738       r = guestfs_aug_insert (g, path, label, before);
739       if (r == -1)
740         croak ("aug_insert: %s", guestfs_last_error (g));
741
742 SV *
743 aug_rm (g, path)
744       guestfs_h *g;
745       char *path;
746 PREINIT:
747       int nrnodes;
748    CODE:
749       nrnodes = guestfs_aug_rm (g, path);
750       if (nrnodes == -1)
751         croak ("aug_rm: %s", guestfs_last_error (g));
752       RETVAL = newSViv (nrnodes);
753  OUTPUT:
754       RETVAL
755
756 void
757 aug_mv (g, src, dest)
758       guestfs_h *g;
759       char *src;
760       char *dest;
761 PREINIT:
762       int r;
763  PPCODE:
764       r = guestfs_aug_mv (g, src, dest);
765       if (r == -1)
766         croak ("aug_mv: %s", guestfs_last_error (g));
767
768 void
769 aug_match (g, path)
770       guestfs_h *g;
771       char *path;
772 PREINIT:
773       char **matches;
774       int i, n;
775  PPCODE:
776       matches = guestfs_aug_match (g, path);
777       if (matches == NULL)
778         croak ("aug_match: %s", guestfs_last_error (g));
779       for (n = 0; matches[n] != NULL; ++n) /**/;
780       EXTEND (SP, n);
781       for (i = 0; i < n; ++i) {
782         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
783         free (matches[i]);
784       }
785       free (matches);
786
787 void
788 aug_save (g)
789       guestfs_h *g;
790 PREINIT:
791       int r;
792  PPCODE:
793       r = guestfs_aug_save (g);
794       if (r == -1)
795         croak ("aug_save: %s", guestfs_last_error (g));
796
797 void
798 aug_load (g)
799       guestfs_h *g;
800 PREINIT:
801       int r;
802  PPCODE:
803       r = guestfs_aug_load (g);
804       if (r == -1)
805         croak ("aug_load: %s", guestfs_last_error (g));
806
807 void
808 aug_ls (g, path)
809       guestfs_h *g;
810       char *path;
811 PREINIT:
812       char **matches;
813       int i, n;
814  PPCODE:
815       matches = guestfs_aug_ls (g, path);
816       if (matches == NULL)
817         croak ("aug_ls: %s", guestfs_last_error (g));
818       for (n = 0; matches[n] != NULL; ++n) /**/;
819       EXTEND (SP, n);
820       for (i = 0; i < n; ++i) {
821         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
822         free (matches[i]);
823       }
824       free (matches);
825
826 void
827 rm (g, path)
828       guestfs_h *g;
829       char *path;
830 PREINIT:
831       int r;
832  PPCODE:
833       r = guestfs_rm (g, path);
834       if (r == -1)
835         croak ("rm: %s", guestfs_last_error (g));
836
837 void
838 rmdir (g, path)
839       guestfs_h *g;
840       char *path;
841 PREINIT:
842       int r;
843  PPCODE:
844       r = guestfs_rmdir (g, path);
845       if (r == -1)
846         croak ("rmdir: %s", guestfs_last_error (g));
847
848 void
849 rm_rf (g, path)
850       guestfs_h *g;
851       char *path;
852 PREINIT:
853       int r;
854  PPCODE:
855       r = guestfs_rm_rf (g, path);
856       if (r == -1)
857         croak ("rm_rf: %s", guestfs_last_error (g));
858
859 void
860 mkdir (g, path)
861       guestfs_h *g;
862       char *path;
863 PREINIT:
864       int r;
865  PPCODE:
866       r = guestfs_mkdir (g, path);
867       if (r == -1)
868         croak ("mkdir: %s", guestfs_last_error (g));
869
870 void
871 mkdir_p (g, path)
872       guestfs_h *g;
873       char *path;
874 PREINIT:
875       int r;
876  PPCODE:
877       r = guestfs_mkdir_p (g, path);
878       if (r == -1)
879         croak ("mkdir_p: %s", guestfs_last_error (g));
880
881 void
882 chmod (g, mode, path)
883       guestfs_h *g;
884       int mode;
885       char *path;
886 PREINIT:
887       int r;
888  PPCODE:
889       r = guestfs_chmod (g, mode, path);
890       if (r == -1)
891         croak ("chmod: %s", guestfs_last_error (g));
892
893 void
894 chown (g, owner, group, path)
895       guestfs_h *g;
896       int owner;
897       int group;
898       char *path;
899 PREINIT:
900       int r;
901  PPCODE:
902       r = guestfs_chown (g, owner, group, path);
903       if (r == -1)
904         croak ("chown: %s", guestfs_last_error (g));
905
906 SV *
907 exists (g, path)
908       guestfs_h *g;
909       char *path;
910 PREINIT:
911       int existsflag;
912    CODE:
913       existsflag = guestfs_exists (g, path);
914       if (existsflag == -1)
915         croak ("exists: %s", guestfs_last_error (g));
916       RETVAL = newSViv (existsflag);
917  OUTPUT:
918       RETVAL
919
920 SV *
921 is_file (g, path)
922       guestfs_h *g;
923       char *path;
924 PREINIT:
925       int fileflag;
926    CODE:
927       fileflag = guestfs_is_file (g, path);
928       if (fileflag == -1)
929         croak ("is_file: %s", guestfs_last_error (g));
930       RETVAL = newSViv (fileflag);
931  OUTPUT:
932       RETVAL
933
934 SV *
935 is_dir (g, path)
936       guestfs_h *g;
937       char *path;
938 PREINIT:
939       int dirflag;
940    CODE:
941       dirflag = guestfs_is_dir (g, path);
942       if (dirflag == -1)
943         croak ("is_dir: %s", guestfs_last_error (g));
944       RETVAL = newSViv (dirflag);
945  OUTPUT:
946       RETVAL
947
948 void
949 pvcreate (g, device)
950       guestfs_h *g;
951       char *device;
952 PREINIT:
953       int r;
954  PPCODE:
955       r = guestfs_pvcreate (g, device);
956       if (r == -1)
957         croak ("pvcreate: %s", guestfs_last_error (g));
958
959 void
960 vgcreate (g, volgroup, physvols)
961       guestfs_h *g;
962       char *volgroup;
963       char **physvols;
964 PREINIT:
965       int r;
966  PPCODE:
967       r = guestfs_vgcreate (g, volgroup, physvols);
968       free (physvols);
969       if (r == -1)
970         croak ("vgcreate: %s", guestfs_last_error (g));
971
972 void
973 lvcreate (g, logvol, volgroup, mbytes)
974       guestfs_h *g;
975       char *logvol;
976       char *volgroup;
977       int mbytes;
978 PREINIT:
979       int r;
980  PPCODE:
981       r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
982       if (r == -1)
983         croak ("lvcreate: %s", guestfs_last_error (g));
984
985 void
986 mkfs (g, fstype, device)
987       guestfs_h *g;
988       char *fstype;
989       char *device;
990 PREINIT:
991       int r;
992  PPCODE:
993       r = guestfs_mkfs (g, fstype, device);
994       if (r == -1)
995         croak ("mkfs: %s", guestfs_last_error (g));
996
997 void
998 sfdisk (g, device, cyls, heads, sectors, lines)
999       guestfs_h *g;
1000       char *device;
1001       int cyls;
1002       int heads;
1003       int sectors;
1004       char **lines;
1005 PREINIT:
1006       int r;
1007  PPCODE:
1008       r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1009       free (lines);
1010       if (r == -1)
1011         croak ("sfdisk: %s", guestfs_last_error (g));
1012
1013 void
1014 write_file (g, path, content, size)
1015       guestfs_h *g;
1016       char *path;
1017       char *content;
1018       int size;
1019 PREINIT:
1020       int r;
1021  PPCODE:
1022       r = guestfs_write_file (g, path, content, size);
1023       if (r == -1)
1024         croak ("write_file: %s", guestfs_last_error (g));
1025
1026 void
1027 umount (g, pathordevice)
1028       guestfs_h *g;
1029       char *pathordevice;
1030 PREINIT:
1031       int r;
1032  PPCODE:
1033       r = guestfs_umount (g, pathordevice);
1034       if (r == -1)
1035         croak ("umount: %s", guestfs_last_error (g));
1036
1037 void
1038 mounts (g)
1039       guestfs_h *g;
1040 PREINIT:
1041       char **devices;
1042       int i, n;
1043  PPCODE:
1044       devices = guestfs_mounts (g);
1045       if (devices == NULL)
1046         croak ("mounts: %s", guestfs_last_error (g));
1047       for (n = 0; devices[n] != NULL; ++n) /**/;
1048       EXTEND (SP, n);
1049       for (i = 0; i < n; ++i) {
1050         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1051         free (devices[i]);
1052       }
1053       free (devices);
1054
1055 void
1056 umount_all (g)
1057       guestfs_h *g;
1058 PREINIT:
1059       int r;
1060  PPCODE:
1061       r = guestfs_umount_all (g);
1062       if (r == -1)
1063         croak ("umount_all: %s", guestfs_last_error (g));
1064
1065 void
1066 lvm_remove_all (g)
1067       guestfs_h *g;
1068 PREINIT:
1069       int r;
1070  PPCODE:
1071       r = guestfs_lvm_remove_all (g);
1072       if (r == -1)
1073         croak ("lvm_remove_all: %s", guestfs_last_error (g));
1074
1075 SV *
1076 file (g, path)
1077       guestfs_h *g;
1078       char *path;
1079 PREINIT:
1080       char *description;
1081    CODE:
1082       description = guestfs_file (g, path);
1083       if (description == NULL)
1084         croak ("file: %s", guestfs_last_error (g));
1085       RETVAL = newSVpv (description, 0);
1086       free (description);
1087  OUTPUT:
1088       RETVAL
1089
1090 SV *
1091 command (g, arguments)
1092       guestfs_h *g;
1093       char **arguments;
1094 PREINIT:
1095       char *output;
1096    CODE:
1097       output = guestfs_command (g, arguments);
1098       free (arguments);
1099       if (output == NULL)
1100         croak ("command: %s", guestfs_last_error (g));
1101       RETVAL = newSVpv (output, 0);
1102       free (output);
1103  OUTPUT:
1104       RETVAL
1105
1106 void
1107 command_lines (g, arguments)
1108       guestfs_h *g;
1109       char **arguments;
1110 PREINIT:
1111       char **lines;
1112       int i, n;
1113  PPCODE:
1114       lines = guestfs_command_lines (g, arguments);
1115       free (arguments);
1116       if (lines == NULL)
1117         croak ("command_lines: %s", guestfs_last_error (g));
1118       for (n = 0; lines[n] != NULL; ++n) /**/;
1119       EXTEND (SP, n);
1120       for (i = 0; i < n; ++i) {
1121         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1122         free (lines[i]);
1123       }
1124       free (lines);
1125
1126 void
1127 stat (g, path)
1128       guestfs_h *g;
1129       char *path;
1130 PREINIT:
1131       struct guestfs_stat *statbuf;
1132  PPCODE:
1133       statbuf = guestfs_stat (g, path);
1134       if (statbuf == NULL)
1135         croak ("stat: %s", guestfs_last_error (g));
1136       EXTEND (SP, 13);
1137       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1138       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1139       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1140       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1141       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1142       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1143       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1144       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1145       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1146       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1147       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1148       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1149       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1150       free (statbuf);
1151
1152 void
1153 lstat (g, path)
1154       guestfs_h *g;
1155       char *path;
1156 PREINIT:
1157       struct guestfs_stat *statbuf;
1158  PPCODE:
1159       statbuf = guestfs_lstat (g, path);
1160       if (statbuf == NULL)
1161         croak ("lstat: %s", guestfs_last_error (g));
1162       EXTEND (SP, 13);
1163       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1164       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1165       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1166       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1167       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1168       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1169       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1170       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1171       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1172       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1173       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1174       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1175       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1176       free (statbuf);
1177
1178 void
1179 statvfs (g, path)
1180       guestfs_h *g;
1181       char *path;
1182 PREINIT:
1183       struct guestfs_statvfs *statbuf;
1184  PPCODE:
1185       statbuf = guestfs_statvfs (g, path);
1186       if (statbuf == NULL)
1187         croak ("statvfs: %s", guestfs_last_error (g));
1188       EXTEND (SP, 11);
1189       PUSHs (sv_2mortal (my_newSVll (statbuf->bsize)));
1190       PUSHs (sv_2mortal (my_newSVll (statbuf->frsize)));
1191       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1192       PUSHs (sv_2mortal (my_newSVll (statbuf->bfree)));
1193       PUSHs (sv_2mortal (my_newSVll (statbuf->bavail)));
1194       PUSHs (sv_2mortal (my_newSVll (statbuf->files)));
1195       PUSHs (sv_2mortal (my_newSVll (statbuf->ffree)));
1196       PUSHs (sv_2mortal (my_newSVll (statbuf->favail)));
1197       PUSHs (sv_2mortal (my_newSVll (statbuf->fsid)));
1198       PUSHs (sv_2mortal (my_newSVll (statbuf->flag)));
1199       PUSHs (sv_2mortal (my_newSVll (statbuf->namemax)));
1200       free (statbuf);
1201
1202 void
1203 tune2fs_l (g, device)
1204       guestfs_h *g;
1205       char *device;
1206 PREINIT:
1207       char **superblock;
1208       int i, n;
1209  PPCODE:
1210       superblock = guestfs_tune2fs_l (g, device);
1211       if (superblock == NULL)
1212         croak ("tune2fs_l: %s", guestfs_last_error (g));
1213       for (n = 0; superblock[n] != NULL; ++n) /**/;
1214       EXTEND (SP, n);
1215       for (i = 0; i < n; ++i) {
1216         PUSHs (sv_2mortal (newSVpv (superblock[i], 0)));
1217         free (superblock[i]);
1218       }
1219       free (superblock);
1220
1221 void
1222 blockdev_setro (g, device)
1223       guestfs_h *g;
1224       char *device;
1225 PREINIT:
1226       int r;
1227  PPCODE:
1228       r = guestfs_blockdev_setro (g, device);
1229       if (r == -1)
1230         croak ("blockdev_setro: %s", guestfs_last_error (g));
1231
1232 void
1233 blockdev_setrw (g, device)
1234       guestfs_h *g;
1235       char *device;
1236 PREINIT:
1237       int r;
1238  PPCODE:
1239       r = guestfs_blockdev_setrw (g, device);
1240       if (r == -1)
1241         croak ("blockdev_setrw: %s", guestfs_last_error (g));
1242
1243 SV *
1244 blockdev_getro (g, device)
1245       guestfs_h *g;
1246       char *device;
1247 PREINIT:
1248       int ro;
1249    CODE:
1250       ro = guestfs_blockdev_getro (g, device);
1251       if (ro == -1)
1252         croak ("blockdev_getro: %s", guestfs_last_error (g));
1253       RETVAL = newSViv (ro);
1254  OUTPUT:
1255       RETVAL
1256
1257 SV *
1258 blockdev_getss (g, device)
1259       guestfs_h *g;
1260       char *device;
1261 PREINIT:
1262       int sectorsize;
1263    CODE:
1264       sectorsize = guestfs_blockdev_getss (g, device);
1265       if (sectorsize == -1)
1266         croak ("blockdev_getss: %s", guestfs_last_error (g));
1267       RETVAL = newSViv (sectorsize);
1268  OUTPUT:
1269       RETVAL
1270
1271 SV *
1272 blockdev_getbsz (g, device)
1273       guestfs_h *g;
1274       char *device;
1275 PREINIT:
1276       int blocksize;
1277    CODE:
1278       blocksize = guestfs_blockdev_getbsz (g, device);
1279       if (blocksize == -1)
1280         croak ("blockdev_getbsz: %s", guestfs_last_error (g));
1281       RETVAL = newSViv (blocksize);
1282  OUTPUT:
1283       RETVAL
1284
1285 void
1286 blockdev_setbsz (g, device, blocksize)
1287       guestfs_h *g;
1288       char *device;
1289       int blocksize;
1290 PREINIT:
1291       int r;
1292  PPCODE:
1293       r = guestfs_blockdev_setbsz (g, device, blocksize);
1294       if (r == -1)
1295         croak ("blockdev_setbsz: %s", guestfs_last_error (g));
1296
1297 SV *
1298 blockdev_getsz (g, device)
1299       guestfs_h *g;
1300       char *device;
1301 PREINIT:
1302       int64_t sizeinsectors;
1303    CODE:
1304       sizeinsectors = guestfs_blockdev_getsz (g, device);
1305       if (sizeinsectors == -1)
1306         croak ("blockdev_getsz: %s", guestfs_last_error (g));
1307       RETVAL = my_newSVll (sizeinsectors);
1308  OUTPUT:
1309       RETVAL
1310
1311 SV *
1312 blockdev_getsize64 (g, device)
1313       guestfs_h *g;
1314       char *device;
1315 PREINIT:
1316       int64_t sizeinbytes;
1317    CODE:
1318       sizeinbytes = guestfs_blockdev_getsize64 (g, device);
1319       if (sizeinbytes == -1)
1320         croak ("blockdev_getsize64: %s", guestfs_last_error (g));
1321       RETVAL = my_newSVll (sizeinbytes);
1322  OUTPUT:
1323       RETVAL
1324
1325 void
1326 blockdev_flushbufs (g, device)
1327       guestfs_h *g;
1328       char *device;
1329 PREINIT:
1330       int r;
1331  PPCODE:
1332       r = guestfs_blockdev_flushbufs (g, device);
1333       if (r == -1)
1334         croak ("blockdev_flushbufs: %s", guestfs_last_error (g));
1335
1336 void
1337 blockdev_rereadpt (g, device)
1338       guestfs_h *g;
1339       char *device;
1340 PREINIT:
1341       int r;
1342  PPCODE:
1343       r = guestfs_blockdev_rereadpt (g, device);
1344       if (r == -1)
1345         croak ("blockdev_rereadpt: %s", guestfs_last_error (g));
1346
1347 void
1348 upload (g, filename, remotefilename)
1349       guestfs_h *g;
1350       char *filename;
1351       char *remotefilename;
1352 PREINIT:
1353       int r;
1354  PPCODE:
1355       r = guestfs_upload (g, filename, remotefilename);
1356       if (r == -1)
1357         croak ("upload: %s", guestfs_last_error (g));
1358
1359 void
1360 download (g, remotefilename, filename)
1361       guestfs_h *g;
1362       char *remotefilename;
1363       char *filename;
1364 PREINIT:
1365       int r;
1366  PPCODE:
1367       r = guestfs_download (g, remotefilename, filename);
1368       if (r == -1)
1369         croak ("download: %s", guestfs_last_error (g));
1370
1371 SV *
1372 checksum (g, csumtype, path)
1373       guestfs_h *g;
1374       char *csumtype;
1375       char *path;
1376 PREINIT:
1377       char *checksum;
1378    CODE:
1379       checksum = guestfs_checksum (g, csumtype, path);
1380       if (checksum == NULL)
1381         croak ("checksum: %s", guestfs_last_error (g));
1382       RETVAL = newSVpv (checksum, 0);
1383       free (checksum);
1384  OUTPUT:
1385       RETVAL
1386
1387 void
1388 tar_in (g, tarfile, directory)
1389       guestfs_h *g;
1390       char *tarfile;
1391       char *directory;
1392 PREINIT:
1393       int r;
1394  PPCODE:
1395       r = guestfs_tar_in (g, tarfile, directory);
1396       if (r == -1)
1397         croak ("tar_in: %s", guestfs_last_error (g));
1398
1399 void
1400 tar_out (g, directory, tarfile)
1401       guestfs_h *g;
1402       char *directory;
1403       char *tarfile;
1404 PREINIT:
1405       int r;
1406  PPCODE:
1407       r = guestfs_tar_out (g, directory, tarfile);
1408       if (r == -1)
1409         croak ("tar_out: %s", guestfs_last_error (g));
1410
1411 void
1412 tgz_in (g, tarball, directory)
1413       guestfs_h *g;
1414       char *tarball;
1415       char *directory;
1416 PREINIT:
1417       int r;
1418  PPCODE:
1419       r = guestfs_tgz_in (g, tarball, directory);
1420       if (r == -1)
1421         croak ("tgz_in: %s", guestfs_last_error (g));
1422
1423 void
1424 tgz_out (g, directory, tarball)
1425       guestfs_h *g;
1426       char *directory;
1427       char *tarball;
1428 PREINIT:
1429       int r;
1430  PPCODE:
1431       r = guestfs_tgz_out (g, directory, tarball);
1432       if (r == -1)
1433         croak ("tgz_out: %s", guestfs_last_error (g));
1434
1435 void
1436 mount_ro (g, device, mountpoint)
1437       guestfs_h *g;
1438       char *device;
1439       char *mountpoint;
1440 PREINIT:
1441       int r;
1442  PPCODE:
1443       r = guestfs_mount_ro (g, device, mountpoint);
1444       if (r == -1)
1445         croak ("mount_ro: %s", guestfs_last_error (g));
1446
1447 void
1448 mount_options (g, options, device, mountpoint)
1449       guestfs_h *g;
1450       char *options;
1451       char *device;
1452       char *mountpoint;
1453 PREINIT:
1454       int r;
1455  PPCODE:
1456       r = guestfs_mount_options (g, options, device, mountpoint);
1457       if (r == -1)
1458         croak ("mount_options: %s", guestfs_last_error (g));
1459
1460 void
1461 mount_vfs (g, options, vfstype, device, mountpoint)
1462       guestfs_h *g;
1463       char *options;
1464       char *vfstype;
1465       char *device;
1466       char *mountpoint;
1467 PREINIT:
1468       int r;
1469  PPCODE:
1470       r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
1471       if (r == -1)
1472         croak ("mount_vfs: %s", guestfs_last_error (g));
1473
1474 SV *
1475 debug (g, subcmd, extraargs)
1476       guestfs_h *g;
1477       char *subcmd;
1478       char **extraargs;
1479 PREINIT:
1480       char *result;
1481    CODE:
1482       result = guestfs_debug (g, subcmd, extraargs);
1483       free (extraargs);
1484       if (result == NULL)
1485         croak ("debug: %s", guestfs_last_error (g));
1486       RETVAL = newSVpv (result, 0);
1487       free (result);
1488  OUTPUT:
1489       RETVAL
1490
1491 void
1492 lvremove (g, device)
1493       guestfs_h *g;
1494       char *device;
1495 PREINIT:
1496       int r;
1497  PPCODE:
1498       r = guestfs_lvremove (g, device);
1499       if (r == -1)
1500         croak ("lvremove: %s", guestfs_last_error (g));
1501
1502 void
1503 vgremove (g, vgname)
1504       guestfs_h *g;
1505       char *vgname;
1506 PREINIT:
1507       int r;
1508  PPCODE:
1509       r = guestfs_vgremove (g, vgname);
1510       if (r == -1)
1511         croak ("vgremove: %s", guestfs_last_error (g));
1512
1513 void
1514 pvremove (g, device)
1515       guestfs_h *g;
1516       char *device;
1517 PREINIT:
1518       int r;
1519  PPCODE:
1520       r = guestfs_pvremove (g, device);
1521       if (r == -1)
1522         croak ("pvremove: %s", guestfs_last_error (g));
1523
1524 void
1525 set_e2label (g, device, label)
1526       guestfs_h *g;
1527       char *device;
1528       char *label;
1529 PREINIT:
1530       int r;
1531  PPCODE:
1532       r = guestfs_set_e2label (g, device, label);
1533       if (r == -1)
1534         croak ("set_e2label: %s", guestfs_last_error (g));
1535
1536 SV *
1537 get_e2label (g, device)
1538       guestfs_h *g;
1539       char *device;
1540 PREINIT:
1541       char *label;
1542    CODE:
1543       label = guestfs_get_e2label (g, device);
1544       if (label == NULL)
1545         croak ("get_e2label: %s", guestfs_last_error (g));
1546       RETVAL = newSVpv (label, 0);
1547       free (label);
1548  OUTPUT:
1549       RETVAL
1550
1551 void
1552 set_e2uuid (g, device, uuid)
1553       guestfs_h *g;
1554       char *device;
1555       char *uuid;
1556 PREINIT:
1557       int r;
1558  PPCODE:
1559       r = guestfs_set_e2uuid (g, device, uuid);
1560       if (r == -1)
1561         croak ("set_e2uuid: %s", guestfs_last_error (g));
1562
1563 SV *
1564 get_e2uuid (g, device)
1565       guestfs_h *g;
1566       char *device;
1567 PREINIT:
1568       char *uuid;
1569    CODE:
1570       uuid = guestfs_get_e2uuid (g, device);
1571       if (uuid == NULL)
1572         croak ("get_e2uuid: %s", guestfs_last_error (g));
1573       RETVAL = newSVpv (uuid, 0);
1574       free (uuid);
1575  OUTPUT:
1576       RETVAL
1577
1578 SV *
1579 fsck (g, fstype, device)
1580       guestfs_h *g;
1581       char *fstype;
1582       char *device;
1583 PREINIT:
1584       int status;
1585    CODE:
1586       status = guestfs_fsck (g, fstype, device);
1587       if (status == -1)
1588         croak ("fsck: %s", guestfs_last_error (g));
1589       RETVAL = newSViv (status);
1590  OUTPUT:
1591       RETVAL
1592
1593 void
1594 zero (g, device)
1595       guestfs_h *g;
1596       char *device;
1597 PREINIT:
1598       int r;
1599  PPCODE:
1600       r = guestfs_zero (g, device);
1601       if (r == -1)
1602         croak ("zero: %s", guestfs_last_error (g));
1603
1604 void
1605 grub_install (g, root, device)
1606       guestfs_h *g;
1607       char *root;
1608       char *device;
1609 PREINIT:
1610       int r;
1611  PPCODE:
1612       r = guestfs_grub_install (g, root, device);
1613       if (r == -1)
1614         croak ("grub_install: %s", guestfs_last_error (g));
1615
1616 void
1617 cp (g, src, dest)
1618       guestfs_h *g;
1619       char *src;
1620       char *dest;
1621 PREINIT:
1622       int r;
1623  PPCODE:
1624       r = guestfs_cp (g, src, dest);
1625       if (r == -1)
1626         croak ("cp: %s", guestfs_last_error (g));
1627
1628 void
1629 cp_a (g, src, dest)
1630       guestfs_h *g;
1631       char *src;
1632       char *dest;
1633 PREINIT:
1634       int r;
1635  PPCODE:
1636       r = guestfs_cp_a (g, src, dest);
1637       if (r == -1)
1638         croak ("cp_a: %s", guestfs_last_error (g));
1639
1640 void
1641 mv (g, src, dest)
1642       guestfs_h *g;
1643       char *src;
1644       char *dest;
1645 PREINIT:
1646       int r;
1647  PPCODE:
1648       r = guestfs_mv (g, src, dest);
1649       if (r == -1)
1650         croak ("mv: %s", guestfs_last_error (g));
1651
1652 void
1653 drop_caches (g, whattodrop)
1654       guestfs_h *g;
1655       int whattodrop;
1656 PREINIT:
1657       int r;
1658  PPCODE:
1659       r = guestfs_drop_caches (g, whattodrop);
1660       if (r == -1)
1661         croak ("drop_caches: %s", guestfs_last_error (g));
1662
1663 SV *
1664 dmesg (g)
1665       guestfs_h *g;
1666 PREINIT:
1667       char *kmsgs;
1668    CODE:
1669       kmsgs = guestfs_dmesg (g);
1670       if (kmsgs == NULL)
1671         croak ("dmesg: %s", guestfs_last_error (g));
1672       RETVAL = newSVpv (kmsgs, 0);
1673       free (kmsgs);
1674  OUTPUT:
1675       RETVAL
1676
1677 void
1678 ping_daemon (g)
1679       guestfs_h *g;
1680 PREINIT:
1681       int r;
1682  PPCODE:
1683       r = guestfs_ping_daemon (g);
1684       if (r == -1)
1685         croak ("ping_daemon: %s", guestfs_last_error (g));
1686
1687 SV *
1688 equal (g, file1, file2)
1689       guestfs_h *g;
1690       char *file1;
1691       char *file2;
1692 PREINIT:
1693       int equality;
1694    CODE:
1695       equality = guestfs_equal (g, file1, file2);
1696       if (equality == -1)
1697         croak ("equal: %s", guestfs_last_error (g));
1698       RETVAL = newSViv (equality);
1699  OUTPUT:
1700       RETVAL
1701