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
33 my_newSVll(long long val) {
39 len = snprintf(buf, 100, "%" PRId64, val);
40 return newSVpv(buf, len);
49 my_newSVull(unsigned long long val) {
55 len = snprintf(buf, 100, "%" PRIu64, val);
56 return newSVpv(buf, len);
60 /* http://www.perlmonks.org/?node_id=680842 */
62 XS_unpack_charPtrPtr (SV *arg) {
67 if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV) {
68 croak ("array reference expected");
71 av = (AV *)SvRV (arg);
72 ret = (char **)malloc (av_len (av) + 1 + 1);
74 for (i = 0; i <= av_len (av); i++) {
75 SV **elem = av_fetch (av, i, 0);
78 croak ("missing element in list");
80 ret[i] = SvPV_nolen (*elem);
88 MODULE = Sys::Guestfs PACKAGE = Sys::Guestfs
93 RETVAL = guestfs_create ();
95 croak ("could not create guestfs handle");
96 guestfs_set_error_handler (RETVAL, NULL, NULL);
112 r = guestfs_launch (g);
114 croak ("launch: %s", guestfs_last_error (g));
122 r = guestfs_wait_ready (g);
124 croak ("wait_ready: %s", guestfs_last_error (g));
132 r = guestfs_kill_subprocess (g);
134 croak ("kill_subprocess: %s", guestfs_last_error (g));
137 add_drive (g, filename)
143 r = guestfs_add_drive (g, filename);
145 croak ("add_drive: %s", guestfs_last_error (g));
148 add_cdrom (g, filename)
154 r = guestfs_add_cdrom (g, filename);
156 croak ("add_cdrom: %s", guestfs_last_error (g));
159 config (g, qemuparam, qemuvalue)
166 r = guestfs_config (g, qemuparam, qemuvalue);
168 croak ("config: %s", guestfs_last_error (g));
177 r = guestfs_set_path (g, path);
179 croak ("set_path: %s", guestfs_last_error (g));
187 path = guestfs_get_path (g);
189 croak ("get_path: %s", guestfs_last_error (g));
190 RETVAL = newSVpv (path, 0);
195 set_autosync (g, autosync)
201 r = guestfs_set_autosync (g, autosync);
203 croak ("set_autosync: %s", guestfs_last_error (g));
211 autosync = guestfs_get_autosync (g);
213 croak ("get_autosync: %s", guestfs_last_error (g));
214 RETVAL = newSViv (autosync);
219 set_verbose (g, verbose)
225 r = guestfs_set_verbose (g, verbose);
227 croak ("set_verbose: %s", guestfs_last_error (g));
235 verbose = guestfs_get_verbose (g);
237 croak ("get_verbose: %s", guestfs_last_error (g));
238 RETVAL = newSViv (verbose);
243 mount (g, device, mountpoint)
250 r = guestfs_mount (g, device, mountpoint);
252 croak ("mount: %s", guestfs_last_error (g));
260 r = guestfs_sync (g);
262 croak ("sync: %s", guestfs_last_error (g));
271 r = guestfs_touch (g, path);
273 croak ("touch: %s", guestfs_last_error (g));
282 content = guestfs_cat (g, path);
284 croak ("cat: %s", guestfs_last_error (g));
285 RETVAL = newSVpv (content, 0);
297 listing = guestfs_ll (g, directory);
299 croak ("ll: %s", guestfs_last_error (g));
300 RETVAL = newSVpv (listing, 0);
313 listing = guestfs_ls (g, directory);
315 croak ("ls: %s", guestfs_last_error (g));
316 for (n = 0; listing[n] != NULL; ++n) /**/;
318 for (i = 0; i < n; ++i) {
319 PUSHs (sv_2mortal (newSVpv (listing[i], 0)));
331 devices = guestfs_list_devices (g);
333 croak ("list_devices: %s", guestfs_last_error (g));
334 for (n = 0; devices[n] != NULL; ++n) /**/;
336 for (i = 0; i < n; ++i) {
337 PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
349 partitions = guestfs_list_partitions (g);
350 if (partitions == NULL)
351 croak ("list_partitions: %s", guestfs_last_error (g));
352 for (n = 0; partitions[n] != NULL; ++n) /**/;
354 for (i = 0; i < n; ++i) {
355 PUSHs (sv_2mortal (newSVpv (partitions[i], 0)));
356 free (partitions[i]);
367 physvols = guestfs_pvs (g);
368 if (physvols == NULL)
369 croak ("pvs: %s", guestfs_last_error (g));
370 for (n = 0; physvols[n] != NULL; ++n) /**/;
372 for (i = 0; i < n; ++i) {
373 PUSHs (sv_2mortal (newSVpv (physvols[i], 0)));
385 volgroups = guestfs_vgs (g);
386 if (volgroups == NULL)
387 croak ("vgs: %s", guestfs_last_error (g));
388 for (n = 0; volgroups[n] != NULL; ++n) /**/;
390 for (i = 0; i < n; ++i) {
391 PUSHs (sv_2mortal (newSVpv (volgroups[i], 0)));
403 logvols = guestfs_lvs (g);
405 croak ("lvs: %s", guestfs_last_error (g));
406 for (n = 0; logvols[n] != NULL; ++n) /**/;
408 for (i = 0; i < n; ++i) {
409 PUSHs (sv_2mortal (newSVpv (logvols[i], 0)));
418 struct guestfs_lvm_pv_list *physvols;
422 physvols = guestfs_pvs_full (g);
423 if (physvols == NULL)
424 croak ("pvs_full: %s", guestfs_last_error (g));
425 EXTEND (SP, physvols->len);
426 for (i = 0; i < physvols->len; ++i) {
428 (void) hv_store (hv, "pv_name", 7, newSVpv (physvols->val[i].pv_name, 0), 0);
429 (void) hv_store (hv, "pv_uuid", 7, newSVpv (physvols->val[i].pv_uuid, 32), 0);
430 (void) hv_store (hv, "pv_fmt", 6, newSVpv (physvols->val[i].pv_fmt, 0), 0);
431 (void) hv_store (hv, "pv_size", 7, my_newSVull (physvols->val[i].pv_size), 0);
432 (void) hv_store (hv, "dev_size", 8, my_newSVull (physvols->val[i].dev_size), 0);
433 (void) hv_store (hv, "pv_free", 7, my_newSVull (physvols->val[i].pv_free), 0);
434 (void) hv_store (hv, "pv_used", 7, my_newSVull (physvols->val[i].pv_used), 0);
435 (void) hv_store (hv, "pv_attr", 7, newSVpv (physvols->val[i].pv_attr, 0), 0);
436 (void) hv_store (hv, "pv_pe_count", 11, my_newSVll (physvols->val[i].pv_pe_count), 0);
437 (void) hv_store (hv, "pv_pe_alloc_count", 17, my_newSVll (physvols->val[i].pv_pe_alloc_count), 0);
438 (void) hv_store (hv, "pv_tags", 7, newSVpv (physvols->val[i].pv_tags, 0), 0);
439 (void) hv_store (hv, "pe_start", 8, my_newSVull (physvols->val[i].pe_start), 0);
440 (void) hv_store (hv, "pv_mda_count", 12, my_newSVll (physvols->val[i].pv_mda_count), 0);
441 (void) hv_store (hv, "pv_mda_free", 11, my_newSVull (physvols->val[i].pv_mda_free), 0);
442 PUSHs (sv_2mortal ((SV *) hv));
444 guestfs_free_lvm_pv_list (physvols);
450 struct guestfs_lvm_vg_list *volgroups;
454 volgroups = guestfs_vgs_full (g);
455 if (volgroups == NULL)
456 croak ("vgs_full: %s", guestfs_last_error (g));
457 EXTEND (SP, volgroups->len);
458 for (i = 0; i < volgroups->len; ++i) {
460 (void) hv_store (hv, "vg_name", 7, newSVpv (volgroups->val[i].vg_name, 0), 0);
461 (void) hv_store (hv, "vg_uuid", 7, newSVpv (volgroups->val[i].vg_uuid, 32), 0);
462 (void) hv_store (hv, "vg_fmt", 6, newSVpv (volgroups->val[i].vg_fmt, 0), 0);
463 (void) hv_store (hv, "vg_attr", 7, newSVpv (volgroups->val[i].vg_attr, 0), 0);
464 (void) hv_store (hv, "vg_size", 7, my_newSVull (volgroups->val[i].vg_size), 0);
465 (void) hv_store (hv, "vg_free", 7, my_newSVull (volgroups->val[i].vg_free), 0);
466 (void) hv_store (hv, "vg_sysid", 8, newSVpv (volgroups->val[i].vg_sysid, 0), 0);
467 (void) hv_store (hv, "vg_extent_size", 14, my_newSVull (volgroups->val[i].vg_extent_size), 0);
468 (void) hv_store (hv, "vg_extent_count", 15, my_newSVll (volgroups->val[i].vg_extent_count), 0);
469 (void) hv_store (hv, "vg_free_count", 13, my_newSVll (volgroups->val[i].vg_free_count), 0);
470 (void) hv_store (hv, "max_lv", 6, my_newSVll (volgroups->val[i].max_lv), 0);
471 (void) hv_store (hv, "max_pv", 6, my_newSVll (volgroups->val[i].max_pv), 0);
472 (void) hv_store (hv, "pv_count", 8, my_newSVll (volgroups->val[i].pv_count), 0);
473 (void) hv_store (hv, "lv_count", 8, my_newSVll (volgroups->val[i].lv_count), 0);
474 (void) hv_store (hv, "snap_count", 10, my_newSVll (volgroups->val[i].snap_count), 0);
475 (void) hv_store (hv, "vg_seqno", 8, my_newSVll (volgroups->val[i].vg_seqno), 0);
476 (void) hv_store (hv, "vg_tags", 7, newSVpv (volgroups->val[i].vg_tags, 0), 0);
477 (void) hv_store (hv, "vg_mda_count", 12, my_newSVll (volgroups->val[i].vg_mda_count), 0);
478 (void) hv_store (hv, "vg_mda_free", 11, my_newSVull (volgroups->val[i].vg_mda_free), 0);
479 PUSHs (sv_2mortal ((SV *) hv));
481 guestfs_free_lvm_vg_list (volgroups);
487 struct guestfs_lvm_lv_list *logvols;
491 logvols = guestfs_lvs_full (g);
493 croak ("lvs_full: %s", guestfs_last_error (g));
494 EXTEND (SP, logvols->len);
495 for (i = 0; i < logvols->len; ++i) {
497 (void) hv_store (hv, "lv_name", 7, newSVpv (logvols->val[i].lv_name, 0), 0);
498 (void) hv_store (hv, "lv_uuid", 7, newSVpv (logvols->val[i].lv_uuid, 32), 0);
499 (void) hv_store (hv, "lv_attr", 7, newSVpv (logvols->val[i].lv_attr, 0), 0);
500 (void) hv_store (hv, "lv_major", 8, my_newSVll (logvols->val[i].lv_major), 0);
501 (void) hv_store (hv, "lv_minor", 8, my_newSVll (logvols->val[i].lv_minor), 0);
502 (void) hv_store (hv, "lv_kernel_major", 15, my_newSVll (logvols->val[i].lv_kernel_major), 0);
503 (void) hv_store (hv, "lv_kernel_minor", 15, my_newSVll (logvols->val[i].lv_kernel_minor), 0);
504 (void) hv_store (hv, "lv_size", 7, my_newSVull (logvols->val[i].lv_size), 0);
505 (void) hv_store (hv, "seg_count", 9, my_newSVll (logvols->val[i].seg_count), 0);
506 (void) hv_store (hv, "origin", 6, newSVpv (logvols->val[i].origin, 0), 0);
507 (void) hv_store (hv, "snap_percent", 12, newSVnv (logvols->val[i].snap_percent), 0);
508 (void) hv_store (hv, "copy_percent", 12, newSVnv (logvols->val[i].copy_percent), 0);
509 (void) hv_store (hv, "move_pv", 7, newSVpv (logvols->val[i].move_pv, 0), 0);
510 (void) hv_store (hv, "lv_tags", 7, newSVpv (logvols->val[i].lv_tags, 0), 0);
511 (void) hv_store (hv, "mirror_log", 10, newSVpv (logvols->val[i].mirror_log, 0), 0);
512 (void) hv_store (hv, "modules", 7, newSVpv (logvols->val[i].modules, 0), 0);
513 PUSHs (sv_2mortal ((SV *) hv));
515 guestfs_free_lvm_lv_list (logvols);
525 lines = guestfs_read_lines (g, path);
527 croak ("read_lines: %s", guestfs_last_error (g));
528 for (n = 0; lines[n] != NULL; ++n) /**/;
530 for (i = 0; i < n; ++i) {
531 PUSHs (sv_2mortal (newSVpv (lines[i], 0)));
537 aug_init (g, root, flags)
544 r = guestfs_aug_init (g, root, flags);
546 croak ("aug_init: %s", guestfs_last_error (g));
554 r = guestfs_aug_close (g);
556 croak ("aug_close: %s", guestfs_last_error (g));
559 aug_defvar (g, name, expr)
566 nrnodes = guestfs_aug_defvar (g, name, expr);
568 croak ("aug_defvar: %s", guestfs_last_error (g));
569 RETVAL = newSViv (nrnodes);
574 aug_defnode (g, name, expr, val)
580 struct guestfs_int_bool *r;
582 r = guestfs_aug_defnode (g, name, expr, val);
584 croak ("aug_defnode: %s", guestfs_last_error (g));
586 PUSHs (sv_2mortal (newSViv (r->i)));
587 PUSHs (sv_2mortal (newSViv (r->b)));
588 guestfs_free_int_bool (r);
597 val = guestfs_aug_get (g, path);
599 croak ("aug_get: %s", guestfs_last_error (g));
600 RETVAL = newSVpv (val, 0);
606 aug_set (g, path, val)
613 r = guestfs_aug_set (g, path, val);
615 croak ("aug_set: %s", guestfs_last_error (g));
618 aug_insert (g, path, label, before)
626 r = guestfs_aug_insert (g, path, label, before);
628 croak ("aug_insert: %s", guestfs_last_error (g));
637 nrnodes = guestfs_aug_rm (g, path);
639 croak ("aug_rm: %s", guestfs_last_error (g));
640 RETVAL = newSViv (nrnodes);
645 aug_mv (g, src, dest)
652 r = guestfs_aug_mv (g, src, dest);
654 croak ("aug_mv: %s", guestfs_last_error (g));
664 matches = guestfs_aug_match (g, path);
666 croak ("aug_match: %s", guestfs_last_error (g));
667 for (n = 0; matches[n] != NULL; ++n) /**/;
669 for (i = 0; i < n; ++i) {
670 PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
681 r = guestfs_aug_save (g);
683 croak ("aug_save: %s", guestfs_last_error (g));
691 r = guestfs_aug_load (g);
693 croak ("aug_load: %s", guestfs_last_error (g));
703 matches = guestfs_aug_ls (g, path);
705 croak ("aug_ls: %s", guestfs_last_error (g));
706 for (n = 0; matches[n] != NULL; ++n) /**/;
708 for (i = 0; i < n; ++i) {
709 PUSHs (sv_2mortal (newSVpv (matches[i], 0)));
721 r = guestfs_rm (g, path);
723 croak ("rm: %s", guestfs_last_error (g));
732 r = guestfs_rmdir (g, path);
734 croak ("rmdir: %s", guestfs_last_error (g));
743 r = guestfs_rm_rf (g, path);
745 croak ("rm_rf: %s", guestfs_last_error (g));
754 r = guestfs_mkdir (g, path);
756 croak ("mkdir: %s", guestfs_last_error (g));
765 r = guestfs_mkdir_p (g, path);
767 croak ("mkdir_p: %s", guestfs_last_error (g));
770 chmod (g, mode, path)
777 r = guestfs_chmod (g, mode, path);
779 croak ("chmod: %s", guestfs_last_error (g));
782 chown (g, owner, group, path)
790 r = guestfs_chown (g, owner, group, path);
792 croak ("chown: %s", guestfs_last_error (g));
801 existsflag = guestfs_exists (g, path);
802 if (existsflag == -1)
803 croak ("exists: %s", guestfs_last_error (g));
804 RETVAL = newSViv (existsflag);
815 fileflag = guestfs_is_file (g, path);
817 croak ("is_file: %s", guestfs_last_error (g));
818 RETVAL = newSViv (fileflag);
829 dirflag = guestfs_is_dir (g, path);
831 croak ("is_dir: %s", guestfs_last_error (g));
832 RETVAL = newSViv (dirflag);
843 r = guestfs_pvcreate (g, device);
845 croak ("pvcreate: %s", guestfs_last_error (g));
848 vgcreate (g, volgroup, physvols)
855 r = guestfs_vgcreate (g, volgroup, physvols);
858 croak ("vgcreate: %s", guestfs_last_error (g));
861 lvcreate (g, logvol, volgroup, mbytes)
869 r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
871 croak ("lvcreate: %s", guestfs_last_error (g));
874 mkfs (g, fstype, device)
881 r = guestfs_mkfs (g, fstype, device);
883 croak ("mkfs: %s", guestfs_last_error (g));
886 sfdisk (g, device, cyls, heads, sectors, lines)
896 r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
899 croak ("sfdisk: %s", guestfs_last_error (g));
902 write_file (g, path, content, size)
910 r = guestfs_write_file (g, path, content, size);
912 croak ("write_file: %s", guestfs_last_error (g));
915 umount (g, pathordevice)
921 r = guestfs_umount (g, pathordevice);
923 croak ("umount: %s", guestfs_last_error (g));
932 devices = guestfs_mounts (g);
934 croak ("mounts: %s", guestfs_last_error (g));
935 for (n = 0; devices[n] != NULL; ++n) /**/;
937 for (i = 0; i < n; ++i) {
938 PUSHs (sv_2mortal (newSVpv (devices[i], 0)));
949 r = guestfs_umount_all (g);
951 croak ("umount_all: %s", guestfs_last_error (g));
959 r = guestfs_lvm_remove_all (g);
961 croak ("lvm_remove_all: %s", guestfs_last_error (g));
970 description = guestfs_file (g, path);
971 if (description == NULL)
972 croak ("file: %s", guestfs_last_error (g));
973 RETVAL = newSVpv (description, 0);
979 command (g, arguments)
985 output = guestfs_command (g, arguments);
988 croak ("command: %s", guestfs_last_error (g));
989 RETVAL = newSVpv (output, 0);
995 command_lines (g, arguments)
1002 lines = guestfs_command_lines (g, arguments);
1005 croak ("command_lines: %s", guestfs_last_error (g));
1006 for (n = 0; lines[n] != NULL; ++n) /**/;
1008 for (i = 0; i < n; ++i) {
1009 PUSHs (sv_2mortal (newSVpv (lines[i], 0)));