fcf62f7263647c71244fefbe700bed83eff42a76
[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;
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 config (g, qemuparam, qemuvalue)
728       guestfs_h *g;
729       char *qemuparam;
730       char *qemuvalue;
731 PREINIT:
732       int r;
733  PPCODE:
734       r = guestfs_config (g, qemuparam, qemuvalue);
735       if (r == -1)
736         croak ("config: %s", guestfs_last_error (g));
737
738 void
739 set_qemu (g, qemu)
740       guestfs_h *g;
741       char *qemu;
742 PREINIT:
743       int r;
744  PPCODE:
745       r = guestfs_set_qemu (g, qemu);
746       if (r == -1)
747         croak ("set_qemu: %s", guestfs_last_error (g));
748
749 SV *
750 get_qemu (g)
751       guestfs_h *g;
752 PREINIT:
753       const char *qemu;
754    CODE:
755       qemu = guestfs_get_qemu (g);
756       if (qemu == NULL)
757         croak ("get_qemu: %s", guestfs_last_error (g));
758       RETVAL = newSVpv (qemu, 0);
759  OUTPUT:
760       RETVAL
761
762 void
763 set_path (g, path)
764       guestfs_h *g;
765       char *path;
766 PREINIT:
767       int r;
768  PPCODE:
769       r = guestfs_set_path (g, path);
770       if (r == -1)
771         croak ("set_path: %s", guestfs_last_error (g));
772
773 SV *
774 get_path (g)
775       guestfs_h *g;
776 PREINIT:
777       const char *path;
778    CODE:
779       path = guestfs_get_path (g);
780       if (path == NULL)
781         croak ("get_path: %s", guestfs_last_error (g));
782       RETVAL = newSVpv (path, 0);
783  OUTPUT:
784       RETVAL
785
786 void
787 set_append (g, append)
788       guestfs_h *g;
789       char *append;
790 PREINIT:
791       int r;
792  PPCODE:
793       r = guestfs_set_append (g, append);
794       if (r == -1)
795         croak ("set_append: %s", guestfs_last_error (g));
796
797 SV *
798 get_append (g)
799       guestfs_h *g;
800 PREINIT:
801       const char *append;
802    CODE:
803       append = guestfs_get_append (g);
804       if (append == NULL)
805         croak ("get_append: %s", guestfs_last_error (g));
806       RETVAL = newSVpv (append, 0);
807  OUTPUT:
808       RETVAL
809
810 void
811 set_autosync (g, autosync)
812       guestfs_h *g;
813       int autosync;
814 PREINIT:
815       int r;
816  PPCODE:
817       r = guestfs_set_autosync (g, autosync);
818       if (r == -1)
819         croak ("set_autosync: %s", guestfs_last_error (g));
820
821 SV *
822 get_autosync (g)
823       guestfs_h *g;
824 PREINIT:
825       int autosync;
826    CODE:
827       autosync = guestfs_get_autosync (g);
828       if (autosync == -1)
829         croak ("get_autosync: %s", guestfs_last_error (g));
830       RETVAL = newSViv (autosync);
831  OUTPUT:
832       RETVAL
833
834 void
835 set_verbose (g, verbose)
836       guestfs_h *g;
837       int verbose;
838 PREINIT:
839       int r;
840  PPCODE:
841       r = guestfs_set_verbose (g, verbose);
842       if (r == -1)
843         croak ("set_verbose: %s", guestfs_last_error (g));
844
845 SV *
846 get_verbose (g)
847       guestfs_h *g;
848 PREINIT:
849       int verbose;
850    CODE:
851       verbose = guestfs_get_verbose (g);
852       if (verbose == -1)
853         croak ("get_verbose: %s", guestfs_last_error (g));
854       RETVAL = newSViv (verbose);
855  OUTPUT:
856       RETVAL
857
858 SV *
859 is_ready (g)
860       guestfs_h *g;
861 PREINIT:
862       int ready;
863    CODE:
864       ready = guestfs_is_ready (g);
865       if (ready == -1)
866         croak ("is_ready: %s", guestfs_last_error (g));
867       RETVAL = newSViv (ready);
868  OUTPUT:
869       RETVAL
870
871 SV *
872 is_config (g)
873       guestfs_h *g;
874 PREINIT:
875       int config;
876    CODE:
877       config = guestfs_is_config (g);
878       if (config == -1)
879         croak ("is_config: %s", guestfs_last_error (g));
880       RETVAL = newSViv (config);
881  OUTPUT:
882       RETVAL
883
884 SV *
885 is_launching (g)
886       guestfs_h *g;
887 PREINIT:
888       int launching;
889    CODE:
890       launching = guestfs_is_launching (g);
891       if (launching == -1)
892         croak ("is_launching: %s", guestfs_last_error (g));
893       RETVAL = newSViv (launching);
894  OUTPUT:
895       RETVAL
896
897 SV *
898 is_busy (g)
899       guestfs_h *g;
900 PREINIT:
901       int busy;
902    CODE:
903       busy = guestfs_is_busy (g);
904       if (busy == -1)
905         croak ("is_busy: %s", guestfs_last_error (g));
906       RETVAL = newSViv (busy);
907  OUTPUT:
908       RETVAL
909
910 SV *
911 get_state (g)
912       guestfs_h *g;
913 PREINIT:
914       int state;
915    CODE:
916       state = guestfs_get_state (g);
917       if (state == -1)
918         croak ("get_state: %s", guestfs_last_error (g));
919       RETVAL = newSViv (state);
920  OUTPUT:
921       RETVAL
922
923 void
924 set_busy (g)
925       guestfs_h *g;
926 PREINIT:
927       int r;
928  PPCODE:
929       r = guestfs_set_busy (g);
930       if (r == -1)
931         croak ("set_busy: %s", guestfs_last_error (g));
932
933 void
934 set_ready (g)
935       guestfs_h *g;
936 PREINIT:
937       int r;
938  PPCODE:
939       r = guestfs_set_ready (g);
940       if (r == -1)
941         croak ("set_ready: %s", guestfs_last_error (g));
942
943 void
944 end_busy (g)
945       guestfs_h *g;
946 PREINIT:
947       int r;
948  PPCODE:
949       r = guestfs_end_busy (g);
950       if (r == -1)
951         croak ("end_busy: %s", guestfs_last_error (g));
952
953 void
954 mount (g, device, mountpoint)
955       guestfs_h *g;
956       char *device;
957       char *mountpoint;
958 PREINIT:
959       int r;
960  PPCODE:
961       r = guestfs_mount (g, device, mountpoint);
962       if (r == -1)
963         croak ("mount: %s", guestfs_last_error (g));
964
965 void
966 sync (g)
967       guestfs_h *g;
968 PREINIT:
969       int r;
970  PPCODE:
971       r = guestfs_sync (g);
972       if (r == -1)
973         croak ("sync: %s", guestfs_last_error (g));
974
975 void
976 touch (g, path)
977       guestfs_h *g;
978       char *path;
979 PREINIT:
980       int r;
981  PPCODE:
982       r = guestfs_touch (g, path);
983       if (r == -1)
984         croak ("touch: %s", guestfs_last_error (g));
985
986 SV *
987 cat (g, path)
988       guestfs_h *g;
989       char *path;
990 PREINIT:
991       char *content;
992    CODE:
993       content = guestfs_cat (g, path);
994       if (content == NULL)
995         croak ("cat: %s", guestfs_last_error (g));
996       RETVAL = newSVpv (content, 0);
997       free (content);
998  OUTPUT:
999       RETVAL
1000
1001 SV *
1002 ll (g, directory)
1003       guestfs_h *g;
1004       char *directory;
1005 PREINIT:
1006       char *listing;
1007    CODE:
1008       listing = guestfs_ll (g, directory);
1009       if (listing == NULL)
1010         croak ("ll: %s", guestfs_last_error (g));
1011       RETVAL = newSVpv (listing, 0);
1012       free (listing);
1013  OUTPUT:
1014       RETVAL
1015
1016 void
1017 ls (g, directory)
1018       guestfs_h *g;
1019       char *directory;
1020 PREINIT:
1021       char **listing;
1022       int i, n;
1023  PPCODE:
1024       listing = guestfs_ls (g, directory);
1025       if (listing == NULL)
1026         croak ("ls: %s", guestfs_last_error (g));
1027       for (n = 0; listing[n] != NULL; ++n) /**/;
1028       EXTEND (SP, n);
1029       for (i = 0; i < n; ++i) {
1030         PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
1031         free (listing[i]);
1032       }
1033       free (listing);
1034
1035 void
1036 list_devices (g)
1037       guestfs_h *g;
1038 PREINIT:
1039       char **devices;
1040       int i, n;
1041  PPCODE:
1042       devices = guestfs_list_devices (g);
1043       if (devices == NULL)
1044         croak ("list_devices: %s", guestfs_last_error (g));
1045       for (n = 0; devices[n] != NULL; ++n) /**/;
1046       EXTEND (SP, n);
1047       for (i = 0; i < n; ++i) {
1048         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1049         free (devices[i]);
1050       }
1051       free (devices);
1052
1053 void
1054 list_partitions (g)
1055       guestfs_h *g;
1056 PREINIT:
1057       char **partitions;
1058       int i, n;
1059  PPCODE:
1060       partitions = guestfs_list_partitions (g);
1061       if (partitions == NULL)
1062         croak ("list_partitions: %s", guestfs_last_error (g));
1063       for (n = 0; partitions[n] != NULL; ++n) /**/;
1064       EXTEND (SP, n);
1065       for (i = 0; i < n; ++i) {
1066         PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
1067         free (partitions[i]);
1068       }
1069       free (partitions);
1070
1071 void
1072 pvs (g)
1073       guestfs_h *g;
1074 PREINIT:
1075       char **physvols;
1076       int i, n;
1077  PPCODE:
1078       physvols = guestfs_pvs (g);
1079       if (physvols == NULL)
1080         croak ("pvs: %s", guestfs_last_error (g));
1081       for (n = 0; physvols[n] != NULL; ++n) /**/;
1082       EXTEND (SP, n);
1083       for (i = 0; i < n; ++i) {
1084         PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
1085         free (physvols[i]);
1086       }
1087       free (physvols);
1088
1089 void
1090 vgs (g)
1091       guestfs_h *g;
1092 PREINIT:
1093       char **volgroups;
1094       int i, n;
1095  PPCODE:
1096       volgroups = guestfs_vgs (g);
1097       if (volgroups == NULL)
1098         croak ("vgs: %s", guestfs_last_error (g));
1099       for (n = 0; volgroups[n] != NULL; ++n) /**/;
1100       EXTEND (SP, n);
1101       for (i = 0; i < n; ++i) {
1102         PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
1103         free (volgroups[i]);
1104       }
1105       free (volgroups);
1106
1107 void
1108 lvs (g)
1109       guestfs_h *g;
1110 PREINIT:
1111       char **logvols;
1112       int i, n;
1113  PPCODE:
1114       logvols = guestfs_lvs (g);
1115       if (logvols == NULL)
1116         croak ("lvs: %s", guestfs_last_error (g));
1117       for (n = 0; logvols[n] != NULL; ++n) /**/;
1118       EXTEND (SP, n);
1119       for (i = 0; i < n; ++i) {
1120         PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
1121         free (logvols[i]);
1122       }
1123       free (logvols);
1124
1125 void
1126 pvs_full (g)
1127       guestfs_h *g;
1128 PREINIT:
1129       struct guestfs_lvm_pv_list *physvols;
1130       int i;
1131       HV *hv;
1132  PPCODE:
1133       physvols = guestfs_pvs_full (g);
1134       if (physvols == NULL)
1135         croak ("pvs_full: %s", guestfs_last_error (g));
1136       EXTEND (SP, physvols->len);
1137       for (i = 0; i < physvols->len; ++i) {
1138         hv = newHV ();
1139         (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
1140         (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
1141         (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
1142         (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
1143         (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
1144         (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
1145         (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
1146         (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
1147         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
1148         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
1149         (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
1150         (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
1151         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
1152         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
1153         PUSHs (sv_2mortal ((SV *) hv));
1154       }
1155       guestfs_free_lvm_pv_list (physvols);
1156
1157 void
1158 vgs_full (g)
1159       guestfs_h *g;
1160 PREINIT:
1161       struct guestfs_lvm_vg_list *volgroups;
1162       int i;
1163       HV *hv;
1164  PPCODE:
1165       volgroups = guestfs_vgs_full (g);
1166       if (volgroups == NULL)
1167         croak ("vgs_full: %s", guestfs_last_error (g));
1168       EXTEND (SP, volgroups->len);
1169       for (i = 0; i < volgroups->len; ++i) {
1170         hv = newHV ();
1171         (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
1172         (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
1173         (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
1174         (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
1175         (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
1176         (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
1177         (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
1178         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
1179         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
1180         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
1181         (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
1182         (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
1183         (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
1184         (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
1185         (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
1186         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
1187         (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
1188         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
1189         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
1190         PUSHs (sv_2mortal ((SV *) hv));
1191       }
1192       guestfs_free_lvm_vg_list (volgroups);
1193
1194 void
1195 lvs_full (g)
1196       guestfs_h *g;
1197 PREINIT:
1198       struct guestfs_lvm_lv_list *logvols;
1199       int i;
1200       HV *hv;
1201  PPCODE:
1202       logvols = guestfs_lvs_full (g);
1203       if (logvols == NULL)
1204         croak ("lvs_full: %s", guestfs_last_error (g));
1205       EXTEND (SP, logvols->len);
1206       for (i = 0; i < logvols->len; ++i) {
1207         hv = newHV ();
1208         (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
1209         (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
1210         (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
1211         (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
1212         (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
1213         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
1214         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
1215         (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
1216         (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
1217         (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
1218         (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
1219         (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
1220         (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
1221         (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
1222         (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
1223         (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
1224         PUSHs (sv_2mortal ((SV *) hv));
1225       }
1226       guestfs_free_lvm_lv_list (logvols);
1227
1228 void
1229 read_lines (g, path)
1230       guestfs_h *g;
1231       char *path;
1232 PREINIT:
1233       char **lines;
1234       int i, n;
1235  PPCODE:
1236       lines = guestfs_read_lines (g, path);
1237       if (lines == NULL)
1238         croak ("read_lines: %s", guestfs_last_error (g));
1239       for (n = 0; lines[n] != NULL; ++n) /**/;
1240       EXTEND (SP, n);
1241       for (i = 0; i < n; ++i) {
1242         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1243         free (lines[i]);
1244       }
1245       free (lines);
1246
1247 void
1248 aug_init (g, root, flags)
1249       guestfs_h *g;
1250       char *root;
1251       int flags;
1252 PREINIT:
1253       int r;
1254  PPCODE:
1255       r = guestfs_aug_init (g, root, flags);
1256       if (r == -1)
1257         croak ("aug_init: %s", guestfs_last_error (g));
1258
1259 void
1260 aug_close (g)
1261       guestfs_h *g;
1262 PREINIT:
1263       int r;
1264  PPCODE:
1265       r = guestfs_aug_close (g);
1266       if (r == -1)
1267         croak ("aug_close: %s", guestfs_last_error (g));
1268
1269 SV *
1270 aug_defvar (g, name, expr)
1271       guestfs_h *g;
1272       char *name;
1273       char *expr;
1274 PREINIT:
1275       int nrnodes;
1276    CODE:
1277       nrnodes = guestfs_aug_defvar (g, name, expr);
1278       if (nrnodes == -1)
1279         croak ("aug_defvar: %s", guestfs_last_error (g));
1280       RETVAL = newSViv (nrnodes);
1281  OUTPUT:
1282       RETVAL
1283
1284 void
1285 aug_defnode (g, name, expr, val)
1286       guestfs_h *g;
1287       char *name;
1288       char *expr;
1289       char *val;
1290 PREINIT:
1291       struct guestfs_int_bool *r;
1292  PPCODE:
1293       r = guestfs_aug_defnode (g, name, expr, val);
1294       if (r == NULL)
1295         croak ("aug_defnode: %s", guestfs_last_error (g));
1296       EXTEND (SP, 2);
1297       PUSHs (sv_2mortal (newSViv (r->i)));
1298       PUSHs (sv_2mortal (newSViv (r->b)));
1299       guestfs_free_int_bool (r);
1300
1301 SV *
1302 aug_get (g, path)
1303       guestfs_h *g;
1304       char *path;
1305 PREINIT:
1306       char *val;
1307    CODE:
1308       val = guestfs_aug_get (g, path);
1309       if (val == NULL)
1310         croak ("aug_get: %s", guestfs_last_error (g));
1311       RETVAL = newSVpv (val, 0);
1312       free (val);
1313  OUTPUT:
1314       RETVAL
1315
1316 void
1317 aug_set (g, path, val)
1318       guestfs_h *g;
1319       char *path;
1320       char *val;
1321 PREINIT:
1322       int r;
1323  PPCODE:
1324       r = guestfs_aug_set (g, path, val);
1325       if (r == -1)
1326         croak ("aug_set: %s", guestfs_last_error (g));
1327
1328 void
1329 aug_insert (g, path, label, before)
1330       guestfs_h *g;
1331       char *path;
1332       char *label;
1333       int before;
1334 PREINIT:
1335       int r;
1336  PPCODE:
1337       r = guestfs_aug_insert (g, path, label, before);
1338       if (r == -1)
1339         croak ("aug_insert: %s", guestfs_last_error (g));
1340
1341 SV *
1342 aug_rm (g, path)
1343       guestfs_h *g;
1344       char *path;
1345 PREINIT:
1346       int nrnodes;
1347    CODE:
1348       nrnodes = guestfs_aug_rm (g, path);
1349       if (nrnodes == -1)
1350         croak ("aug_rm: %s", guestfs_last_error (g));
1351       RETVAL = newSViv (nrnodes);
1352  OUTPUT:
1353       RETVAL
1354
1355 void
1356 aug_mv (g, src, dest)
1357       guestfs_h *g;
1358       char *src;
1359       char *dest;
1360 PREINIT:
1361       int r;
1362  PPCODE:
1363       r = guestfs_aug_mv (g, src, dest);
1364       if (r == -1)
1365         croak ("aug_mv: %s", guestfs_last_error (g));
1366
1367 void
1368 aug_match (g, path)
1369       guestfs_h *g;
1370       char *path;
1371 PREINIT:
1372       char **matches;
1373       int i, n;
1374  PPCODE:
1375       matches = guestfs_aug_match (g, path);
1376       if (matches == NULL)
1377         croak ("aug_match: %s", guestfs_last_error (g));
1378       for (n = 0; matches[n] != NULL; ++n) /**/;
1379       EXTEND (SP, n);
1380       for (i = 0; i < n; ++i) {
1381         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
1382         free (matches[i]);
1383       }
1384       free (matches);
1385
1386 void
1387 aug_save (g)
1388       guestfs_h *g;
1389 PREINIT:
1390       int r;
1391  PPCODE:
1392       r = guestfs_aug_save (g);
1393       if (r == -1)
1394         croak ("aug_save: %s", guestfs_last_error (g));
1395
1396 void
1397 aug_load (g)
1398       guestfs_h *g;
1399 PREINIT:
1400       int r;
1401  PPCODE:
1402       r = guestfs_aug_load (g);
1403       if (r == -1)
1404         croak ("aug_load: %s", guestfs_last_error (g));
1405
1406 void
1407 aug_ls (g, path)
1408       guestfs_h *g;
1409       char *path;
1410 PREINIT:
1411       char **matches;
1412       int i, n;
1413  PPCODE:
1414       matches = guestfs_aug_ls (g, path);
1415       if (matches == NULL)
1416         croak ("aug_ls: %s", guestfs_last_error (g));
1417       for (n = 0; matches[n] != NULL; ++n) /**/;
1418       EXTEND (SP, n);
1419       for (i = 0; i < n; ++i) {
1420         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
1421         free (matches[i]);
1422       }
1423       free (matches);
1424
1425 void
1426 rm (g, path)
1427       guestfs_h *g;
1428       char *path;
1429 PREINIT:
1430       int r;
1431  PPCODE:
1432       r = guestfs_rm (g, path);
1433       if (r == -1)
1434         croak ("rm: %s", guestfs_last_error (g));
1435
1436 void
1437 rmdir (g, path)
1438       guestfs_h *g;
1439       char *path;
1440 PREINIT:
1441       int r;
1442  PPCODE:
1443       r = guestfs_rmdir (g, path);
1444       if (r == -1)
1445         croak ("rmdir: %s", guestfs_last_error (g));
1446
1447 void
1448 rm_rf (g, path)
1449       guestfs_h *g;
1450       char *path;
1451 PREINIT:
1452       int r;
1453  PPCODE:
1454       r = guestfs_rm_rf (g, path);
1455       if (r == -1)
1456         croak ("rm_rf: %s", guestfs_last_error (g));
1457
1458 void
1459 mkdir (g, path)
1460       guestfs_h *g;
1461       char *path;
1462 PREINIT:
1463       int r;
1464  PPCODE:
1465       r = guestfs_mkdir (g, path);
1466       if (r == -1)
1467         croak ("mkdir: %s", guestfs_last_error (g));
1468
1469 void
1470 mkdir_p (g, path)
1471       guestfs_h *g;
1472       char *path;
1473 PREINIT:
1474       int r;
1475  PPCODE:
1476       r = guestfs_mkdir_p (g, path);
1477       if (r == -1)
1478         croak ("mkdir_p: %s", guestfs_last_error (g));
1479
1480 void
1481 chmod (g, mode, path)
1482       guestfs_h *g;
1483       int mode;
1484       char *path;
1485 PREINIT:
1486       int r;
1487  PPCODE:
1488       r = guestfs_chmod (g, mode, path);
1489       if (r == -1)
1490         croak ("chmod: %s", guestfs_last_error (g));
1491
1492 void
1493 chown (g, owner, group, path)
1494       guestfs_h *g;
1495       int owner;
1496       int group;
1497       char *path;
1498 PREINIT:
1499       int r;
1500  PPCODE:
1501       r = guestfs_chown (g, owner, group, path);
1502       if (r == -1)
1503         croak ("chown: %s", guestfs_last_error (g));
1504
1505 SV *
1506 exists (g, path)
1507       guestfs_h *g;
1508       char *path;
1509 PREINIT:
1510       int existsflag;
1511    CODE:
1512       existsflag = guestfs_exists (g, path);
1513       if (existsflag == -1)
1514         croak ("exists: %s", guestfs_last_error (g));
1515       RETVAL = newSViv (existsflag);
1516  OUTPUT:
1517       RETVAL
1518
1519 SV *
1520 is_file (g, path)
1521       guestfs_h *g;
1522       char *path;
1523 PREINIT:
1524       int fileflag;
1525    CODE:
1526       fileflag = guestfs_is_file (g, path);
1527       if (fileflag == -1)
1528         croak ("is_file: %s", guestfs_last_error (g));
1529       RETVAL = newSViv (fileflag);
1530  OUTPUT:
1531       RETVAL
1532
1533 SV *
1534 is_dir (g, path)
1535       guestfs_h *g;
1536       char *path;
1537 PREINIT:
1538       int dirflag;
1539    CODE:
1540       dirflag = guestfs_is_dir (g, path);
1541       if (dirflag == -1)
1542         croak ("is_dir: %s", guestfs_last_error (g));
1543       RETVAL = newSViv (dirflag);
1544  OUTPUT:
1545       RETVAL
1546
1547 void
1548 pvcreate (g, device)
1549       guestfs_h *g;
1550       char *device;
1551 PREINIT:
1552       int r;
1553  PPCODE:
1554       r = guestfs_pvcreate (g, device);
1555       if (r == -1)
1556         croak ("pvcreate: %s", guestfs_last_error (g));
1557
1558 void
1559 vgcreate (g, volgroup, physvols)
1560       guestfs_h *g;
1561       char *volgroup;
1562       char **physvols;
1563 PREINIT:
1564       int r;
1565  PPCODE:
1566       r = guestfs_vgcreate (g, volgroup, physvols);
1567       free (physvols);
1568       if (r == -1)
1569         croak ("vgcreate: %s", guestfs_last_error (g));
1570
1571 void
1572 lvcreate (g, logvol, volgroup, mbytes)
1573       guestfs_h *g;
1574       char *logvol;
1575       char *volgroup;
1576       int mbytes;
1577 PREINIT:
1578       int r;
1579  PPCODE:
1580       r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
1581       if (r == -1)
1582         croak ("lvcreate: %s", guestfs_last_error (g));
1583
1584 void
1585 mkfs (g, fstype, device)
1586       guestfs_h *g;
1587       char *fstype;
1588       char *device;
1589 PREINIT:
1590       int r;
1591  PPCODE:
1592       r = guestfs_mkfs (g, fstype, device);
1593       if (r == -1)
1594         croak ("mkfs: %s", guestfs_last_error (g));
1595
1596 void
1597 sfdisk (g, device, cyls, heads, sectors, lines)
1598       guestfs_h *g;
1599       char *device;
1600       int cyls;
1601       int heads;
1602       int sectors;
1603       char **lines;
1604 PREINIT:
1605       int r;
1606  PPCODE:
1607       r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1608       free (lines);
1609       if (r == -1)
1610         croak ("sfdisk: %s", guestfs_last_error (g));
1611
1612 void
1613 write_file (g, path, content, size)
1614       guestfs_h *g;
1615       char *path;
1616       char *content;
1617       int size;
1618 PREINIT:
1619       int r;
1620  PPCODE:
1621       r = guestfs_write_file (g, path, content, size);
1622       if (r == -1)
1623         croak ("write_file: %s", guestfs_last_error (g));
1624
1625 void
1626 umount (g, pathordevice)
1627       guestfs_h *g;
1628       char *pathordevice;
1629 PREINIT:
1630       int r;
1631  PPCODE:
1632       r = guestfs_umount (g, pathordevice);
1633       if (r == -1)
1634         croak ("umount: %s", guestfs_last_error (g));
1635
1636 void
1637 mounts (g)
1638       guestfs_h *g;
1639 PREINIT:
1640       char **devices;
1641       int i, n;
1642  PPCODE:
1643       devices = guestfs_mounts (g);
1644       if (devices == NULL)
1645         croak ("mounts: %s", guestfs_last_error (g));
1646       for (n = 0; devices[n] != NULL; ++n) /**/;
1647       EXTEND (SP, n);
1648       for (i = 0; i < n; ++i) {
1649         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1650         free (devices[i]);
1651       }
1652       free (devices);
1653
1654 void
1655 umount_all (g)
1656       guestfs_h *g;
1657 PREINIT:
1658       int r;
1659  PPCODE:
1660       r = guestfs_umount_all (g);
1661       if (r == -1)
1662         croak ("umount_all: %s", guestfs_last_error (g));
1663
1664 void
1665 lvm_remove_all (g)
1666       guestfs_h *g;
1667 PREINIT:
1668       int r;
1669  PPCODE:
1670       r = guestfs_lvm_remove_all (g);
1671       if (r == -1)
1672         croak ("lvm_remove_all: %s", guestfs_last_error (g));
1673
1674 SV *
1675 file (g, path)
1676       guestfs_h *g;
1677       char *path;
1678 PREINIT:
1679       char *description;
1680    CODE:
1681       description = guestfs_file (g, path);
1682       if (description == NULL)
1683         croak ("file: %s", guestfs_last_error (g));
1684       RETVAL = newSVpv (description, 0);
1685       free (description);
1686  OUTPUT:
1687       RETVAL
1688
1689 SV *
1690 command (g, arguments)
1691       guestfs_h *g;
1692       char **arguments;
1693 PREINIT:
1694       char *output;
1695    CODE:
1696       output = guestfs_command (g, arguments);
1697       free (arguments);
1698       if (output == NULL)
1699         croak ("command: %s", guestfs_last_error (g));
1700       RETVAL = newSVpv (output, 0);
1701       free (output);
1702  OUTPUT:
1703       RETVAL
1704
1705 void
1706 command_lines (g, arguments)
1707       guestfs_h *g;
1708       char **arguments;
1709 PREINIT:
1710       char **lines;
1711       int i, n;
1712  PPCODE:
1713       lines = guestfs_command_lines (g, arguments);
1714       free (arguments);
1715       if (lines == NULL)
1716         croak ("command_lines: %s", guestfs_last_error (g));
1717       for (n = 0; lines[n] != NULL; ++n) /**/;
1718       EXTEND (SP, n);
1719       for (i = 0; i < n; ++i) {
1720         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1721         free (lines[i]);
1722       }
1723       free (lines);
1724
1725 void
1726 stat (g, path)
1727       guestfs_h *g;
1728       char *path;
1729 PREINIT:
1730       struct guestfs_stat *statbuf;
1731  PPCODE:
1732       statbuf = guestfs_stat (g, path);
1733       if (statbuf == NULL)
1734         croak ("stat: %s", guestfs_last_error (g));
1735       EXTEND (SP, 13);
1736       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1737       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1738       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1739       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1740       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1741       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1742       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1743       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1744       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1745       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1746       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1747       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1748       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1749       free (statbuf);
1750
1751 void
1752 lstat (g, path)
1753       guestfs_h *g;
1754       char *path;
1755 PREINIT:
1756       struct guestfs_stat *statbuf;
1757  PPCODE:
1758       statbuf = guestfs_lstat (g, path);
1759       if (statbuf == NULL)
1760         croak ("lstat: %s", guestfs_last_error (g));
1761       EXTEND (SP, 13);
1762       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1763       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1764       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1765       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1766       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1767       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1768       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1769       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1770       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1771       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1772       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1773       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1774       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1775       free (statbuf);
1776
1777 void
1778 statvfs (g, path)
1779       guestfs_h *g;
1780       char *path;
1781 PREINIT:
1782       struct guestfs_statvfs *statbuf;
1783  PPCODE:
1784       statbuf = guestfs_statvfs (g, path);
1785       if (statbuf == NULL)
1786         croak ("statvfs: %s", guestfs_last_error (g));
1787       EXTEND (SP, 11);
1788       PUSHs (sv_2mortal (my_newSVll (statbuf->bsize)));
1789       PUSHs (sv_2mortal (my_newSVll (statbuf->frsize)));
1790       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1791       PUSHs (sv_2mortal (my_newSVll (statbuf->bfree)));
1792       PUSHs (sv_2mortal (my_newSVll (statbuf->bavail)));
1793       PUSHs (sv_2mortal (my_newSVll (statbuf->files)));
1794       PUSHs (sv_2mortal (my_newSVll (statbuf->ffree)));
1795       PUSHs (sv_2mortal (my_newSVll (statbuf->favail)));
1796       PUSHs (sv_2mortal (my_newSVll (statbuf->fsid)));
1797       PUSHs (sv_2mortal (my_newSVll (statbuf->flag)));
1798       PUSHs (sv_2mortal (my_newSVll (statbuf->namemax)));
1799       free (statbuf);
1800
1801 void
1802 tune2fs_l (g, device)
1803       guestfs_h *g;
1804       char *device;
1805 PREINIT:
1806       char **superblock;
1807       int i, n;
1808  PPCODE:
1809       superblock = guestfs_tune2fs_l (g, device);
1810       if (superblock == NULL)
1811         croak ("tune2fs_l: %s", guestfs_last_error (g));
1812       for (n = 0; superblock[n] != NULL; ++n) /**/;
1813       EXTEND (SP, n);
1814       for (i = 0; i < n; ++i) {
1815         PUSHs (sv_2mortal (newSVpv (superblock[i], 0)));
1816         free (superblock[i]);
1817       }
1818       free (superblock);
1819
1820 void
1821 blockdev_setro (g, device)
1822       guestfs_h *g;
1823       char *device;
1824 PREINIT:
1825       int r;
1826  PPCODE:
1827       r = guestfs_blockdev_setro (g, device);
1828       if (r == -1)
1829         croak ("blockdev_setro: %s", guestfs_last_error (g));
1830
1831 void
1832 blockdev_setrw (g, device)
1833       guestfs_h *g;
1834       char *device;
1835 PREINIT:
1836       int r;
1837  PPCODE:
1838       r = guestfs_blockdev_setrw (g, device);
1839       if (r == -1)
1840         croak ("blockdev_setrw: %s", guestfs_last_error (g));
1841
1842 SV *
1843 blockdev_getro (g, device)
1844       guestfs_h *g;
1845       char *device;
1846 PREINIT:
1847       int ro;
1848    CODE:
1849       ro = guestfs_blockdev_getro (g, device);
1850       if (ro == -1)
1851         croak ("blockdev_getro: %s", guestfs_last_error (g));
1852       RETVAL = newSViv (ro);
1853  OUTPUT:
1854       RETVAL
1855
1856 SV *
1857 blockdev_getss (g, device)
1858       guestfs_h *g;
1859       char *device;
1860 PREINIT:
1861       int sectorsize;
1862    CODE:
1863       sectorsize = guestfs_blockdev_getss (g, device);
1864       if (sectorsize == -1)
1865         croak ("blockdev_getss: %s", guestfs_last_error (g));
1866       RETVAL = newSViv (sectorsize);
1867  OUTPUT:
1868       RETVAL
1869
1870 SV *
1871 blockdev_getbsz (g, device)
1872       guestfs_h *g;
1873       char *device;
1874 PREINIT:
1875       int blocksize;
1876    CODE:
1877       blocksize = guestfs_blockdev_getbsz (g, device);
1878       if (blocksize == -1)
1879         croak ("blockdev_getbsz: %s", guestfs_last_error (g));
1880       RETVAL = newSViv (blocksize);
1881  OUTPUT:
1882       RETVAL
1883
1884 void
1885 blockdev_setbsz (g, device, blocksize)
1886       guestfs_h *g;
1887       char *device;
1888       int blocksize;
1889 PREINIT:
1890       int r;
1891  PPCODE:
1892       r = guestfs_blockdev_setbsz (g, device, blocksize);
1893       if (r == -1)
1894         croak ("blockdev_setbsz: %s", guestfs_last_error (g));
1895
1896 SV *
1897 blockdev_getsz (g, device)
1898       guestfs_h *g;
1899       char *device;
1900 PREINIT:
1901       int64_t sizeinsectors;
1902    CODE:
1903       sizeinsectors = guestfs_blockdev_getsz (g, device);
1904       if (sizeinsectors == -1)
1905         croak ("blockdev_getsz: %s", guestfs_last_error (g));
1906       RETVAL = my_newSVll (sizeinsectors);
1907  OUTPUT:
1908       RETVAL
1909
1910 SV *
1911 blockdev_getsize64 (g, device)
1912       guestfs_h *g;
1913       char *device;
1914 PREINIT:
1915       int64_t sizeinbytes;
1916    CODE:
1917       sizeinbytes = guestfs_blockdev_getsize64 (g, device);
1918       if (sizeinbytes == -1)
1919         croak ("blockdev_getsize64: %s", guestfs_last_error (g));
1920       RETVAL = my_newSVll (sizeinbytes);
1921  OUTPUT:
1922       RETVAL
1923
1924 void
1925 blockdev_flushbufs (g, device)
1926       guestfs_h *g;
1927       char *device;
1928 PREINIT:
1929       int r;
1930  PPCODE:
1931       r = guestfs_blockdev_flushbufs (g, device);
1932       if (r == -1)
1933         croak ("blockdev_flushbufs: %s", guestfs_last_error (g));
1934
1935 void
1936 blockdev_rereadpt (g, device)
1937       guestfs_h *g;
1938       char *device;
1939 PREINIT:
1940       int r;
1941  PPCODE:
1942       r = guestfs_blockdev_rereadpt (g, device);
1943       if (r == -1)
1944         croak ("blockdev_rereadpt: %s", guestfs_last_error (g));
1945
1946 void
1947 upload (g, filename, remotefilename)
1948       guestfs_h *g;
1949       char *filename;
1950       char *remotefilename;
1951 PREINIT:
1952       int r;
1953  PPCODE:
1954       r = guestfs_upload (g, filename, remotefilename);
1955       if (r == -1)
1956         croak ("upload: %s", guestfs_last_error (g));
1957
1958 void
1959 download (g, remotefilename, filename)
1960       guestfs_h *g;
1961       char *remotefilename;
1962       char *filename;
1963 PREINIT:
1964       int r;
1965  PPCODE:
1966       r = guestfs_download (g, remotefilename, filename);
1967       if (r == -1)
1968         croak ("download: %s", guestfs_last_error (g));
1969
1970 SV *
1971 checksum (g, csumtype, path)
1972       guestfs_h *g;
1973       char *csumtype;
1974       char *path;
1975 PREINIT:
1976       char *checksum;
1977    CODE:
1978       checksum = guestfs_checksum (g, csumtype, path);
1979       if (checksum == NULL)
1980         croak ("checksum: %s", guestfs_last_error (g));
1981       RETVAL = newSVpv (checksum, 0);
1982       free (checksum);
1983  OUTPUT:
1984       RETVAL
1985
1986 void
1987 tar_in (g, tarfile, directory)
1988       guestfs_h *g;
1989       char *tarfile;
1990       char *directory;
1991 PREINIT:
1992       int r;
1993  PPCODE:
1994       r = guestfs_tar_in (g, tarfile, directory);
1995       if (r == -1)
1996         croak ("tar_in: %s", guestfs_last_error (g));
1997
1998 void
1999 tar_out (g, directory, tarfile)
2000       guestfs_h *g;
2001       char *directory;
2002       char *tarfile;
2003 PREINIT:
2004       int r;
2005  PPCODE:
2006       r = guestfs_tar_out (g, directory, tarfile);
2007       if (r == -1)
2008         croak ("tar_out: %s", guestfs_last_error (g));
2009
2010 void
2011 tgz_in (g, tarball, directory)
2012       guestfs_h *g;
2013       char *tarball;
2014       char *directory;
2015 PREINIT:
2016       int r;
2017  PPCODE:
2018       r = guestfs_tgz_in (g, tarball, directory);
2019       if (r == -1)
2020         croak ("tgz_in: %s", guestfs_last_error (g));
2021
2022 void
2023 tgz_out (g, directory, tarball)
2024       guestfs_h *g;
2025       char *directory;
2026       char *tarball;
2027 PREINIT:
2028       int r;
2029  PPCODE:
2030       r = guestfs_tgz_out (g, directory, tarball);
2031       if (r == -1)
2032         croak ("tgz_out: %s", guestfs_last_error (g));
2033
2034 void
2035 mount_ro (g, device, mountpoint)
2036       guestfs_h *g;
2037       char *device;
2038       char *mountpoint;
2039 PREINIT:
2040       int r;
2041  PPCODE:
2042       r = guestfs_mount_ro (g, device, mountpoint);
2043       if (r == -1)
2044         croak ("mount_ro: %s", guestfs_last_error (g));
2045
2046 void
2047 mount_options (g, options, device, mountpoint)
2048       guestfs_h *g;
2049       char *options;
2050       char *device;
2051       char *mountpoint;
2052 PREINIT:
2053       int r;
2054  PPCODE:
2055       r = guestfs_mount_options (g, options, device, mountpoint);
2056       if (r == -1)
2057         croak ("mount_options: %s", guestfs_last_error (g));
2058
2059 void
2060 mount_vfs (g, options, vfstype, device, mountpoint)
2061       guestfs_h *g;
2062       char *options;
2063       char *vfstype;
2064       char *device;
2065       char *mountpoint;
2066 PREINIT:
2067       int r;
2068  PPCODE:
2069       r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
2070       if (r == -1)
2071         croak ("mount_vfs: %s", guestfs_last_error (g));
2072
2073 SV *
2074 debug (g, subcmd, extraargs)
2075       guestfs_h *g;
2076       char *subcmd;
2077       char **extraargs;
2078 PREINIT:
2079       char *result;
2080    CODE:
2081       result = guestfs_debug (g, subcmd, extraargs);
2082       free (extraargs);
2083       if (result == NULL)
2084         croak ("debug: %s", guestfs_last_error (g));
2085       RETVAL = newSVpv (result, 0);
2086       free (result);
2087  OUTPUT:
2088       RETVAL
2089
2090 void
2091 lvremove (g, device)
2092       guestfs_h *g;
2093       char *device;
2094 PREINIT:
2095       int r;
2096  PPCODE:
2097       r = guestfs_lvremove (g, device);
2098       if (r == -1)
2099         croak ("lvremove: %s", guestfs_last_error (g));
2100
2101 void
2102 vgremove (g, vgname)
2103       guestfs_h *g;
2104       char *vgname;
2105 PREINIT:
2106       int r;
2107  PPCODE:
2108       r = guestfs_vgremove (g, vgname);
2109       if (r == -1)
2110         croak ("vgremove: %s", guestfs_last_error (g));
2111
2112 void
2113 pvremove (g, device)
2114       guestfs_h *g;
2115       char *device;
2116 PREINIT:
2117       int r;
2118  PPCODE:
2119       r = guestfs_pvremove (g, device);
2120       if (r == -1)
2121         croak ("pvremove: %s", guestfs_last_error (g));
2122
2123 void
2124 set_e2label (g, device, label)
2125       guestfs_h *g;
2126       char *device;
2127       char *label;
2128 PREINIT:
2129       int r;
2130  PPCODE:
2131       r = guestfs_set_e2label (g, device, label);
2132       if (r == -1)
2133         croak ("set_e2label: %s", guestfs_last_error (g));
2134
2135 SV *
2136 get_e2label (g, device)
2137       guestfs_h *g;
2138       char *device;
2139 PREINIT:
2140       char *label;
2141    CODE:
2142       label = guestfs_get_e2label (g, device);
2143       if (label == NULL)
2144         croak ("get_e2label: %s", guestfs_last_error (g));
2145       RETVAL = newSVpv (label, 0);
2146       free (label);
2147  OUTPUT:
2148       RETVAL
2149
2150 void
2151 set_e2uuid (g, device, uuid)
2152       guestfs_h *g;
2153       char *device;
2154       char *uuid;
2155 PREINIT:
2156       int r;
2157  PPCODE:
2158       r = guestfs_set_e2uuid (g, device, uuid);
2159       if (r == -1)
2160         croak ("set_e2uuid: %s", guestfs_last_error (g));
2161
2162 SV *
2163 get_e2uuid (g, device)
2164       guestfs_h *g;
2165       char *device;
2166 PREINIT:
2167       char *uuid;
2168    CODE:
2169       uuid = guestfs_get_e2uuid (g, device);
2170       if (uuid == NULL)
2171         croak ("get_e2uuid: %s", guestfs_last_error (g));
2172       RETVAL = newSVpv (uuid, 0);
2173       free (uuid);
2174  OUTPUT:
2175       RETVAL
2176
2177 SV *
2178 fsck (g, fstype, device)
2179       guestfs_h *g;
2180       char *fstype;
2181       char *device;
2182 PREINIT:
2183       int status;
2184    CODE:
2185       status = guestfs_fsck (g, fstype, device);
2186       if (status == -1)
2187         croak ("fsck: %s", guestfs_last_error (g));
2188       RETVAL = newSViv (status);
2189  OUTPUT:
2190       RETVAL
2191
2192 void
2193 zero (g, device)
2194       guestfs_h *g;
2195       char *device;
2196 PREINIT:
2197       int r;
2198  PPCODE:
2199       r = guestfs_zero (g, device);
2200       if (r == -1)
2201         croak ("zero: %s", guestfs_last_error (g));
2202
2203 void
2204 grub_install (g, root, device)
2205       guestfs_h *g;
2206       char *root;
2207       char *device;
2208 PREINIT:
2209       int r;
2210  PPCODE:
2211       r = guestfs_grub_install (g, root, device);
2212       if (r == -1)
2213         croak ("grub_install: %s", guestfs_last_error (g));
2214
2215 void
2216 cp (g, src, dest)
2217       guestfs_h *g;
2218       char *src;
2219       char *dest;
2220 PREINIT:
2221       int r;
2222  PPCODE:
2223       r = guestfs_cp (g, src, dest);
2224       if (r == -1)
2225         croak ("cp: %s", guestfs_last_error (g));
2226
2227 void
2228 cp_a (g, src, dest)
2229       guestfs_h *g;
2230       char *src;
2231       char *dest;
2232 PREINIT:
2233       int r;
2234  PPCODE:
2235       r = guestfs_cp_a (g, src, dest);
2236       if (r == -1)
2237         croak ("cp_a: %s", guestfs_last_error (g));
2238
2239 void
2240 mv (g, src, dest)
2241       guestfs_h *g;
2242       char *src;
2243       char *dest;
2244 PREINIT:
2245       int r;
2246  PPCODE:
2247       r = guestfs_mv (g, src, dest);
2248       if (r == -1)
2249         croak ("mv: %s", guestfs_last_error (g));
2250
2251 void
2252 drop_caches (g, whattodrop)
2253       guestfs_h *g;
2254       int whattodrop;
2255 PREINIT:
2256       int r;
2257  PPCODE:
2258       r = guestfs_drop_caches (g, whattodrop);
2259       if (r == -1)
2260         croak ("drop_caches: %s", guestfs_last_error (g));
2261
2262 SV *
2263 dmesg (g)
2264       guestfs_h *g;
2265 PREINIT:
2266       char *kmsgs;
2267    CODE:
2268       kmsgs = guestfs_dmesg (g);
2269       if (kmsgs == NULL)
2270         croak ("dmesg: %s", guestfs_last_error (g));
2271       RETVAL = newSVpv (kmsgs, 0);
2272       free (kmsgs);
2273  OUTPUT:
2274       RETVAL
2275
2276 void
2277 ping_daemon (g)
2278       guestfs_h *g;
2279 PREINIT:
2280       int r;
2281  PPCODE:
2282       r = guestfs_ping_daemon (g);
2283       if (r == -1)
2284         croak ("ping_daemon: %s", guestfs_last_error (g));
2285
2286 SV *
2287 equal (g, file1, file2)
2288       guestfs_h *g;
2289       char *file1;
2290       char *file2;
2291 PREINIT:
2292       int equality;
2293    CODE:
2294       equality = guestfs_equal (g, file1, file2);
2295       if (equality == -1)
2296         croak ("equal: %s", guestfs_last_error (g));
2297       RETVAL = newSViv (equality);
2298  OUTPUT:
2299       RETVAL
2300
2301 void
2302 strings (g, path)
2303       guestfs_h *g;
2304       char *path;
2305 PREINIT:
2306       char **stringsout;
2307       int i, n;
2308  PPCODE:
2309       stringsout = guestfs_strings (g, path);
2310       if (stringsout == NULL)
2311         croak ("strings: %s", guestfs_last_error (g));
2312       for (n = 0; stringsout[n] != NULL; ++n) /**/;
2313       EXTEND (SP, n);
2314       for (i = 0; i < n; ++i) {
2315         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
2316         free (stringsout[i]);
2317       }
2318       free (stringsout);
2319
2320 void
2321 strings_e (g, encoding, path)
2322       guestfs_h *g;
2323       char *encoding;
2324       char *path;
2325 PREINIT:
2326       char **stringsout;
2327       int i, n;
2328  PPCODE:
2329       stringsout = guestfs_strings_e (g, encoding, path);
2330       if (stringsout == NULL)
2331         croak ("strings_e: %s", guestfs_last_error (g));
2332       for (n = 0; stringsout[n] != NULL; ++n) /**/;
2333       EXTEND (SP, n);
2334       for (i = 0; i < n; ++i) {
2335         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
2336         free (stringsout[i]);
2337       }
2338       free (stringsout);
2339
2340 SV *
2341 hexdump (g, path)
2342       guestfs_h *g;
2343       char *path;
2344 PREINIT:
2345       char *dump;
2346    CODE:
2347       dump = guestfs_hexdump (g, path);
2348       if (dump == NULL)
2349         croak ("hexdump: %s", guestfs_last_error (g));
2350       RETVAL = newSVpv (dump, 0);
2351       free (dump);
2352  OUTPUT:
2353       RETVAL
2354
2355 void
2356 zerofree (g, device)
2357       guestfs_h *g;
2358       char *device;
2359 PREINIT:
2360       int r;
2361  PPCODE:
2362       r = guestfs_zerofree (g, device);
2363       if (r == -1)
2364         croak ("zerofree: %s", guestfs_last_error (g));
2365
2366 void
2367 pvresize (g, device)
2368       guestfs_h *g;
2369       char *device;
2370 PREINIT:
2371       int r;
2372  PPCODE:
2373       r = guestfs_pvresize (g, device);
2374       if (r == -1)
2375         croak ("pvresize: %s", guestfs_last_error (g));
2376
2377 void
2378 sfdisk_N (g, device, n, cyls, heads, sectors, line)
2379       guestfs_h *g;
2380       char *device;
2381       int n;
2382       int cyls;
2383       int heads;
2384       int sectors;
2385       char *line;
2386 PREINIT:
2387       int r;
2388  PPCODE:
2389       r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line);
2390       if (r == -1)
2391         croak ("sfdisk_N: %s", guestfs_last_error (g));
2392
2393 SV *
2394 sfdisk_l (g, device)
2395       guestfs_h *g;
2396       char *device;
2397 PREINIT:
2398       char *partitions;
2399    CODE:
2400       partitions = guestfs_sfdisk_l (g, device);
2401       if (partitions == NULL)
2402         croak ("sfdisk_l: %s", guestfs_last_error (g));
2403       RETVAL = newSVpv (partitions, 0);
2404       free (partitions);
2405  OUTPUT:
2406       RETVAL
2407
2408 SV *
2409 sfdisk_kernel_geometry (g, device)
2410       guestfs_h *g;
2411       char *device;
2412 PREINIT:
2413       char *partitions;
2414    CODE:
2415       partitions = guestfs_sfdisk_kernel_geometry (g, device);
2416       if (partitions == NULL)
2417         croak ("sfdisk_kernel_geometry: %s", guestfs_last_error (g));
2418       RETVAL = newSVpv (partitions, 0);
2419       free (partitions);
2420  OUTPUT:
2421       RETVAL
2422
2423 SV *
2424 sfdisk_disk_geometry (g, device)
2425       guestfs_h *g;
2426       char *device;
2427 PREINIT:
2428       char *partitions;
2429    CODE:
2430       partitions = guestfs_sfdisk_disk_geometry (g, device);
2431       if (partitions == NULL)
2432         croak ("sfdisk_disk_geometry: %s", guestfs_last_error (g));
2433       RETVAL = newSVpv (partitions, 0);
2434       free (partitions);
2435  OUTPUT:
2436       RETVAL
2437
2438 void
2439 vg_activate_all (g, activate)
2440       guestfs_h *g;
2441       int activate;
2442 PREINIT:
2443       int r;
2444  PPCODE:
2445       r = guestfs_vg_activate_all (g, activate);
2446       if (r == -1)
2447         croak ("vg_activate_all: %s", guestfs_last_error (g));
2448
2449 void
2450 vg_activate (g, activate, volgroups)
2451       guestfs_h *g;
2452       int activate;
2453       char **volgroups;
2454 PREINIT:
2455       int r;
2456  PPCODE:
2457       r = guestfs_vg_activate (g, activate, volgroups);
2458       free (volgroups);
2459       if (r == -1)
2460         croak ("vg_activate: %s", guestfs_last_error (g));
2461
2462 void
2463 lvresize (g, device, mbytes)
2464       guestfs_h *g;
2465       char *device;
2466       int mbytes;
2467 PREINIT:
2468       int r;
2469  PPCODE:
2470       r = guestfs_lvresize (g, device, mbytes);
2471       if (r == -1)
2472         croak ("lvresize: %s", guestfs_last_error (g));
2473
2474 void
2475 resize2fs (g, device)
2476       guestfs_h *g;
2477       char *device;
2478 PREINIT:
2479       int r;
2480  PPCODE:
2481       r = guestfs_resize2fs (g, device);
2482       if (r == -1)
2483         croak ("resize2fs: %s", guestfs_last_error (g));
2484
2485 void
2486 find (g, directory)
2487       guestfs_h *g;
2488       char *directory;
2489 PREINIT:
2490       char **names;
2491       int i, n;
2492  PPCODE:
2493       names = guestfs_find (g, directory);
2494       if (names == NULL)
2495         croak ("find: %s", guestfs_last_error (g));
2496       for (n = 0; names[n] != NULL; ++n) /**/;
2497       EXTEND (SP, n);
2498       for (i = 0; i < n; ++i) {
2499         PUSHs (sv_2mortal (newSVpv (names[i], 0)));
2500         free (names[i]);
2501       }
2502       free (names);
2503
2504 void
2505 e2fsck_f (g, device)
2506       guestfs_h *g;
2507       char *device;
2508 PREINIT:
2509       int r;
2510  PPCODE:
2511       r = guestfs_e2fsck_f (g, device);
2512       if (r == -1)
2513         croak ("e2fsck_f: %s", guestfs_last_error (g));
2514