Clarify documentation for mkdtemp.
[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 test0 (g, str, optstr, strlist, b, integer, filein, fileout)
111       guestfs_h *g;
112       char *str;
113       char *optstr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
114       char **strlist;
115       int b;
116       int integer;
117       char *filein;
118       char *fileout;
119 PREINIT:
120       int r;
121  PPCODE:
122       r = guestfs_test0 (g, str, optstr, strlist, b, integer, filein, fileout);
123       free (strlist);
124       if (r == -1)
125         croak ("test0: %s", guestfs_last_error (g));
126
127 SV *
128 test0rint (g, val)
129       guestfs_h *g;
130       char *val;
131 PREINIT:
132       int valout;
133    CODE:
134       valout = guestfs_test0rint (g, val);
135       if (valout == -1)
136         croak ("test0rint: %s", guestfs_last_error (g));
137       RETVAL = newSViv (valout);
138  OUTPUT:
139       RETVAL
140
141 SV *
142 test0rinterr (g)
143       guestfs_h *g;
144 PREINIT:
145       int valout;
146    CODE:
147       valout = guestfs_test0rinterr (g);
148       if (valout == -1)
149         croak ("test0rinterr: %s", guestfs_last_error (g));
150       RETVAL = newSViv (valout);
151  OUTPUT:
152       RETVAL
153
154 SV *
155 test0rint64 (g, val)
156       guestfs_h *g;
157       char *val;
158 PREINIT:
159       int64_t valout;
160    CODE:
161       valout = guestfs_test0rint64 (g, val);
162       if (valout == -1)
163         croak ("test0rint64: %s", guestfs_last_error (g));
164       RETVAL = my_newSVll (valout);
165  OUTPUT:
166       RETVAL
167
168 SV *
169 test0rint64err (g)
170       guestfs_h *g;
171 PREINIT:
172       int64_t valout;
173    CODE:
174       valout = guestfs_test0rint64err (g);
175       if (valout == -1)
176         croak ("test0rint64err: %s", guestfs_last_error (g));
177       RETVAL = my_newSVll (valout);
178  OUTPUT:
179       RETVAL
180
181 SV *
182 test0rbool (g, val)
183       guestfs_h *g;
184       char *val;
185 PREINIT:
186       int valout;
187    CODE:
188       valout = guestfs_test0rbool (g, val);
189       if (valout == -1)
190         croak ("test0rbool: %s", guestfs_last_error (g));
191       RETVAL = newSViv (valout);
192  OUTPUT:
193       RETVAL
194
195 SV *
196 test0rboolerr (g)
197       guestfs_h *g;
198 PREINIT:
199       int valout;
200    CODE:
201       valout = guestfs_test0rboolerr (g);
202       if (valout == -1)
203         croak ("test0rboolerr: %s", guestfs_last_error (g));
204       RETVAL = newSViv (valout);
205  OUTPUT:
206       RETVAL
207
208 SV *
209 test0rconststring (g, val)
210       guestfs_h *g;
211       char *val;
212 PREINIT:
213       const char *valout;
214    CODE:
215       valout = guestfs_test0rconststring (g, val);
216       if (valout == NULL)
217         croak ("test0rconststring: %s", guestfs_last_error (g));
218       RETVAL = newSVpv (valout, 0);
219  OUTPUT:
220       RETVAL
221
222 SV *
223 test0rconststringerr (g)
224       guestfs_h *g;
225 PREINIT:
226       const char *valout;
227    CODE:
228       valout = guestfs_test0rconststringerr (g);
229       if (valout == NULL)
230         croak ("test0rconststringerr: %s", guestfs_last_error (g));
231       RETVAL = newSVpv (valout, 0);
232  OUTPUT:
233       RETVAL
234
235 SV *
236 test0rstring (g, val)
237       guestfs_h *g;
238       char *val;
239 PREINIT:
240       char *valout;
241    CODE:
242       valout = guestfs_test0rstring (g, val);
243       if (valout == NULL)
244         croak ("test0rstring: %s", guestfs_last_error (g));
245       RETVAL = newSVpv (valout, 0);
246       free (valout);
247  OUTPUT:
248       RETVAL
249
250 SV *
251 test0rstringerr (g)
252       guestfs_h *g;
253 PREINIT:
254       char *valout;
255    CODE:
256       valout = guestfs_test0rstringerr (g);
257       if (valout == NULL)
258         croak ("test0rstringerr: %s", guestfs_last_error (g));
259       RETVAL = newSVpv (valout, 0);
260       free (valout);
261  OUTPUT:
262       RETVAL
263
264 void
265 test0rstringlist (g, val)
266       guestfs_h *g;
267       char *val;
268 PREINIT:
269       char **valout;
270       int i, n;
271  PPCODE:
272       valout = guestfs_test0rstringlist (g, val);
273       if (valout == NULL)
274         croak ("test0rstringlist: %s", guestfs_last_error (g));
275       for (n = 0; valout[n] != NULL; ++n) /**/;
276       EXTEND (SP, n);
277       for (i = 0; i < n; ++i) {
278         PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
279         free (valout[i]);
280       }
281       free (valout);
282
283 void
284 test0rstringlisterr (g)
285       guestfs_h *g;
286 PREINIT:
287       char **valout;
288       int i, n;
289  PPCODE:
290       valout = guestfs_test0rstringlisterr (g);
291       if (valout == NULL)
292         croak ("test0rstringlisterr: %s", guestfs_last_error (g));
293       for (n = 0; valout[n] != NULL; ++n) /**/;
294       EXTEND (SP, n);
295       for (i = 0; i < n; ++i) {
296         PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
297         free (valout[i]);
298       }
299       free (valout);
300
301 void
302 test0rintbool (g, val)
303       guestfs_h *g;
304       char *val;
305 PREINIT:
306       struct guestfs_int_bool *r;
307  PPCODE:
308       r = guestfs_test0rintbool (g, val);
309       if (r == NULL)
310         croak ("test0rintbool: %s", guestfs_last_error (g));
311       EXTEND (SP, 2);
312       PUSHs (sv_2mortal (newSViv (r->i)));
313       PUSHs (sv_2mortal (newSViv (r->b)));
314       guestfs_free_int_bool (r);
315
316 void
317 test0rintboolerr (g)
318       guestfs_h *g;
319 PREINIT:
320       struct guestfs_int_bool *r;
321  PPCODE:
322       r = guestfs_test0rintboolerr (g);
323       if (r == NULL)
324         croak ("test0rintboolerr: %s", guestfs_last_error (g));
325       EXTEND (SP, 2);
326       PUSHs (sv_2mortal (newSViv (r->i)));
327       PUSHs (sv_2mortal (newSViv (r->b)));
328       guestfs_free_int_bool (r);
329
330 void
331 test0rpvlist (g, val)
332       guestfs_h *g;
333       char *val;
334 PREINIT:
335       struct guestfs_lvm_pv_list *valout;
336       int i;
337       HV *hv;
338  PPCODE:
339       valout = guestfs_test0rpvlist (g, val);
340       if (valout == NULL)
341         croak ("test0rpvlist: %s", guestfs_last_error (g));
342       EXTEND (SP, valout->len);
343       for (i = 0; i < valout->len; ++i) {
344         hv = newHV ();
345         (void) hv_store (hv, "pv_name", 7, newSVpv (valout->val[i].pv_name, 0), 0);
346         (void) hv_store (hv, "pv_uuid", 7, newSVpv (valout->val[i].pv_uuid, 32), 0);
347         (void) hv_store (hv, "pv_fmt", 6, newSVpv (valout->val[i].pv_fmt, 0), 0);
348         (void) hv_store (hv, "pv_size", 7, my_newSVull (valout->val[i].pv_size), 0);
349         (void) hv_store (hv, "dev_size", 8, my_newSVull (valout->val[i].dev_size), 0);
350         (void) hv_store (hv, "pv_free", 7, my_newSVull (valout->val[i].pv_free), 0);
351         (void) hv_store (hv, "pv_used", 7, my_newSVull (valout->val[i].pv_used), 0);
352         (void) hv_store (hv, "pv_attr", 7, newSVpv (valout->val[i].pv_attr, 0), 0);
353         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (valout->val[i].pv_pe_count), 0);
354         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (valout->val[i].pv_pe_alloc_count), 0);
355         (void) hv_store (hv, "pv_tags", 7, newSVpv (valout->val[i].pv_tags, 0), 0);
356         (void) hv_store (hv, "pe_start", 8, my_newSVull (valout->val[i].pe_start), 0);
357         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (valout->val[i].pv_mda_count), 0);
358         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (valout->val[i].pv_mda_free), 0);
359         PUSHs (sv_2mortal ((SV *) hv));
360       }
361       guestfs_free_lvm_pv_list (valout);
362
363 void
364 test0rpvlisterr (g)
365       guestfs_h *g;
366 PREINIT:
367       struct guestfs_lvm_pv_list *valout;
368       int i;
369       HV *hv;
370  PPCODE:
371       valout = guestfs_test0rpvlisterr (g);
372       if (valout == NULL)
373         croak ("test0rpvlisterr: %s", guestfs_last_error (g));
374       EXTEND (SP, valout->len);
375       for (i = 0; i < valout->len; ++i) {
376         hv = newHV ();
377         (void) hv_store (hv, "pv_name", 7, newSVpv (valout->val[i].pv_name, 0), 0);
378         (void) hv_store (hv, "pv_uuid", 7, newSVpv (valout->val[i].pv_uuid, 32), 0);
379         (void) hv_store (hv, "pv_fmt", 6, newSVpv (valout->val[i].pv_fmt, 0), 0);
380         (void) hv_store (hv, "pv_size", 7, my_newSVull (valout->val[i].pv_size), 0);
381         (void) hv_store (hv, "dev_size", 8, my_newSVull (valout->val[i].dev_size), 0);
382         (void) hv_store (hv, "pv_free", 7, my_newSVull (valout->val[i].pv_free), 0);
383         (void) hv_store (hv, "pv_used", 7, my_newSVull (valout->val[i].pv_used), 0);
384         (void) hv_store (hv, "pv_attr", 7, newSVpv (valout->val[i].pv_attr, 0), 0);
385         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (valout->val[i].pv_pe_count), 0);
386         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (valout->val[i].pv_pe_alloc_count), 0);
387         (void) hv_store (hv, "pv_tags", 7, newSVpv (valout->val[i].pv_tags, 0), 0);
388         (void) hv_store (hv, "pe_start", 8, my_newSVull (valout->val[i].pe_start), 0);
389         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (valout->val[i].pv_mda_count), 0);
390         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (valout->val[i].pv_mda_free), 0);
391         PUSHs (sv_2mortal ((SV *) hv));
392       }
393       guestfs_free_lvm_pv_list (valout);
394
395 void
396 test0rvglist (g, val)
397       guestfs_h *g;
398       char *val;
399 PREINIT:
400       struct guestfs_lvm_vg_list *valout;
401       int i;
402       HV *hv;
403  PPCODE:
404       valout = guestfs_test0rvglist (g, val);
405       if (valout == NULL)
406         croak ("test0rvglist: %s", guestfs_last_error (g));
407       EXTEND (SP, valout->len);
408       for (i = 0; i < valout->len; ++i) {
409         hv = newHV ();
410         (void) hv_store (hv, "vg_name", 7, newSVpv (valout->val[i].vg_name, 0), 0);
411         (void) hv_store (hv, "vg_uuid", 7, newSVpv (valout->val[i].vg_uuid, 32), 0);
412         (void) hv_store (hv, "vg_fmt", 6, newSVpv (valout->val[i].vg_fmt, 0), 0);
413         (void) hv_store (hv, "vg_attr", 7, newSVpv (valout->val[i].vg_attr, 0), 0);
414         (void) hv_store (hv, "vg_size", 7, my_newSVull (valout->val[i].vg_size), 0);
415         (void) hv_store (hv, "vg_free", 7, my_newSVull (valout->val[i].vg_free), 0);
416         (void) hv_store (hv, "vg_sysid", 8, newSVpv (valout->val[i].vg_sysid, 0), 0);
417         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (valout->val[i].vg_extent_size), 0);
418         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (valout->val[i].vg_extent_count), 0);
419         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (valout->val[i].vg_free_count), 0);
420         (void) hv_store (hv, "max_lv", 6, my_newSVll (valout->val[i].max_lv), 0);
421         (void) hv_store (hv, "max_pv", 6, my_newSVll (valout->val[i].max_pv), 0);
422         (void) hv_store (hv, "pv_count", 8, my_newSVll (valout->val[i].pv_count), 0);
423         (void) hv_store (hv, "lv_count", 8, my_newSVll (valout->val[i].lv_count), 0);
424         (void) hv_store (hv, "snap_count", 10, my_newSVll (valout->val[i].snap_count), 0);
425         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (valout->val[i].vg_seqno), 0);
426         (void) hv_store (hv, "vg_tags", 7, newSVpv (valout->val[i].vg_tags, 0), 0);
427         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (valout->val[i].vg_mda_count), 0);
428         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (valout->val[i].vg_mda_free), 0);
429         PUSHs (sv_2mortal ((SV *) hv));
430       }
431       guestfs_free_lvm_vg_list (valout);
432
433 void
434 test0rvglisterr (g)
435       guestfs_h *g;
436 PREINIT:
437       struct guestfs_lvm_vg_list *valout;
438       int i;
439       HV *hv;
440  PPCODE:
441       valout = guestfs_test0rvglisterr (g);
442       if (valout == NULL)
443         croak ("test0rvglisterr: %s", guestfs_last_error (g));
444       EXTEND (SP, valout->len);
445       for (i = 0; i < valout->len; ++i) {
446         hv = newHV ();
447         (void) hv_store (hv, "vg_name", 7, newSVpv (valout->val[i].vg_name, 0), 0);
448         (void) hv_store (hv, "vg_uuid", 7, newSVpv (valout->val[i].vg_uuid, 32), 0);
449         (void) hv_store (hv, "vg_fmt", 6, newSVpv (valout->val[i].vg_fmt, 0), 0);
450         (void) hv_store (hv, "vg_attr", 7, newSVpv (valout->val[i].vg_attr, 0), 0);
451         (void) hv_store (hv, "vg_size", 7, my_newSVull (valout->val[i].vg_size), 0);
452         (void) hv_store (hv, "vg_free", 7, my_newSVull (valout->val[i].vg_free), 0);
453         (void) hv_store (hv, "vg_sysid", 8, newSVpv (valout->val[i].vg_sysid, 0), 0);
454         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (valout->val[i].vg_extent_size), 0);
455         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (valout->val[i].vg_extent_count), 0);
456         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (valout->val[i].vg_free_count), 0);
457         (void) hv_store (hv, "max_lv", 6, my_newSVll (valout->val[i].max_lv), 0);
458         (void) hv_store (hv, "max_pv", 6, my_newSVll (valout->val[i].max_pv), 0);
459         (void) hv_store (hv, "pv_count", 8, my_newSVll (valout->val[i].pv_count), 0);
460         (void) hv_store (hv, "lv_count", 8, my_newSVll (valout->val[i].lv_count), 0);
461         (void) hv_store (hv, "snap_count", 10, my_newSVll (valout->val[i].snap_count), 0);
462         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (valout->val[i].vg_seqno), 0);
463         (void) hv_store (hv, "vg_tags", 7, newSVpv (valout->val[i].vg_tags, 0), 0);
464         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (valout->val[i].vg_mda_count), 0);
465         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (valout->val[i].vg_mda_free), 0);
466         PUSHs (sv_2mortal ((SV *) hv));
467       }
468       guestfs_free_lvm_vg_list (valout);
469
470 void
471 test0rlvlist (g, val)
472       guestfs_h *g;
473       char *val;
474 PREINIT:
475       struct guestfs_lvm_lv_list *valout;
476       int i;
477       HV *hv;
478  PPCODE:
479       valout = guestfs_test0rlvlist (g, val);
480       if (valout == NULL)
481         croak ("test0rlvlist: %s", guestfs_last_error (g));
482       EXTEND (SP, valout->len);
483       for (i = 0; i < valout->len; ++i) {
484         hv = newHV ();
485         (void) hv_store (hv, "lv_name", 7, newSVpv (valout->val[i].lv_name, 0), 0);
486         (void) hv_store (hv, "lv_uuid", 7, newSVpv (valout->val[i].lv_uuid, 32), 0);
487         (void) hv_store (hv, "lv_attr", 7, newSVpv (valout->val[i].lv_attr, 0), 0);
488         (void) hv_store (hv, "lv_major", 8, my_newSVll (valout->val[i].lv_major), 0);
489         (void) hv_store (hv, "lv_minor", 8, my_newSVll (valout->val[i].lv_minor), 0);
490         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (valout->val[i].lv_kernel_major), 0);
491         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (valout->val[i].lv_kernel_minor), 0);
492         (void) hv_store (hv, "lv_size", 7, my_newSVull (valout->val[i].lv_size), 0);
493         (void) hv_store (hv, "seg_count", 9, my_newSVll (valout->val[i].seg_count), 0);
494         (void) hv_store (hv, "origin", 6, newSVpv (valout->val[i].origin, 0), 0);
495         (void) hv_store (hv, "snap_percent", 12, newSVnv (valout->val[i].snap_percent), 0);
496         (void) hv_store (hv, "copy_percent", 12, newSVnv (valout->val[i].copy_percent), 0);
497         (void) hv_store (hv, "move_pv", 7, newSVpv (valout->val[i].move_pv, 0), 0);
498         (void) hv_store (hv, "lv_tags", 7, newSVpv (valout->val[i].lv_tags, 0), 0);
499         (void) hv_store (hv, "mirror_log", 10, newSVpv (valout->val[i].mirror_log, 0), 0);
500         (void) hv_store (hv, "modules", 7, newSVpv (valout->val[i].modules, 0), 0);
501         PUSHs (sv_2mortal ((SV *) hv));
502       }
503       guestfs_free_lvm_lv_list (valout);
504
505 void
506 test0rlvlisterr (g)
507       guestfs_h *g;
508 PREINIT:
509       struct guestfs_lvm_lv_list *valout;
510       int i;
511       HV *hv;
512  PPCODE:
513       valout = guestfs_test0rlvlisterr (g);
514       if (valout == NULL)
515         croak ("test0rlvlisterr: %s", guestfs_last_error (g));
516       EXTEND (SP, valout->len);
517       for (i = 0; i < valout->len; ++i) {
518         hv = newHV ();
519         (void) hv_store (hv, "lv_name", 7, newSVpv (valout->val[i].lv_name, 0), 0);
520         (void) hv_store (hv, "lv_uuid", 7, newSVpv (valout->val[i].lv_uuid, 32), 0);
521         (void) hv_store (hv, "lv_attr", 7, newSVpv (valout->val[i].lv_attr, 0), 0);
522         (void) hv_store (hv, "lv_major", 8, my_newSVll (valout->val[i].lv_major), 0);
523         (void) hv_store (hv, "lv_minor", 8, my_newSVll (valout->val[i].lv_minor), 0);
524         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (valout->val[i].lv_kernel_major), 0);
525         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (valout->val[i].lv_kernel_minor), 0);
526         (void) hv_store (hv, "lv_size", 7, my_newSVull (valout->val[i].lv_size), 0);
527         (void) hv_store (hv, "seg_count", 9, my_newSVll (valout->val[i].seg_count), 0);
528         (void) hv_store (hv, "origin", 6, newSVpv (valout->val[i].origin, 0), 0);
529         (void) hv_store (hv, "snap_percent", 12, newSVnv (valout->val[i].snap_percent), 0);
530         (void) hv_store (hv, "copy_percent", 12, newSVnv (valout->val[i].copy_percent), 0);
531         (void) hv_store (hv, "move_pv", 7, newSVpv (valout->val[i].move_pv, 0), 0);
532         (void) hv_store (hv, "lv_tags", 7, newSVpv (valout->val[i].lv_tags, 0), 0);
533         (void) hv_store (hv, "mirror_log", 10, newSVpv (valout->val[i].mirror_log, 0), 0);
534         (void) hv_store (hv, "modules", 7, newSVpv (valout->val[i].modules, 0), 0);
535         PUSHs (sv_2mortal ((SV *) hv));
536       }
537       guestfs_free_lvm_lv_list (valout);
538
539 void
540 test0rstat (g, val)
541       guestfs_h *g;
542       char *val;
543 PREINIT:
544       struct guestfs_stat *valout;
545  PPCODE:
546       valout = guestfs_test0rstat (g, val);
547       if (valout == NULL)
548         croak ("test0rstat: %s", guestfs_last_error (g));
549       EXTEND (SP, 13);
550       PUSHs (sv_2mortal (my_newSVll (valout->dev)));
551       PUSHs (sv_2mortal (my_newSVll (valout->ino)));
552       PUSHs (sv_2mortal (my_newSVll (valout->mode)));
553       PUSHs (sv_2mortal (my_newSVll (valout->nlink)));
554       PUSHs (sv_2mortal (my_newSVll (valout->uid)));
555       PUSHs (sv_2mortal (my_newSVll (valout->gid)));
556       PUSHs (sv_2mortal (my_newSVll (valout->rdev)));
557       PUSHs (sv_2mortal (my_newSVll (valout->size)));
558       PUSHs (sv_2mortal (my_newSVll (valout->blksize)));
559       PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
560       PUSHs (sv_2mortal (my_newSVll (valout->atime)));
561       PUSHs (sv_2mortal (my_newSVll (valout->mtime)));
562       PUSHs (sv_2mortal (my_newSVll (valout->ctime)));
563       free (valout);
564
565 void
566 test0rstaterr (g)
567       guestfs_h *g;
568 PREINIT:
569       struct guestfs_stat *valout;
570  PPCODE:
571       valout = guestfs_test0rstaterr (g);
572       if (valout == NULL)
573         croak ("test0rstaterr: %s", guestfs_last_error (g));
574       EXTEND (SP, 13);
575       PUSHs (sv_2mortal (my_newSVll (valout->dev)));
576       PUSHs (sv_2mortal (my_newSVll (valout->ino)));
577       PUSHs (sv_2mortal (my_newSVll (valout->mode)));
578       PUSHs (sv_2mortal (my_newSVll (valout->nlink)));
579       PUSHs (sv_2mortal (my_newSVll (valout->uid)));
580       PUSHs (sv_2mortal (my_newSVll (valout->gid)));
581       PUSHs (sv_2mortal (my_newSVll (valout->rdev)));
582       PUSHs (sv_2mortal (my_newSVll (valout->size)));
583       PUSHs (sv_2mortal (my_newSVll (valout->blksize)));
584       PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
585       PUSHs (sv_2mortal (my_newSVll (valout->atime)));
586       PUSHs (sv_2mortal (my_newSVll (valout->mtime)));
587       PUSHs (sv_2mortal (my_newSVll (valout->ctime)));
588       free (valout);
589
590 void
591 test0rstatvfs (g, val)
592       guestfs_h *g;
593       char *val;
594 PREINIT:
595       struct guestfs_statvfs *valout;
596  PPCODE:
597       valout = guestfs_test0rstatvfs (g, val);
598       if (valout == NULL)
599         croak ("test0rstatvfs: %s", guestfs_last_error (g));
600       EXTEND (SP, 11);
601       PUSHs (sv_2mortal (my_newSVll (valout->bsize)));
602       PUSHs (sv_2mortal (my_newSVll (valout->frsize)));
603       PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
604       PUSHs (sv_2mortal (my_newSVll (valout->bfree)));
605       PUSHs (sv_2mortal (my_newSVll (valout->bavail)));
606       PUSHs (sv_2mortal (my_newSVll (valout->files)));
607       PUSHs (sv_2mortal (my_newSVll (valout->ffree)));
608       PUSHs (sv_2mortal (my_newSVll (valout->favail)));
609       PUSHs (sv_2mortal (my_newSVll (valout->fsid)));
610       PUSHs (sv_2mortal (my_newSVll (valout->flag)));
611       PUSHs (sv_2mortal (my_newSVll (valout->namemax)));
612       free (valout);
613
614 void
615 test0rstatvfserr (g)
616       guestfs_h *g;
617 PREINIT:
618       struct guestfs_statvfs *valout;
619  PPCODE:
620       valout = guestfs_test0rstatvfserr (g);
621       if (valout == NULL)
622         croak ("test0rstatvfserr: %s", guestfs_last_error (g));
623       EXTEND (SP, 11);
624       PUSHs (sv_2mortal (my_newSVll (valout->bsize)));
625       PUSHs (sv_2mortal (my_newSVll (valout->frsize)));
626       PUSHs (sv_2mortal (my_newSVll (valout->blocks)));
627       PUSHs (sv_2mortal (my_newSVll (valout->bfree)));
628       PUSHs (sv_2mortal (my_newSVll (valout->bavail)));
629       PUSHs (sv_2mortal (my_newSVll (valout->files)));
630       PUSHs (sv_2mortal (my_newSVll (valout->ffree)));
631       PUSHs (sv_2mortal (my_newSVll (valout->favail)));
632       PUSHs (sv_2mortal (my_newSVll (valout->fsid)));
633       PUSHs (sv_2mortal (my_newSVll (valout->flag)));
634       PUSHs (sv_2mortal (my_newSVll (valout->namemax)));
635       free (valout);
636
637 void
638 test0rhashtable (g, val)
639       guestfs_h *g;
640       char *val;
641 PREINIT:
642       char **valout;
643       int i, n;
644  PPCODE:
645       valout = guestfs_test0rhashtable (g, val);
646       if (valout == NULL)
647         croak ("test0rhashtable: %s", guestfs_last_error (g));
648       for (n = 0; valout[n] != NULL; ++n) /**/;
649       EXTEND (SP, n);
650       for (i = 0; i < n; ++i) {
651         PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
652         free (valout[i]);
653       }
654       free (valout);
655
656 void
657 test0rhashtableerr (g)
658       guestfs_h *g;
659 PREINIT:
660       char **valout;
661       int i, n;
662  PPCODE:
663       valout = guestfs_test0rhashtableerr (g);
664       if (valout == NULL)
665         croak ("test0rhashtableerr: %s", guestfs_last_error (g));
666       for (n = 0; valout[n] != NULL; ++n) /**/;
667       EXTEND (SP, n);
668       for (i = 0; i < n; ++i) {
669         PUSHs (sv_2mortal (newSVpv (valout[i], 0)));
670         free (valout[i]);
671       }
672       free (valout);
673
674 void
675 launch (g)
676       guestfs_h *g;
677 PREINIT:
678       int r;
679  PPCODE:
680       r = guestfs_launch (g);
681       if (r == -1)
682         croak ("launch: %s", guestfs_last_error (g));
683
684 void
685 wait_ready (g)
686       guestfs_h *g;
687 PREINIT:
688       int r;
689  PPCODE:
690       r = guestfs_wait_ready (g);
691       if (r == -1)
692         croak ("wait_ready: %s", guestfs_last_error (g));
693
694 void
695 kill_subprocess (g)
696       guestfs_h *g;
697 PREINIT:
698       int r;
699  PPCODE:
700       r = guestfs_kill_subprocess (g);
701       if (r == -1)
702         croak ("kill_subprocess: %s", guestfs_last_error (g));
703
704 void
705 add_drive (g, filename)
706       guestfs_h *g;
707       char *filename;
708 PREINIT:
709       int r;
710  PPCODE:
711       r = guestfs_add_drive (g, filename);
712       if (r == -1)
713         croak ("add_drive: %s", guestfs_last_error (g));
714
715 void
716 add_cdrom (g, filename)
717       guestfs_h *g;
718       char *filename;
719 PREINIT:
720       int r;
721  PPCODE:
722       r = guestfs_add_cdrom (g, filename);
723       if (r == -1)
724         croak ("add_cdrom: %s", guestfs_last_error (g));
725
726 void
727 add_drive_ro (g, filename)
728       guestfs_h *g;
729       char *filename;
730 PREINIT:
731       int r;
732  PPCODE:
733       r = guestfs_add_drive_ro (g, filename);
734       if (r == -1)
735         croak ("add_drive_ro: %s", guestfs_last_error (g));
736
737 void
738 config (g, qemuparam, qemuvalue)
739       guestfs_h *g;
740       char *qemuparam;
741       char *qemuvalue = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
742 PREINIT:
743       int r;
744  PPCODE:
745       r = guestfs_config (g, qemuparam, qemuvalue);
746       if (r == -1)
747         croak ("config: %s", guestfs_last_error (g));
748
749 void
750 set_qemu (g, qemu)
751       guestfs_h *g;
752       char *qemu;
753 PREINIT:
754       int r;
755  PPCODE:
756       r = guestfs_set_qemu (g, qemu);
757       if (r == -1)
758         croak ("set_qemu: %s", guestfs_last_error (g));
759
760 SV *
761 get_qemu (g)
762       guestfs_h *g;
763 PREINIT:
764       const char *qemu;
765    CODE:
766       qemu = guestfs_get_qemu (g);
767       if (qemu == NULL)
768         croak ("get_qemu: %s", guestfs_last_error (g));
769       RETVAL = newSVpv (qemu, 0);
770  OUTPUT:
771       RETVAL
772
773 void
774 set_path (g, path)
775       guestfs_h *g;
776       char *path;
777 PREINIT:
778       int r;
779  PPCODE:
780       r = guestfs_set_path (g, path);
781       if (r == -1)
782         croak ("set_path: %s", guestfs_last_error (g));
783
784 SV *
785 get_path (g)
786       guestfs_h *g;
787 PREINIT:
788       const char *path;
789    CODE:
790       path = guestfs_get_path (g);
791       if (path == NULL)
792         croak ("get_path: %s", guestfs_last_error (g));
793       RETVAL = newSVpv (path, 0);
794  OUTPUT:
795       RETVAL
796
797 void
798 set_append (g, append)
799       guestfs_h *g;
800       char *append;
801 PREINIT:
802       int r;
803  PPCODE:
804       r = guestfs_set_append (g, append);
805       if (r == -1)
806         croak ("set_append: %s", guestfs_last_error (g));
807
808 SV *
809 get_append (g)
810       guestfs_h *g;
811 PREINIT:
812       const char *append;
813    CODE:
814       append = guestfs_get_append (g);
815       if (append == NULL)
816         croak ("get_append: %s", guestfs_last_error (g));
817       RETVAL = newSVpv (append, 0);
818  OUTPUT:
819       RETVAL
820
821 void
822 set_autosync (g, autosync)
823       guestfs_h *g;
824       int autosync;
825 PREINIT:
826       int r;
827  PPCODE:
828       r = guestfs_set_autosync (g, autosync);
829       if (r == -1)
830         croak ("set_autosync: %s", guestfs_last_error (g));
831
832 SV *
833 get_autosync (g)
834       guestfs_h *g;
835 PREINIT:
836       int autosync;
837    CODE:
838       autosync = guestfs_get_autosync (g);
839       if (autosync == -1)
840         croak ("get_autosync: %s", guestfs_last_error (g));
841       RETVAL = newSViv (autosync);
842  OUTPUT:
843       RETVAL
844
845 void
846 set_verbose (g, verbose)
847       guestfs_h *g;
848       int verbose;
849 PREINIT:
850       int r;
851  PPCODE:
852       r = guestfs_set_verbose (g, verbose);
853       if (r == -1)
854         croak ("set_verbose: %s", guestfs_last_error (g));
855
856 SV *
857 get_verbose (g)
858       guestfs_h *g;
859 PREINIT:
860       int verbose;
861    CODE:
862       verbose = guestfs_get_verbose (g);
863       if (verbose == -1)
864         croak ("get_verbose: %s", guestfs_last_error (g));
865       RETVAL = newSViv (verbose);
866  OUTPUT:
867       RETVAL
868
869 SV *
870 is_ready (g)
871       guestfs_h *g;
872 PREINIT:
873       int ready;
874    CODE:
875       ready = guestfs_is_ready (g);
876       if (ready == -1)
877         croak ("is_ready: %s", guestfs_last_error (g));
878       RETVAL = newSViv (ready);
879  OUTPUT:
880       RETVAL
881
882 SV *
883 is_config (g)
884       guestfs_h *g;
885 PREINIT:
886       int config;
887    CODE:
888       config = guestfs_is_config (g);
889       if (config == -1)
890         croak ("is_config: %s", guestfs_last_error (g));
891       RETVAL = newSViv (config);
892  OUTPUT:
893       RETVAL
894
895 SV *
896 is_launching (g)
897       guestfs_h *g;
898 PREINIT:
899       int launching;
900    CODE:
901       launching = guestfs_is_launching (g);
902       if (launching == -1)
903         croak ("is_launching: %s", guestfs_last_error (g));
904       RETVAL = newSViv (launching);
905  OUTPUT:
906       RETVAL
907
908 SV *
909 is_busy (g)
910       guestfs_h *g;
911 PREINIT:
912       int busy;
913    CODE:
914       busy = guestfs_is_busy (g);
915       if (busy == -1)
916         croak ("is_busy: %s", guestfs_last_error (g));
917       RETVAL = newSViv (busy);
918  OUTPUT:
919       RETVAL
920
921 SV *
922 get_state (g)
923       guestfs_h *g;
924 PREINIT:
925       int state;
926    CODE:
927       state = guestfs_get_state (g);
928       if (state == -1)
929         croak ("get_state: %s", guestfs_last_error (g));
930       RETVAL = newSViv (state);
931  OUTPUT:
932       RETVAL
933
934 void
935 set_busy (g)
936       guestfs_h *g;
937 PREINIT:
938       int r;
939  PPCODE:
940       r = guestfs_set_busy (g);
941       if (r == -1)
942         croak ("set_busy: %s", guestfs_last_error (g));
943
944 void
945 set_ready (g)
946       guestfs_h *g;
947 PREINIT:
948       int r;
949  PPCODE:
950       r = guestfs_set_ready (g);
951       if (r == -1)
952         croak ("set_ready: %s", guestfs_last_error (g));
953
954 void
955 end_busy (g)
956       guestfs_h *g;
957 PREINIT:
958       int r;
959  PPCODE:
960       r = guestfs_end_busy (g);
961       if (r == -1)
962         croak ("end_busy: %s", guestfs_last_error (g));
963
964 void
965 mount (g, device, mountpoint)
966       guestfs_h *g;
967       char *device;
968       char *mountpoint;
969 PREINIT:
970       int r;
971  PPCODE:
972       r = guestfs_mount (g, device, mountpoint);
973       if (r == -1)
974         croak ("mount: %s", guestfs_last_error (g));
975
976 void
977 sync (g)
978       guestfs_h *g;
979 PREINIT:
980       int r;
981  PPCODE:
982       r = guestfs_sync (g);
983       if (r == -1)
984         croak ("sync: %s", guestfs_last_error (g));
985
986 void
987 touch (g, path)
988       guestfs_h *g;
989       char *path;
990 PREINIT:
991       int r;
992  PPCODE:
993       r = guestfs_touch (g, path);
994       if (r == -1)
995         croak ("touch: %s", guestfs_last_error (g));
996
997 SV *
998 cat (g, path)
999       guestfs_h *g;
1000       char *path;
1001 PREINIT:
1002       char *content;
1003    CODE:
1004       content = guestfs_cat (g, path);
1005       if (content == NULL)
1006         croak ("cat: %s", guestfs_last_error (g));
1007       RETVAL = newSVpv (content, 0);
1008       free (content);
1009  OUTPUT:
1010       RETVAL
1011
1012 SV *
1013 ll (g, directory)
1014       guestfs_h *g;
1015       char *directory;
1016 PREINIT:
1017       char *listing;
1018    CODE:
1019       listing = guestfs_ll (g, directory);
1020       if (listing == NULL)
1021         croak ("ll: %s", guestfs_last_error (g));
1022       RETVAL = newSVpv (listing, 0);
1023       free (listing);
1024  OUTPUT:
1025       RETVAL
1026
1027 void
1028 ls (g, directory)
1029       guestfs_h *g;
1030       char *directory;
1031 PREINIT:
1032       char **listing;
1033       int i, n;
1034  PPCODE:
1035       listing = guestfs_ls (g, directory);
1036       if (listing == NULL)
1037         croak ("ls: %s", guestfs_last_error (g));
1038       for (n = 0; listing[n] != NULL; ++n) /**/;
1039       EXTEND (SP, n);
1040       for (i = 0; i < n; ++i) {
1041         PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
1042         free (listing[i]);
1043       }
1044       free (listing);
1045
1046 void
1047 list_devices (g)
1048       guestfs_h *g;
1049 PREINIT:
1050       char **devices;
1051       int i, n;
1052  PPCODE:
1053       devices = guestfs_list_devices (g);
1054       if (devices == NULL)
1055         croak ("list_devices: %s", guestfs_last_error (g));
1056       for (n = 0; devices[n] != NULL; ++n) /**/;
1057       EXTEND (SP, n);
1058       for (i = 0; i < n; ++i) {
1059         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1060         free (devices[i]);
1061       }
1062       free (devices);
1063
1064 void
1065 list_partitions (g)
1066       guestfs_h *g;
1067 PREINIT:
1068       char **partitions;
1069       int i, n;
1070  PPCODE:
1071       partitions = guestfs_list_partitions (g);
1072       if (partitions == NULL)
1073         croak ("list_partitions: %s", guestfs_last_error (g));
1074       for (n = 0; partitions[n] != NULL; ++n) /**/;
1075       EXTEND (SP, n);
1076       for (i = 0; i < n; ++i) {
1077         PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
1078         free (partitions[i]);
1079       }
1080       free (partitions);
1081
1082 void
1083 pvs (g)
1084       guestfs_h *g;
1085 PREINIT:
1086       char **physvols;
1087       int i, n;
1088  PPCODE:
1089       physvols = guestfs_pvs (g);
1090       if (physvols == NULL)
1091         croak ("pvs: %s", guestfs_last_error (g));
1092       for (n = 0; physvols[n] != NULL; ++n) /**/;
1093       EXTEND (SP, n);
1094       for (i = 0; i < n; ++i) {
1095         PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
1096         free (physvols[i]);
1097       }
1098       free (physvols);
1099
1100 void
1101 vgs (g)
1102       guestfs_h *g;
1103 PREINIT:
1104       char **volgroups;
1105       int i, n;
1106  PPCODE:
1107       volgroups = guestfs_vgs (g);
1108       if (volgroups == NULL)
1109         croak ("vgs: %s", guestfs_last_error (g));
1110       for (n = 0; volgroups[n] != NULL; ++n) /**/;
1111       EXTEND (SP, n);
1112       for (i = 0; i < n; ++i) {
1113         PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
1114         free (volgroups[i]);
1115       }
1116       free (volgroups);
1117
1118 void
1119 lvs (g)
1120       guestfs_h *g;
1121 PREINIT:
1122       char **logvols;
1123       int i, n;
1124  PPCODE:
1125       logvols = guestfs_lvs (g);
1126       if (logvols == NULL)
1127         croak ("lvs: %s", guestfs_last_error (g));
1128       for (n = 0; logvols[n] != NULL; ++n) /**/;
1129       EXTEND (SP, n);
1130       for (i = 0; i < n; ++i) {
1131         PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
1132         free (logvols[i]);
1133       }
1134       free (logvols);
1135
1136 void
1137 pvs_full (g)
1138       guestfs_h *g;
1139 PREINIT:
1140       struct guestfs_lvm_pv_list *physvols;
1141       int i;
1142       HV *hv;
1143  PPCODE:
1144       physvols = guestfs_pvs_full (g);
1145       if (physvols == NULL)
1146         croak ("pvs_full: %s", guestfs_last_error (g));
1147       EXTEND (SP, physvols->len);
1148       for (i = 0; i < physvols->len; ++i) {
1149         hv = newHV ();
1150         (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
1151         (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
1152         (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
1153         (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
1154         (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
1155         (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
1156         (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
1157         (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
1158         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
1159         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
1160         (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
1161         (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
1162         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
1163         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
1164         PUSHs (sv_2mortal ((SV *) hv));
1165       }
1166       guestfs_free_lvm_pv_list (physvols);
1167
1168 void
1169 vgs_full (g)
1170       guestfs_h *g;
1171 PREINIT:
1172       struct guestfs_lvm_vg_list *volgroups;
1173       int i;
1174       HV *hv;
1175  PPCODE:
1176       volgroups = guestfs_vgs_full (g);
1177       if (volgroups == NULL)
1178         croak ("vgs_full: %s", guestfs_last_error (g));
1179       EXTEND (SP, volgroups->len);
1180       for (i = 0; i < volgroups->len; ++i) {
1181         hv = newHV ();
1182         (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
1183         (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
1184         (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
1185         (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
1186         (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
1187         (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
1188         (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
1189         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
1190         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
1191         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
1192         (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
1193         (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
1194         (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
1195         (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
1196         (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
1197         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
1198         (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
1199         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
1200         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
1201         PUSHs (sv_2mortal ((SV *) hv));
1202       }
1203       guestfs_free_lvm_vg_list (volgroups);
1204
1205 void
1206 lvs_full (g)
1207       guestfs_h *g;
1208 PREINIT:
1209       struct guestfs_lvm_lv_list *logvols;
1210       int i;
1211       HV *hv;
1212  PPCODE:
1213       logvols = guestfs_lvs_full (g);
1214       if (logvols == NULL)
1215         croak ("lvs_full: %s", guestfs_last_error (g));
1216       EXTEND (SP, logvols->len);
1217       for (i = 0; i < logvols->len; ++i) {
1218         hv = newHV ();
1219         (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
1220         (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
1221         (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
1222         (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
1223         (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
1224         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
1225         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
1226         (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
1227         (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
1228         (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
1229         (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
1230         (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
1231         (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
1232         (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
1233         (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
1234         (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
1235         PUSHs (sv_2mortal ((SV *) hv));
1236       }
1237       guestfs_free_lvm_lv_list (logvols);
1238
1239 void
1240 read_lines (g, path)
1241       guestfs_h *g;
1242       char *path;
1243 PREINIT:
1244       char **lines;
1245       int i, n;
1246  PPCODE:
1247       lines = guestfs_read_lines (g, path);
1248       if (lines == NULL)
1249         croak ("read_lines: %s", guestfs_last_error (g));
1250       for (n = 0; lines[n] != NULL; ++n) /**/;
1251       EXTEND (SP, n);
1252       for (i = 0; i < n; ++i) {
1253         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1254         free (lines[i]);
1255       }
1256       free (lines);
1257
1258 void
1259 aug_init (g, root, flags)
1260       guestfs_h *g;
1261       char *root;
1262       int flags;
1263 PREINIT:
1264       int r;
1265  PPCODE:
1266       r = guestfs_aug_init (g, root, flags);
1267       if (r == -1)
1268         croak ("aug_init: %s", guestfs_last_error (g));
1269
1270 void
1271 aug_close (g)
1272       guestfs_h *g;
1273 PREINIT:
1274       int r;
1275  PPCODE:
1276       r = guestfs_aug_close (g);
1277       if (r == -1)
1278         croak ("aug_close: %s", guestfs_last_error (g));
1279
1280 SV *
1281 aug_defvar (g, name, expr)
1282       guestfs_h *g;
1283       char *name;
1284       char *expr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
1285 PREINIT:
1286       int nrnodes;
1287    CODE:
1288       nrnodes = guestfs_aug_defvar (g, name, expr);
1289       if (nrnodes == -1)
1290         croak ("aug_defvar: %s", guestfs_last_error (g));
1291       RETVAL = newSViv (nrnodes);
1292  OUTPUT:
1293       RETVAL
1294
1295 void
1296 aug_defnode (g, name, expr, val)
1297       guestfs_h *g;
1298       char *name;
1299       char *expr;
1300       char *val;
1301 PREINIT:
1302       struct guestfs_int_bool *r;
1303  PPCODE:
1304       r = guestfs_aug_defnode (g, name, expr, val);
1305       if (r == NULL)
1306         croak ("aug_defnode: %s", guestfs_last_error (g));
1307       EXTEND (SP, 2);
1308       PUSHs (sv_2mortal (newSViv (r->i)));
1309       PUSHs (sv_2mortal (newSViv (r->b)));
1310       guestfs_free_int_bool (r);
1311
1312 SV *
1313 aug_get (g, path)
1314       guestfs_h *g;
1315       char *path;
1316 PREINIT:
1317       char *val;
1318    CODE:
1319       val = guestfs_aug_get (g, path);
1320       if (val == NULL)
1321         croak ("aug_get: %s", guestfs_last_error (g));
1322       RETVAL = newSVpv (val, 0);
1323       free (val);
1324  OUTPUT:
1325       RETVAL
1326
1327 void
1328 aug_set (g, path, val)
1329       guestfs_h *g;
1330       char *path;
1331       char *val;
1332 PREINIT:
1333       int r;
1334  PPCODE:
1335       r = guestfs_aug_set (g, path, val);
1336       if (r == -1)
1337         croak ("aug_set: %s", guestfs_last_error (g));
1338
1339 void
1340 aug_insert (g, path, label, before)
1341       guestfs_h *g;
1342       char *path;
1343       char *label;
1344       int before;
1345 PREINIT:
1346       int r;
1347  PPCODE:
1348       r = guestfs_aug_insert (g, path, label, before);
1349       if (r == -1)
1350         croak ("aug_insert: %s", guestfs_last_error (g));
1351
1352 SV *
1353 aug_rm (g, path)
1354       guestfs_h *g;
1355       char *path;
1356 PREINIT:
1357       int nrnodes;
1358    CODE:
1359       nrnodes = guestfs_aug_rm (g, path);
1360       if (nrnodes == -1)
1361         croak ("aug_rm: %s", guestfs_last_error (g));
1362       RETVAL = newSViv (nrnodes);
1363  OUTPUT:
1364       RETVAL
1365
1366 void
1367 aug_mv (g, src, dest)
1368       guestfs_h *g;
1369       char *src;
1370       char *dest;
1371 PREINIT:
1372       int r;
1373  PPCODE:
1374       r = guestfs_aug_mv (g, src, dest);
1375       if (r == -1)
1376         croak ("aug_mv: %s", guestfs_last_error (g));
1377
1378 void
1379 aug_match (g, path)
1380       guestfs_h *g;
1381       char *path;
1382 PREINIT:
1383       char **matches;
1384       int i, n;
1385  PPCODE:
1386       matches = guestfs_aug_match (g, path);
1387       if (matches == NULL)
1388         croak ("aug_match: %s", guestfs_last_error (g));
1389       for (n = 0; matches[n] != NULL; ++n) /**/;
1390       EXTEND (SP, n);
1391       for (i = 0; i < n; ++i) {
1392         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
1393         free (matches[i]);
1394       }
1395       free (matches);
1396
1397 void
1398 aug_save (g)
1399       guestfs_h *g;
1400 PREINIT:
1401       int r;
1402  PPCODE:
1403       r = guestfs_aug_save (g);
1404       if (r == -1)
1405         croak ("aug_save: %s", guestfs_last_error (g));
1406
1407 void
1408 aug_load (g)
1409       guestfs_h *g;
1410 PREINIT:
1411       int r;
1412  PPCODE:
1413       r = guestfs_aug_load (g);
1414       if (r == -1)
1415         croak ("aug_load: %s", guestfs_last_error (g));
1416
1417 void
1418 aug_ls (g, path)
1419       guestfs_h *g;
1420       char *path;
1421 PREINIT:
1422       char **matches;
1423       int i, n;
1424  PPCODE:
1425       matches = guestfs_aug_ls (g, path);
1426       if (matches == NULL)
1427         croak ("aug_ls: %s", guestfs_last_error (g));
1428       for (n = 0; matches[n] != NULL; ++n) /**/;
1429       EXTEND (SP, n);
1430       for (i = 0; i < n; ++i) {
1431         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
1432         free (matches[i]);
1433       }
1434       free (matches);
1435
1436 void
1437 rm (g, path)
1438       guestfs_h *g;
1439       char *path;
1440 PREINIT:
1441       int r;
1442  PPCODE:
1443       r = guestfs_rm (g, path);
1444       if (r == -1)
1445         croak ("rm: %s", guestfs_last_error (g));
1446
1447 void
1448 rmdir (g, path)
1449       guestfs_h *g;
1450       char *path;
1451 PREINIT:
1452       int r;
1453  PPCODE:
1454       r = guestfs_rmdir (g, path);
1455       if (r == -1)
1456         croak ("rmdir: %s", guestfs_last_error (g));
1457
1458 void
1459 rm_rf (g, path)
1460       guestfs_h *g;
1461       char *path;
1462 PREINIT:
1463       int r;
1464  PPCODE:
1465       r = guestfs_rm_rf (g, path);
1466       if (r == -1)
1467         croak ("rm_rf: %s", guestfs_last_error (g));
1468
1469 void
1470 mkdir (g, path)
1471       guestfs_h *g;
1472       char *path;
1473 PREINIT:
1474       int r;
1475  PPCODE:
1476       r = guestfs_mkdir (g, path);
1477       if (r == -1)
1478         croak ("mkdir: %s", guestfs_last_error (g));
1479
1480 void
1481 mkdir_p (g, path)
1482       guestfs_h *g;
1483       char *path;
1484 PREINIT:
1485       int r;
1486  PPCODE:
1487       r = guestfs_mkdir_p (g, path);
1488       if (r == -1)
1489         croak ("mkdir_p: %s", guestfs_last_error (g));
1490
1491 void
1492 chmod (g, mode, path)
1493       guestfs_h *g;
1494       int mode;
1495       char *path;
1496 PREINIT:
1497       int r;
1498  PPCODE:
1499       r = guestfs_chmod (g, mode, path);
1500       if (r == -1)
1501         croak ("chmod: %s", guestfs_last_error (g));
1502
1503 void
1504 chown (g, owner, group, path)
1505       guestfs_h *g;
1506       int owner;
1507       int group;
1508       char *path;
1509 PREINIT:
1510       int r;
1511  PPCODE:
1512       r = guestfs_chown (g, owner, group, path);
1513       if (r == -1)
1514         croak ("chown: %s", guestfs_last_error (g));
1515
1516 SV *
1517 exists (g, path)
1518       guestfs_h *g;
1519       char *path;
1520 PREINIT:
1521       int existsflag;
1522    CODE:
1523       existsflag = guestfs_exists (g, path);
1524       if (existsflag == -1)
1525         croak ("exists: %s", guestfs_last_error (g));
1526       RETVAL = newSViv (existsflag);
1527  OUTPUT:
1528       RETVAL
1529
1530 SV *
1531 is_file (g, path)
1532       guestfs_h *g;
1533       char *path;
1534 PREINIT:
1535       int fileflag;
1536    CODE:
1537       fileflag = guestfs_is_file (g, path);
1538       if (fileflag == -1)
1539         croak ("is_file: %s", guestfs_last_error (g));
1540       RETVAL = newSViv (fileflag);
1541  OUTPUT:
1542       RETVAL
1543
1544 SV *
1545 is_dir (g, path)
1546       guestfs_h *g;
1547       char *path;
1548 PREINIT:
1549       int dirflag;
1550    CODE:
1551       dirflag = guestfs_is_dir (g, path);
1552       if (dirflag == -1)
1553         croak ("is_dir: %s", guestfs_last_error (g));
1554       RETVAL = newSViv (dirflag);
1555  OUTPUT:
1556       RETVAL
1557
1558 void
1559 pvcreate (g, device)
1560       guestfs_h *g;
1561       char *device;
1562 PREINIT:
1563       int r;
1564  PPCODE:
1565       r = guestfs_pvcreate (g, device);
1566       if (r == -1)
1567         croak ("pvcreate: %s", guestfs_last_error (g));
1568
1569 void
1570 vgcreate (g, volgroup, physvols)
1571       guestfs_h *g;
1572       char *volgroup;
1573       char **physvols;
1574 PREINIT:
1575       int r;
1576  PPCODE:
1577       r = guestfs_vgcreate (g, volgroup, physvols);
1578       free (physvols);
1579       if (r == -1)
1580         croak ("vgcreate: %s", guestfs_last_error (g));
1581
1582 void
1583 lvcreate (g, logvol, volgroup, mbytes)
1584       guestfs_h *g;
1585       char *logvol;
1586       char *volgroup;
1587       int mbytes;
1588 PREINIT:
1589       int r;
1590  PPCODE:
1591       r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
1592       if (r == -1)
1593         croak ("lvcreate: %s", guestfs_last_error (g));
1594
1595 void
1596 mkfs (g, fstype, device)
1597       guestfs_h *g;
1598       char *fstype;
1599       char *device;
1600 PREINIT:
1601       int r;
1602  PPCODE:
1603       r = guestfs_mkfs (g, fstype, device);
1604       if (r == -1)
1605         croak ("mkfs: %s", guestfs_last_error (g));
1606
1607 void
1608 sfdisk (g, device, cyls, heads, sectors, lines)
1609       guestfs_h *g;
1610       char *device;
1611       int cyls;
1612       int heads;
1613       int sectors;
1614       char **lines;
1615 PREINIT:
1616       int r;
1617  PPCODE:
1618       r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1619       free (lines);
1620       if (r == -1)
1621         croak ("sfdisk: %s", guestfs_last_error (g));
1622
1623 void
1624 write_file (g, path, content, size)
1625       guestfs_h *g;
1626       char *path;
1627       char *content;
1628       int size;
1629 PREINIT:
1630       int r;
1631  PPCODE:
1632       r = guestfs_write_file (g, path, content, size);
1633       if (r == -1)
1634         croak ("write_file: %s", guestfs_last_error (g));
1635
1636 void
1637 umount (g, pathordevice)
1638       guestfs_h *g;
1639       char *pathordevice;
1640 PREINIT:
1641       int r;
1642  PPCODE:
1643       r = guestfs_umount (g, pathordevice);
1644       if (r == -1)
1645         croak ("umount: %s", guestfs_last_error (g));
1646
1647 void
1648 mounts (g)
1649       guestfs_h *g;
1650 PREINIT:
1651       char **devices;
1652       int i, n;
1653  PPCODE:
1654       devices = guestfs_mounts (g);
1655       if (devices == NULL)
1656         croak ("mounts: %s", guestfs_last_error (g));
1657       for (n = 0; devices[n] != NULL; ++n) /**/;
1658       EXTEND (SP, n);
1659       for (i = 0; i < n; ++i) {
1660         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1661         free (devices[i]);
1662       }
1663       free (devices);
1664
1665 void
1666 umount_all (g)
1667       guestfs_h *g;
1668 PREINIT:
1669       int r;
1670  PPCODE:
1671       r = guestfs_umount_all (g);
1672       if (r == -1)
1673         croak ("umount_all: %s", guestfs_last_error (g));
1674
1675 void
1676 lvm_remove_all (g)
1677       guestfs_h *g;
1678 PREINIT:
1679       int r;
1680  PPCODE:
1681       r = guestfs_lvm_remove_all (g);
1682       if (r == -1)
1683         croak ("lvm_remove_all: %s", guestfs_last_error (g));
1684
1685 SV *
1686 file (g, path)
1687       guestfs_h *g;
1688       char *path;
1689 PREINIT:
1690       char *description;
1691    CODE:
1692       description = guestfs_file (g, path);
1693       if (description == NULL)
1694         croak ("file: %s", guestfs_last_error (g));
1695       RETVAL = newSVpv (description, 0);
1696       free (description);
1697  OUTPUT:
1698       RETVAL
1699
1700 SV *
1701 command (g, arguments)
1702       guestfs_h *g;
1703       char **arguments;
1704 PREINIT:
1705       char *output;
1706    CODE:
1707       output = guestfs_command (g, arguments);
1708       free (arguments);
1709       if (output == NULL)
1710         croak ("command: %s", guestfs_last_error (g));
1711       RETVAL = newSVpv (output, 0);
1712       free (output);
1713  OUTPUT:
1714       RETVAL
1715
1716 void
1717 command_lines (g, arguments)
1718       guestfs_h *g;
1719       char **arguments;
1720 PREINIT:
1721       char **lines;
1722       int i, n;
1723  PPCODE:
1724       lines = guestfs_command_lines (g, arguments);
1725       free (arguments);
1726       if (lines == NULL)
1727         croak ("command_lines: %s", guestfs_last_error (g));
1728       for (n = 0; lines[n] != NULL; ++n) /**/;
1729       EXTEND (SP, n);
1730       for (i = 0; i < n; ++i) {
1731         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1732         free (lines[i]);
1733       }
1734       free (lines);
1735
1736 void
1737 stat (g, path)
1738       guestfs_h *g;
1739       char *path;
1740 PREINIT:
1741       struct guestfs_stat *statbuf;
1742  PPCODE:
1743       statbuf = guestfs_stat (g, path);
1744       if (statbuf == NULL)
1745         croak ("stat: %s", guestfs_last_error (g));
1746       EXTEND (SP, 13);
1747       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1748       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1749       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1750       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1751       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1752       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1753       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1754       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1755       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1756       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1757       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1758       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1759       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1760       free (statbuf);
1761
1762 void
1763 lstat (g, path)
1764       guestfs_h *g;
1765       char *path;
1766 PREINIT:
1767       struct guestfs_stat *statbuf;
1768  PPCODE:
1769       statbuf = guestfs_lstat (g, path);
1770       if (statbuf == NULL)
1771         croak ("lstat: %s", guestfs_last_error (g));
1772       EXTEND (SP, 13);
1773       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1774       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1775       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1776       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1777       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1778       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1779       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1780       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1781       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1782       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1783       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1784       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1785       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1786       free (statbuf);
1787
1788 void
1789 statvfs (g, path)
1790       guestfs_h *g;
1791       char *path;
1792 PREINIT:
1793       struct guestfs_statvfs *statbuf;
1794  PPCODE:
1795       statbuf = guestfs_statvfs (g, path);
1796       if (statbuf == NULL)
1797         croak ("statvfs: %s", guestfs_last_error (g));
1798       EXTEND (SP, 11);
1799       PUSHs (sv_2mortal (my_newSVll (statbuf->bsize)));
1800       PUSHs (sv_2mortal (my_newSVll (statbuf->frsize)));
1801       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1802       PUSHs (sv_2mortal (my_newSVll (statbuf->bfree)));
1803       PUSHs (sv_2mortal (my_newSVll (statbuf->bavail)));
1804       PUSHs (sv_2mortal (my_newSVll (statbuf->files)));
1805       PUSHs (sv_2mortal (my_newSVll (statbuf->ffree)));
1806       PUSHs (sv_2mortal (my_newSVll (statbuf->favail)));
1807       PUSHs (sv_2mortal (my_newSVll (statbuf->fsid)));
1808       PUSHs (sv_2mortal (my_newSVll (statbuf->flag)));
1809       PUSHs (sv_2mortal (my_newSVll (statbuf->namemax)));
1810       free (statbuf);
1811
1812 void
1813 tune2fs_l (g, device)
1814       guestfs_h *g;
1815       char *device;
1816 PREINIT:
1817       char **superblock;
1818       int i, n;
1819  PPCODE:
1820       superblock = guestfs_tune2fs_l (g, device);
1821       if (superblock == NULL)
1822         croak ("tune2fs_l: %s", guestfs_last_error (g));
1823       for (n = 0; superblock[n] != NULL; ++n) /**/;
1824       EXTEND (SP, n);
1825       for (i = 0; i < n; ++i) {
1826         PUSHs (sv_2mortal (newSVpv (superblock[i], 0)));
1827         free (superblock[i]);
1828       }
1829       free (superblock);
1830
1831 void
1832 blockdev_setro (g, device)
1833       guestfs_h *g;
1834       char *device;
1835 PREINIT:
1836       int r;
1837  PPCODE:
1838       r = guestfs_blockdev_setro (g, device);
1839       if (r == -1)
1840         croak ("blockdev_setro: %s", guestfs_last_error (g));
1841
1842 void
1843 blockdev_setrw (g, device)
1844       guestfs_h *g;
1845       char *device;
1846 PREINIT:
1847       int r;
1848  PPCODE:
1849       r = guestfs_blockdev_setrw (g, device);
1850       if (r == -1)
1851         croak ("blockdev_setrw: %s", guestfs_last_error (g));
1852
1853 SV *
1854 blockdev_getro (g, device)
1855       guestfs_h *g;
1856       char *device;
1857 PREINIT:
1858       int ro;
1859    CODE:
1860       ro = guestfs_blockdev_getro (g, device);
1861       if (ro == -1)
1862         croak ("blockdev_getro: %s", guestfs_last_error (g));
1863       RETVAL = newSViv (ro);
1864  OUTPUT:
1865       RETVAL
1866
1867 SV *
1868 blockdev_getss (g, device)
1869       guestfs_h *g;
1870       char *device;
1871 PREINIT:
1872       int sectorsize;
1873    CODE:
1874       sectorsize = guestfs_blockdev_getss (g, device);
1875       if (sectorsize == -1)
1876         croak ("blockdev_getss: %s", guestfs_last_error (g));
1877       RETVAL = newSViv (sectorsize);
1878  OUTPUT:
1879       RETVAL
1880
1881 SV *
1882 blockdev_getbsz (g, device)
1883       guestfs_h *g;
1884       char *device;
1885 PREINIT:
1886       int blocksize;
1887    CODE:
1888       blocksize = guestfs_blockdev_getbsz (g, device);
1889       if (blocksize == -1)
1890         croak ("blockdev_getbsz: %s", guestfs_last_error (g));
1891       RETVAL = newSViv (blocksize);
1892  OUTPUT:
1893       RETVAL
1894
1895 void
1896 blockdev_setbsz (g, device, blocksize)
1897       guestfs_h *g;
1898       char *device;
1899       int blocksize;
1900 PREINIT:
1901       int r;
1902  PPCODE:
1903       r = guestfs_blockdev_setbsz (g, device, blocksize);
1904       if (r == -1)
1905         croak ("blockdev_setbsz: %s", guestfs_last_error (g));
1906
1907 SV *
1908 blockdev_getsz (g, device)
1909       guestfs_h *g;
1910       char *device;
1911 PREINIT:
1912       int64_t sizeinsectors;
1913    CODE:
1914       sizeinsectors = guestfs_blockdev_getsz (g, device);
1915       if (sizeinsectors == -1)
1916         croak ("blockdev_getsz: %s", guestfs_last_error (g));
1917       RETVAL = my_newSVll (sizeinsectors);
1918  OUTPUT:
1919       RETVAL
1920
1921 SV *
1922 blockdev_getsize64 (g, device)
1923       guestfs_h *g;
1924       char *device;
1925 PREINIT:
1926       int64_t sizeinbytes;
1927    CODE:
1928       sizeinbytes = guestfs_blockdev_getsize64 (g, device);
1929       if (sizeinbytes == -1)
1930         croak ("blockdev_getsize64: %s", guestfs_last_error (g));
1931       RETVAL = my_newSVll (sizeinbytes);
1932  OUTPUT:
1933       RETVAL
1934
1935 void
1936 blockdev_flushbufs (g, device)
1937       guestfs_h *g;
1938       char *device;
1939 PREINIT:
1940       int r;
1941  PPCODE:
1942       r = guestfs_blockdev_flushbufs (g, device);
1943       if (r == -1)
1944         croak ("blockdev_flushbufs: %s", guestfs_last_error (g));
1945
1946 void
1947 blockdev_rereadpt (g, device)
1948       guestfs_h *g;
1949       char *device;
1950 PREINIT:
1951       int r;
1952  PPCODE:
1953       r = guestfs_blockdev_rereadpt (g, device);
1954       if (r == -1)
1955         croak ("blockdev_rereadpt: %s", guestfs_last_error (g));
1956
1957 void
1958 upload (g, filename, remotefilename)
1959       guestfs_h *g;
1960       char *filename;
1961       char *remotefilename;
1962 PREINIT:
1963       int r;
1964  PPCODE:
1965       r = guestfs_upload (g, filename, remotefilename);
1966       if (r == -1)
1967         croak ("upload: %s", guestfs_last_error (g));
1968
1969 void
1970 download (g, remotefilename, filename)
1971       guestfs_h *g;
1972       char *remotefilename;
1973       char *filename;
1974 PREINIT:
1975       int r;
1976  PPCODE:
1977       r = guestfs_download (g, remotefilename, filename);
1978       if (r == -1)
1979         croak ("download: %s", guestfs_last_error (g));
1980
1981 SV *
1982 checksum (g, csumtype, path)
1983       guestfs_h *g;
1984       char *csumtype;
1985       char *path;
1986 PREINIT:
1987       char *checksum;
1988    CODE:
1989       checksum = guestfs_checksum (g, csumtype, path);
1990       if (checksum == NULL)
1991         croak ("checksum: %s", guestfs_last_error (g));
1992       RETVAL = newSVpv (checksum, 0);
1993       free (checksum);
1994  OUTPUT:
1995       RETVAL
1996
1997 void
1998 tar_in (g, tarfile, directory)
1999       guestfs_h *g;
2000       char *tarfile;
2001       char *directory;
2002 PREINIT:
2003       int r;
2004  PPCODE:
2005       r = guestfs_tar_in (g, tarfile, directory);
2006       if (r == -1)
2007         croak ("tar_in: %s", guestfs_last_error (g));
2008
2009 void
2010 tar_out (g, directory, tarfile)
2011       guestfs_h *g;
2012       char *directory;
2013       char *tarfile;
2014 PREINIT:
2015       int r;
2016  PPCODE:
2017       r = guestfs_tar_out (g, directory, tarfile);
2018       if (r == -1)
2019         croak ("tar_out: %s", guestfs_last_error (g));
2020
2021 void
2022 tgz_in (g, tarball, directory)
2023       guestfs_h *g;
2024       char *tarball;
2025       char *directory;
2026 PREINIT:
2027       int r;
2028  PPCODE:
2029       r = guestfs_tgz_in (g, tarball, directory);
2030       if (r == -1)
2031         croak ("tgz_in: %s", guestfs_last_error (g));
2032
2033 void
2034 tgz_out (g, directory, tarball)
2035       guestfs_h *g;
2036       char *directory;
2037       char *tarball;
2038 PREINIT:
2039       int r;
2040  PPCODE:
2041       r = guestfs_tgz_out (g, directory, tarball);
2042       if (r == -1)
2043         croak ("tgz_out: %s", guestfs_last_error (g));
2044
2045 void
2046 mount_ro (g, device, mountpoint)
2047       guestfs_h *g;
2048       char *device;
2049       char *mountpoint;
2050 PREINIT:
2051       int r;
2052  PPCODE:
2053       r = guestfs_mount_ro (g, device, mountpoint);
2054       if (r == -1)
2055         croak ("mount_ro: %s", guestfs_last_error (g));
2056
2057 void
2058 mount_options (g, options, device, mountpoint)
2059       guestfs_h *g;
2060       char *options;
2061       char *device;
2062       char *mountpoint;
2063 PREINIT:
2064       int r;
2065  PPCODE:
2066       r = guestfs_mount_options (g, options, device, mountpoint);
2067       if (r == -1)
2068         croak ("mount_options: %s", guestfs_last_error (g));
2069
2070 void
2071 mount_vfs (g, options, vfstype, device, mountpoint)
2072       guestfs_h *g;
2073       char *options;
2074       char *vfstype;
2075       char *device;
2076       char *mountpoint;
2077 PREINIT:
2078       int r;
2079  PPCODE:
2080       r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
2081       if (r == -1)
2082         croak ("mount_vfs: %s", guestfs_last_error (g));
2083
2084 SV *
2085 debug (g, subcmd, extraargs)
2086       guestfs_h *g;
2087       char *subcmd;
2088       char **extraargs;
2089 PREINIT:
2090       char *result;
2091    CODE:
2092       result = guestfs_debug (g, subcmd, extraargs);
2093       free (extraargs);
2094       if (result == NULL)
2095         croak ("debug: %s", guestfs_last_error (g));
2096       RETVAL = newSVpv (result, 0);
2097       free (result);
2098  OUTPUT:
2099       RETVAL
2100
2101 void
2102 lvremove (g, device)
2103       guestfs_h *g;
2104       char *device;
2105 PREINIT:
2106       int r;
2107  PPCODE:
2108       r = guestfs_lvremove (g, device);
2109       if (r == -1)
2110         croak ("lvremove: %s", guestfs_last_error (g));
2111
2112 void
2113 vgremove (g, vgname)
2114       guestfs_h *g;
2115       char *vgname;
2116 PREINIT:
2117       int r;
2118  PPCODE:
2119       r = guestfs_vgremove (g, vgname);
2120       if (r == -1)
2121         croak ("vgremove: %s", guestfs_last_error (g));
2122
2123 void
2124 pvremove (g, device)
2125       guestfs_h *g;
2126       char *device;
2127 PREINIT:
2128       int r;
2129  PPCODE:
2130       r = guestfs_pvremove (g, device);
2131       if (r == -1)
2132         croak ("pvremove: %s", guestfs_last_error (g));
2133
2134 void
2135 set_e2label (g, device, label)
2136       guestfs_h *g;
2137       char *device;
2138       char *label;
2139 PREINIT:
2140       int r;
2141  PPCODE:
2142       r = guestfs_set_e2label (g, device, label);
2143       if (r == -1)
2144         croak ("set_e2label: %s", guestfs_last_error (g));
2145
2146 SV *
2147 get_e2label (g, device)
2148       guestfs_h *g;
2149       char *device;
2150 PREINIT:
2151       char *label;
2152    CODE:
2153       label = guestfs_get_e2label (g, device);
2154       if (label == NULL)
2155         croak ("get_e2label: %s", guestfs_last_error (g));
2156       RETVAL = newSVpv (label, 0);
2157       free (label);
2158  OUTPUT:
2159       RETVAL
2160
2161 void
2162 set_e2uuid (g, device, uuid)
2163       guestfs_h *g;
2164       char *device;
2165       char *uuid;
2166 PREINIT:
2167       int r;
2168  PPCODE:
2169       r = guestfs_set_e2uuid (g, device, uuid);
2170       if (r == -1)
2171         croak ("set_e2uuid: %s", guestfs_last_error (g));
2172
2173 SV *
2174 get_e2uuid (g, device)
2175       guestfs_h *g;
2176       char *device;
2177 PREINIT:
2178       char *uuid;
2179    CODE:
2180       uuid = guestfs_get_e2uuid (g, device);
2181       if (uuid == NULL)
2182         croak ("get_e2uuid: %s", guestfs_last_error (g));
2183       RETVAL = newSVpv (uuid, 0);
2184       free (uuid);
2185  OUTPUT:
2186       RETVAL
2187
2188 SV *
2189 fsck (g, fstype, device)
2190       guestfs_h *g;
2191       char *fstype;
2192       char *device;
2193 PREINIT:
2194       int status;
2195    CODE:
2196       status = guestfs_fsck (g, fstype, device);
2197       if (status == -1)
2198         croak ("fsck: %s", guestfs_last_error (g));
2199       RETVAL = newSViv (status);
2200  OUTPUT:
2201       RETVAL
2202
2203 void
2204 zero (g, device)
2205       guestfs_h *g;
2206       char *device;
2207 PREINIT:
2208       int r;
2209  PPCODE:
2210       r = guestfs_zero (g, device);
2211       if (r == -1)
2212         croak ("zero: %s", guestfs_last_error (g));
2213
2214 void
2215 grub_install (g, root, device)
2216       guestfs_h *g;
2217       char *root;
2218       char *device;
2219 PREINIT:
2220       int r;
2221  PPCODE:
2222       r = guestfs_grub_install (g, root, device);
2223       if (r == -1)
2224         croak ("grub_install: %s", guestfs_last_error (g));
2225
2226 void
2227 cp (g, src, dest)
2228       guestfs_h *g;
2229       char *src;
2230       char *dest;
2231 PREINIT:
2232       int r;
2233  PPCODE:
2234       r = guestfs_cp (g, src, dest);
2235       if (r == -1)
2236         croak ("cp: %s", guestfs_last_error (g));
2237
2238 void
2239 cp_a (g, src, dest)
2240       guestfs_h *g;
2241       char *src;
2242       char *dest;
2243 PREINIT:
2244       int r;
2245  PPCODE:
2246       r = guestfs_cp_a (g, src, dest);
2247       if (r == -1)
2248         croak ("cp_a: %s", guestfs_last_error (g));
2249
2250 void
2251 mv (g, src, dest)
2252       guestfs_h *g;
2253       char *src;
2254       char *dest;
2255 PREINIT:
2256       int r;
2257  PPCODE:
2258       r = guestfs_mv (g, src, dest);
2259       if (r == -1)
2260         croak ("mv: %s", guestfs_last_error (g));
2261
2262 void
2263 drop_caches (g, whattodrop)
2264       guestfs_h *g;
2265       int whattodrop;
2266 PREINIT:
2267       int r;
2268  PPCODE:
2269       r = guestfs_drop_caches (g, whattodrop);
2270       if (r == -1)
2271         croak ("drop_caches: %s", guestfs_last_error (g));
2272
2273 SV *
2274 dmesg (g)
2275       guestfs_h *g;
2276 PREINIT:
2277       char *kmsgs;
2278    CODE:
2279       kmsgs = guestfs_dmesg (g);
2280       if (kmsgs == NULL)
2281         croak ("dmesg: %s", guestfs_last_error (g));
2282       RETVAL = newSVpv (kmsgs, 0);
2283       free (kmsgs);
2284  OUTPUT:
2285       RETVAL
2286
2287 void
2288 ping_daemon (g)
2289       guestfs_h *g;
2290 PREINIT:
2291       int r;
2292  PPCODE:
2293       r = guestfs_ping_daemon (g);
2294       if (r == -1)
2295         croak ("ping_daemon: %s", guestfs_last_error (g));
2296
2297 SV *
2298 equal (g, file1, file2)
2299       guestfs_h *g;
2300       char *file1;
2301       char *file2;
2302 PREINIT:
2303       int equality;
2304    CODE:
2305       equality = guestfs_equal (g, file1, file2);
2306       if (equality == -1)
2307         croak ("equal: %s", guestfs_last_error (g));
2308       RETVAL = newSViv (equality);
2309  OUTPUT:
2310       RETVAL
2311
2312 void
2313 strings (g, path)
2314       guestfs_h *g;
2315       char *path;
2316 PREINIT:
2317       char **stringsout;
2318       int i, n;
2319  PPCODE:
2320       stringsout = guestfs_strings (g, path);
2321       if (stringsout == NULL)
2322         croak ("strings: %s", guestfs_last_error (g));
2323       for (n = 0; stringsout[n] != NULL; ++n) /**/;
2324       EXTEND (SP, n);
2325       for (i = 0; i < n; ++i) {
2326         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
2327         free (stringsout[i]);
2328       }
2329       free (stringsout);
2330
2331 void
2332 strings_e (g, encoding, path)
2333       guestfs_h *g;
2334       char *encoding;
2335       char *path;
2336 PREINIT:
2337       char **stringsout;
2338       int i, n;
2339  PPCODE:
2340       stringsout = guestfs_strings_e (g, encoding, path);
2341       if (stringsout == NULL)
2342         croak ("strings_e: %s", guestfs_last_error (g));
2343       for (n = 0; stringsout[n] != NULL; ++n) /**/;
2344       EXTEND (SP, n);
2345       for (i = 0; i < n; ++i) {
2346         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
2347         free (stringsout[i]);
2348       }
2349       free (stringsout);
2350
2351 SV *
2352 hexdump (g, path)
2353       guestfs_h *g;
2354       char *path;
2355 PREINIT:
2356       char *dump;
2357    CODE:
2358       dump = guestfs_hexdump (g, path);
2359       if (dump == NULL)
2360         croak ("hexdump: %s", guestfs_last_error (g));
2361       RETVAL = newSVpv (dump, 0);
2362       free (dump);
2363  OUTPUT:
2364       RETVAL
2365
2366 void
2367 zerofree (g, device)
2368       guestfs_h *g;
2369       char *device;
2370 PREINIT:
2371       int r;
2372  PPCODE:
2373       r = guestfs_zerofree (g, device);
2374       if (r == -1)
2375         croak ("zerofree: %s", guestfs_last_error (g));
2376
2377 void
2378 pvresize (g, device)
2379       guestfs_h *g;
2380       char *device;
2381 PREINIT:
2382       int r;
2383  PPCODE:
2384       r = guestfs_pvresize (g, device);
2385       if (r == -1)
2386         croak ("pvresize: %s", guestfs_last_error (g));
2387
2388 void
2389 sfdisk_N (g, device, n, cyls, heads, sectors, line)
2390       guestfs_h *g;
2391       char *device;
2392       int n;
2393       int cyls;
2394       int heads;
2395       int sectors;
2396       char *line;
2397 PREINIT:
2398       int r;
2399  PPCODE:
2400       r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line);
2401       if (r == -1)
2402         croak ("sfdisk_N: %s", guestfs_last_error (g));
2403
2404 SV *
2405 sfdisk_l (g, device)
2406       guestfs_h *g;
2407       char *device;
2408 PREINIT:
2409       char *partitions;
2410    CODE:
2411       partitions = guestfs_sfdisk_l (g, device);
2412       if (partitions == NULL)
2413         croak ("sfdisk_l: %s", guestfs_last_error (g));
2414       RETVAL = newSVpv (partitions, 0);
2415       free (partitions);
2416  OUTPUT:
2417       RETVAL
2418
2419 SV *
2420 sfdisk_kernel_geometry (g, device)
2421       guestfs_h *g;
2422       char *device;
2423 PREINIT:
2424       char *partitions;
2425    CODE:
2426       partitions = guestfs_sfdisk_kernel_geometry (g, device);
2427       if (partitions == NULL)
2428         croak ("sfdisk_kernel_geometry: %s", guestfs_last_error (g));
2429       RETVAL = newSVpv (partitions, 0);
2430       free (partitions);
2431  OUTPUT:
2432       RETVAL
2433
2434 SV *
2435 sfdisk_disk_geometry (g, device)
2436       guestfs_h *g;
2437       char *device;
2438 PREINIT:
2439       char *partitions;
2440    CODE:
2441       partitions = guestfs_sfdisk_disk_geometry (g, device);
2442       if (partitions == NULL)
2443         croak ("sfdisk_disk_geometry: %s", guestfs_last_error (g));
2444       RETVAL = newSVpv (partitions, 0);
2445       free (partitions);
2446  OUTPUT:
2447       RETVAL
2448
2449 void
2450 vg_activate_all (g, activate)
2451       guestfs_h *g;
2452       int activate;
2453 PREINIT:
2454       int r;
2455  PPCODE:
2456       r = guestfs_vg_activate_all (g, activate);
2457       if (r == -1)
2458         croak ("vg_activate_all: %s", guestfs_last_error (g));
2459
2460 void
2461 vg_activate (g, activate, volgroups)
2462       guestfs_h *g;
2463       int activate;
2464       char **volgroups;
2465 PREINIT:
2466       int r;
2467  PPCODE:
2468       r = guestfs_vg_activate (g, activate, volgroups);
2469       free (volgroups);
2470       if (r == -1)
2471         croak ("vg_activate: %s", guestfs_last_error (g));
2472
2473 void
2474 lvresize (g, device, mbytes)
2475       guestfs_h *g;
2476       char *device;
2477       int mbytes;
2478 PREINIT:
2479       int r;
2480  PPCODE:
2481       r = guestfs_lvresize (g, device, mbytes);
2482       if (r == -1)
2483         croak ("lvresize: %s", guestfs_last_error (g));
2484
2485 void
2486 resize2fs (g, device)
2487       guestfs_h *g;
2488       char *device;
2489 PREINIT:
2490       int r;
2491  PPCODE:
2492       r = guestfs_resize2fs (g, device);
2493       if (r == -1)
2494         croak ("resize2fs: %s", guestfs_last_error (g));
2495
2496 void
2497 find (g, directory)
2498       guestfs_h *g;
2499       char *directory;
2500 PREINIT:
2501       char **names;
2502       int i, n;
2503  PPCODE:
2504       names = guestfs_find (g, directory);
2505       if (names == NULL)
2506         croak ("find: %s", guestfs_last_error (g));
2507       for (n = 0; names[n] != NULL; ++n) /**/;
2508       EXTEND (SP, n);
2509       for (i = 0; i < n; ++i) {
2510         PUSHs (sv_2mortal (newSVpv (names[i], 0)));
2511         free (names[i]);
2512       }
2513       free (names);
2514
2515 void
2516 e2fsck_f (g, device)
2517       guestfs_h *g;
2518       char *device;
2519 PREINIT:
2520       int r;
2521  PPCODE:
2522       r = guestfs_e2fsck_f (g, device);
2523       if (r == -1)
2524         croak ("e2fsck_f: %s", guestfs_last_error (g));
2525
2526 void
2527 sleep (g, secs)
2528       guestfs_h *g;
2529       int secs;
2530 PREINIT:
2531       int r;
2532  PPCODE:
2533       r = guestfs_sleep (g, secs);
2534       if (r == -1)
2535         croak ("sleep: %s", guestfs_last_error (g));
2536
2537 SV *
2538 ntfs_3g_probe (g, rw, device)
2539       guestfs_h *g;
2540       int rw;
2541       char *device;
2542 PREINIT:
2543       int status;
2544    CODE:
2545       status = guestfs_ntfs_3g_probe (g, rw, device);
2546       if (status == -1)
2547         croak ("ntfs_3g_probe: %s", guestfs_last_error (g));
2548       RETVAL = newSViv (status);
2549  OUTPUT:
2550       RETVAL
2551
2552 SV *
2553 sh (g, command)
2554       guestfs_h *g;
2555       char *command;
2556 PREINIT:
2557       char *output;
2558    CODE:
2559       output = guestfs_sh (g, command);
2560       if (output == NULL)
2561         croak ("sh: %s", guestfs_last_error (g));
2562       RETVAL = newSVpv (output, 0);
2563       free (output);
2564  OUTPUT:
2565       RETVAL
2566
2567 void
2568 sh_lines (g, command)
2569       guestfs_h *g;
2570       char *command;
2571 PREINIT:
2572       char **lines;
2573       int i, n;
2574  PPCODE:
2575       lines = guestfs_sh_lines (g, command);
2576       if (lines == NULL)
2577         croak ("sh_lines: %s", guestfs_last_error (g));
2578       for (n = 0; lines[n] != NULL; ++n) /**/;
2579       EXTEND (SP, n);
2580       for (i = 0; i < n; ++i) {
2581         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
2582         free (lines[i]);
2583       }
2584       free (lines);
2585
2586 void
2587 glob_expand (g, pattern)
2588       guestfs_h *g;
2589       char *pattern;
2590 PREINIT:
2591       char **paths;
2592       int i, n;
2593  PPCODE:
2594       paths = guestfs_glob_expand (g, pattern);
2595       if (paths == NULL)
2596         croak ("glob_expand: %s", guestfs_last_error (g));
2597       for (n = 0; paths[n] != NULL; ++n) /**/;
2598       EXTEND (SP, n);
2599       for (i = 0; i < n; ++i) {
2600         PUSHs (sv_2mortal (newSVpv (paths[i], 0)));
2601         free (paths[i]);
2602       }
2603       free (paths);
2604
2605 void
2606 scrub_device (g, device)
2607       guestfs_h *g;
2608       char *device;
2609 PREINIT:
2610       int r;
2611  PPCODE:
2612       r = guestfs_scrub_device (g, device);
2613       if (r == -1)
2614         croak ("scrub_device: %s", guestfs_last_error (g));
2615
2616 void
2617 scrub_file (g, file)
2618       guestfs_h *g;
2619       char *file;
2620 PREINIT:
2621       int r;
2622  PPCODE:
2623       r = guestfs_scrub_file (g, file);
2624       if (r == -1)
2625         croak ("scrub_file: %s", guestfs_last_error (g));
2626
2627 void
2628 scrub_freespace (g, dir)
2629       guestfs_h *g;
2630       char *dir;
2631 PREINIT:
2632       int r;
2633  PPCODE:
2634       r = guestfs_scrub_freespace (g, dir);
2635       if (r == -1)
2636         croak ("scrub_freespace: %s", guestfs_last_error (g));
2637
2638 SV *
2639 mkdtemp (g, template)
2640       guestfs_h *g;
2641       char *template;
2642 PREINIT:
2643       char *dir;
2644    CODE:
2645       dir = guestfs_mkdtemp (g, template);
2646       if (dir == NULL)
2647         croak ("mkdtemp: %s", guestfs_last_error (g));
2648       RETVAL = newSVpv (dir, 0);
2649       free (dir);
2650  OUTPUT:
2651       RETVAL
2652