8f4ab5f328f30475c78a04563d8b10fe473213e0
[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 set_memsize (g, memsize)
966       guestfs_h *g;
967       int memsize;
968 PREINIT:
969       int r;
970  PPCODE:
971       r = guestfs_set_memsize (g, memsize);
972       if (r == -1)
973         croak ("set_memsize: %s", guestfs_last_error (g));
974
975 SV *
976 get_memsize (g)
977       guestfs_h *g;
978 PREINIT:
979       int memsize;
980    CODE:
981       memsize = guestfs_get_memsize (g);
982       if (memsize == -1)
983         croak ("get_memsize: %s", guestfs_last_error (g));
984       RETVAL = newSViv (memsize);
985  OUTPUT:
986       RETVAL
987
988 void
989 mount (g, device, mountpoint)
990       guestfs_h *g;
991       char *device;
992       char *mountpoint;
993 PREINIT:
994       int r;
995  PPCODE:
996       r = guestfs_mount (g, device, mountpoint);
997       if (r == -1)
998         croak ("mount: %s", guestfs_last_error (g));
999
1000 void
1001 sync (g)
1002       guestfs_h *g;
1003 PREINIT:
1004       int r;
1005  PPCODE:
1006       r = guestfs_sync (g);
1007       if (r == -1)
1008         croak ("sync: %s", guestfs_last_error (g));
1009
1010 void
1011 touch (g, path)
1012       guestfs_h *g;
1013       char *path;
1014 PREINIT:
1015       int r;
1016  PPCODE:
1017       r = guestfs_touch (g, path);
1018       if (r == -1)
1019         croak ("touch: %s", guestfs_last_error (g));
1020
1021 SV *
1022 cat (g, path)
1023       guestfs_h *g;
1024       char *path;
1025 PREINIT:
1026       char *content;
1027    CODE:
1028       content = guestfs_cat (g, path);
1029       if (content == NULL)
1030         croak ("cat: %s", guestfs_last_error (g));
1031       RETVAL = newSVpv (content, 0);
1032       free (content);
1033  OUTPUT:
1034       RETVAL
1035
1036 SV *
1037 ll (g, directory)
1038       guestfs_h *g;
1039       char *directory;
1040 PREINIT:
1041       char *listing;
1042    CODE:
1043       listing = guestfs_ll (g, directory);
1044       if (listing == NULL)
1045         croak ("ll: %s", guestfs_last_error (g));
1046       RETVAL = newSVpv (listing, 0);
1047       free (listing);
1048  OUTPUT:
1049       RETVAL
1050
1051 void
1052 ls (g, directory)
1053       guestfs_h *g;
1054       char *directory;
1055 PREINIT:
1056       char **listing;
1057       int i, n;
1058  PPCODE:
1059       listing = guestfs_ls (g, directory);
1060       if (listing == NULL)
1061         croak ("ls: %s", guestfs_last_error (g));
1062       for (n = 0; listing[n] != NULL; ++n) /**/;
1063       EXTEND (SP, n);
1064       for (i = 0; i < n; ++i) {
1065         PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
1066         free (listing[i]);
1067       }
1068       free (listing);
1069
1070 void
1071 list_devices (g)
1072       guestfs_h *g;
1073 PREINIT:
1074       char **devices;
1075       int i, n;
1076  PPCODE:
1077       devices = guestfs_list_devices (g);
1078       if (devices == NULL)
1079         croak ("list_devices: %s", guestfs_last_error (g));
1080       for (n = 0; devices[n] != NULL; ++n) /**/;
1081       EXTEND (SP, n);
1082       for (i = 0; i < n; ++i) {
1083         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1084         free (devices[i]);
1085       }
1086       free (devices);
1087
1088 void
1089 list_partitions (g)
1090       guestfs_h *g;
1091 PREINIT:
1092       char **partitions;
1093       int i, n;
1094  PPCODE:
1095       partitions = guestfs_list_partitions (g);
1096       if (partitions == NULL)
1097         croak ("list_partitions: %s", guestfs_last_error (g));
1098       for (n = 0; partitions[n] != NULL; ++n) /**/;
1099       EXTEND (SP, n);
1100       for (i = 0; i < n; ++i) {
1101         PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
1102         free (partitions[i]);
1103       }
1104       free (partitions);
1105
1106 void
1107 pvs (g)
1108       guestfs_h *g;
1109 PREINIT:
1110       char **physvols;
1111       int i, n;
1112  PPCODE:
1113       physvols = guestfs_pvs (g);
1114       if (physvols == NULL)
1115         croak ("pvs: %s", guestfs_last_error (g));
1116       for (n = 0; physvols[n] != NULL; ++n) /**/;
1117       EXTEND (SP, n);
1118       for (i = 0; i < n; ++i) {
1119         PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
1120         free (physvols[i]);
1121       }
1122       free (physvols);
1123
1124 void
1125 vgs (g)
1126       guestfs_h *g;
1127 PREINIT:
1128       char **volgroups;
1129       int i, n;
1130  PPCODE:
1131       volgroups = guestfs_vgs (g);
1132       if (volgroups == NULL)
1133         croak ("vgs: %s", guestfs_last_error (g));
1134       for (n = 0; volgroups[n] != NULL; ++n) /**/;
1135       EXTEND (SP, n);
1136       for (i = 0; i < n; ++i) {
1137         PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
1138         free (volgroups[i]);
1139       }
1140       free (volgroups);
1141
1142 void
1143 lvs (g)
1144       guestfs_h *g;
1145 PREINIT:
1146       char **logvols;
1147       int i, n;
1148  PPCODE:
1149       logvols = guestfs_lvs (g);
1150       if (logvols == NULL)
1151         croak ("lvs: %s", guestfs_last_error (g));
1152       for (n = 0; logvols[n] != NULL; ++n) /**/;
1153       EXTEND (SP, n);
1154       for (i = 0; i < n; ++i) {
1155         PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
1156         free (logvols[i]);
1157       }
1158       free (logvols);
1159
1160 void
1161 pvs_full (g)
1162       guestfs_h *g;
1163 PREINIT:
1164       struct guestfs_lvm_pv_list *physvols;
1165       int i;
1166       HV *hv;
1167  PPCODE:
1168       physvols = guestfs_pvs_full (g);
1169       if (physvols == NULL)
1170         croak ("pvs_full: %s", guestfs_last_error (g));
1171       EXTEND (SP, physvols->len);
1172       for (i = 0; i < physvols->len; ++i) {
1173         hv = newHV ();
1174         (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
1175         (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
1176         (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
1177         (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
1178         (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
1179         (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
1180         (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
1181         (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
1182         (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
1183         (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
1184         (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
1185         (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
1186         (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
1187         (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
1188         PUSHs (sv_2mortal ((SV *) hv));
1189       }
1190       guestfs_free_lvm_pv_list (physvols);
1191
1192 void
1193 vgs_full (g)
1194       guestfs_h *g;
1195 PREINIT:
1196       struct guestfs_lvm_vg_list *volgroups;
1197       int i;
1198       HV *hv;
1199  PPCODE:
1200       volgroups = guestfs_vgs_full (g);
1201       if (volgroups == NULL)
1202         croak ("vgs_full: %s", guestfs_last_error (g));
1203       EXTEND (SP, volgroups->len);
1204       for (i = 0; i < volgroups->len; ++i) {
1205         hv = newHV ();
1206         (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
1207         (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
1208         (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
1209         (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
1210         (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
1211         (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
1212         (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
1213         (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
1214         (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
1215         (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
1216         (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
1217         (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
1218         (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
1219         (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
1220         (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
1221         (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
1222         (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
1223         (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
1224         (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
1225         PUSHs (sv_2mortal ((SV *) hv));
1226       }
1227       guestfs_free_lvm_vg_list (volgroups);
1228
1229 void
1230 lvs_full (g)
1231       guestfs_h *g;
1232 PREINIT:
1233       struct guestfs_lvm_lv_list *logvols;
1234       int i;
1235       HV *hv;
1236  PPCODE:
1237       logvols = guestfs_lvs_full (g);
1238       if (logvols == NULL)
1239         croak ("lvs_full: %s", guestfs_last_error (g));
1240       EXTEND (SP, logvols->len);
1241       for (i = 0; i < logvols->len; ++i) {
1242         hv = newHV ();
1243         (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
1244         (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
1245         (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
1246         (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
1247         (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
1248         (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
1249         (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
1250         (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
1251         (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
1252         (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
1253         (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
1254         (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
1255         (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
1256         (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
1257         (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
1258         (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
1259         PUSHs (sv_2mortal ((SV *) hv));
1260       }
1261       guestfs_free_lvm_lv_list (logvols);
1262
1263 void
1264 read_lines (g, path)
1265       guestfs_h *g;
1266       char *path;
1267 PREINIT:
1268       char **lines;
1269       int i, n;
1270  PPCODE:
1271       lines = guestfs_read_lines (g, path);
1272       if (lines == NULL)
1273         croak ("read_lines: %s", guestfs_last_error (g));
1274       for (n = 0; lines[n] != NULL; ++n) /**/;
1275       EXTEND (SP, n);
1276       for (i = 0; i < n; ++i) {
1277         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1278         free (lines[i]);
1279       }
1280       free (lines);
1281
1282 void
1283 aug_init (g, root, flags)
1284       guestfs_h *g;
1285       char *root;
1286       int flags;
1287 PREINIT:
1288       int r;
1289  PPCODE:
1290       r = guestfs_aug_init (g, root, flags);
1291       if (r == -1)
1292         croak ("aug_init: %s", guestfs_last_error (g));
1293
1294 void
1295 aug_close (g)
1296       guestfs_h *g;
1297 PREINIT:
1298       int r;
1299  PPCODE:
1300       r = guestfs_aug_close (g);
1301       if (r == -1)
1302         croak ("aug_close: %s", guestfs_last_error (g));
1303
1304 SV *
1305 aug_defvar (g, name, expr)
1306       guestfs_h *g;
1307       char *name;
1308       char *expr = SvOK(ST(2)) ? SvPV_nolen(ST(2)) : NULL;
1309 PREINIT:
1310       int nrnodes;
1311    CODE:
1312       nrnodes = guestfs_aug_defvar (g, name, expr);
1313       if (nrnodes == -1)
1314         croak ("aug_defvar: %s", guestfs_last_error (g));
1315       RETVAL = newSViv (nrnodes);
1316  OUTPUT:
1317       RETVAL
1318
1319 void
1320 aug_defnode (g, name, expr, val)
1321       guestfs_h *g;
1322       char *name;
1323       char *expr;
1324       char *val;
1325 PREINIT:
1326       struct guestfs_int_bool *r;
1327  PPCODE:
1328       r = guestfs_aug_defnode (g, name, expr, val);
1329       if (r == NULL)
1330         croak ("aug_defnode: %s", guestfs_last_error (g));
1331       EXTEND (SP, 2);
1332       PUSHs (sv_2mortal (newSViv (r->i)));
1333       PUSHs (sv_2mortal (newSViv (r->b)));
1334       guestfs_free_int_bool (r);
1335
1336 SV *
1337 aug_get (g, path)
1338       guestfs_h *g;
1339       char *path;
1340 PREINIT:
1341       char *val;
1342    CODE:
1343       val = guestfs_aug_get (g, path);
1344       if (val == NULL)
1345         croak ("aug_get: %s", guestfs_last_error (g));
1346       RETVAL = newSVpv (val, 0);
1347       free (val);
1348  OUTPUT:
1349       RETVAL
1350
1351 void
1352 aug_set (g, path, val)
1353       guestfs_h *g;
1354       char *path;
1355       char *val;
1356 PREINIT:
1357       int r;
1358  PPCODE:
1359       r = guestfs_aug_set (g, path, val);
1360       if (r == -1)
1361         croak ("aug_set: %s", guestfs_last_error (g));
1362
1363 void
1364 aug_insert (g, path, label, before)
1365       guestfs_h *g;
1366       char *path;
1367       char *label;
1368       int before;
1369 PREINIT:
1370       int r;
1371  PPCODE:
1372       r = guestfs_aug_insert (g, path, label, before);
1373       if (r == -1)
1374         croak ("aug_insert: %s", guestfs_last_error (g));
1375
1376 SV *
1377 aug_rm (g, path)
1378       guestfs_h *g;
1379       char *path;
1380 PREINIT:
1381       int nrnodes;
1382    CODE:
1383       nrnodes = guestfs_aug_rm (g, path);
1384       if (nrnodes == -1)
1385         croak ("aug_rm: %s", guestfs_last_error (g));
1386       RETVAL = newSViv (nrnodes);
1387  OUTPUT:
1388       RETVAL
1389
1390 void
1391 aug_mv (g, src, dest)
1392       guestfs_h *g;
1393       char *src;
1394       char *dest;
1395 PREINIT:
1396       int r;
1397  PPCODE:
1398       r = guestfs_aug_mv (g, src, dest);
1399       if (r == -1)
1400         croak ("aug_mv: %s", guestfs_last_error (g));
1401
1402 void
1403 aug_match (g, path)
1404       guestfs_h *g;
1405       char *path;
1406 PREINIT:
1407       char **matches;
1408       int i, n;
1409  PPCODE:
1410       matches = guestfs_aug_match (g, path);
1411       if (matches == NULL)
1412         croak ("aug_match: %s", guestfs_last_error (g));
1413       for (n = 0; matches[n] != NULL; ++n) /**/;
1414       EXTEND (SP, n);
1415       for (i = 0; i < n; ++i) {
1416         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
1417         free (matches[i]);
1418       }
1419       free (matches);
1420
1421 void
1422 aug_save (g)
1423       guestfs_h *g;
1424 PREINIT:
1425       int r;
1426  PPCODE:
1427       r = guestfs_aug_save (g);
1428       if (r == -1)
1429         croak ("aug_save: %s", guestfs_last_error (g));
1430
1431 void
1432 aug_load (g)
1433       guestfs_h *g;
1434 PREINIT:
1435       int r;
1436  PPCODE:
1437       r = guestfs_aug_load (g);
1438       if (r == -1)
1439         croak ("aug_load: %s", guestfs_last_error (g));
1440
1441 void
1442 aug_ls (g, path)
1443       guestfs_h *g;
1444       char *path;
1445 PREINIT:
1446       char **matches;
1447       int i, n;
1448  PPCODE:
1449       matches = guestfs_aug_ls (g, path);
1450       if (matches == NULL)
1451         croak ("aug_ls: %s", guestfs_last_error (g));
1452       for (n = 0; matches[n] != NULL; ++n) /**/;
1453       EXTEND (SP, n);
1454       for (i = 0; i < n; ++i) {
1455         PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
1456         free (matches[i]);
1457       }
1458       free (matches);
1459
1460 void
1461 rm (g, path)
1462       guestfs_h *g;
1463       char *path;
1464 PREINIT:
1465       int r;
1466  PPCODE:
1467       r = guestfs_rm (g, path);
1468       if (r == -1)
1469         croak ("rm: %s", guestfs_last_error (g));
1470
1471 void
1472 rmdir (g, path)
1473       guestfs_h *g;
1474       char *path;
1475 PREINIT:
1476       int r;
1477  PPCODE:
1478       r = guestfs_rmdir (g, path);
1479       if (r == -1)
1480         croak ("rmdir: %s", guestfs_last_error (g));
1481
1482 void
1483 rm_rf (g, path)
1484       guestfs_h *g;
1485       char *path;
1486 PREINIT:
1487       int r;
1488  PPCODE:
1489       r = guestfs_rm_rf (g, path);
1490       if (r == -1)
1491         croak ("rm_rf: %s", guestfs_last_error (g));
1492
1493 void
1494 mkdir (g, path)
1495       guestfs_h *g;
1496       char *path;
1497 PREINIT:
1498       int r;
1499  PPCODE:
1500       r = guestfs_mkdir (g, path);
1501       if (r == -1)
1502         croak ("mkdir: %s", guestfs_last_error (g));
1503
1504 void
1505 mkdir_p (g, path)
1506       guestfs_h *g;
1507       char *path;
1508 PREINIT:
1509       int r;
1510  PPCODE:
1511       r = guestfs_mkdir_p (g, path);
1512       if (r == -1)
1513         croak ("mkdir_p: %s", guestfs_last_error (g));
1514
1515 void
1516 chmod (g, mode, path)
1517       guestfs_h *g;
1518       int mode;
1519       char *path;
1520 PREINIT:
1521       int r;
1522  PPCODE:
1523       r = guestfs_chmod (g, mode, path);
1524       if (r == -1)
1525         croak ("chmod: %s", guestfs_last_error (g));
1526
1527 void
1528 chown (g, owner, group, path)
1529       guestfs_h *g;
1530       int owner;
1531       int group;
1532       char *path;
1533 PREINIT:
1534       int r;
1535  PPCODE:
1536       r = guestfs_chown (g, owner, group, path);
1537       if (r == -1)
1538         croak ("chown: %s", guestfs_last_error (g));
1539
1540 SV *
1541 exists (g, path)
1542       guestfs_h *g;
1543       char *path;
1544 PREINIT:
1545       int existsflag;
1546    CODE:
1547       existsflag = guestfs_exists (g, path);
1548       if (existsflag == -1)
1549         croak ("exists: %s", guestfs_last_error (g));
1550       RETVAL = newSViv (existsflag);
1551  OUTPUT:
1552       RETVAL
1553
1554 SV *
1555 is_file (g, path)
1556       guestfs_h *g;
1557       char *path;
1558 PREINIT:
1559       int fileflag;
1560    CODE:
1561       fileflag = guestfs_is_file (g, path);
1562       if (fileflag == -1)
1563         croak ("is_file: %s", guestfs_last_error (g));
1564       RETVAL = newSViv (fileflag);
1565  OUTPUT:
1566       RETVAL
1567
1568 SV *
1569 is_dir (g, path)
1570       guestfs_h *g;
1571       char *path;
1572 PREINIT:
1573       int dirflag;
1574    CODE:
1575       dirflag = guestfs_is_dir (g, path);
1576       if (dirflag == -1)
1577         croak ("is_dir: %s", guestfs_last_error (g));
1578       RETVAL = newSViv (dirflag);
1579  OUTPUT:
1580       RETVAL
1581
1582 void
1583 pvcreate (g, device)
1584       guestfs_h *g;
1585       char *device;
1586 PREINIT:
1587       int r;
1588  PPCODE:
1589       r = guestfs_pvcreate (g, device);
1590       if (r == -1)
1591         croak ("pvcreate: %s", guestfs_last_error (g));
1592
1593 void
1594 vgcreate (g, volgroup, physvols)
1595       guestfs_h *g;
1596       char *volgroup;
1597       char **physvols;
1598 PREINIT:
1599       int r;
1600  PPCODE:
1601       r = guestfs_vgcreate (g, volgroup, physvols);
1602       free (physvols);
1603       if (r == -1)
1604         croak ("vgcreate: %s", guestfs_last_error (g));
1605
1606 void
1607 lvcreate (g, logvol, volgroup, mbytes)
1608       guestfs_h *g;
1609       char *logvol;
1610       char *volgroup;
1611       int mbytes;
1612 PREINIT:
1613       int r;
1614  PPCODE:
1615       r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
1616       if (r == -1)
1617         croak ("lvcreate: %s", guestfs_last_error (g));
1618
1619 void
1620 mkfs (g, fstype, device)
1621       guestfs_h *g;
1622       char *fstype;
1623       char *device;
1624 PREINIT:
1625       int r;
1626  PPCODE:
1627       r = guestfs_mkfs (g, fstype, device);
1628       if (r == -1)
1629         croak ("mkfs: %s", guestfs_last_error (g));
1630
1631 void
1632 sfdisk (g, device, cyls, heads, sectors, lines)
1633       guestfs_h *g;
1634       char *device;
1635       int cyls;
1636       int heads;
1637       int sectors;
1638       char **lines;
1639 PREINIT:
1640       int r;
1641  PPCODE:
1642       r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1643       free (lines);
1644       if (r == -1)
1645         croak ("sfdisk: %s", guestfs_last_error (g));
1646
1647 void
1648 write_file (g, path, content, size)
1649       guestfs_h *g;
1650       char *path;
1651       char *content;
1652       int size;
1653 PREINIT:
1654       int r;
1655  PPCODE:
1656       r = guestfs_write_file (g, path, content, size);
1657       if (r == -1)
1658         croak ("write_file: %s", guestfs_last_error (g));
1659
1660 void
1661 umount (g, pathordevice)
1662       guestfs_h *g;
1663       char *pathordevice;
1664 PREINIT:
1665       int r;
1666  PPCODE:
1667       r = guestfs_umount (g, pathordevice);
1668       if (r == -1)
1669         croak ("umount: %s", guestfs_last_error (g));
1670
1671 void
1672 mounts (g)
1673       guestfs_h *g;
1674 PREINIT:
1675       char **devices;
1676       int i, n;
1677  PPCODE:
1678       devices = guestfs_mounts (g);
1679       if (devices == NULL)
1680         croak ("mounts: %s", guestfs_last_error (g));
1681       for (n = 0; devices[n] != NULL; ++n) /**/;
1682       EXTEND (SP, n);
1683       for (i = 0; i < n; ++i) {
1684         PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
1685         free (devices[i]);
1686       }
1687       free (devices);
1688
1689 void
1690 umount_all (g)
1691       guestfs_h *g;
1692 PREINIT:
1693       int r;
1694  PPCODE:
1695       r = guestfs_umount_all (g);
1696       if (r == -1)
1697         croak ("umount_all: %s", guestfs_last_error (g));
1698
1699 void
1700 lvm_remove_all (g)
1701       guestfs_h *g;
1702 PREINIT:
1703       int r;
1704  PPCODE:
1705       r = guestfs_lvm_remove_all (g);
1706       if (r == -1)
1707         croak ("lvm_remove_all: %s", guestfs_last_error (g));
1708
1709 SV *
1710 file (g, path)
1711       guestfs_h *g;
1712       char *path;
1713 PREINIT:
1714       char *description;
1715    CODE:
1716       description = guestfs_file (g, path);
1717       if (description == NULL)
1718         croak ("file: %s", guestfs_last_error (g));
1719       RETVAL = newSVpv (description, 0);
1720       free (description);
1721  OUTPUT:
1722       RETVAL
1723
1724 SV *
1725 command (g, arguments)
1726       guestfs_h *g;
1727       char **arguments;
1728 PREINIT:
1729       char *output;
1730    CODE:
1731       output = guestfs_command (g, arguments);
1732       free (arguments);
1733       if (output == NULL)
1734         croak ("command: %s", guestfs_last_error (g));
1735       RETVAL = newSVpv (output, 0);
1736       free (output);
1737  OUTPUT:
1738       RETVAL
1739
1740 void
1741 command_lines (g, arguments)
1742       guestfs_h *g;
1743       char **arguments;
1744 PREINIT:
1745       char **lines;
1746       int i, n;
1747  PPCODE:
1748       lines = guestfs_command_lines (g, arguments);
1749       free (arguments);
1750       if (lines == NULL)
1751         croak ("command_lines: %s", guestfs_last_error (g));
1752       for (n = 0; lines[n] != NULL; ++n) /**/;
1753       EXTEND (SP, n);
1754       for (i = 0; i < n; ++i) {
1755         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
1756         free (lines[i]);
1757       }
1758       free (lines);
1759
1760 void
1761 stat (g, path)
1762       guestfs_h *g;
1763       char *path;
1764 PREINIT:
1765       struct guestfs_stat *statbuf;
1766  PPCODE:
1767       statbuf = guestfs_stat (g, path);
1768       if (statbuf == NULL)
1769         croak ("stat: %s", guestfs_last_error (g));
1770       EXTEND (SP, 13);
1771       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1772       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1773       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1774       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1775       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1776       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1777       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1778       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1779       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1780       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1781       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1782       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1783       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1784       free (statbuf);
1785
1786 void
1787 lstat (g, path)
1788       guestfs_h *g;
1789       char *path;
1790 PREINIT:
1791       struct guestfs_stat *statbuf;
1792  PPCODE:
1793       statbuf = guestfs_lstat (g, path);
1794       if (statbuf == NULL)
1795         croak ("lstat: %s", guestfs_last_error (g));
1796       EXTEND (SP, 13);
1797       PUSHs (sv_2mortal (my_newSVll (statbuf->dev)));
1798       PUSHs (sv_2mortal (my_newSVll (statbuf->ino)));
1799       PUSHs (sv_2mortal (my_newSVll (statbuf->mode)));
1800       PUSHs (sv_2mortal (my_newSVll (statbuf->nlink)));
1801       PUSHs (sv_2mortal (my_newSVll (statbuf->uid)));
1802       PUSHs (sv_2mortal (my_newSVll (statbuf->gid)));
1803       PUSHs (sv_2mortal (my_newSVll (statbuf->rdev)));
1804       PUSHs (sv_2mortal (my_newSVll (statbuf->size)));
1805       PUSHs (sv_2mortal (my_newSVll (statbuf->blksize)));
1806       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1807       PUSHs (sv_2mortal (my_newSVll (statbuf->atime)));
1808       PUSHs (sv_2mortal (my_newSVll (statbuf->mtime)));
1809       PUSHs (sv_2mortal (my_newSVll (statbuf->ctime)));
1810       free (statbuf);
1811
1812 void
1813 statvfs (g, path)
1814       guestfs_h *g;
1815       char *path;
1816 PREINIT:
1817       struct guestfs_statvfs *statbuf;
1818  PPCODE:
1819       statbuf = guestfs_statvfs (g, path);
1820       if (statbuf == NULL)
1821         croak ("statvfs: %s", guestfs_last_error (g));
1822       EXTEND (SP, 11);
1823       PUSHs (sv_2mortal (my_newSVll (statbuf->bsize)));
1824       PUSHs (sv_2mortal (my_newSVll (statbuf->frsize)));
1825       PUSHs (sv_2mortal (my_newSVll (statbuf->blocks)));
1826       PUSHs (sv_2mortal (my_newSVll (statbuf->bfree)));
1827       PUSHs (sv_2mortal (my_newSVll (statbuf->bavail)));
1828       PUSHs (sv_2mortal (my_newSVll (statbuf->files)));
1829       PUSHs (sv_2mortal (my_newSVll (statbuf->ffree)));
1830       PUSHs (sv_2mortal (my_newSVll (statbuf->favail)));
1831       PUSHs (sv_2mortal (my_newSVll (statbuf->fsid)));
1832       PUSHs (sv_2mortal (my_newSVll (statbuf->flag)));
1833       PUSHs (sv_2mortal (my_newSVll (statbuf->namemax)));
1834       free (statbuf);
1835
1836 void
1837 tune2fs_l (g, device)
1838       guestfs_h *g;
1839       char *device;
1840 PREINIT:
1841       char **superblock;
1842       int i, n;
1843  PPCODE:
1844       superblock = guestfs_tune2fs_l (g, device);
1845       if (superblock == NULL)
1846         croak ("tune2fs_l: %s", guestfs_last_error (g));
1847       for (n = 0; superblock[n] != NULL; ++n) /**/;
1848       EXTEND (SP, n);
1849       for (i = 0; i < n; ++i) {
1850         PUSHs (sv_2mortal (newSVpv (superblock[i], 0)));
1851         free (superblock[i]);
1852       }
1853       free (superblock);
1854
1855 void
1856 blockdev_setro (g, device)
1857       guestfs_h *g;
1858       char *device;
1859 PREINIT:
1860       int r;
1861  PPCODE:
1862       r = guestfs_blockdev_setro (g, device);
1863       if (r == -1)
1864         croak ("blockdev_setro: %s", guestfs_last_error (g));
1865
1866 void
1867 blockdev_setrw (g, device)
1868       guestfs_h *g;
1869       char *device;
1870 PREINIT:
1871       int r;
1872  PPCODE:
1873       r = guestfs_blockdev_setrw (g, device);
1874       if (r == -1)
1875         croak ("blockdev_setrw: %s", guestfs_last_error (g));
1876
1877 SV *
1878 blockdev_getro (g, device)
1879       guestfs_h *g;
1880       char *device;
1881 PREINIT:
1882       int ro;
1883    CODE:
1884       ro = guestfs_blockdev_getro (g, device);
1885       if (ro == -1)
1886         croak ("blockdev_getro: %s", guestfs_last_error (g));
1887       RETVAL = newSViv (ro);
1888  OUTPUT:
1889       RETVAL
1890
1891 SV *
1892 blockdev_getss (g, device)
1893       guestfs_h *g;
1894       char *device;
1895 PREINIT:
1896       int sectorsize;
1897    CODE:
1898       sectorsize = guestfs_blockdev_getss (g, device);
1899       if (sectorsize == -1)
1900         croak ("blockdev_getss: %s", guestfs_last_error (g));
1901       RETVAL = newSViv (sectorsize);
1902  OUTPUT:
1903       RETVAL
1904
1905 SV *
1906 blockdev_getbsz (g, device)
1907       guestfs_h *g;
1908       char *device;
1909 PREINIT:
1910       int blocksize;
1911    CODE:
1912       blocksize = guestfs_blockdev_getbsz (g, device);
1913       if (blocksize == -1)
1914         croak ("blockdev_getbsz: %s", guestfs_last_error (g));
1915       RETVAL = newSViv (blocksize);
1916  OUTPUT:
1917       RETVAL
1918
1919 void
1920 blockdev_setbsz (g, device, blocksize)
1921       guestfs_h *g;
1922       char *device;
1923       int blocksize;
1924 PREINIT:
1925       int r;
1926  PPCODE:
1927       r = guestfs_blockdev_setbsz (g, device, blocksize);
1928       if (r == -1)
1929         croak ("blockdev_setbsz: %s", guestfs_last_error (g));
1930
1931 SV *
1932 blockdev_getsz (g, device)
1933       guestfs_h *g;
1934       char *device;
1935 PREINIT:
1936       int64_t sizeinsectors;
1937    CODE:
1938       sizeinsectors = guestfs_blockdev_getsz (g, device);
1939       if (sizeinsectors == -1)
1940         croak ("blockdev_getsz: %s", guestfs_last_error (g));
1941       RETVAL = my_newSVll (sizeinsectors);
1942  OUTPUT:
1943       RETVAL
1944
1945 SV *
1946 blockdev_getsize64 (g, device)
1947       guestfs_h *g;
1948       char *device;
1949 PREINIT:
1950       int64_t sizeinbytes;
1951    CODE:
1952       sizeinbytes = guestfs_blockdev_getsize64 (g, device);
1953       if (sizeinbytes == -1)
1954         croak ("blockdev_getsize64: %s", guestfs_last_error (g));
1955       RETVAL = my_newSVll (sizeinbytes);
1956  OUTPUT:
1957       RETVAL
1958
1959 void
1960 blockdev_flushbufs (g, device)
1961       guestfs_h *g;
1962       char *device;
1963 PREINIT:
1964       int r;
1965  PPCODE:
1966       r = guestfs_blockdev_flushbufs (g, device);
1967       if (r == -1)
1968         croak ("blockdev_flushbufs: %s", guestfs_last_error (g));
1969
1970 void
1971 blockdev_rereadpt (g, device)
1972       guestfs_h *g;
1973       char *device;
1974 PREINIT:
1975       int r;
1976  PPCODE:
1977       r = guestfs_blockdev_rereadpt (g, device);
1978       if (r == -1)
1979         croak ("blockdev_rereadpt: %s", guestfs_last_error (g));
1980
1981 void
1982 upload (g, filename, remotefilename)
1983       guestfs_h *g;
1984       char *filename;
1985       char *remotefilename;
1986 PREINIT:
1987       int r;
1988  PPCODE:
1989       r = guestfs_upload (g, filename, remotefilename);
1990       if (r == -1)
1991         croak ("upload: %s", guestfs_last_error (g));
1992
1993 void
1994 download (g, remotefilename, filename)
1995       guestfs_h *g;
1996       char *remotefilename;
1997       char *filename;
1998 PREINIT:
1999       int r;
2000  PPCODE:
2001       r = guestfs_download (g, remotefilename, filename);
2002       if (r == -1)
2003         croak ("download: %s", guestfs_last_error (g));
2004
2005 SV *
2006 checksum (g, csumtype, path)
2007       guestfs_h *g;
2008       char *csumtype;
2009       char *path;
2010 PREINIT:
2011       char *checksum;
2012    CODE:
2013       checksum = guestfs_checksum (g, csumtype, path);
2014       if (checksum == NULL)
2015         croak ("checksum: %s", guestfs_last_error (g));
2016       RETVAL = newSVpv (checksum, 0);
2017       free (checksum);
2018  OUTPUT:
2019       RETVAL
2020
2021 void
2022 tar_in (g, tarfile, directory)
2023       guestfs_h *g;
2024       char *tarfile;
2025       char *directory;
2026 PREINIT:
2027       int r;
2028  PPCODE:
2029       r = guestfs_tar_in (g, tarfile, directory);
2030       if (r == -1)
2031         croak ("tar_in: %s", guestfs_last_error (g));
2032
2033 void
2034 tar_out (g, directory, tarfile)
2035       guestfs_h *g;
2036       char *directory;
2037       char *tarfile;
2038 PREINIT:
2039       int r;
2040  PPCODE:
2041       r = guestfs_tar_out (g, directory, tarfile);
2042       if (r == -1)
2043         croak ("tar_out: %s", guestfs_last_error (g));
2044
2045 void
2046 tgz_in (g, tarball, directory)
2047       guestfs_h *g;
2048       char *tarball;
2049       char *directory;
2050 PREINIT:
2051       int r;
2052  PPCODE:
2053       r = guestfs_tgz_in (g, tarball, directory);
2054       if (r == -1)
2055         croak ("tgz_in: %s", guestfs_last_error (g));
2056
2057 void
2058 tgz_out (g, directory, tarball)
2059       guestfs_h *g;
2060       char *directory;
2061       char *tarball;
2062 PREINIT:
2063       int r;
2064  PPCODE:
2065       r = guestfs_tgz_out (g, directory, tarball);
2066       if (r == -1)
2067         croak ("tgz_out: %s", guestfs_last_error (g));
2068
2069 void
2070 mount_ro (g, device, mountpoint)
2071       guestfs_h *g;
2072       char *device;
2073       char *mountpoint;
2074 PREINIT:
2075       int r;
2076  PPCODE:
2077       r = guestfs_mount_ro (g, device, mountpoint);
2078       if (r == -1)
2079         croak ("mount_ro: %s", guestfs_last_error (g));
2080
2081 void
2082 mount_options (g, options, device, mountpoint)
2083       guestfs_h *g;
2084       char *options;
2085       char *device;
2086       char *mountpoint;
2087 PREINIT:
2088       int r;
2089  PPCODE:
2090       r = guestfs_mount_options (g, options, device, mountpoint);
2091       if (r == -1)
2092         croak ("mount_options: %s", guestfs_last_error (g));
2093
2094 void
2095 mount_vfs (g, options, vfstype, device, mountpoint)
2096       guestfs_h *g;
2097       char *options;
2098       char *vfstype;
2099       char *device;
2100       char *mountpoint;
2101 PREINIT:
2102       int r;
2103  PPCODE:
2104       r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint);
2105       if (r == -1)
2106         croak ("mount_vfs: %s", guestfs_last_error (g));
2107
2108 SV *
2109 debug (g, subcmd, extraargs)
2110       guestfs_h *g;
2111       char *subcmd;
2112       char **extraargs;
2113 PREINIT:
2114       char *result;
2115    CODE:
2116       result = guestfs_debug (g, subcmd, extraargs);
2117       free (extraargs);
2118       if (result == NULL)
2119         croak ("debug: %s", guestfs_last_error (g));
2120       RETVAL = newSVpv (result, 0);
2121       free (result);
2122  OUTPUT:
2123       RETVAL
2124
2125 void
2126 lvremove (g, device)
2127       guestfs_h *g;
2128       char *device;
2129 PREINIT:
2130       int r;
2131  PPCODE:
2132       r = guestfs_lvremove (g, device);
2133       if (r == -1)
2134         croak ("lvremove: %s", guestfs_last_error (g));
2135
2136 void
2137 vgremove (g, vgname)
2138       guestfs_h *g;
2139       char *vgname;
2140 PREINIT:
2141       int r;
2142  PPCODE:
2143       r = guestfs_vgremove (g, vgname);
2144       if (r == -1)
2145         croak ("vgremove: %s", guestfs_last_error (g));
2146
2147 void
2148 pvremove (g, device)
2149       guestfs_h *g;
2150       char *device;
2151 PREINIT:
2152       int r;
2153  PPCODE:
2154       r = guestfs_pvremove (g, device);
2155       if (r == -1)
2156         croak ("pvremove: %s", guestfs_last_error (g));
2157
2158 void
2159 set_e2label (g, device, label)
2160       guestfs_h *g;
2161       char *device;
2162       char *label;
2163 PREINIT:
2164       int r;
2165  PPCODE:
2166       r = guestfs_set_e2label (g, device, label);
2167       if (r == -1)
2168         croak ("set_e2label: %s", guestfs_last_error (g));
2169
2170 SV *
2171 get_e2label (g, device)
2172       guestfs_h *g;
2173       char *device;
2174 PREINIT:
2175       char *label;
2176    CODE:
2177       label = guestfs_get_e2label (g, device);
2178       if (label == NULL)
2179         croak ("get_e2label: %s", guestfs_last_error (g));
2180       RETVAL = newSVpv (label, 0);
2181       free (label);
2182  OUTPUT:
2183       RETVAL
2184
2185 void
2186 set_e2uuid (g, device, uuid)
2187       guestfs_h *g;
2188       char *device;
2189       char *uuid;
2190 PREINIT:
2191       int r;
2192  PPCODE:
2193       r = guestfs_set_e2uuid (g, device, uuid);
2194       if (r == -1)
2195         croak ("set_e2uuid: %s", guestfs_last_error (g));
2196
2197 SV *
2198 get_e2uuid (g, device)
2199       guestfs_h *g;
2200       char *device;
2201 PREINIT:
2202       char *uuid;
2203    CODE:
2204       uuid = guestfs_get_e2uuid (g, device);
2205       if (uuid == NULL)
2206         croak ("get_e2uuid: %s", guestfs_last_error (g));
2207       RETVAL = newSVpv (uuid, 0);
2208       free (uuid);
2209  OUTPUT:
2210       RETVAL
2211
2212 SV *
2213 fsck (g, fstype, device)
2214       guestfs_h *g;
2215       char *fstype;
2216       char *device;
2217 PREINIT:
2218       int status;
2219    CODE:
2220       status = guestfs_fsck (g, fstype, device);
2221       if (status == -1)
2222         croak ("fsck: %s", guestfs_last_error (g));
2223       RETVAL = newSViv (status);
2224  OUTPUT:
2225       RETVAL
2226
2227 void
2228 zero (g, device)
2229       guestfs_h *g;
2230       char *device;
2231 PREINIT:
2232       int r;
2233  PPCODE:
2234       r = guestfs_zero (g, device);
2235       if (r == -1)
2236         croak ("zero: %s", guestfs_last_error (g));
2237
2238 void
2239 grub_install (g, root, device)
2240       guestfs_h *g;
2241       char *root;
2242       char *device;
2243 PREINIT:
2244       int r;
2245  PPCODE:
2246       r = guestfs_grub_install (g, root, device);
2247       if (r == -1)
2248         croak ("grub_install: %s", guestfs_last_error (g));
2249
2250 void
2251 cp (g, src, dest)
2252       guestfs_h *g;
2253       char *src;
2254       char *dest;
2255 PREINIT:
2256       int r;
2257  PPCODE:
2258       r = guestfs_cp (g, src, dest);
2259       if (r == -1)
2260         croak ("cp: %s", guestfs_last_error (g));
2261
2262 void
2263 cp_a (g, src, dest)
2264       guestfs_h *g;
2265       char *src;
2266       char *dest;
2267 PREINIT:
2268       int r;
2269  PPCODE:
2270       r = guestfs_cp_a (g, src, dest);
2271       if (r == -1)
2272         croak ("cp_a: %s", guestfs_last_error (g));
2273
2274 void
2275 mv (g, src, dest)
2276       guestfs_h *g;
2277       char *src;
2278       char *dest;
2279 PREINIT:
2280       int r;
2281  PPCODE:
2282       r = guestfs_mv (g, src, dest);
2283       if (r == -1)
2284         croak ("mv: %s", guestfs_last_error (g));
2285
2286 void
2287 drop_caches (g, whattodrop)
2288       guestfs_h *g;
2289       int whattodrop;
2290 PREINIT:
2291       int r;
2292  PPCODE:
2293       r = guestfs_drop_caches (g, whattodrop);
2294       if (r == -1)
2295         croak ("drop_caches: %s", guestfs_last_error (g));
2296
2297 SV *
2298 dmesg (g)
2299       guestfs_h *g;
2300 PREINIT:
2301       char *kmsgs;
2302    CODE:
2303       kmsgs = guestfs_dmesg (g);
2304       if (kmsgs == NULL)
2305         croak ("dmesg: %s", guestfs_last_error (g));
2306       RETVAL = newSVpv (kmsgs, 0);
2307       free (kmsgs);
2308  OUTPUT:
2309       RETVAL
2310
2311 void
2312 ping_daemon (g)
2313       guestfs_h *g;
2314 PREINIT:
2315       int r;
2316  PPCODE:
2317       r = guestfs_ping_daemon (g);
2318       if (r == -1)
2319         croak ("ping_daemon: %s", guestfs_last_error (g));
2320
2321 SV *
2322 equal (g, file1, file2)
2323       guestfs_h *g;
2324       char *file1;
2325       char *file2;
2326 PREINIT:
2327       int equality;
2328    CODE:
2329       equality = guestfs_equal (g, file1, file2);
2330       if (equality == -1)
2331         croak ("equal: %s", guestfs_last_error (g));
2332       RETVAL = newSViv (equality);
2333  OUTPUT:
2334       RETVAL
2335
2336 void
2337 strings (g, path)
2338       guestfs_h *g;
2339       char *path;
2340 PREINIT:
2341       char **stringsout;
2342       int i, n;
2343  PPCODE:
2344       stringsout = guestfs_strings (g, path);
2345       if (stringsout == NULL)
2346         croak ("strings: %s", guestfs_last_error (g));
2347       for (n = 0; stringsout[n] != NULL; ++n) /**/;
2348       EXTEND (SP, n);
2349       for (i = 0; i < n; ++i) {
2350         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
2351         free (stringsout[i]);
2352       }
2353       free (stringsout);
2354
2355 void
2356 strings_e (g, encoding, path)
2357       guestfs_h *g;
2358       char *encoding;
2359       char *path;
2360 PREINIT:
2361       char **stringsout;
2362       int i, n;
2363  PPCODE:
2364       stringsout = guestfs_strings_e (g, encoding, path);
2365       if (stringsout == NULL)
2366         croak ("strings_e: %s", guestfs_last_error (g));
2367       for (n = 0; stringsout[n] != NULL; ++n) /**/;
2368       EXTEND (SP, n);
2369       for (i = 0; i < n; ++i) {
2370         PUSHs (sv_2mortal (newSVpv (stringsout[i], 0)));
2371         free (stringsout[i]);
2372       }
2373       free (stringsout);
2374
2375 SV *
2376 hexdump (g, path)
2377       guestfs_h *g;
2378       char *path;
2379 PREINIT:
2380       char *dump;
2381    CODE:
2382       dump = guestfs_hexdump (g, path);
2383       if (dump == NULL)
2384         croak ("hexdump: %s", guestfs_last_error (g));
2385       RETVAL = newSVpv (dump, 0);
2386       free (dump);
2387  OUTPUT:
2388       RETVAL
2389
2390 void
2391 zerofree (g, device)
2392       guestfs_h *g;
2393       char *device;
2394 PREINIT:
2395       int r;
2396  PPCODE:
2397       r = guestfs_zerofree (g, device);
2398       if (r == -1)
2399         croak ("zerofree: %s", guestfs_last_error (g));
2400
2401 void
2402 pvresize (g, device)
2403       guestfs_h *g;
2404       char *device;
2405 PREINIT:
2406       int r;
2407  PPCODE:
2408       r = guestfs_pvresize (g, device);
2409       if (r == -1)
2410         croak ("pvresize: %s", guestfs_last_error (g));
2411
2412 void
2413 sfdisk_N (g, device, partnum, cyls, heads, sectors, line)
2414       guestfs_h *g;
2415       char *device;
2416       int partnum;
2417       int cyls;
2418       int heads;
2419       int sectors;
2420       char *line;
2421 PREINIT:
2422       int r;
2423  PPCODE:
2424       r = guestfs_sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
2425       if (r == -1)
2426         croak ("sfdisk_N: %s", guestfs_last_error (g));
2427
2428 SV *
2429 sfdisk_l (g, device)
2430       guestfs_h *g;
2431       char *device;
2432 PREINIT:
2433       char *partitions;
2434    CODE:
2435       partitions = guestfs_sfdisk_l (g, device);
2436       if (partitions == NULL)
2437         croak ("sfdisk_l: %s", guestfs_last_error (g));
2438       RETVAL = newSVpv (partitions, 0);
2439       free (partitions);
2440  OUTPUT:
2441       RETVAL
2442
2443 SV *
2444 sfdisk_kernel_geometry (g, device)
2445       guestfs_h *g;
2446       char *device;
2447 PREINIT:
2448       char *partitions;
2449    CODE:
2450       partitions = guestfs_sfdisk_kernel_geometry (g, device);
2451       if (partitions == NULL)
2452         croak ("sfdisk_kernel_geometry: %s", guestfs_last_error (g));
2453       RETVAL = newSVpv (partitions, 0);
2454       free (partitions);
2455  OUTPUT:
2456       RETVAL
2457
2458 SV *
2459 sfdisk_disk_geometry (g, device)
2460       guestfs_h *g;
2461       char *device;
2462 PREINIT:
2463       char *partitions;
2464    CODE:
2465       partitions = guestfs_sfdisk_disk_geometry (g, device);
2466       if (partitions == NULL)
2467         croak ("sfdisk_disk_geometry: %s", guestfs_last_error (g));
2468       RETVAL = newSVpv (partitions, 0);
2469       free (partitions);
2470  OUTPUT:
2471       RETVAL
2472
2473 void
2474 vg_activate_all (g, activate)
2475       guestfs_h *g;
2476       int activate;
2477 PREINIT:
2478       int r;
2479  PPCODE:
2480       r = guestfs_vg_activate_all (g, activate);
2481       if (r == -1)
2482         croak ("vg_activate_all: %s", guestfs_last_error (g));
2483
2484 void
2485 vg_activate (g, activate, volgroups)
2486       guestfs_h *g;
2487       int activate;
2488       char **volgroups;
2489 PREINIT:
2490       int r;
2491  PPCODE:
2492       r = guestfs_vg_activate (g, activate, volgroups);
2493       free (volgroups);
2494       if (r == -1)
2495         croak ("vg_activate: %s", guestfs_last_error (g));
2496
2497 void
2498 lvresize (g, device, mbytes)
2499       guestfs_h *g;
2500       char *device;
2501       int mbytes;
2502 PREINIT:
2503       int r;
2504  PPCODE:
2505       r = guestfs_lvresize (g, device, mbytes);
2506       if (r == -1)
2507         croak ("lvresize: %s", guestfs_last_error (g));
2508
2509 void
2510 resize2fs (g, device)
2511       guestfs_h *g;
2512       char *device;
2513 PREINIT:
2514       int r;
2515  PPCODE:
2516       r = guestfs_resize2fs (g, device);
2517       if (r == -1)
2518         croak ("resize2fs: %s", guestfs_last_error (g));
2519
2520 void
2521 find (g, directory)
2522       guestfs_h *g;
2523       char *directory;
2524 PREINIT:
2525       char **names;
2526       int i, n;
2527  PPCODE:
2528       names = guestfs_find (g, directory);
2529       if (names == NULL)
2530         croak ("find: %s", guestfs_last_error (g));
2531       for (n = 0; names[n] != NULL; ++n) /**/;
2532       EXTEND (SP, n);
2533       for (i = 0; i < n; ++i) {
2534         PUSHs (sv_2mortal (newSVpv (names[i], 0)));
2535         free (names[i]);
2536       }
2537       free (names);
2538
2539 void
2540 e2fsck_f (g, device)
2541       guestfs_h *g;
2542       char *device;
2543 PREINIT:
2544       int r;
2545  PPCODE:
2546       r = guestfs_e2fsck_f (g, device);
2547       if (r == -1)
2548         croak ("e2fsck_f: %s", guestfs_last_error (g));
2549
2550 void
2551 sleep (g, secs)
2552       guestfs_h *g;
2553       int secs;
2554 PREINIT:
2555       int r;
2556  PPCODE:
2557       r = guestfs_sleep (g, secs);
2558       if (r == -1)
2559         croak ("sleep: %s", guestfs_last_error (g));
2560
2561 SV *
2562 ntfs_3g_probe (g, rw, device)
2563       guestfs_h *g;
2564       int rw;
2565       char *device;
2566 PREINIT:
2567       int status;
2568    CODE:
2569       status = guestfs_ntfs_3g_probe (g, rw, device);
2570       if (status == -1)
2571         croak ("ntfs_3g_probe: %s", guestfs_last_error (g));
2572       RETVAL = newSViv (status);
2573  OUTPUT:
2574       RETVAL
2575
2576 SV *
2577 sh (g, command)
2578       guestfs_h *g;
2579       char *command;
2580 PREINIT:
2581       char *output;
2582    CODE:
2583       output = guestfs_sh (g, command);
2584       if (output == NULL)
2585         croak ("sh: %s", guestfs_last_error (g));
2586       RETVAL = newSVpv (output, 0);
2587       free (output);
2588  OUTPUT:
2589       RETVAL
2590
2591 void
2592 sh_lines (g, command)
2593       guestfs_h *g;
2594       char *command;
2595 PREINIT:
2596       char **lines;
2597       int i, n;
2598  PPCODE:
2599       lines = guestfs_sh_lines (g, command);
2600       if (lines == NULL)
2601         croak ("sh_lines: %s", guestfs_last_error (g));
2602       for (n = 0; lines[n] != NULL; ++n) /**/;
2603       EXTEND (SP, n);
2604       for (i = 0; i < n; ++i) {
2605         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
2606         free (lines[i]);
2607       }
2608       free (lines);
2609
2610 void
2611 glob_expand (g, pattern)
2612       guestfs_h *g;
2613       char *pattern;
2614 PREINIT:
2615       char **paths;
2616       int i, n;
2617  PPCODE:
2618       paths = guestfs_glob_expand (g, pattern);
2619       if (paths == NULL)
2620         croak ("glob_expand: %s", guestfs_last_error (g));
2621       for (n = 0; paths[n] != NULL; ++n) /**/;
2622       EXTEND (SP, n);
2623       for (i = 0; i < n; ++i) {
2624         PUSHs (sv_2mortal (newSVpv (paths[i], 0)));
2625         free (paths[i]);
2626       }
2627       free (paths);
2628
2629 void
2630 scrub_device (g, device)
2631       guestfs_h *g;
2632       char *device;
2633 PREINIT:
2634       int r;
2635  PPCODE:
2636       r = guestfs_scrub_device (g, device);
2637       if (r == -1)
2638         croak ("scrub_device: %s", guestfs_last_error (g));
2639
2640 void
2641 scrub_file (g, file)
2642       guestfs_h *g;
2643       char *file;
2644 PREINIT:
2645       int r;
2646  PPCODE:
2647       r = guestfs_scrub_file (g, file);
2648       if (r == -1)
2649         croak ("scrub_file: %s", guestfs_last_error (g));
2650
2651 void
2652 scrub_freespace (g, dir)
2653       guestfs_h *g;
2654       char *dir;
2655 PREINIT:
2656       int r;
2657  PPCODE:
2658       r = guestfs_scrub_freespace (g, dir);
2659       if (r == -1)
2660         croak ("scrub_freespace: %s", guestfs_last_error (g));
2661
2662 SV *
2663 mkdtemp (g, template)
2664       guestfs_h *g;
2665       char *template;
2666 PREINIT:
2667       char *dir;
2668    CODE:
2669       dir = guestfs_mkdtemp (g, template);
2670       if (dir == NULL)
2671         croak ("mkdtemp: %s", guestfs_last_error (g));
2672       RETVAL = newSVpv (dir, 0);
2673       free (dir);
2674  OUTPUT:
2675       RETVAL
2676
2677 SV *
2678 wc_l (g, path)
2679       guestfs_h *g;
2680       char *path;
2681 PREINIT:
2682       int lines;
2683    CODE:
2684       lines = guestfs_wc_l (g, path);
2685       if (lines == -1)
2686         croak ("wc_l: %s", guestfs_last_error (g));
2687       RETVAL = newSViv (lines);
2688  OUTPUT:
2689       RETVAL
2690
2691 SV *
2692 wc_w (g, path)
2693       guestfs_h *g;
2694       char *path;
2695 PREINIT:
2696       int words;
2697    CODE:
2698       words = guestfs_wc_w (g, path);
2699       if (words == -1)
2700         croak ("wc_w: %s", guestfs_last_error (g));
2701       RETVAL = newSViv (words);
2702  OUTPUT:
2703       RETVAL
2704
2705 SV *
2706 wc_c (g, path)
2707       guestfs_h *g;
2708       char *path;
2709 PREINIT:
2710       int chars;
2711    CODE:
2712       chars = guestfs_wc_c (g, path);
2713       if (chars == -1)
2714         croak ("wc_c: %s", guestfs_last_error (g));
2715       RETVAL = newSViv (chars);
2716  OUTPUT:
2717       RETVAL
2718
2719 void
2720 head (g, path)
2721       guestfs_h *g;
2722       char *path;
2723 PREINIT:
2724       char **lines;
2725       int i, n;
2726  PPCODE:
2727       lines = guestfs_head (g, path);
2728       if (lines == NULL)
2729         croak ("head: %s", guestfs_last_error (g));
2730       for (n = 0; lines[n] != NULL; ++n) /**/;
2731       EXTEND (SP, n);
2732       for (i = 0; i < n; ++i) {
2733         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
2734         free (lines[i]);
2735       }
2736       free (lines);
2737
2738 void
2739 head_n (g, nrlines, path)
2740       guestfs_h *g;
2741       int nrlines;
2742       char *path;
2743 PREINIT:
2744       char **lines;
2745       int i, n;
2746  PPCODE:
2747       lines = guestfs_head_n (g, nrlines, path);
2748       if (lines == NULL)
2749         croak ("head_n: %s", guestfs_last_error (g));
2750       for (n = 0; lines[n] != NULL; ++n) /**/;
2751       EXTEND (SP, n);
2752       for (i = 0; i < n; ++i) {
2753         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
2754         free (lines[i]);
2755       }
2756       free (lines);
2757
2758 void
2759 tail (g, path)
2760       guestfs_h *g;
2761       char *path;
2762 PREINIT:
2763       char **lines;
2764       int i, n;
2765  PPCODE:
2766       lines = guestfs_tail (g, path);
2767       if (lines == NULL)
2768         croak ("tail: %s", guestfs_last_error (g));
2769       for (n = 0; lines[n] != NULL; ++n) /**/;
2770       EXTEND (SP, n);
2771       for (i = 0; i < n; ++i) {
2772         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
2773         free (lines[i]);
2774       }
2775       free (lines);
2776
2777 void
2778 tail_n (g, nrlines, path)
2779       guestfs_h *g;
2780       int nrlines;
2781       char *path;
2782 PREINIT:
2783       char **lines;
2784       int i, n;
2785  PPCODE:
2786       lines = guestfs_tail_n (g, nrlines, path);
2787       if (lines == NULL)
2788         croak ("tail_n: %s", guestfs_last_error (g));
2789       for (n = 0; lines[n] != NULL; ++n) /**/;
2790       EXTEND (SP, n);
2791       for (i = 0; i < n; ++i) {
2792         PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
2793         free (lines[i]);
2794       }
2795       free (lines);
2796
2797 SV *
2798 df (g)
2799       guestfs_h *g;
2800 PREINIT:
2801       char *output;
2802    CODE:
2803       output = guestfs_df (g);
2804       if (output == NULL)
2805         croak ("df: %s", guestfs_last_error (g));
2806       RETVAL = newSVpv (output, 0);
2807       free (output);
2808  OUTPUT:
2809       RETVAL
2810
2811 SV *
2812 df_h (g)
2813       guestfs_h *g;
2814 PREINIT:
2815       char *output;
2816    CODE:
2817       output = guestfs_df_h (g);
2818       if (output == NULL)
2819         croak ("df_h: %s", guestfs_last_error (g));
2820       RETVAL = newSVpv (output, 0);
2821       free (output);
2822  OUTPUT:
2823       RETVAL
2824
2825 SV *
2826 du (g, path)
2827       guestfs_h *g;
2828       char *path;
2829 PREINIT:
2830       int64_t sizekb;
2831    CODE:
2832       sizekb = guestfs_du (g, path);
2833       if (sizekb == -1)
2834         croak ("du: %s", guestfs_last_error (g));
2835       RETVAL = my_newSVll (sizekb);
2836  OUTPUT:
2837       RETVAL
2838
2839 void
2840 initrd_list (g, path)
2841       guestfs_h *g;
2842       char *path;
2843 PREINIT:
2844       char **filenames;
2845       int i, n;
2846  PPCODE:
2847       filenames = guestfs_initrd_list (g, path);
2848       if (filenames == NULL)
2849         croak ("initrd_list: %s", guestfs_last_error (g));
2850       for (n = 0; filenames[n] != NULL; ++n) /**/;
2851       EXTEND (SP, n);
2852       for (i = 0; i < n; ++i) {
2853         PUSHs (sv_2mortal (newSVpv (filenames[i], 0)));
2854         free (filenames[i]);
2855       }
2856       free (filenames);
2857
2858 void
2859 mount_loop (g, file, mountpoint)
2860       guestfs_h *g;
2861       char *file;
2862       char *mountpoint;
2863 PREINIT:
2864       int r;
2865  PPCODE:
2866       r = guestfs_mount_loop (g, file, mountpoint);
2867       if (r == -1)
2868         croak ("mount_loop: %s", guestfs_last_error (g));
2869
2870 void
2871 mkswap (g, device)
2872       guestfs_h *g;
2873       char *device;
2874 PREINIT:
2875       int r;
2876  PPCODE:
2877       r = guestfs_mkswap (g, device);
2878       if (r == -1)
2879         croak ("mkswap: %s", guestfs_last_error (g));
2880
2881 void
2882 mkswap_L (g, label, device)
2883       guestfs_h *g;
2884       char *label;
2885       char *device;
2886 PREINIT:
2887       int r;
2888  PPCODE:
2889       r = guestfs_mkswap_L (g, label, device);
2890       if (r == -1)
2891         croak ("mkswap_L: %s", guestfs_last_error (g));
2892
2893 void
2894 mkswap_U (g, uuid, device)
2895       guestfs_h *g;
2896       char *uuid;
2897       char *device;
2898 PREINIT:
2899       int r;
2900  PPCODE:
2901       r = guestfs_mkswap_U (g, uuid, device);
2902       if (r == -1)
2903         croak ("mkswap_U: %s", guestfs_last_error (g));
2904
2905 void
2906 mknod (g, mode, devmajor, devminor, path)
2907       guestfs_h *g;
2908       int mode;
2909       int devmajor;
2910       int devminor;
2911       char *path;
2912 PREINIT:
2913       int r;
2914  PPCODE:
2915       r = guestfs_mknod (g, mode, devmajor, devminor, path);
2916       if (r == -1)
2917         croak ("mknod: %s", guestfs_last_error (g));
2918
2919 void
2920 mkfifo (g, mode, path)
2921       guestfs_h *g;
2922       int mode;
2923       char *path;
2924 PREINIT:
2925       int r;
2926  PPCODE:
2927       r = guestfs_mkfifo (g, mode, path);
2928       if (r == -1)
2929         croak ("mkfifo: %s", guestfs_last_error (g));
2930
2931 void
2932 mknod_b (g, mode, devmajor, devminor, path)
2933       guestfs_h *g;
2934       int mode;
2935       int devmajor;
2936       int devminor;
2937       char *path;
2938 PREINIT:
2939       int r;
2940  PPCODE:
2941       r = guestfs_mknod_b (g, mode, devmajor, devminor, path);
2942       if (r == -1)
2943         croak ("mknod_b: %s", guestfs_last_error (g));
2944
2945 void
2946 mknod_c (g, mode, devmajor, devminor, path)
2947       guestfs_h *g;
2948       int mode;
2949       int devmajor;
2950       int devminor;
2951       char *path;
2952 PREINIT:
2953       int r;
2954  PPCODE:
2955       r = guestfs_mknod_c (g, mode, devmajor, devminor, path);
2956       if (r == -1)
2957         croak ("mknod_c: %s", guestfs_last_error (g));
2958
2959 SV *
2960 umask (g, mask)
2961       guestfs_h *g;
2962       int mask;
2963 PREINIT:
2964       int oldmask;
2965    CODE:
2966       oldmask = guestfs_umask (g, mask);
2967       if (oldmask == -1)
2968         croak ("umask: %s", guestfs_last_error (g));
2969       RETVAL = newSViv (oldmask);
2970  OUTPUT:
2971       RETVAL
2972