Perl bindings fix: Not enough memory was allocated for array params.
[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) * sizeof (char *));
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 end_busy (g)
356       guestfs_h *g;
357 PREINIT:
358       int r;
359  PPCODE:
360       r = guestfs_end_busy (g);
361       if (r == -1)
362         croak ("end_busy: %s", guestfs_last_error (g));
363
364 void
365 mount (g, device, mountpoint)
366       guestfs_h *g;
367       char *device;
368       char *mountpoint;
369 PREINIT:
370       int r;
371  PPCODE:
372       r = guestfs_mount (g, device, mountpoint);
373       if (r == -1)
374         croak ("mount: %s", guestfs_last_error (g));
375
376 void
377 sync (g)
378       guestfs_h *g;
379 PREINIT:
380       int r;
381  PPCODE:
382       r = guestfs_sync (g);
383       if (r == -1)
384         croak ("sync: %s", guestfs_last_error (g));
385
386 void
387 touch (g, path)
388       guestfs_h *g;
389       char *path;
390 PREINIT:
391       int r;
392  PPCODE:
393       r = guestfs_touch (g, path);
394       if (r == -1)
395         croak ("touch: %s", guestfs_last_error (g));
396
397 SV *
398 cat (g, path)
399       guestfs_h *g;
400       char *path;
401 PREINIT:
402       char *content;
403    CODE:
404       content = guestfs_cat (g, path);
405       if (content == NULL)
406         croak ("cat: %s", guestfs_last_error (g));
407       RETVAL = newSVpv (content, 0);
408       free (content);
409  OUTPUT:
410       RETVAL
411
412 SV *
413 ll (g, directory)
414       guestfs_h *g;
415       char *directory;
416 PREINIT:
417       char *listing;
418    CODE:
419       listing = guestfs_ll (g, directory);
420       if (listing == NULL)
421         croak ("ll: %s", guestfs_last_error (g));
422       RETVAL = newSVpv (listing, 0);
423       free (listing);
424  OUTPUT:
425       RETVAL
426
427 void
428 ls (g, directory)
429       guestfs_h *g;
430       char *directory;
431 PREINIT:
432       char **listing;
433       int i, n;
434  PPCODE:
435       listing = guestfs_ls (g, directory);
436       if (listing == NULL)
437         croak ("ls: %s", guestfs_last_error (g));
438       for (n = 0; listing[n] != NULL; ++n) /**/;
439       EXTEND (SP, n);
440       for (i = 0; i < n; ++i) {
441         PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
442         free (listing[i]);
443       }
444       free (listing);
445
446 void
447 list_devices (g)
448       guestfs_h *g;
449 PREINIT:
450       char **devices;
451       int i, n;
452  PPCODE:
453       devices = guestfs_list_devices (g);
454       if (devices == NULL)
455         croak ("list_devices: %s", guestfs_last_error (g));
456       for (n = 0; devices[n] != NULL; ++n) /**/;
457       EXTEND (SP, n);
458       for (i = 0; i < n; ++i) {
459         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
460         free (devices[i]);
461       }
462       free (devices);
463
464 void
465 list_partitions (g)
466       guestfs_h *g;
467 PREINIT:
468       char **partitions;
469       int i, n;
470  PPCODE:
471       partitions = guestfs_list_partitions (g);
472       if (partitions == NULL)
473         croak ("list_partitions: %s", guestfs_last_error (g));
474       for (n = 0; partitions[n] != NULL; ++n) /**/;
475       EXTEND (SP, n);
476       for (i = 0; i < n; ++i) {
477         PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
478         free (partitions[i]);
479       }
480       free (partitions);
481
482 void
483 pvs (g)
484       guestfs_h *g;
485 PREINIT:
486       char **physvols;
487       int i, n;
488  PPCODE:
489       physvols = guestfs_pvs (g);
490       if (physvols == NULL)
491         croak ("pvs: %s", guestfs_last_error (g));
492       for (n = 0; physvols[n] != NULL; ++n) /**/;
493       EXTEND (SP, n);
494       for (i = 0; i < n; ++i) {
495         PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
496         free (physvols[i]);
497       }
498       free (physvols);
499
500 void
501 vgs (g)
502       guestfs_h *g;
503 PREINIT:
504       char **volgroups;
505       int i, n;
506  PPCODE:
507       volgroups = guestfs_vgs (g);
508       if (volgroups == NULL)
509         croak ("vgs: %s", guestfs_last_error (g));
510       for (n = 0; volgroups[n] != NULL; ++n) /**/;
511       EXTEND (SP, n);
512       for (i = 0; i < n; ++i) {
513         PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
514         free (volgroups[i]);
515       }
516       free (volgroups);
517
518 void
519 lvs (g)
520       guestfs_h *g;
521 PREINIT:
522       char **logvols;
523       int i, n;
524  PPCODE:
525       logvols = guestfs_lvs (g);
526       if (logvols == NULL)
527         croak ("lvs: %s", guestfs_last_error (g));
528       for (n = 0; logvols[n] != NULL; ++n) /**/;
529       EXTEND (SP, n);
530       for (i = 0; i < n; ++i) {
531         PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
532         free (logvols[i]);
533       }
534       free (logvols);
535
536 void
537 pvs_full (g)
538       guestfs_h *g;
539 PREINIT:
540       struct guestfs_lvm_pv_list *physvols;
541       int i;
542       HV *hv;
543  PPCODE:
544       physvols = guestfs_pvs_full (g);
545       if (physvols == NULL)
546         croak ("pvs_full: %s", guestfs_last_error (g));
547       EXTEND (SP, physvols->len);
548       for (i = 0; i < physvols->len; ++i) {
549         hv = newHV ();
550         (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
551         (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
552         (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
553         (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
554         (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
555         (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
556         (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
557         (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
558         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
559         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
560         (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
561         (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
562         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
563         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
564         PUSHs (sv_2mortal ((SV *) hv));
565       }
566       guestfs_free_lvm_pv_list (physvols);
567
568 void
569 vgs_full (g)
570       guestfs_h *g;
571 PREINIT:
572       struct guestfs_lvm_vg_list *volgroups;
573       int i;
574       HV *hv;
575  PPCODE:
576       volgroups = guestfs_vgs_full (g);
577       if (volgroups == NULL)
578         croak ("vgs_full: %s", guestfs_last_error (g));
579       EXTEND (SP, volgroups->len);
580       for (i = 0; i < volgroups->len; ++i) {
581         hv = newHV ();
582         (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
583         (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
584         (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
585         (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
586         (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
587         (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
588         (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
589         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
590         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
591         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
592         (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
593         (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
594         (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
595         (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
596         (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
597         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
598         (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
599         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
600         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
601         PUSHs (sv_2mortal ((SV *) hv));
602       }
603       guestfs_free_lvm_vg_list (volgroups);
604
605 void
606 lvs_full (g)
607       guestfs_h *g;
608 PREINIT:
609       struct guestfs_lvm_lv_list *logvols;
610       int i;
611       HV *hv;
612  PPCODE:
613       logvols = guestfs_lvs_full (g);
614       if (logvols == NULL)
615         croak ("lvs_full: %s", guestfs_last_error (g));
616       EXTEND (SP, logvols->len);
617       for (i = 0; i < logvols->len; ++i) {
618         hv = newHV ();
619         (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
620         (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
621         (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
622         (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
623         (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
624         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
625         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
626         (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
627         (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
628         (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
629         (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
630         (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
631         (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
632         (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
633         (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
634         (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
635         PUSHs (sv_2mortal ((SV *) hv));
636       }
637       guestfs_free_lvm_lv_list (logvols);
638
639 void
640 read_lines (g, path)
641       guestfs_h *g;
642       char *path;
643 PREINIT:
644       char **lines;
645       int i, n;
646  PPCODE:
647       lines = guestfs_read_lines (g, path);
648       if (lines == NULL)
649         croak ("read_lines: %s", guestfs_last_error (g));
650       for (n = 0; lines[n] != NULL; ++n) /**/;
651       EXTEND (SP, n);
652       for (i = 0; i < n; ++i) {
653         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
654         free (lines[i]);
655       }
656       free (lines);
657
658 void
659 aug_init (g, root, flags)
660       guestfs_h *g;
661       char *root;
662       int flags;
663 PREINIT:
664       int r;
665  PPCODE:
666       r = guestfs_aug_init (g, root, flags);
667       if (r == -1)
668         croak ("aug_init: %s", guestfs_last_error (g));
669
670 void
671 aug_close (g)
672       guestfs_h *g;
673 PREINIT:
674       int r;
675  PPCODE:
676       r = guestfs_aug_close (g);
677       if (r == -1)
678         croak ("aug_close: %s", guestfs_last_error (g));
679
680 SV *
681 aug_defvar (g, name, expr)
682       guestfs_h *g;
683       char *name;
684       char *expr;
685 PREINIT:
686       int nrnodes;
687    CODE:
688       nrnodes = guestfs_aug_defvar (g, name, expr);
689       if (nrnodes == -1)
690         croak ("aug_defvar: %s", guestfs_last_error (g));
691       RETVAL = newSViv (nrnodes);
692  OUTPUT:
693       RETVAL
694
695 void
696 aug_defnode (g, name, expr, val)
697       guestfs_h *g;
698       char *name;
699       char *expr;
700       char *val;
701 PREINIT:
702       struct guestfs_int_bool *r;
703  PPCODE:
704       r = guestfs_aug_defnode (g, name, expr, val);
705       if (r == NULL)
706         croak ("aug_defnode: %s", guestfs_last_error (g));
707       EXTEND (SP, 2);
708       PUSHs (sv_2mortal (newSViv (r->i)));
709       PUSHs (sv_2mortal (newSViv (r->b)));
710       guestfs_free_int_bool (r);
711
712 SV *
713 aug_get (g, path)
714       guestfs_h *g;
715       char *path;
716 PREINIT:
717       char *val;
718    CODE:
719       val = guestfs_aug_get (g, path);
720       if (val == NULL)
721         croak ("aug_get: %s", guestfs_last_error (g));
722       RETVAL = newSVpv (val, 0);
723       free (val);
724  OUTPUT:
725       RETVAL
726
727 void
728 aug_set (g, path, val)
729       guestfs_h *g;
730       char *path;
731       char *val;
732 PREINIT:
733       int r;
734  PPCODE:
735       r = guestfs_aug_set (g, path, val);
736       if (r == -1)
737         croak ("aug_set: %s", guestfs_last_error (g));
738
739 void
740 aug_insert (g, path, label, before)
741       guestfs_h *g;
742       char *path;
743       char *label;
744       int before;
745 PREINIT:
746       int r;
747  PPCODE:
748       r = guestfs_aug_insert (g, path, label, before);
749       if (r == -1)
750         croak ("aug_insert: %s", guestfs_last_error (g));
751
752 SV *
753 aug_rm (g, path)
754       guestfs_h *g;
755       char *path;
756 PREINIT:
757       int nrnodes;
758    CODE:
759       nrnodes = guestfs_aug_rm (g, path);
760       if (nrnodes == -1)
761         croak ("aug_rm: %s", guestfs_last_error (g));
762       RETVAL = newSViv (nrnodes);
763  OUTPUT:
764       RETVAL
765
766 void
767 aug_mv (g, src, dest)
768       guestfs_h *g;
769       char *src;
770       char *dest;
771 PREINIT:
772       int r;
773  PPCODE:
774       r = guestfs_aug_mv (g, src, dest);
775       if (r == -1)
776         croak ("aug_mv: %s", guestfs_last_error (g));
777
778 void
779 aug_match (g, path)
780       guestfs_h *g;
781       char *path;
782 PREINIT:
783       char **matches;
784       int i, n;
785  PPCODE:
786       matches = guestfs_aug_match (g, path);
787       if (matches == NULL)
788         croak ("aug_match: %s", guestfs_last_error (g));
789       for (n = 0; matches[n] != NULL; ++n) /**/;
790       EXTEND (SP, n);
791       for (i = 0; i < n; ++i) {
792         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
793         free (matches[i]);
794       }
795       free (matches);
796
797 void
798 aug_save (g)
799       guestfs_h *g;
800 PREINIT:
801       int r;
802  PPCODE:
803       r = guestfs_aug_save (g);
804       if (r == -1)
805         croak ("aug_save: %s", guestfs_last_error (g));
806
807 void
808 aug_load (g)
809       guestfs_h *g;
810 PREINIT:
811       int r;
812  PPCODE:
813       r = guestfs_aug_load (g);
814       if (r == -1)
815         croak ("aug_load: %s", guestfs_last_error (g));
816
817 void
818 aug_ls (g, path)
819       guestfs_h *g;
820       char *path;
821 PREINIT:
822       char **matches;
823       int i, n;
824  PPCODE:
825       matches = guestfs_aug_ls (g, path);
826       if (matches == NULL)
827         croak ("aug_ls: %s", guestfs_last_error (g));
828       for (n = 0; matches[n] != NULL; ++n) /**/;
829       EXTEND (SP, n);
830       for (i = 0; i < n; ++i) {
831         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
832         free (matches[i]);
833       }
834       free (matches);
835
836 void
837 rm (g, path)
838       guestfs_h *g;
839       char *path;
840 PREINIT:
841       int r;
842  PPCODE:
843       r = guestfs_rm (g, path);
844       if (r == -1)
845         croak ("rm: %s", guestfs_last_error (g));
846
847 void
848 rmdir (g, path)
849       guestfs_h *g;
850       char *path;
851 PREINIT:
852       int r;
853  PPCODE:
854       r = guestfs_rmdir (g, path);
855       if (r == -1)
856         croak ("rmdir: %s", guestfs_last_error (g));
857
858 void
859 rm_rf (g, path)
860       guestfs_h *g;
861       char *path;
862 PREINIT:
863       int r;
864  PPCODE:
865       r = guestfs_rm_rf (g, path);
866       if (r == -1)
867         croak ("rm_rf: %s", guestfs_last_error (g));
868
869 void
870 mkdir (g, path)
871       guestfs_h *g;
872       char *path;
873 PREINIT:
874       int r;
875  PPCODE:
876       r = guestfs_mkdir (g, path);
877       if (r == -1)
878         croak ("mkdir: %s", guestfs_last_error (g));
879
880 void
881 mkdir_p (g, path)
882       guestfs_h *g;
883       char *path;
884 PREINIT:
885       int r;
886  PPCODE:
887       r = guestfs_mkdir_p (g, path);
888       if (r == -1)
889         croak ("mkdir_p: %s", guestfs_last_error (g));
890
891 void
892 chmod (g, mode, path)
893       guestfs_h *g;
894       int mode;
895       char *path;
896 PREINIT:
897       int r;
898  PPCODE:
899       r = guestfs_chmod (g, mode, path);
900       if (r == -1)
901         croak ("chmod: %s", guestfs_last_error (g));
902
903 void
904 chown (g, owner, group, path)
905       guestfs_h *g;
906       int owner;
907       int group;
908       char *path;
909 PREINIT:
910       int r;
911  PPCODE:
912       r = guestfs_chown (g, owner, group, path);
913       if (r == -1)
914         croak ("chown: %s", guestfs_last_error (g));
915
916 SV *
917 exists (g, path)
918       guestfs_h *g;
919       char *path;
920 PREINIT:
921       int existsflag;
922    CODE:
923       existsflag = guestfs_exists (g, path);
924       if (existsflag == -1)
925         croak ("exists: %s", guestfs_last_error (g));
926       RETVAL = newSViv (existsflag);
927  OUTPUT:
928       RETVAL
929
930 SV *
931 is_file (g, path)
932       guestfs_h *g;
933       char *path;
934 PREINIT:
935       int fileflag;
936    CODE:
937       fileflag = guestfs_is_file (g, path);
938       if (fileflag == -1)
939         croak ("is_file: %s", guestfs_last_error (g));
940       RETVAL = newSViv (fileflag);
941  OUTPUT:
942       RETVAL
943
944 SV *
945 is_dir (g, path)
946       guestfs_h *g;
947       char *path;
948 PREINIT:
949       int dirflag;
950    CODE:
951       dirflag = guestfs_is_dir (g, path);
952       if (dirflag == -1)
953         croak ("is_dir: %s", guestfs_last_error (g));
954       RETVAL = newSViv (dirflag);
955  OUTPUT:
956       RETVAL
957
958 void
959 pvcreate (g, device)
960       guestfs_h *g;
961       char *device;
962 PREINIT:
963       int r;
964  PPCODE:
965       r = guestfs_pvcreate (g, device);
966       if (r == -1)
967         croak ("pvcreate: %s", guestfs_last_error (g));
968
969 void
970 vgcreate (g, volgroup, physvols)
971       guestfs_h *g;
972       char *volgroup;
973       char **physvols;
974 PREINIT:
975       int r;
976  PPCODE:
977       r = guestfs_vgcreate (g, volgroup, physvols);
978       free (physvols);
979       if (r == -1)
980         croak ("vgcreate: %s", guestfs_last_error (g));
981
982 void
983 lvcreate (g, logvol, volgroup, mbytes)
984       guestfs_h *g;
985       char *logvol;
986       char *volgroup;
987       int mbytes;
988 PREINIT:
989       int r;
990  PPCODE:
991       r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
992       if (r == -1)
993         croak ("lvcreate: %s", guestfs_last_error (g));
994
995 void
996 mkfs (g, fstype, device)
997       guestfs_h *g;
998       char *fstype;
999       char *device;
1000 PREINIT:
1001       int r;
1002  PPCODE:
1003       r = guestfs_mkfs (g, fstype, device);
1004       if (r == -1)
1005         croak ("mkfs: %s", guestfs_last_error (g));
1006
1007 void
1008 sfdisk (g, device, cyls, heads, sectors, lines)
1009       guestfs_h *g;
1010       char *device;
1011       int cyls;
1012       int heads;
1013       int sectors;
1014       char **lines;
1015 PREINIT:
1016       int r;
1017  PPCODE:
1018       r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1019       free (lines);
1020       if (r == -1)
1021         croak ("sfdisk: %s", guestfs_last_error (g));
1022
1023 void
1024 write_file (g, path, content, size)
1025       guestfs_h *g;
1026       char *path;
1027       char *content;
1028       int size;
1029 PREINIT:
1030       int r;
1031  PPCODE:
1032       r = guestfs_write_file (g, path, content, size);
1033       if (r == -1)
1034         croak ("write_file: %s", guestfs_last_error (g));
1035
1036 void
1037 umount (g, pathordevice)
1038       guestfs_h *g;
1039       char *pathordevice;
1040 PREINIT:
1041       int r;
1042  PPCODE:
1043       r = guestfs_umount (g, pathordevice);
1044       if (r == -1)
1045         croak ("umount: %s", guestfs_last_error (g));
1046
1047 void
1048 mounts (g)
1049       guestfs_h *g;
1050 PREINIT:
1051       char **devices;
1052       int i, n;
1053  PPCODE:
1054       devices = guestfs_mounts (g);
1055       if (devices == NULL)
1056         croak ("mounts: %s", guestfs_last_error (g));
1057       for (n = 0; devices[n] != NULL; ++n) /**/;
1058       EXTEND (SP, n);
1059       for (i = 0; i < n; ++i) {
1060         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1061         free (devices[i]);
1062       }
1063       free (devices);
1064
1065 void
1066 umount_all (g)
1067       guestfs_h *g;
1068 PREINIT:
1069       int r;
1070  PPCODE:
1071       r = guestfs_umount_all (g);
1072       if (r == -1)
1073         croak ("umount_all: %s", guestfs_last_error (g));
1074
1075 void
1076 lvm_remove_all (g)
1077       guestfs_h *g;
1078 PREINIT:
1079       int r;
1080  PPCODE:
1081       r = guestfs_lvm_remove_all (g);
1082       if (r == -1)
1083         croak ("lvm_remove_all: %s", guestfs_last_error (g));
1084
1085 SV *
1086 file (g, path)
1087       guestfs_h *g;
1088       char *path;
1089 PREINIT:
1090       char *description;
1091    CODE:
1092       description = guestfs_file (g, path);
1093       if (description == NULL)
1094         croak ("file: %s", guestfs_last_error (g));
1095       RETVAL = newSVpv (description, 0);
1096       free (description);
1097  OUTPUT:
1098       RETVAL
1099
1100 SV *
1101 command (g, arguments)
1102       guestfs_h *g;
1103       char **arguments;
1104 PREINIT:
1105       char *output;
1106    CODE:
1107       output = guestfs_command (g, arguments);
1108       free (arguments);
1109       if (output == NULL)
1110         croak ("command: %s", guestfs_last_error (g));
1111       RETVAL = newSVpv (output, 0);
1112       free (output);
1113  OUTPUT:
1114       RETVAL
1115
1116 void
1117 command_lines (g, arguments)
1118       guestfs_h *g;
1119       char **arguments;
1120 PREINIT:
1121       char **lines;
1122       int i, n;
1123  PPCODE:
1124       lines = guestfs_command_lines (g, arguments);
1125       free (arguments);
1126       if (lines == NULL)
1127         croak ("command_lines: %s", guestfs_last_error (g));
1128       for (n = 0; lines[n] != NULL; ++n) /**/;
1129       EXTEND (SP, n);
1130       for (i = 0; i < n; ++i) {
1131         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1132         free (lines[i]);
1133       }
1134       free (lines);
1135
1136 void
1137 stat (g, path)
1138       guestfs_h *g;
1139       char *path;
1140 PREINIT:
1141       struct guestfs_stat *statbuf;
1142  PPCODE:
1143       statbuf = guestfs_stat (g, path);
1144       if (statbuf == NULL)
1145         croak ("stat: %s", guestfs_last_error (g));
1146       EXTEND (SP, 13);
1147       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1148       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1149       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1150       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1151       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1152       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1153       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1154       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1155       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1156       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1157       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1158       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1159       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1160       free (statbuf);
1161
1162 void
1163 lstat (g, path)
1164       guestfs_h *g;
1165       char *path;
1166 PREINIT:
1167       struct guestfs_stat *statbuf;
1168  PPCODE:
1169       statbuf = guestfs_lstat (g, path);
1170       if (statbuf == NULL)
1171         croak ("lstat: %s", guestfs_last_error (g));
1172       EXTEND (SP, 13);
1173       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1174       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1175       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1176       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1177       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1178       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1179       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1180       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1181       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1182       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1183       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1184       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1185       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1186       free (statbuf);
1187
1188 void
1189 statvfs (g, path)
1190       guestfs_h *g;
1191       char *path;
1192 PREINIT:
1193       struct guestfs_statvfs *statbuf;
1194  PPCODE:
1195       statbuf = guestfs_statvfs (g, path);
1196       if (statbuf == NULL)
1197         croak ("statvfs: %s", guestfs_last_error (g));
1198       EXTEND (SP, 11);
1199       PUSHs (sv_2mortal (my_newSVll (statbuf->bsize)));
1200       PUSHs (sv_2mortal (my_newSVll (statbuf->frsize)));
1201       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1202       PUSHs (sv_2mortal (my_newSVll (statbuf->bfree)));
1203       PUSHs (sv_2mortal (my_newSVll (statbuf->bavail)));
1204       PUSHs (sv_2mortal (my_newSVll (statbuf->files)));
1205       PUSHs (sv_2mortal (my_newSVll (statbuf->ffree)));
1206       PUSHs (sv_2mortal (my_newSVll (statbuf->favail)));
1207       PUSHs (sv_2mortal (my_newSVll (statbuf->fsid)));
1208       PUSHs (sv_2mortal (my_newSVll (statbuf->flag)));
1209       PUSHs (sv_2mortal (my_newSVll (statbuf->namemax)));
1210       free (statbuf);
1211
1212 void
1213 tune2fs_l (g, device)
1214       guestfs_h *g;
1215       char *device;
1216 PREINIT:
1217       char **superblock;
1218       int i, n;
1219  PPCODE:
1220       superblock = guestfs_tune2fs_l (g, device);
1221       if (superblock == NULL)
1222         croak ("tune2fs_l: %s", guestfs_last_error (g));
1223       for (n = 0; superblock[n] != NULL; ++n) /**/;
1224       EXTEND (SP, n);
1225       for (i = 0; i < n; ++i) {
1226         PUSHs (sv_2mortal (newSVpv (superblock[i], 0)));
1227         free (superblock[i]);
1228       }
1229       free (superblock);
1230
1231 void
1232 blockdev_setro (g, device)
1233       guestfs_h *g;
1234       char *device;
1235 PREINIT:
1236       int r;
1237  PPCODE:
1238       r = guestfs_blockdev_setro (g, device);
1239       if (r == -1)
1240         croak ("blockdev_setro: %s", guestfs_last_error (g));
1241
1242 void
1243 blockdev_setrw (g, device)
1244       guestfs_h *g;
1245       char *device;
1246 PREINIT:
1247       int r;
1248  PPCODE:
1249       r = guestfs_blockdev_setrw (g, device);
1250       if (r == -1)
1251         croak ("blockdev_setrw: %s", guestfs_last_error (g));
1252
1253 SV *
1254 blockdev_getro (g, device)
1255       guestfs_h *g;
1256       char *device;
1257 PREINIT:
1258       int ro;
1259    CODE:
1260       ro = guestfs_blockdev_getro (g, device);
1261       if (ro == -1)
1262         croak ("blockdev_getro: %s", guestfs_last_error (g));
1263       RETVAL = newSViv (ro);
1264  OUTPUT:
1265       RETVAL
1266
1267 SV *
1268 blockdev_getss (g, device)
1269       guestfs_h *g;
1270       char *device;
1271 PREINIT:
1272       int sectorsize;
1273    CODE:
1274       sectorsize = guestfs_blockdev_getss (g, device);
1275       if (sectorsize == -1)
1276         croak ("blockdev_getss: %s", guestfs_last_error (g));
1277       RETVAL = newSViv (sectorsize);
1278  OUTPUT:
1279       RETVAL
1280
1281 SV *
1282 blockdev_getbsz (g, device)
1283       guestfs_h *g;
1284       char *device;
1285 PREINIT:
1286       int blocksize;
1287    CODE:
1288       blocksize = guestfs_blockdev_getbsz (g, device);
1289       if (blocksize == -1)
1290         croak ("blockdev_getbsz: %s", guestfs_last_error (g));
1291       RETVAL = newSViv (blocksize);
1292  OUTPUT:
1293       RETVAL
1294
1295 void
1296 blockdev_setbsz (g, device, blocksize)
1297       guestfs_h *g;
1298       char *device;
1299       int blocksize;
1300 PREINIT:
1301       int r;
1302  PPCODE:
1303       r = guestfs_blockdev_setbsz (g, device, blocksize);
1304       if (r == -1)
1305         croak ("blockdev_setbsz: %s", guestfs_last_error (g));
1306
1307 SV *
1308 blockdev_getsz (g, device)
1309       guestfs_h *g;
1310       char *device;
1311 PREINIT:
1312       int64_t sizeinsectors;
1313    CODE:
1314       sizeinsectors = guestfs_blockdev_getsz (g, device);
1315       if (sizeinsectors == -1)
1316         croak ("blockdev_getsz: %s", guestfs_last_error (g));
1317       RETVAL = my_newSVll (sizeinsectors);
1318  OUTPUT:
1319       RETVAL
1320
1321 SV *
1322 blockdev_getsize64 (g, device)
1323       guestfs_h *g;
1324       char *device;
1325 PREINIT:
1326       int64_t sizeinbytes;
1327    CODE:
1328       sizeinbytes = guestfs_blockdev_getsize64 (g, device);
1329       if (sizeinbytes == -1)
1330         croak ("blockdev_getsize64: %s", guestfs_last_error (g));
1331       RETVAL = my_newSVll (sizeinbytes);
1332  OUTPUT:
1333       RETVAL
1334
1335 void
1336 blockdev_flushbufs (g, device)
1337       guestfs_h *g;
1338       char *device;
1339 PREINIT:
1340       int r;
1341  PPCODE:
1342       r = guestfs_blockdev_flushbufs (g, device);
1343       if (r == -1)
1344         croak ("blockdev_flushbufs: %s", guestfs_last_error (g));
1345
1346 void
1347 blockdev_rereadpt (g, device)
1348       guestfs_h *g;
1349       char *device;
1350 PREINIT:
1351       int r;
1352  PPCODE:
1353       r = guestfs_blockdev_rereadpt (g, device);
1354       if (r == -1)
1355         croak ("blockdev_rereadpt: %s", guestfs_last_error (g));
1356
1357 void
1358 upload (g, filename, remotefilename)
1359       guestfs_h *g;
1360       char *filename;
1361       char *remotefilename;
1362 PREINIT:
1363       int r;
1364  PPCODE:
1365       r = guestfs_upload (g, filename, remotefilename);
1366       if (r == -1)
1367         croak ("upload: %s", guestfs_last_error (g));
1368
1369 void
1370 download (g, remotefilename, filename)
1371       guestfs_h *g;
1372       char *remotefilename;
1373       char *filename;
1374 PREINIT:
1375       int r;
1376  PPCODE:
1377       r = guestfs_download (g, remotefilename, filename);
1378       if (r == -1)
1379         croak ("download: %s", guestfs_last_error (g));
1380
1381 SV *
1382 checksum (g, csumtype, path)
1383       guestfs_h *g;
1384       char *csumtype;
1385       char *path;
1386 PREINIT:
1387       char *checksum;
1388    CODE:
1389       checksum = guestfs_checksum (g, csumtype, path);
1390       if (checksum == NULL)
1391         croak ("checksum: %s", guestfs_last_error (g));
1392       RETVAL = newSVpv (checksum, 0);
1393       free (checksum);
1394  OUTPUT:
1395       RETVAL
1396
1397 void
1398 tar_in (g, tarfile, directory)
1399       guestfs_h *g;
1400       char *tarfile;
1401       char *directory;
1402 PREINIT:
1403       int r;
1404  PPCODE:
1405       r = guestfs_tar_in (g, tarfile, directory);
1406       if (r == -1)
1407         croak ("tar_in: %s", guestfs_last_error (g));
1408
1409 void
1410 tar_out (g, directory, tarfile)
1411       guestfs_h *g;
1412       char *directory;
1413       char *tarfile;
1414 PREINIT:
1415       int r;
1416  PPCODE:
1417       r = guestfs_tar_out (g, directory, tarfile);
1418       if (r == -1)
1419         croak ("tar_out: %s", guestfs_last_error (g));
1420
1421 void
1422 tgz_in (g, tarball, directory)
1423       guestfs_h *g;
1424       char *tarball;
1425       char *directory;
1426 PREINIT:
1427       int r;
1428  PPCODE:
1429       r = guestfs_tgz_in (g, tarball, directory);
1430       if (r == -1)
1431         croak ("tgz_in: %s", guestfs_last_error (g));
1432
1433 void
1434 tgz_out (g, directory, tarball)
1435       guestfs_h *g;
1436       char *directory;
1437       char *tarball;
1438 PREINIT:
1439       int r;
1440  PPCODE:
1441       r = guestfs_tgz_out (g, directory, tarball);
1442       if (r == -1)
1443         croak ("tgz_out: %s", guestfs_last_error (g));
1444
1445 void
1446 mount_ro (g, device, mountpoint)
1447       guestfs_h *g;
1448       char *device;
1449       char *mountpoint;
1450 PREINIT:
1451       int r;
1452  PPCODE:
1453       r = guestfs_mount_ro (g, device, mountpoint);
1454       if (r == -1)
1455         croak ("mount_ro: %s", guestfs_last_error (g));
1456
1457 void
1458 mount_options (g, options, device, mountpoint)
1459       guestfs_h *g;
1460       char *options;
1461       char *device;
1462       char *mountpoint;
1463 PREINIT:
1464       int r;
1465  PPCODE:
1466       r = guestfs_mount_options (g, options, device, mountpoint);
1467       if (r == -1)
1468         croak ("mount_options: %s", guestfs_last_error (g));
1469
1470 void
1471 mount_vfs (g, options, vfstype, device, mountpoint)
1472       guestfs_h *g;
1473       char *options;
1474       char *vfstype;
1475       char *device;
1476       char *mountpoint;
1477 PREINIT:
1478       int r;
1479  PPCODE:
1480       r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
1481       if (r == -1)
1482         croak ("mount_vfs: %s", guestfs_last_error (g));
1483
1484 SV *
1485 debug (g, subcmd, extraargs)
1486       guestfs_h *g;
1487       char *subcmd;
1488       char **extraargs;
1489 PREINIT:
1490       char *result;
1491    CODE:
1492       result = guestfs_debug (g, subcmd, extraargs);
1493       free (extraargs);
1494       if (result == NULL)
1495         croak ("debug: %s", guestfs_last_error (g));
1496       RETVAL = newSVpv (result, 0);
1497       free (result);
1498  OUTPUT:
1499       RETVAL
1500
1501 void
1502 lvremove (g, device)
1503       guestfs_h *g;
1504       char *device;
1505 PREINIT:
1506       int r;
1507  PPCODE:
1508       r = guestfs_lvremove (g, device);
1509       if (r == -1)
1510         croak ("lvremove: %s", guestfs_last_error (g));
1511
1512 void
1513 vgremove (g, vgname)
1514       guestfs_h *g;
1515       char *vgname;
1516 PREINIT:
1517       int r;
1518  PPCODE:
1519       r = guestfs_vgremove (g, vgname);
1520       if (r == -1)
1521         croak ("vgremove: %s", guestfs_last_error (g));
1522
1523 void
1524 pvremove (g, device)
1525       guestfs_h *g;
1526       char *device;
1527 PREINIT:
1528       int r;
1529  PPCODE:
1530       r = guestfs_pvremove (g, device);
1531       if (r == -1)
1532         croak ("pvremove: %s", guestfs_last_error (g));
1533
1534 void
1535 set_e2label (g, device, label)
1536       guestfs_h *g;
1537       char *device;
1538       char *label;
1539 PREINIT:
1540       int r;
1541  PPCODE:
1542       r = guestfs_set_e2label (g, device, label);
1543       if (r == -1)
1544         croak ("set_e2label: %s", guestfs_last_error (g));
1545
1546 SV *
1547 get_e2label (g, device)
1548       guestfs_h *g;
1549       char *device;
1550 PREINIT:
1551       char *label;
1552    CODE:
1553       label = guestfs_get_e2label (g, device);
1554       if (label == NULL)
1555         croak ("get_e2label: %s", guestfs_last_error (g));
1556       RETVAL = newSVpv (label, 0);
1557       free (label);
1558  OUTPUT:
1559       RETVAL
1560
1561 void
1562 set_e2uuid (g, device, uuid)
1563       guestfs_h *g;
1564       char *device;
1565       char *uuid;
1566 PREINIT:
1567       int r;
1568  PPCODE:
1569       r = guestfs_set_e2uuid (g, device, uuid);
1570       if (r == -1)
1571         croak ("set_e2uuid: %s", guestfs_last_error (g));
1572
1573 SV *
1574 get_e2uuid (g, device)
1575       guestfs_h *g;
1576       char *device;
1577 PREINIT:
1578       char *uuid;
1579    CODE:
1580       uuid = guestfs_get_e2uuid (g, device);
1581       if (uuid == NULL)
1582         croak ("get_e2uuid: %s", guestfs_last_error (g));
1583       RETVAL = newSVpv (uuid, 0);
1584       free (uuid);
1585  OUTPUT:
1586       RETVAL
1587
1588 SV *
1589 fsck (g, fstype, device)
1590       guestfs_h *g;
1591       char *fstype;
1592       char *device;
1593 PREINIT:
1594       int status;
1595    CODE:
1596       status = guestfs_fsck (g, fstype, device);
1597       if (status == -1)
1598         croak ("fsck: %s", guestfs_last_error (g));
1599       RETVAL = newSViv (status);
1600  OUTPUT:
1601       RETVAL
1602
1603 void
1604 zero (g, device)
1605       guestfs_h *g;
1606       char *device;
1607 PREINIT:
1608       int r;
1609  PPCODE:
1610       r = guestfs_zero (g, device);
1611       if (r == -1)
1612         croak ("zero: %s", guestfs_last_error (g));
1613
1614 void
1615 grub_install (g, root, device)
1616       guestfs_h *g;
1617       char *root;
1618       char *device;
1619 PREINIT:
1620       int r;
1621  PPCODE:
1622       r = guestfs_grub_install (g, root, device);
1623       if (r == -1)
1624         croak ("grub_install: %s", guestfs_last_error (g));
1625
1626 void
1627 cp (g, src, dest)
1628       guestfs_h *g;
1629       char *src;
1630       char *dest;
1631 PREINIT:
1632       int r;
1633  PPCODE:
1634       r = guestfs_cp (g, src, dest);
1635       if (r == -1)
1636         croak ("cp: %s", guestfs_last_error (g));
1637
1638 void
1639 cp_a (g, src, dest)
1640       guestfs_h *g;
1641       char *src;
1642       char *dest;
1643 PREINIT:
1644       int r;
1645  PPCODE:
1646       r = guestfs_cp_a (g, src, dest);
1647       if (r == -1)
1648         croak ("cp_a: %s", guestfs_last_error (g));
1649
1650 void
1651 mv (g, src, dest)
1652       guestfs_h *g;
1653       char *src;
1654       char *dest;
1655 PREINIT:
1656       int r;
1657  PPCODE:
1658       r = guestfs_mv (g, src, dest);
1659       if (r == -1)
1660         croak ("mv: %s", guestfs_last_error (g));
1661
1662 void
1663 drop_caches (g, whattodrop)
1664       guestfs_h *g;
1665       int whattodrop;
1666 PREINIT:
1667       int r;
1668  PPCODE:
1669       r = guestfs_drop_caches (g, whattodrop);
1670       if (r == -1)
1671         croak ("drop_caches: %s", guestfs_last_error (g));
1672
1673 SV *
1674 dmesg (g)
1675       guestfs_h *g;
1676 PREINIT:
1677       char *kmsgs;
1678    CODE:
1679       kmsgs = guestfs_dmesg (g);
1680       if (kmsgs == NULL)
1681         croak ("dmesg: %s", guestfs_last_error (g));
1682       RETVAL = newSVpv (kmsgs, 0);
1683       free (kmsgs);
1684  OUTPUT:
1685       RETVAL
1686
1687 void
1688 ping_daemon (g)
1689       guestfs_h *g;
1690 PREINIT:
1691       int r;
1692  PPCODE:
1693       r = guestfs_ping_daemon (g);
1694       if (r == -1)
1695         croak ("ping_daemon: %s", guestfs_last_error (g));
1696
1697 SV *
1698 equal (g, file1, file2)
1699       guestfs_h *g;
1700       char *file1;
1701       char *file2;
1702 PREINIT:
1703       int equality;
1704    CODE:
1705       equality = guestfs_equal (g, file1, file2);
1706       if (equality == -1)
1707         croak ("equal: %s", guestfs_last_error (g));
1708       RETVAL = newSViv (equality);
1709  OUTPUT:
1710       RETVAL
1711
1712 void
1713 strings (g, path)
1714       guestfs_h *g;
1715       char *path;
1716 PREINIT:
1717       char **stringsout;
1718       int i, n;
1719  PPCODE:
1720       stringsout = guestfs_strings (g, path);
1721       if (stringsout == NULL)
1722         croak ("strings: %s", guestfs_last_error (g));
1723       for (n = 0; stringsout[n] != NULL; ++n) /**/;
1724       EXTEND (SP, n);
1725       for (i = 0; i < n; ++i) {
1726         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
1727         free (stringsout[i]);
1728       }
1729       free (stringsout);
1730
1731 void
1732 strings_e (g, encoding, path)
1733       guestfs_h *g;
1734       char *encoding;
1735       char *path;
1736 PREINIT:
1737       char **stringsout;
1738       int i, n;
1739  PPCODE:
1740       stringsout = guestfs_strings_e (g, encoding, path);
1741       if (stringsout == NULL)
1742         croak ("strings_e: %s", guestfs_last_error (g));
1743       for (n = 0; stringsout[n] != NULL; ++n) /**/;
1744       EXTEND (SP, n);
1745       for (i = 0; i < n; ++i) {
1746         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
1747         free (stringsout[i]);
1748       }
1749       free (stringsout);
1750
1751 SV *
1752 hexdump (g, path)
1753       guestfs_h *g;
1754       char *path;
1755 PREINIT:
1756       char *dump;
1757    CODE:
1758       dump = guestfs_hexdump (g, path);
1759       if (dump == NULL)
1760         croak ("hexdump: %s", guestfs_last_error (g));
1761       RETVAL = newSVpv (dump, 0);
1762       free (dump);
1763  OUTPUT:
1764       RETVAL
1765