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.
5 * Copyright (C) 2009 Red Hat Inc.
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.
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.
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
28 /* #include cannot be used for local files in XS */
35 my_newSVll(long long val) {
41 len = snprintf(buf, 100, "%" PRId64, val);
42 return newSVpv(buf, len);
51 my_newSVull(unsigned long long val) {
57 len = snprintf(buf, 100, "%" PRIu64, val);
58 return newSVpv(buf, len);
62 /* XXX Not thread-safe, and in general not safe if the caller is
63 * issuing multiple requests in parallel (on different guestfs
64 * handles). We should use the guestfs_h handle passed to the
65 * error handle to distinguish these cases.
67 static char *last_error = NULL;
70 error_handler (guestfs_h *g,
74 if (last_error != NULL) free (last_error);
75 last_error = strdup (msg);
78 MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
83 RETVAL = guestfs_create ();
85 croak ("could not create guestfs handle");
86 guestfs_set_error_handler (RETVAL, error_handler, NULL);
97 mount (g, device, mountpoint)
102 if (guestfs_mount (g, device, mountpoint) == -1)
103 croak ("mount: %s", last_error);
109 if (guestfs_sync (g) == -1)
110 croak ("sync: %s", last_error);
117 if (guestfs_touch (g, path) == -1)
118 croak ("touch: %s", last_error);
127 content = guestfs_cat (g, path);
129 croak ("cat: %s", last_error);
130 RETVAL = newSVpv (content, 0);
142 listing = guestfs_ll (g, directory);
144 croak ("ll: %s", last_error);
145 RETVAL = newSVpv (listing, 0);
158 listing = guestfs_ls (g, directory);
160 croak ("ls: %s", last_error);
161 for (n = 0; listing[n] != NULL; ++n) /**/;
163 for (i = 0; i < n; ++i) {
164 PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
176 devices = guestfs_list_devices (g);
178 croak ("list_devices: %s", last_error);
179 for (n = 0; devices[n] != NULL; ++n) /**/;
181 for (i = 0; i < n; ++i) {
182 PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
194 partitions = guestfs_list_partitions (g);
195 if (partitions == NULL)
196 croak ("list_partitions: %s", last_error);
197 for (n = 0; partitions[n] != NULL; ++n) /**/;
199 for (i = 0; i < n; ++i) {
200 PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
201 free (partitions[i]);
212 physvols = guestfs_pvs (g);
213 if (physvols == NULL)
214 croak ("pvs: %s", last_error);
215 for (n = 0; physvols[n] != NULL; ++n) /**/;
217 for (i = 0; i < n; ++i) {
218 PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
230 volgroups = guestfs_vgs (g);
231 if (volgroups == NULL)
232 croak ("vgs: %s", last_error);
233 for (n = 0; volgroups[n] != NULL; ++n) /**/;
235 for (i = 0; i < n; ++i) {
236 PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
248 logvols = guestfs_lvs (g);
250 croak ("lvs: %s", last_error);
251 for (n = 0; logvols[n] != NULL; ++n) /**/;
253 for (i = 0; i < n; ++i) {
254 PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
263 struct guestfs_lvm_pv_list *physvols;
267 physvols = guestfs_pvs_full (g);
268 if (physvols == NULL)
269 croak ("pvs_full: %s", last_error);
270 EXTEND (SP, physvols->len);
271 for (i = 0; i < physvols->len; ++i) {
273 (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
274 (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
275 (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
276 (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
277 (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
278 (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
279 (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
280 (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
281 (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
282 (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
283 (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
284 (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
285 (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
286 (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
287 PUSHs (sv_2mortal ((SV *) hv));
289 guestfs_free_lvm_pv_list (physvols);
295 struct guestfs_lvm_vg_list *volgroups;
299 volgroups = guestfs_vgs_full (g);
300 if (volgroups == NULL)
301 croak ("vgs_full: %s", last_error);
302 EXTEND (SP, volgroups->len);
303 for (i = 0; i < volgroups->len; ++i) {
305 (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
306 (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
307 (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
308 (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
309 (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
310 (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
311 (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
312 (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
313 (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
314 (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
315 (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
316 (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
317 (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
318 (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
319 (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
320 (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
321 (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
322 (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
323 (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
324 PUSHs (sv_2mortal ((SV *) hv));
326 guestfs_free_lvm_vg_list (volgroups);
332 struct guestfs_lvm_lv_list *logvols;
336 logvols = guestfs_lvs_full (g);
338 croak ("lvs_full: %s", last_error);
339 EXTEND (SP, logvols->len);
340 for (i = 0; i < logvols->len; ++i) {
342 (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
343 (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
344 (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
345 (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
346 (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
347 (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
348 (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
349 (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
350 (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
351 (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
352 (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
353 (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
354 (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
355 (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
356 (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
357 (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
358 PUSHs (sv_2mortal ((SV *) hv));
360 guestfs_free_lvm_lv_list (logvols);