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
22 package com.redhat.et.libguestfs;
24 import java.util.HashMap;
25 import com.redhat.et.libguestfs.LibGuestFSException;
26 import com.redhat.et.libguestfs.PV;
27 import com.redhat.et.libguestfs.VG;
28 import com.redhat.et.libguestfs.LV;
29 import com.redhat.et.libguestfs.Stat;
30 import com.redhat.et.libguestfs.StatVFS;
31 import com.redhat.et.libguestfs.IntBool;
34 * The GuestFS object is a libguestfs handle.
38 public class GuestFS {
39 // Load the native code.
41 System.loadLibrary ("guestfs_jni");
45 * The native guestfs_h pointer.
50 * Create a libguestfs handle.
52 * @throws LibGuestFSException
54 public GuestFS () throws LibGuestFSException
58 private native long _create () throws LibGuestFSException;
61 * Close a libguestfs handle.
63 * You can also leave handles to be collected by the garbage
64 * collector, but this method ensures that the resources used
65 * by the handle are freed up immediately. If you call any
66 * other methods after closing the handle, you will get an
69 * @throws LibGuestFSException
71 public void close () throws LibGuestFSException
77 private native void _close (long g) throws LibGuestFSException;
79 public void finalize () throws LibGuestFSException
84 public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
85 throws LibGuestFSException
88 throw new LibGuestFSException ("test0: handle is closed");
89 _test0 (g, str, optstr, strlist, b, integer, filein, fileout);
91 private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
92 throws LibGuestFSException;
94 public int test0rint (String val)
95 throws LibGuestFSException
98 throw new LibGuestFSException ("test0rint: handle is closed");
99 return _test0rint (g, val);
101 private native int _test0rint (long g, String val)
102 throws LibGuestFSException;
104 public int test0rinterr ()
105 throws LibGuestFSException
108 throw new LibGuestFSException ("test0rinterr: handle is closed");
109 return _test0rinterr (g);
111 private native int _test0rinterr (long g)
112 throws LibGuestFSException;
114 public long test0rint64 (String val)
115 throws LibGuestFSException
118 throw new LibGuestFSException ("test0rint64: handle is closed");
119 return _test0rint64 (g, val);
121 private native long _test0rint64 (long g, String val)
122 throws LibGuestFSException;
124 public long test0rint64err ()
125 throws LibGuestFSException
128 throw new LibGuestFSException ("test0rint64err: handle is closed");
129 return _test0rint64err (g);
131 private native long _test0rint64err (long g)
132 throws LibGuestFSException;
134 public boolean test0rbool (String val)
135 throws LibGuestFSException
138 throw new LibGuestFSException ("test0rbool: handle is closed");
139 return _test0rbool (g, val);
141 private native boolean _test0rbool (long g, String val)
142 throws LibGuestFSException;
144 public boolean test0rboolerr ()
145 throws LibGuestFSException
148 throw new LibGuestFSException ("test0rboolerr: handle is closed");
149 return _test0rboolerr (g);
151 private native boolean _test0rboolerr (long g)
152 throws LibGuestFSException;
154 public String test0rconststring (String val)
155 throws LibGuestFSException
158 throw new LibGuestFSException ("test0rconststring: handle is closed");
159 return _test0rconststring (g, val);
161 private native String _test0rconststring (long g, String val)
162 throws LibGuestFSException;
164 public String test0rconststringerr ()
165 throws LibGuestFSException
168 throw new LibGuestFSException ("test0rconststringerr: handle is closed");
169 return _test0rconststringerr (g);
171 private native String _test0rconststringerr (long g)
172 throws LibGuestFSException;
174 public String test0rstring (String val)
175 throws LibGuestFSException
178 throw new LibGuestFSException ("test0rstring: handle is closed");
179 return _test0rstring (g, val);
181 private native String _test0rstring (long g, String val)
182 throws LibGuestFSException;
184 public String test0rstringerr ()
185 throws LibGuestFSException
188 throw new LibGuestFSException ("test0rstringerr: handle is closed");
189 return _test0rstringerr (g);
191 private native String _test0rstringerr (long g)
192 throws LibGuestFSException;
194 public String[] test0rstringlist (String val)
195 throws LibGuestFSException
198 throw new LibGuestFSException ("test0rstringlist: handle is closed");
199 return _test0rstringlist (g, val);
201 private native String[] _test0rstringlist (long g, String val)
202 throws LibGuestFSException;
204 public String[] test0rstringlisterr ()
205 throws LibGuestFSException
208 throw new LibGuestFSException ("test0rstringlisterr: handle is closed");
209 return _test0rstringlisterr (g);
211 private native String[] _test0rstringlisterr (long g)
212 throws LibGuestFSException;
214 public IntBool test0rintbool (String val)
215 throws LibGuestFSException
218 throw new LibGuestFSException ("test0rintbool: handle is closed");
219 return _test0rintbool (g, val);
221 private native IntBool _test0rintbool (long g, String val)
222 throws LibGuestFSException;
224 public IntBool test0rintboolerr ()
225 throws LibGuestFSException
228 throw new LibGuestFSException ("test0rintboolerr: handle is closed");
229 return _test0rintboolerr (g);
231 private native IntBool _test0rintboolerr (long g)
232 throws LibGuestFSException;
234 public PV[] test0rpvlist (String val)
235 throws LibGuestFSException
238 throw new LibGuestFSException ("test0rpvlist: handle is closed");
239 return _test0rpvlist (g, val);
241 private native PV[] _test0rpvlist (long g, String val)
242 throws LibGuestFSException;
244 public PV[] test0rpvlisterr ()
245 throws LibGuestFSException
248 throw new LibGuestFSException ("test0rpvlisterr: handle is closed");
249 return _test0rpvlisterr (g);
251 private native PV[] _test0rpvlisterr (long g)
252 throws LibGuestFSException;
254 public VG[] test0rvglist (String val)
255 throws LibGuestFSException
258 throw new LibGuestFSException ("test0rvglist: handle is closed");
259 return _test0rvglist (g, val);
261 private native VG[] _test0rvglist (long g, String val)
262 throws LibGuestFSException;
264 public VG[] test0rvglisterr ()
265 throws LibGuestFSException
268 throw new LibGuestFSException ("test0rvglisterr: handle is closed");
269 return _test0rvglisterr (g);
271 private native VG[] _test0rvglisterr (long g)
272 throws LibGuestFSException;
274 public LV[] test0rlvlist (String val)
275 throws LibGuestFSException
278 throw new LibGuestFSException ("test0rlvlist: handle is closed");
279 return _test0rlvlist (g, val);
281 private native LV[] _test0rlvlist (long g, String val)
282 throws LibGuestFSException;
284 public LV[] test0rlvlisterr ()
285 throws LibGuestFSException
288 throw new LibGuestFSException ("test0rlvlisterr: handle is closed");
289 return _test0rlvlisterr (g);
291 private native LV[] _test0rlvlisterr (long g)
292 throws LibGuestFSException;
294 public Stat test0rstat (String val)
295 throws LibGuestFSException
298 throw new LibGuestFSException ("test0rstat: handle is closed");
299 return _test0rstat (g, val);
301 private native Stat _test0rstat (long g, String val)
302 throws LibGuestFSException;
304 public Stat test0rstaterr ()
305 throws LibGuestFSException
308 throw new LibGuestFSException ("test0rstaterr: handle is closed");
309 return _test0rstaterr (g);
311 private native Stat _test0rstaterr (long g)
312 throws LibGuestFSException;
314 public StatVFS test0rstatvfs (String val)
315 throws LibGuestFSException
318 throw new LibGuestFSException ("test0rstatvfs: handle is closed");
319 return _test0rstatvfs (g, val);
321 private native StatVFS _test0rstatvfs (long g, String val)
322 throws LibGuestFSException;
324 public StatVFS test0rstatvfserr ()
325 throws LibGuestFSException
328 throw new LibGuestFSException ("test0rstatvfserr: handle is closed");
329 return _test0rstatvfserr (g);
331 private native StatVFS _test0rstatvfserr (long g)
332 throws LibGuestFSException;
334 public HashMap<String,String> test0rhashtable (String val)
335 throws LibGuestFSException
338 throw new LibGuestFSException ("test0rhashtable: handle is closed");
339 return _test0rhashtable (g, val);
341 private native HashMap<String,String> _test0rhashtable (long g, String val)
342 throws LibGuestFSException;
344 public HashMap<String,String> test0rhashtableerr ()
345 throws LibGuestFSException
348 throw new LibGuestFSException ("test0rhashtableerr: handle is closed");
349 return _test0rhashtableerr (g);
351 private native HashMap<String,String> _test0rhashtableerr (long g)
352 throws LibGuestFSException;
355 * launch the qemu subprocess
357 * Internally libguestfs is implemented by running a
358 * virtual machine using qemu(1).
360 * You should call this after configuring the handle (eg.
361 * adding drives) but before performing any actions.
363 * @throws LibGuestFSException
365 public void launch ()
366 throws LibGuestFSException
369 throw new LibGuestFSException ("launch: handle is closed");
372 private native void _launch (long g)
373 throws LibGuestFSException;
376 * wait until the qemu subprocess launches
378 * Internally libguestfs is implemented by running a
379 * virtual machine using qemu(1).
381 * You should call this after "g.launch" to wait for the
382 * launch to complete.
384 * @throws LibGuestFSException
386 public void wait_ready ()
387 throws LibGuestFSException
390 throw new LibGuestFSException ("wait_ready: handle is closed");
393 private native void _wait_ready (long g)
394 throws LibGuestFSException;
397 * kill the qemu subprocess
399 * This kills the qemu subprocess. You should never need to
402 * @throws LibGuestFSException
404 public void kill_subprocess ()
405 throws LibGuestFSException
408 throw new LibGuestFSException ("kill_subprocess: handle is closed");
409 _kill_subprocess (g);
411 private native void _kill_subprocess (long g)
412 throws LibGuestFSException;
415 * add an image to examine or modify
417 * This function adds a virtual machine disk image
418 * "filename" to the guest. The first time you call this
419 * function, the disk appears as IDE disk 0 ("/dev/sda") in
420 * the guest, the second time as "/dev/sdb", and so on.
422 * You don't necessarily need to be root when using
423 * libguestfs. However you obviously do need sufficient
424 * permissions to access the filename for whatever
425 * operations you want to perform (ie. read access if you
426 * just want to read the image or write access if you want
427 * to modify the image).
429 * This is equivalent to the qemu parameter "-drive
430 * file=filename,cache=off".
432 * Note that this call checks for the existence of
433 * "filename". This stops you from specifying other types
434 * of drive which are supported by qemu such as "nbd:" and
435 * "http:" URLs. To specify those, use the general
436 * "g.config" call instead.
438 * @throws LibGuestFSException
440 public void add_drive (String filename)
441 throws LibGuestFSException
444 throw new LibGuestFSException ("add_drive: handle is closed");
445 _add_drive (g, filename);
447 private native void _add_drive (long g, String filename)
448 throws LibGuestFSException;
451 * add a CD-ROM disk image to examine
453 * This function adds a virtual CD-ROM disk image to the
456 * This is equivalent to the qemu parameter "-cdrom
459 * Note that this call checks for the existence of
460 * "filename". This stops you from specifying other types
461 * of drive which are supported by qemu such as "nbd:" and
462 * "http:" URLs. To specify those, use the general
463 * "g.config" call instead.
465 * @throws LibGuestFSException
467 public void add_cdrom (String filename)
468 throws LibGuestFSException
471 throw new LibGuestFSException ("add_cdrom: handle is closed");
472 _add_cdrom (g, filename);
474 private native void _add_cdrom (long g, String filename)
475 throws LibGuestFSException;
478 * add a drive in snapshot mode (read-only)
480 * This adds a drive in snapshot mode, making it
481 * effectively read-only.
483 * Note that writes to the device are allowed, and will be
484 * seen for the duration of the guestfs handle, but they
485 * are written to a temporary file which is discarded as
486 * soon as the guestfs handle is closed. We don't currently
487 * have any method to enable changes to be committed,
488 * although qemu can support this.
490 * This is equivalent to the qemu parameter "-drive
491 * file=filename,snapshot=on".
493 * Note that this call checks for the existence of
494 * "filename". This stops you from specifying other types
495 * of drive which are supported by qemu such as "nbd:" and
496 * "http:" URLs. To specify those, use the general
497 * "g.config" call instead.
499 * @throws LibGuestFSException
501 public void add_drive_ro (String filename)
502 throws LibGuestFSException
505 throw new LibGuestFSException ("add_drive_ro: handle is closed");
506 _add_drive_ro (g, filename);
508 private native void _add_drive_ro (long g, String filename)
509 throws LibGuestFSException;
512 * add qemu parameters
514 * This can be used to add arbitrary qemu command line
515 * parameters of the form "-param value". Actually it's not
516 * quite arbitrary - we prevent you from setting some
517 * parameters which would interfere with parameters that we
520 * The first character of "param" string must be a "-"
523 * "value" can be NULL.
525 * @throws LibGuestFSException
527 public void config (String qemuparam, String qemuvalue)
528 throws LibGuestFSException
531 throw new LibGuestFSException ("config: handle is closed");
532 _config (g, qemuparam, qemuvalue);
534 private native void _config (long g, String qemuparam, String qemuvalue)
535 throws LibGuestFSException;
538 * set the qemu binary
540 * Set the qemu binary that we will use.
542 * The default is chosen when the library was compiled by
543 * the configure script.
545 * You can also override this by setting the
546 * "LIBGUESTFS_QEMU" environment variable.
548 * Setting "qemu" to "NULL" restores the default qemu
551 * @throws LibGuestFSException
553 public void set_qemu (String qemu)
554 throws LibGuestFSException
557 throw new LibGuestFSException ("set_qemu: handle is closed");
560 private native void _set_qemu (long g, String qemu)
561 throws LibGuestFSException;
564 * get the qemu binary
566 * Return the current qemu binary.
568 * This is always non-NULL. If it wasn't set already, then
569 * this will return the default qemu binary name.
571 * @throws LibGuestFSException
573 public String get_qemu ()
574 throws LibGuestFSException
577 throw new LibGuestFSException ("get_qemu: handle is closed");
578 return _get_qemu (g);
580 private native String _get_qemu (long g)
581 throws LibGuestFSException;
584 * set the search path
586 * Set the path that libguestfs searches for kernel and
589 * The default is "$libdir/guestfs" unless overridden by
590 * setting "LIBGUESTFS_PATH" environment variable.
592 * Setting "path" to "NULL" restores the default path.
594 * @throws LibGuestFSException
596 public void set_path (String path)
597 throws LibGuestFSException
600 throw new LibGuestFSException ("set_path: handle is closed");
603 private native void _set_path (long g, String path)
604 throws LibGuestFSException;
607 * get the search path
609 * Return the current search path.
611 * This is always non-NULL. If it wasn't set already, then
612 * this will return the default path.
614 * @throws LibGuestFSException
616 public String get_path ()
617 throws LibGuestFSException
620 throw new LibGuestFSException ("get_path: handle is closed");
621 return _get_path (g);
623 private native String _get_path (long g)
624 throws LibGuestFSException;
627 * add options to kernel command line
629 * This function is used to add additional options to the
630 * guest kernel command line.
632 * The default is "NULL" unless overridden by setting
633 * "LIBGUESTFS_APPEND" environment variable.
635 * Setting "append" to "NULL" means *no* additional options
636 * are passed (libguestfs always adds a few of its own).
638 * @throws LibGuestFSException
640 public void set_append (String append)
641 throws LibGuestFSException
644 throw new LibGuestFSException ("set_append: handle is closed");
645 _set_append (g, append);
647 private native void _set_append (long g, String append)
648 throws LibGuestFSException;
651 * get the additional kernel options
653 * Return the additional kernel options which are added to
654 * the guest kernel command line.
656 * If "NULL" then no options are added.
658 * @throws LibGuestFSException
660 public String get_append ()
661 throws LibGuestFSException
664 throw new LibGuestFSException ("get_append: handle is closed");
665 return _get_append (g);
667 private native String _get_append (long g)
668 throws LibGuestFSException;
673 * If "autosync" is true, this enables autosync. Libguestfs
674 * will make a best effort attempt to run "g.umount_all"
675 * followed by "g.sync" when the handle is closed (also if
676 * the program exits without closing handles).
678 * This is disabled by default (except in guestfish where
679 * it is enabled by default).
681 * @throws LibGuestFSException
683 public void set_autosync (boolean autosync)
684 throws LibGuestFSException
687 throw new LibGuestFSException ("set_autosync: handle is closed");
688 _set_autosync (g, autosync);
690 private native void _set_autosync (long g, boolean autosync)
691 throws LibGuestFSException;
696 * Get the autosync flag.
698 * @throws LibGuestFSException
700 public boolean get_autosync ()
701 throws LibGuestFSException
704 throw new LibGuestFSException ("get_autosync: handle is closed");
705 return _get_autosync (g);
707 private native boolean _get_autosync (long g)
708 throws LibGuestFSException;
713 * If "verbose" is true, this turns on verbose messages (to
716 * Verbose messages are disabled unless the environment
717 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
719 * @throws LibGuestFSException
721 public void set_verbose (boolean verbose)
722 throws LibGuestFSException
725 throw new LibGuestFSException ("set_verbose: handle is closed");
726 _set_verbose (g, verbose);
728 private native void _set_verbose (long g, boolean verbose)
729 throws LibGuestFSException;
734 * This returns the verbose messages flag.
736 * @throws LibGuestFSException
738 public boolean get_verbose ()
739 throws LibGuestFSException
742 throw new LibGuestFSException ("get_verbose: handle is closed");
743 return _get_verbose (g);
745 private native boolean _get_verbose (long g)
746 throws LibGuestFSException;
749 * is ready to accept commands
751 * This returns true iff this handle is ready to accept
752 * commands (in the "READY" state).
754 * For more information on states, see guestfs(3).
756 * @throws LibGuestFSException
758 public boolean is_ready ()
759 throws LibGuestFSException
762 throw new LibGuestFSException ("is_ready: handle is closed");
763 return _is_ready (g);
765 private native boolean _is_ready (long g)
766 throws LibGuestFSException;
769 * is in configuration state
771 * This returns true iff this handle is being configured
772 * (in the "CONFIG" state).
774 * For more information on states, see guestfs(3).
776 * @throws LibGuestFSException
778 public boolean is_config ()
779 throws LibGuestFSException
782 throw new LibGuestFSException ("is_config: handle is closed");
783 return _is_config (g);
785 private native boolean _is_config (long g)
786 throws LibGuestFSException;
789 * is launching subprocess
791 * This returns true iff this handle is launching the
792 * subprocess (in the "LAUNCHING" state).
794 * For more information on states, see guestfs(3).
796 * @throws LibGuestFSException
798 public boolean is_launching ()
799 throws LibGuestFSException
802 throw new LibGuestFSException ("is_launching: handle is closed");
803 return _is_launching (g);
805 private native boolean _is_launching (long g)
806 throws LibGuestFSException;
809 * is busy processing a command
811 * This returns true iff this handle is busy processing a
812 * command (in the "BUSY" state).
814 * For more information on states, see guestfs(3).
816 * @throws LibGuestFSException
818 public boolean is_busy ()
819 throws LibGuestFSException
822 throw new LibGuestFSException ("is_busy: handle is closed");
825 private native boolean _is_busy (long g)
826 throws LibGuestFSException;
829 * get the current state
831 * This returns the current state as an opaque integer.
832 * This is only useful for printing debug and internal
835 * For more information on states, see guestfs(3).
837 * @throws LibGuestFSException
839 public int get_state ()
840 throws LibGuestFSException
843 throw new LibGuestFSException ("get_state: handle is closed");
844 return _get_state (g);
846 private native int _get_state (long g)
847 throws LibGuestFSException;
852 * This sets the state to "BUSY". This is only used when
853 * implementing actions using the low-level API.
855 * For more information on states, see guestfs(3).
857 * @throws LibGuestFSException
859 public void set_busy ()
860 throws LibGuestFSException
863 throw new LibGuestFSException ("set_busy: handle is closed");
866 private native void _set_busy (long g)
867 throws LibGuestFSException;
872 * This sets the state to "READY". This is only used when
873 * implementing actions using the low-level API.
875 * For more information on states, see guestfs(3).
877 * @throws LibGuestFSException
879 public void set_ready ()
880 throws LibGuestFSException
883 throw new LibGuestFSException ("set_ready: handle is closed");
886 private native void _set_ready (long g)
887 throws LibGuestFSException;
890 * leave the busy state
892 * This sets the state to "READY", or if in "CONFIG" then
893 * it leaves the state as is. This is only used when
894 * implementing actions using the low-level API.
896 * For more information on states, see guestfs(3).
898 * @throws LibGuestFSException
900 public void end_busy ()
901 throws LibGuestFSException
904 throw new LibGuestFSException ("end_busy: handle is closed");
907 private native void _end_busy (long g)
908 throws LibGuestFSException;
911 * mount a guest disk at a position in the filesystem
913 * Mount a guest disk at a position in the filesystem.
914 * Block devices are named "/dev/sda", "/dev/sdb" and so
915 * on, as they were added to the guest. If those block
916 * devices contain partitions, they will have the usual
917 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
920 * The rules are the same as for mount(2): A filesystem
921 * must first be mounted on "/" before others can be
922 * mounted. Other filesystems can only be mounted on
923 * directories which already exist.
925 * The mounted filesystem is writable, if we have
926 * sufficient permissions on the underlying device.
928 * The filesystem options "sync" and "noatime" are set with
929 * this call, in order to improve reliability.
931 * @throws LibGuestFSException
933 public void mount (String device, String mountpoint)
934 throws LibGuestFSException
937 throw new LibGuestFSException ("mount: handle is closed");
938 _mount (g, device, mountpoint);
940 private native void _mount (long g, String device, String mountpoint)
941 throws LibGuestFSException;
944 * sync disks, writes are flushed through to the disk image
946 * This syncs the disk, so that any writes are flushed
947 * through to the underlying disk image.
949 * You should always call this if you have modified a disk
950 * image, before closing the handle.
952 * @throws LibGuestFSException
955 throws LibGuestFSException
958 throw new LibGuestFSException ("sync: handle is closed");
961 private native void _sync (long g)
962 throws LibGuestFSException;
965 * update file timestamps or create a new file
967 * Touch acts like the touch(1) command. It can be used to
968 * update the timestamps on a file, or, if the file does
969 * not exist, to create a new zero-length file.
971 * @throws LibGuestFSException
973 public void touch (String path)
974 throws LibGuestFSException
977 throw new LibGuestFSException ("touch: handle is closed");
980 private native void _touch (long g, String path)
981 throws LibGuestFSException;
984 * list the contents of a file
986 * Return the contents of the file named "path".
988 * Note that this function cannot correctly handle binary
989 * files (specifically, files containing "\0" character
990 * which is treated as end of string). For those you need
991 * to use the "g.download" function which has a more
994 * Because of the message protocol, there is a transfer
995 * limit of somewhere between 2MB and 4MB. To transfer
996 * large files you should use FTP.
998 * @throws LibGuestFSException
1000 public String cat (String path)
1001 throws LibGuestFSException
1004 throw new LibGuestFSException ("cat: handle is closed");
1005 return _cat (g, path);
1007 private native String _cat (long g, String path)
1008 throws LibGuestFSException;
1011 * list the files in a directory (long format)
1013 * List the files in "directory" (relative to the root
1014 * directory, there is no cwd) in the format of 'ls -la'.
1016 * This command is mostly useful for interactive sessions.
1017 * It is *not* intended that you try to parse the output
1020 * @throws LibGuestFSException
1022 public String ll (String directory)
1023 throws LibGuestFSException
1026 throw new LibGuestFSException ("ll: handle is closed");
1027 return _ll (g, directory);
1029 private native String _ll (long g, String directory)
1030 throws LibGuestFSException;
1033 * list the files in a directory
1035 * List the files in "directory" (relative to the root
1036 * directory, there is no cwd). The '.' and '..' entries
1037 * are not returned, but hidden files are shown.
1039 * This command is mostly useful for interactive sessions.
1040 * Programs should probably use "g.readdir" instead.
1042 * @throws LibGuestFSException
1044 public String[] ls (String directory)
1045 throws LibGuestFSException
1048 throw new LibGuestFSException ("ls: handle is closed");
1049 return _ls (g, directory);
1051 private native String[] _ls (long g, String directory)
1052 throws LibGuestFSException;
1055 * list the block devices
1057 * List all the block devices.
1059 * The full block device names are returned, eg. "/dev/sda"
1061 * @throws LibGuestFSException
1063 public String[] list_devices ()
1064 throws LibGuestFSException
1067 throw new LibGuestFSException ("list_devices: handle is closed");
1068 return _list_devices (g);
1070 private native String[] _list_devices (long g)
1071 throws LibGuestFSException;
1074 * list the partitions
1076 * List all the partitions detected on all block devices.
1078 * The full partition device names are returned, eg.
1081 * This does not return logical volumes. For that you will
1082 * need to call "g.lvs".
1084 * @throws LibGuestFSException
1086 public String[] list_partitions ()
1087 throws LibGuestFSException
1090 throw new LibGuestFSException ("list_partitions: handle is closed");
1091 return _list_partitions (g);
1093 private native String[] _list_partitions (long g)
1094 throws LibGuestFSException;
1097 * list the LVM physical volumes (PVs)
1099 * List all the physical volumes detected. This is the
1100 * equivalent of the pvs(8) command.
1102 * This returns a list of just the device names that
1103 * contain PVs (eg. "/dev/sda2").
1105 * See also "g.pvs_full".
1107 * @throws LibGuestFSException
1109 public String[] pvs ()
1110 throws LibGuestFSException
1113 throw new LibGuestFSException ("pvs: handle is closed");
1116 private native String[] _pvs (long g)
1117 throws LibGuestFSException;
1120 * list the LVM volume groups (VGs)
1122 * List all the volumes groups detected. This is the
1123 * equivalent of the vgs(8) command.
1125 * This returns a list of just the volume group names that
1126 * were detected (eg. "VolGroup00").
1128 * See also "g.vgs_full".
1130 * @throws LibGuestFSException
1132 public String[] vgs ()
1133 throws LibGuestFSException
1136 throw new LibGuestFSException ("vgs: handle is closed");
1139 private native String[] _vgs (long g)
1140 throws LibGuestFSException;
1143 * list the LVM logical volumes (LVs)
1145 * List all the logical volumes detected. This is the
1146 * equivalent of the lvs(8) command.
1148 * This returns a list of the logical volume device names
1149 * (eg. "/dev/VolGroup00/LogVol00").
1151 * See also "g.lvs_full".
1153 * @throws LibGuestFSException
1155 public String[] lvs ()
1156 throws LibGuestFSException
1159 throw new LibGuestFSException ("lvs: handle is closed");
1162 private native String[] _lvs (long g)
1163 throws LibGuestFSException;
1166 * list the LVM physical volumes (PVs)
1168 * List all the physical volumes detected. This is the
1169 * equivalent of the pvs(8) command. The "full" version
1170 * includes all fields.
1172 * @throws LibGuestFSException
1174 public PV[] pvs_full ()
1175 throws LibGuestFSException
1178 throw new LibGuestFSException ("pvs_full: handle is closed");
1179 return _pvs_full (g);
1181 private native PV[] _pvs_full (long g)
1182 throws LibGuestFSException;
1185 * list the LVM volume groups (VGs)
1187 * List all the volumes groups detected. This is the
1188 * equivalent of the vgs(8) command. The "full" version
1189 * includes all fields.
1191 * @throws LibGuestFSException
1193 public VG[] vgs_full ()
1194 throws LibGuestFSException
1197 throw new LibGuestFSException ("vgs_full: handle is closed");
1198 return _vgs_full (g);
1200 private native VG[] _vgs_full (long g)
1201 throws LibGuestFSException;
1204 * list the LVM logical volumes (LVs)
1206 * List all the logical volumes detected. This is the
1207 * equivalent of the lvs(8) command. The "full" version
1208 * includes all fields.
1210 * @throws LibGuestFSException
1212 public LV[] lvs_full ()
1213 throws LibGuestFSException
1216 throw new LibGuestFSException ("lvs_full: handle is closed");
1217 return _lvs_full (g);
1219 private native LV[] _lvs_full (long g)
1220 throws LibGuestFSException;
1223 * read file as lines
1225 * Return the contents of the file named "path".
1227 * The file contents are returned as a list of lines.
1228 * Trailing "LF" and "CRLF" character sequences are *not*
1231 * Note that this function cannot correctly handle binary
1232 * files (specifically, files containing "\0" character
1233 * which is treated as end of line). For those you need to
1234 * use the "g.read_file" function which has a more complex
1237 * @throws LibGuestFSException
1239 public String[] read_lines (String path)
1240 throws LibGuestFSException
1243 throw new LibGuestFSException ("read_lines: handle is closed");
1244 return _read_lines (g, path);
1246 private native String[] _read_lines (long g, String path)
1247 throws LibGuestFSException;
1250 * create a new Augeas handle
1252 * Create a new Augeas handle for editing configuration
1253 * files. If there was any previous Augeas handle
1254 * associated with this guestfs session, then it is closed.
1256 * You must call this before using any other "g.aug_*"
1259 * "root" is the filesystem root. "root" must not be NULL,
1262 * The flags are the same as the flags defined in
1263 * <augeas.h>, the logical *or* of the following integers:
1265 * "AUG_SAVE_BACKUP" = 1
1266 * Keep the original file with a ".augsave" extension.
1268 * "AUG_SAVE_NEWFILE" = 2
1269 * Save changes into a file with extension ".augnew",
1270 * and do not overwrite original. Overrides
1271 * "AUG_SAVE_BACKUP".
1273 * "AUG_TYPE_CHECK" = 4
1274 * Typecheck lenses (can be expensive).
1276 * "AUG_NO_STDINC" = 8
1277 * Do not use standard load path for modules.
1279 * "AUG_SAVE_NOOP" = 16
1280 * Make save a no-op, just record what would have been
1283 * "AUG_NO_LOAD" = 32
1284 * Do not load the tree in "g.aug_init".
1286 * To close the handle, you can call "g.aug_close".
1288 * To find out more about Augeas, see <http://augeas.net/>.
1290 * @throws LibGuestFSException
1292 public void aug_init (String root, int flags)
1293 throws LibGuestFSException
1296 throw new LibGuestFSException ("aug_init: handle is closed");
1297 _aug_init (g, root, flags);
1299 private native void _aug_init (long g, String root, int flags)
1300 throws LibGuestFSException;
1303 * close the current Augeas handle
1305 * Close the current Augeas handle and free up any
1306 * resources used by it. After calling this, you have to
1307 * call "g.aug_init" again before you can use any other
1310 * @throws LibGuestFSException
1312 public void aug_close ()
1313 throws LibGuestFSException
1316 throw new LibGuestFSException ("aug_close: handle is closed");
1319 private native void _aug_close (long g)
1320 throws LibGuestFSException;
1323 * define an Augeas variable
1325 * Defines an Augeas variable "name" whose value is the
1326 * result of evaluating "expr". If "expr" is NULL, then
1327 * "name" is undefined.
1329 * On success this returns the number of nodes in "expr",
1330 * or 0 if "expr" evaluates to something which is not a
1333 * @throws LibGuestFSException
1335 public int aug_defvar (String name, String expr)
1336 throws LibGuestFSException
1339 throw new LibGuestFSException ("aug_defvar: handle is closed");
1340 return _aug_defvar (g, name, expr);
1342 private native int _aug_defvar (long g, String name, String expr)
1343 throws LibGuestFSException;
1346 * define an Augeas node
1348 * Defines a variable "name" whose value is the result of
1349 * evaluating "expr".
1351 * If "expr" evaluates to an empty nodeset, a node is
1352 * created, equivalent to calling "g.aug_set" "expr",
1353 * "value". "name" will be the nodeset containing that
1356 * On success this returns a pair containing the number of
1357 * nodes in the nodeset, and a boolean flag if a node was
1360 * @throws LibGuestFSException
1362 public IntBool aug_defnode (String name, String expr, String val)
1363 throws LibGuestFSException
1366 throw new LibGuestFSException ("aug_defnode: handle is closed");
1367 return _aug_defnode (g, name, expr, val);
1369 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1370 throws LibGuestFSException;
1373 * look up the value of an Augeas path
1375 * Look up the value associated with "path". If "path"
1376 * matches exactly one node, the "value" is returned.
1378 * @throws LibGuestFSException
1380 public String aug_get (String path)
1381 throws LibGuestFSException
1384 throw new LibGuestFSException ("aug_get: handle is closed");
1385 return _aug_get (g, path);
1387 private native String _aug_get (long g, String path)
1388 throws LibGuestFSException;
1391 * set Augeas path to value
1393 * Set the value associated with "path" to "value".
1395 * @throws LibGuestFSException
1397 public void aug_set (String path, String val)
1398 throws LibGuestFSException
1401 throw new LibGuestFSException ("aug_set: handle is closed");
1402 _aug_set (g, path, val);
1404 private native void _aug_set (long g, String path, String val)
1405 throws LibGuestFSException;
1408 * insert a sibling Augeas node
1410 * Create a new sibling "label" for "path", inserting it
1411 * into the tree before or after "path" (depending on the
1412 * boolean flag "before").
1414 * "path" must match exactly one existing node in the tree,
1415 * and "label" must be a label, ie. not contain "/", "*" or
1416 * end with a bracketed index "[N]".
1418 * @throws LibGuestFSException
1420 public void aug_insert (String path, String label, boolean before)
1421 throws LibGuestFSException
1424 throw new LibGuestFSException ("aug_insert: handle is closed");
1425 _aug_insert (g, path, label, before);
1427 private native void _aug_insert (long g, String path, String label, boolean before)
1428 throws LibGuestFSException;
1431 * remove an Augeas path
1433 * Remove "path" and all of its children.
1435 * On success this returns the number of entries which were
1438 * @throws LibGuestFSException
1440 public int aug_rm (String path)
1441 throws LibGuestFSException
1444 throw new LibGuestFSException ("aug_rm: handle is closed");
1445 return _aug_rm (g, path);
1447 private native int _aug_rm (long g, String path)
1448 throws LibGuestFSException;
1453 * Move the node "src" to "dest". "src" must match exactly
1454 * one node. "dest" is overwritten if it exists.
1456 * @throws LibGuestFSException
1458 public void aug_mv (String src, String dest)
1459 throws LibGuestFSException
1462 throw new LibGuestFSException ("aug_mv: handle is closed");
1463 _aug_mv (g, src, dest);
1465 private native void _aug_mv (long g, String src, String dest)
1466 throws LibGuestFSException;
1469 * return Augeas nodes which match path
1471 * Returns a list of paths which match the path expression
1472 * "path". The returned paths are sufficiently qualified so
1473 * that they match exactly one node in the current tree.
1475 * @throws LibGuestFSException
1477 public String[] aug_match (String path)
1478 throws LibGuestFSException
1481 throw new LibGuestFSException ("aug_match: handle is closed");
1482 return _aug_match (g, path);
1484 private native String[] _aug_match (long g, String path)
1485 throws LibGuestFSException;
1488 * write all pending Augeas changes to disk
1490 * This writes all pending changes to disk.
1492 * The flags which were passed to "g.aug_init" affect
1493 * exactly how files are saved.
1495 * @throws LibGuestFSException
1497 public void aug_save ()
1498 throws LibGuestFSException
1501 throw new LibGuestFSException ("aug_save: handle is closed");
1504 private native void _aug_save (long g)
1505 throws LibGuestFSException;
1508 * load files into the tree
1510 * Load files into the tree.
1512 * See "aug_load" in the Augeas documentation for the full
1515 * @throws LibGuestFSException
1517 public void aug_load ()
1518 throws LibGuestFSException
1521 throw new LibGuestFSException ("aug_load: handle is closed");
1524 private native void _aug_load (long g)
1525 throws LibGuestFSException;
1528 * list Augeas nodes under a path
1530 * This is just a shortcut for listing "g.aug_match"
1531 * "path/*" and sorting the resulting nodes into
1532 * alphabetical order.
1534 * @throws LibGuestFSException
1536 public String[] aug_ls (String path)
1537 throws LibGuestFSException
1540 throw new LibGuestFSException ("aug_ls: handle is closed");
1541 return _aug_ls (g, path);
1543 private native String[] _aug_ls (long g, String path)
1544 throws LibGuestFSException;
1549 * Remove the single file "path".
1551 * @throws LibGuestFSException
1553 public void rm (String path)
1554 throws LibGuestFSException
1557 throw new LibGuestFSException ("rm: handle is closed");
1560 private native void _rm (long g, String path)
1561 throws LibGuestFSException;
1564 * remove a directory
1566 * Remove the single directory "path".
1568 * @throws LibGuestFSException
1570 public void rmdir (String path)
1571 throws LibGuestFSException
1574 throw new LibGuestFSException ("rmdir: handle is closed");
1577 private native void _rmdir (long g, String path)
1578 throws LibGuestFSException;
1581 * remove a file or directory recursively
1583 * Remove the file or directory "path", recursively
1584 * removing the contents if its a directory. This is like
1585 * the "rm -rf" shell command.
1587 * @throws LibGuestFSException
1589 public void rm_rf (String path)
1590 throws LibGuestFSException
1593 throw new LibGuestFSException ("rm_rf: handle is closed");
1596 private native void _rm_rf (long g, String path)
1597 throws LibGuestFSException;
1600 * create a directory
1602 * Create a directory named "path".
1604 * @throws LibGuestFSException
1606 public void mkdir (String path)
1607 throws LibGuestFSException
1610 throw new LibGuestFSException ("mkdir: handle is closed");
1613 private native void _mkdir (long g, String path)
1614 throws LibGuestFSException;
1617 * create a directory and parents
1619 * Create a directory named "path", creating any parent
1620 * directories as necessary. This is like the "mkdir -p"
1623 * @throws LibGuestFSException
1625 public void mkdir_p (String path)
1626 throws LibGuestFSException
1629 throw new LibGuestFSException ("mkdir_p: handle is closed");
1632 private native void _mkdir_p (long g, String path)
1633 throws LibGuestFSException;
1638 * Change the mode (permissions) of "path" to "mode". Only
1639 * numeric modes are supported.
1641 * @throws LibGuestFSException
1643 public void chmod (int mode, String path)
1644 throws LibGuestFSException
1647 throw new LibGuestFSException ("chmod: handle is closed");
1648 _chmod (g, mode, path);
1650 private native void _chmod (long g, int mode, String path)
1651 throws LibGuestFSException;
1654 * change file owner and group
1656 * Change the file owner to "owner" and group to "group".
1658 * Only numeric uid and gid are supported. If you want to
1659 * use names, you will need to locate and parse the
1660 * password file yourself (Augeas support makes this
1663 * @throws LibGuestFSException
1665 public void chown (int owner, int group, String path)
1666 throws LibGuestFSException
1669 throw new LibGuestFSException ("chown: handle is closed");
1670 _chown (g, owner, group, path);
1672 private native void _chown (long g, int owner, int group, String path)
1673 throws LibGuestFSException;
1676 * test if file or directory exists
1678 * This returns "true" if and only if there is a file,
1679 * directory (or anything) with the given "path" name.
1681 * See also "g.is_file", "g.is_dir", "g.stat".
1683 * @throws LibGuestFSException
1685 public boolean exists (String path)
1686 throws LibGuestFSException
1689 throw new LibGuestFSException ("exists: handle is closed");
1690 return _exists (g, path);
1692 private native boolean _exists (long g, String path)
1693 throws LibGuestFSException;
1696 * test if file exists
1698 * This returns "true" if and only if there is a file with
1699 * the given "path" name. Note that it returns false for
1700 * other objects like directories.
1702 * See also "g.stat".
1704 * @throws LibGuestFSException
1706 public boolean is_file (String path)
1707 throws LibGuestFSException
1710 throw new LibGuestFSException ("is_file: handle is closed");
1711 return _is_file (g, path);
1713 private native boolean _is_file (long g, String path)
1714 throws LibGuestFSException;
1717 * test if file exists
1719 * This returns "true" if and only if there is a directory
1720 * with the given "path" name. Note that it returns false
1721 * for other objects like files.
1723 * See also "g.stat".
1725 * @throws LibGuestFSException
1727 public boolean is_dir (String path)
1728 throws LibGuestFSException
1731 throw new LibGuestFSException ("is_dir: handle is closed");
1732 return _is_dir (g, path);
1734 private native boolean _is_dir (long g, String path)
1735 throws LibGuestFSException;
1738 * create an LVM physical volume
1740 * This creates an LVM physical volume on the named
1741 * "device", where "device" should usually be a partition
1742 * name such as "/dev/sda1".
1744 * @throws LibGuestFSException
1746 public void pvcreate (String device)
1747 throws LibGuestFSException
1750 throw new LibGuestFSException ("pvcreate: handle is closed");
1751 _pvcreate (g, device);
1753 private native void _pvcreate (long g, String device)
1754 throws LibGuestFSException;
1757 * create an LVM volume group
1759 * This creates an LVM volume group called "volgroup" from
1760 * the non-empty list of physical volumes "physvols".
1762 * @throws LibGuestFSException
1764 public void vgcreate (String volgroup, String[] physvols)
1765 throws LibGuestFSException
1768 throw new LibGuestFSException ("vgcreate: handle is closed");
1769 _vgcreate (g, volgroup, physvols);
1771 private native void _vgcreate (long g, String volgroup, String[] physvols)
1772 throws LibGuestFSException;
1775 * create an LVM volume group
1777 * This creates an LVM volume group called "logvol" on the
1778 * volume group "volgroup", with "size" megabytes.
1780 * @throws LibGuestFSException
1782 public void lvcreate (String logvol, String volgroup, int mbytes)
1783 throws LibGuestFSException
1786 throw new LibGuestFSException ("lvcreate: handle is closed");
1787 _lvcreate (g, logvol, volgroup, mbytes);
1789 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1790 throws LibGuestFSException;
1795 * This creates a filesystem on "device" (usually a
1796 * partition or LVM logical volume). The filesystem type is
1797 * "fstype", for example "ext3".
1799 * @throws LibGuestFSException
1801 public void mkfs (String fstype, String device)
1802 throws LibGuestFSException
1805 throw new LibGuestFSException ("mkfs: handle is closed");
1806 _mkfs (g, fstype, device);
1808 private native void _mkfs (long g, String fstype, String device)
1809 throws LibGuestFSException;
1812 * create partitions on a block device
1814 * This is a direct interface to the sfdisk(8) program for
1815 * creating partitions on block devices.
1817 * "device" should be a block device, for example
1820 * "cyls", "heads" and "sectors" are the number of
1821 * cylinders, heads and sectors on the device, which are
1822 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1823 * parameters. If you pass 0 for any of these, then the
1824 * corresponding parameter is omitted. Usually for 'large'
1825 * disks, you can just pass 0 for these, but for small
1826 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1827 * cannot work out the right geometry and you will need to
1830 * "lines" is a list of lines that we feed to "sfdisk". For
1831 * more information refer to the sfdisk(8) manpage.
1833 * To create a single partition occupying the whole disk,
1834 * you would pass "lines" as a single element list, when
1835 * the single element being the string "," (comma).
1837 * See also: "g.sfdisk_l", "g.sfdisk_N"
1839 * This command is dangerous. Without careful use you can
1840 * easily destroy all your data.
1842 * @throws LibGuestFSException
1844 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1845 throws LibGuestFSException
1848 throw new LibGuestFSException ("sfdisk: handle is closed");
1849 _sfdisk (g, device, cyls, heads, sectors, lines);
1851 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1852 throws LibGuestFSException;
1857 * This call creates a file called "path". The contents of
1858 * the file is the string "content" (which can contain any
1859 * 8 bit data), with length "size".
1861 * As a special case, if "size" is 0 then the length is
1862 * calculated using "strlen" (so in this case the content
1863 * cannot contain embedded ASCII NULs).
1865 * *NB.* Owing to a bug, writing content containing ASCII
1866 * NUL characters does *not* work, even if the length is
1867 * specified. We hope to resolve this bug in a future
1868 * version. In the meantime use "g.upload".
1870 * Because of the message protocol, there is a transfer
1871 * limit of somewhere between 2MB and 4MB. To transfer
1872 * large files you should use FTP.
1874 * @throws LibGuestFSException
1876 public void write_file (String path, String content, int size)
1877 throws LibGuestFSException
1880 throw new LibGuestFSException ("write_file: handle is closed");
1881 _write_file (g, path, content, size);
1883 private native void _write_file (long g, String path, String content, int size)
1884 throws LibGuestFSException;
1887 * unmount a filesystem
1889 * This unmounts the given filesystem. The filesystem may
1890 * be specified either by its mountpoint (path) or the
1891 * device which contains the filesystem.
1893 * @throws LibGuestFSException
1895 public void umount (String pathordevice)
1896 throws LibGuestFSException
1899 throw new LibGuestFSException ("umount: handle is closed");
1900 _umount (g, pathordevice);
1902 private native void _umount (long g, String pathordevice)
1903 throws LibGuestFSException;
1906 * show mounted filesystems
1908 * This returns the list of currently mounted filesystems.
1909 * It returns the list of devices (eg. "/dev/sda1",
1912 * Some internal mounts are not shown.
1914 * @throws LibGuestFSException
1916 public String[] mounts ()
1917 throws LibGuestFSException
1920 throw new LibGuestFSException ("mounts: handle is closed");
1923 private native String[] _mounts (long g)
1924 throws LibGuestFSException;
1927 * unmount all filesystems
1929 * This unmounts all mounted filesystems.
1931 * Some internal mounts are not unmounted by this call.
1933 * @throws LibGuestFSException
1935 public void umount_all ()
1936 throws LibGuestFSException
1939 throw new LibGuestFSException ("umount_all: handle is closed");
1942 private native void _umount_all (long g)
1943 throws LibGuestFSException;
1946 * remove all LVM LVs, VGs and PVs
1948 * This command removes all LVM logical volumes, volume
1949 * groups and physical volumes.
1951 * This command is dangerous. Without careful use you can
1952 * easily destroy all your data.
1954 * @throws LibGuestFSException
1956 public void lvm_remove_all ()
1957 throws LibGuestFSException
1960 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1961 _lvm_remove_all (g);
1963 private native void _lvm_remove_all (long g)
1964 throws LibGuestFSException;
1967 * determine file type
1969 * This call uses the standard file(1) command to determine
1970 * the type or contents of the file. This also works on
1971 * devices, for example to find out whether a partition
1972 * contains a filesystem.
1974 * The exact command which runs is "file -bsL path". Note
1975 * in particular that the filename is not prepended to the
1976 * output (the "-b" option).
1978 * @throws LibGuestFSException
1980 public String file (String path)
1981 throws LibGuestFSException
1984 throw new LibGuestFSException ("file: handle is closed");
1985 return _file (g, path);
1987 private native String _file (long g, String path)
1988 throws LibGuestFSException;
1991 * run a command from the guest filesystem
1993 * This call runs a command from the guest filesystem. The
1994 * filesystem must be mounted, and must contain a
1995 * compatible operating system (ie. something Linux, with
1996 * the same or compatible processor architecture).
1998 * The single parameter is an argv-style list of arguments.
1999 * The first element is the name of the program to run.
2000 * Subsequent elements are parameters. The list must be
2001 * non-empty (ie. must contain a program name). Note that
2002 * the command runs directly, and is *not* invoked via the
2003 * shell (see "g.sh").
2005 * The return value is anything printed to *stdout* by the
2008 * If the command returns a non-zero exit status, then this
2009 * function returns an error message. The error message
2010 * string is the content of *stderr* from the command.
2012 * The $PATH environment variable will contain at least
2013 * "/usr/bin" and "/bin". If you require a program from
2014 * another location, you should provide the full path in
2015 * the first parameter.
2017 * Shared libraries and data files required by the program
2018 * must be available on filesystems which are mounted in
2019 * the correct places. It is the caller's responsibility to
2020 * ensure all filesystems that are needed are mounted at
2021 * the right locations.
2023 * Because of the message protocol, there is a transfer
2024 * limit of somewhere between 2MB and 4MB. To transfer
2025 * large files you should use FTP.
2027 * @throws LibGuestFSException
2029 public String command (String[] arguments)
2030 throws LibGuestFSException
2033 throw new LibGuestFSException ("command: handle is closed");
2034 return _command (g, arguments);
2036 private native String _command (long g, String[] arguments)
2037 throws LibGuestFSException;
2040 * run a command, returning lines
2042 * This is the same as "g.command", but splits the result
2043 * into a list of lines.
2045 * See also: "g.sh_lines"
2047 * Because of the message protocol, there is a transfer
2048 * limit of somewhere between 2MB and 4MB. To transfer
2049 * large files you should use FTP.
2051 * @throws LibGuestFSException
2053 public String[] command_lines (String[] arguments)
2054 throws LibGuestFSException
2057 throw new LibGuestFSException ("command_lines: handle is closed");
2058 return _command_lines (g, arguments);
2060 private native String[] _command_lines (long g, String[] arguments)
2061 throws LibGuestFSException;
2064 * get file information
2066 * Returns file information for the given "path".
2068 * This is the same as the stat(2) system call.
2070 * @throws LibGuestFSException
2072 public Stat stat (String path)
2073 throws LibGuestFSException
2076 throw new LibGuestFSException ("stat: handle is closed");
2077 return _stat (g, path);
2079 private native Stat _stat (long g, String path)
2080 throws LibGuestFSException;
2083 * get file information for a symbolic link
2085 * Returns file information for the given "path".
2087 * This is the same as "g.stat" except that if "path" is a
2088 * symbolic link, then the link is stat-ed, not the file it
2091 * This is the same as the lstat(2) system call.
2093 * @throws LibGuestFSException
2095 public Stat lstat (String path)
2096 throws LibGuestFSException
2099 throw new LibGuestFSException ("lstat: handle is closed");
2100 return _lstat (g, path);
2102 private native Stat _lstat (long g, String path)
2103 throws LibGuestFSException;
2106 * get file system statistics
2108 * Returns file system statistics for any mounted file
2109 * system. "path" should be a file or directory in the
2110 * mounted file system (typically it is the mount point
2111 * itself, but it doesn't need to be).
2113 * This is the same as the statvfs(2) system call.
2115 * @throws LibGuestFSException
2117 public StatVFS statvfs (String path)
2118 throws LibGuestFSException
2121 throw new LibGuestFSException ("statvfs: handle is closed");
2122 return _statvfs (g, path);
2124 private native StatVFS _statvfs (long g, String path)
2125 throws LibGuestFSException;
2128 * get ext2/ext3/ext4 superblock details
2130 * This returns the contents of the ext2, ext3 or ext4
2131 * filesystem superblock on "device".
2133 * It is the same as running "tune2fs -l device". See
2134 * tune2fs(8) manpage for more details. The list of fields
2135 * returned isn't clearly defined, and depends on both the
2136 * version of "tune2fs" that libguestfs was built against,
2137 * and the filesystem itself.
2139 * @throws LibGuestFSException
2141 public HashMap<String,String> tune2fs_l (String device)
2142 throws LibGuestFSException
2145 throw new LibGuestFSException ("tune2fs_l: handle is closed");
2146 return _tune2fs_l (g, device);
2148 private native HashMap<String,String> _tune2fs_l (long g, String device)
2149 throws LibGuestFSException;
2152 * set block device to read-only
2154 * Sets the block device named "device" to read-only.
2156 * This uses the blockdev(8) command.
2158 * @throws LibGuestFSException
2160 public void blockdev_setro (String device)
2161 throws LibGuestFSException
2164 throw new LibGuestFSException ("blockdev_setro: handle is closed");
2165 _blockdev_setro (g, device);
2167 private native void _blockdev_setro (long g, String device)
2168 throws LibGuestFSException;
2171 * set block device to read-write
2173 * Sets the block device named "device" to read-write.
2175 * This uses the blockdev(8) command.
2177 * @throws LibGuestFSException
2179 public void blockdev_setrw (String device)
2180 throws LibGuestFSException
2183 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
2184 _blockdev_setrw (g, device);
2186 private native void _blockdev_setrw (long g, String device)
2187 throws LibGuestFSException;
2190 * is block device set to read-only
2192 * Returns a boolean indicating if the block device is
2193 * read-only (true if read-only, false if not).
2195 * This uses the blockdev(8) command.
2197 * @throws LibGuestFSException
2199 public boolean blockdev_getro (String device)
2200 throws LibGuestFSException
2203 throw new LibGuestFSException ("blockdev_getro: handle is closed");
2204 return _blockdev_getro (g, device);
2206 private native boolean _blockdev_getro (long g, String device)
2207 throws LibGuestFSException;
2210 * get sectorsize of block device
2212 * This returns the size of sectors on a block device.
2213 * Usually 512, but can be larger for modern devices.
2215 * (Note, this is not the size in sectors, use
2216 * "g.blockdev_getsz" for that).
2218 * This uses the blockdev(8) command.
2220 * @throws LibGuestFSException
2222 public int blockdev_getss (String device)
2223 throws LibGuestFSException
2226 throw new LibGuestFSException ("blockdev_getss: handle is closed");
2227 return _blockdev_getss (g, device);
2229 private native int _blockdev_getss (long g, String device)
2230 throws LibGuestFSException;
2233 * get blocksize of block device
2235 * This returns the block size of a device.
2237 * (Note this is different from both *size in blocks* and
2238 * *filesystem block size*).
2240 * This uses the blockdev(8) command.
2242 * @throws LibGuestFSException
2244 public int blockdev_getbsz (String device)
2245 throws LibGuestFSException
2248 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
2249 return _blockdev_getbsz (g, device);
2251 private native int _blockdev_getbsz (long g, String device)
2252 throws LibGuestFSException;
2255 * set blocksize of block device
2257 * This sets the block size of a device.
2259 * (Note this is different from both *size in blocks* and
2260 * *filesystem block size*).
2262 * This uses the blockdev(8) command.
2264 * @throws LibGuestFSException
2266 public void blockdev_setbsz (String device, int blocksize)
2267 throws LibGuestFSException
2270 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
2271 _blockdev_setbsz (g, device, blocksize);
2273 private native void _blockdev_setbsz (long g, String device, int blocksize)
2274 throws LibGuestFSException;
2277 * get total size of device in 512-byte sectors
2279 * This returns the size of the device in units of 512-byte
2280 * sectors (even if the sectorsize isn't 512 bytes ...
2283 * See also "g.blockdev_getss" for the real sector size of
2284 * the device, and "g.blockdev_getsize64" for the more
2285 * useful *size in bytes*.
2287 * This uses the blockdev(8) command.
2289 * @throws LibGuestFSException
2291 public long blockdev_getsz (String device)
2292 throws LibGuestFSException
2295 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
2296 return _blockdev_getsz (g, device);
2298 private native long _blockdev_getsz (long g, String device)
2299 throws LibGuestFSException;
2302 * get total size of device in bytes
2304 * This returns the size of the device in bytes.
2306 * See also "g.blockdev_getsz".
2308 * This uses the blockdev(8) command.
2310 * @throws LibGuestFSException
2312 public long blockdev_getsize64 (String device)
2313 throws LibGuestFSException
2316 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2317 return _blockdev_getsize64 (g, device);
2319 private native long _blockdev_getsize64 (long g, String device)
2320 throws LibGuestFSException;
2323 * flush device buffers
2325 * This tells the kernel to flush internal buffers
2326 * associated with "device".
2328 * This uses the blockdev(8) command.
2330 * @throws LibGuestFSException
2332 public void blockdev_flushbufs (String device)
2333 throws LibGuestFSException
2336 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2337 _blockdev_flushbufs (g, device);
2339 private native void _blockdev_flushbufs (long g, String device)
2340 throws LibGuestFSException;
2343 * reread partition table
2345 * Reread the partition table on "device".
2347 * This uses the blockdev(8) command.
2349 * @throws LibGuestFSException
2351 public void blockdev_rereadpt (String device)
2352 throws LibGuestFSException
2355 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2356 _blockdev_rereadpt (g, device);
2358 private native void _blockdev_rereadpt (long g, String device)
2359 throws LibGuestFSException;
2362 * upload a file from the local machine
2364 * Upload local file "filename" to "remotefilename" on the
2367 * "filename" can also be a named pipe.
2369 * See also "g.download".
2371 * @throws LibGuestFSException
2373 public void upload (String filename, String remotefilename)
2374 throws LibGuestFSException
2377 throw new LibGuestFSException ("upload: handle is closed");
2378 _upload (g, filename, remotefilename);
2380 private native void _upload (long g, String filename, String remotefilename)
2381 throws LibGuestFSException;
2384 * download a file to the local machine
2386 * Download file "remotefilename" and save it as "filename"
2387 * on the local machine.
2389 * "filename" can also be a named pipe.
2391 * See also "g.upload", "g.cat".
2393 * @throws LibGuestFSException
2395 public void download (String remotefilename, String filename)
2396 throws LibGuestFSException
2399 throw new LibGuestFSException ("download: handle is closed");
2400 _download (g, remotefilename, filename);
2402 private native void _download (long g, String remotefilename, String filename)
2403 throws LibGuestFSException;
2406 * compute MD5, SHAx or CRC checksum of file
2408 * This call computes the MD5, SHAx or CRC checksum of the
2409 * file named "path".
2411 * The type of checksum to compute is given by the
2412 * "csumtype" parameter which must have one of the
2416 * Compute the cyclic redundancy check (CRC) specified
2417 * by POSIX for the "cksum" command.
2420 * Compute the MD5 hash (using the "md5sum" program).
2423 * Compute the SHA1 hash (using the "sha1sum" program).
2426 * Compute the SHA224 hash (using the "sha224sum"
2430 * Compute the SHA256 hash (using the "sha256sum"
2434 * Compute the SHA384 hash (using the "sha384sum"
2438 * Compute the SHA512 hash (using the "sha512sum"
2441 * The checksum is returned as a printable string.
2443 * @throws LibGuestFSException
2445 public String checksum (String csumtype, String path)
2446 throws LibGuestFSException
2449 throw new LibGuestFSException ("checksum: handle is closed");
2450 return _checksum (g, csumtype, path);
2452 private native String _checksum (long g, String csumtype, String path)
2453 throws LibGuestFSException;
2456 * unpack tarfile to directory
2458 * This command uploads and unpacks local file "tarfile"
2459 * (an *uncompressed* tar file) into "directory".
2461 * To upload a compressed tarball, use "g.tgz_in".
2463 * @throws LibGuestFSException
2465 public void tar_in (String tarfile, String directory)
2466 throws LibGuestFSException
2469 throw new LibGuestFSException ("tar_in: handle is closed");
2470 _tar_in (g, tarfile, directory);
2472 private native void _tar_in (long g, String tarfile, String directory)
2473 throws LibGuestFSException;
2476 * pack directory into tarfile
2478 * This command packs the contents of "directory" and
2479 * downloads it to local file "tarfile".
2481 * To download a compressed tarball, use "g.tgz_out".
2483 * @throws LibGuestFSException
2485 public void tar_out (String directory, String tarfile)
2486 throws LibGuestFSException
2489 throw new LibGuestFSException ("tar_out: handle is closed");
2490 _tar_out (g, directory, tarfile);
2492 private native void _tar_out (long g, String directory, String tarfile)
2493 throws LibGuestFSException;
2496 * unpack compressed tarball to directory
2498 * This command uploads and unpacks local file "tarball" (a
2499 * *gzip compressed* tar file) into "directory".
2501 * To upload an uncompressed tarball, use "g.tar_in".
2503 * @throws LibGuestFSException
2505 public void tgz_in (String tarball, String directory)
2506 throws LibGuestFSException
2509 throw new LibGuestFSException ("tgz_in: handle is closed");
2510 _tgz_in (g, tarball, directory);
2512 private native void _tgz_in (long g, String tarball, String directory)
2513 throws LibGuestFSException;
2516 * pack directory into compressed tarball
2518 * This command packs the contents of "directory" and
2519 * downloads it to local file "tarball".
2521 * To download an uncompressed tarball, use "g.tar_out".
2523 * @throws LibGuestFSException
2525 public void tgz_out (String directory, String tarball)
2526 throws LibGuestFSException
2529 throw new LibGuestFSException ("tgz_out: handle is closed");
2530 _tgz_out (g, directory, tarball);
2532 private native void _tgz_out (long g, String directory, String tarball)
2533 throws LibGuestFSException;
2536 * mount a guest disk, read-only
2538 * This is the same as the "g.mount" command, but it mounts
2539 * the filesystem with the read-only (*-o ro*) flag.
2541 * @throws LibGuestFSException
2543 public void mount_ro (String device, String mountpoint)
2544 throws LibGuestFSException
2547 throw new LibGuestFSException ("mount_ro: handle is closed");
2548 _mount_ro (g, device, mountpoint);
2550 private native void _mount_ro (long g, String device, String mountpoint)
2551 throws LibGuestFSException;
2554 * mount a guest disk with mount options
2556 * This is the same as the "g.mount" command, but it allows
2557 * you to set the mount options as for the mount(8) *-o*
2560 * @throws LibGuestFSException
2562 public void mount_options (String options, String device, String mountpoint)
2563 throws LibGuestFSException
2566 throw new LibGuestFSException ("mount_options: handle is closed");
2567 _mount_options (g, options, device, mountpoint);
2569 private native void _mount_options (long g, String options, String device, String mountpoint)
2570 throws LibGuestFSException;
2573 * mount a guest disk with mount options and vfstype
2575 * This is the same as the "g.mount" command, but it allows
2576 * you to set both the mount options and the vfstype as for
2577 * the mount(8) *-o* and *-t* flags.
2579 * @throws LibGuestFSException
2581 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2582 throws LibGuestFSException
2585 throw new LibGuestFSException ("mount_vfs: handle is closed");
2586 _mount_vfs (g, options, vfstype, device, mountpoint);
2588 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2589 throws LibGuestFSException;
2592 * debugging and internals
2594 * The "g.debug" command exposes some internals of
2595 * "guestfsd" (the guestfs daemon) that runs inside the
2598 * There is no comprehensive help for this command. You
2599 * have to look at the file "daemon/debug.c" in the
2600 * libguestfs source to find out what you can do.
2602 * @throws LibGuestFSException
2604 public String debug (String subcmd, String[] extraargs)
2605 throws LibGuestFSException
2608 throw new LibGuestFSException ("debug: handle is closed");
2609 return _debug (g, subcmd, extraargs);
2611 private native String _debug (long g, String subcmd, String[] extraargs)
2612 throws LibGuestFSException;
2615 * remove an LVM logical volume
2617 * Remove an LVM logical volume "device", where "device" is
2618 * the path to the LV, such as "/dev/VG/LV".
2620 * You can also remove all LVs in a volume group by
2621 * specifying the VG name, "/dev/VG".
2623 * @throws LibGuestFSException
2625 public void lvremove (String device)
2626 throws LibGuestFSException
2629 throw new LibGuestFSException ("lvremove: handle is closed");
2630 _lvremove (g, device);
2632 private native void _lvremove (long g, String device)
2633 throws LibGuestFSException;
2636 * remove an LVM volume group
2638 * Remove an LVM volume group "vgname", (for example "VG").
2640 * This also forcibly removes all logical volumes in the
2641 * volume group (if any).
2643 * @throws LibGuestFSException
2645 public void vgremove (String vgname)
2646 throws LibGuestFSException
2649 throw new LibGuestFSException ("vgremove: handle is closed");
2650 _vgremove (g, vgname);
2652 private native void _vgremove (long g, String vgname)
2653 throws LibGuestFSException;
2656 * remove an LVM physical volume
2658 * This wipes a physical volume "device" so that LVM will
2659 * no longer recognise it.
2661 * The implementation uses the "pvremove" command which
2662 * refuses to wipe physical volumes that contain any volume
2663 * groups, so you have to remove those first.
2665 * @throws LibGuestFSException
2667 public void pvremove (String device)
2668 throws LibGuestFSException
2671 throw new LibGuestFSException ("pvremove: handle is closed");
2672 _pvremove (g, device);
2674 private native void _pvremove (long g, String device)
2675 throws LibGuestFSException;
2678 * set the ext2/3/4 filesystem label
2680 * This sets the ext2/3/4 filesystem label of the
2681 * filesystem on "device" to "label". Filesystem labels are
2682 * limited to 16 characters.
2684 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2685 * return the existing label on a filesystem.
2687 * @throws LibGuestFSException
2689 public void set_e2label (String device, String label)
2690 throws LibGuestFSException
2693 throw new LibGuestFSException ("set_e2label: handle is closed");
2694 _set_e2label (g, device, label);
2696 private native void _set_e2label (long g, String device, String label)
2697 throws LibGuestFSException;
2700 * get the ext2/3/4 filesystem label
2702 * This returns the ext2/3/4 filesystem label of the
2703 * filesystem on "device".
2705 * @throws LibGuestFSException
2707 public String get_e2label (String device)
2708 throws LibGuestFSException
2711 throw new LibGuestFSException ("get_e2label: handle is closed");
2712 return _get_e2label (g, device);
2714 private native String _get_e2label (long g, String device)
2715 throws LibGuestFSException;
2718 * set the ext2/3/4 filesystem UUID
2720 * This sets the ext2/3/4 filesystem UUID of the filesystem
2721 * on "device" to "uuid". The format of the UUID and
2722 * alternatives such as "clear", "random" and "time" are
2723 * described in the tune2fs(8) manpage.
2725 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2726 * return the existing UUID of a filesystem.
2728 * @throws LibGuestFSException
2730 public void set_e2uuid (String device, String uuid)
2731 throws LibGuestFSException
2734 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2735 _set_e2uuid (g, device, uuid);
2737 private native void _set_e2uuid (long g, String device, String uuid)
2738 throws LibGuestFSException;
2741 * get the ext2/3/4 filesystem UUID
2743 * This returns the ext2/3/4 filesystem UUID of the
2744 * filesystem on "device".
2746 * @throws LibGuestFSException
2748 public String get_e2uuid (String device)
2749 throws LibGuestFSException
2752 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2753 return _get_e2uuid (g, device);
2755 private native String _get_e2uuid (long g, String device)
2756 throws LibGuestFSException;
2759 * run the filesystem checker
2761 * This runs the filesystem checker (fsck) on "device"
2762 * which should have filesystem type "fstype".
2764 * The returned integer is the status. See fsck(8) for the
2765 * list of status codes from "fsck".
2769 * * Multiple status codes can be summed together.
2771 * * A non-zero return code can mean "success", for
2772 * example if errors have been corrected on the
2775 * * Checking or repairing NTFS volumes is not supported
2778 * This command is entirely equivalent to running "fsck -a
2779 * -t fstype device".
2781 * @throws LibGuestFSException
2783 public int fsck (String fstype, String device)
2784 throws LibGuestFSException
2787 throw new LibGuestFSException ("fsck: handle is closed");
2788 return _fsck (g, fstype, device);
2790 private native int _fsck (long g, String fstype, String device)
2791 throws LibGuestFSException;
2794 * write zeroes to the device
2796 * This command writes zeroes over the first few blocks of
2799 * How many blocks are zeroed isn't specified (but it's
2800 * *not* enough to securely wipe the device). It should be
2801 * sufficient to remove any partition tables, filesystem
2802 * superblocks and so on.
2804 * See also: "g.scrub_device".
2806 * @throws LibGuestFSException
2808 public void zero (String device)
2809 throws LibGuestFSException
2812 throw new LibGuestFSException ("zero: handle is closed");
2815 private native void _zero (long g, String device)
2816 throws LibGuestFSException;
2821 * This command installs GRUB (the Grand Unified
2822 * Bootloader) on "device", with the root directory being
2825 * @throws LibGuestFSException
2827 public void grub_install (String root, String device)
2828 throws LibGuestFSException
2831 throw new LibGuestFSException ("grub_install: handle is closed");
2832 _grub_install (g, root, device);
2834 private native void _grub_install (long g, String root, String device)
2835 throws LibGuestFSException;
2840 * This copies a file from "src" to "dest" where "dest" is
2841 * either a destination filename or destination directory.
2843 * @throws LibGuestFSException
2845 public void cp (String src, String dest)
2846 throws LibGuestFSException
2849 throw new LibGuestFSException ("cp: handle is closed");
2852 private native void _cp (long g, String src, String dest)
2853 throws LibGuestFSException;
2856 * copy a file or directory recursively
2858 * This copies a file or directory from "src" to "dest"
2859 * recursively using the "cp -a" command.
2861 * @throws LibGuestFSException
2863 public void cp_a (String src, String dest)
2864 throws LibGuestFSException
2867 throw new LibGuestFSException ("cp_a: handle is closed");
2868 _cp_a (g, src, dest);
2870 private native void _cp_a (long g, String src, String dest)
2871 throws LibGuestFSException;
2876 * This moves a file from "src" to "dest" where "dest" is
2877 * either a destination filename or destination directory.
2879 * @throws LibGuestFSException
2881 public void mv (String src, String dest)
2882 throws LibGuestFSException
2885 throw new LibGuestFSException ("mv: handle is closed");
2888 private native void _mv (long g, String src, String dest)
2889 throws LibGuestFSException;
2892 * drop kernel page cache, dentries and inodes
2894 * This instructs the guest kernel to drop its page cache,
2895 * and/or dentries and inode caches. The parameter
2896 * "whattodrop" tells the kernel what precisely to drop,
2897 * see <http://linux-mm.org/Drop_Caches>
2899 * Setting "whattodrop" to 3 should drop everything.
2901 * This automatically calls sync(2) before the operation,
2902 * so that the maximum guest memory is freed.
2904 * @throws LibGuestFSException
2906 public void drop_caches (int whattodrop)
2907 throws LibGuestFSException
2910 throw new LibGuestFSException ("drop_caches: handle is closed");
2911 _drop_caches (g, whattodrop);
2913 private native void _drop_caches (long g, int whattodrop)
2914 throws LibGuestFSException;
2917 * return kernel messages
2919 * This returns the kernel messages ("dmesg" output) from
2920 * the guest kernel. This is sometimes useful for extended
2921 * debugging of problems.
2923 * Another way to get the same information is to enable
2924 * verbose messages with "g.set_verbose" or by setting the
2925 * environment variable "LIBGUESTFS_DEBUG=1" before running
2928 * @throws LibGuestFSException
2930 public String dmesg ()
2931 throws LibGuestFSException
2934 throw new LibGuestFSException ("dmesg: handle is closed");
2937 private native String _dmesg (long g)
2938 throws LibGuestFSException;
2941 * ping the guest daemon
2943 * This is a test probe into the guestfs daemon running
2944 * inside the qemu subprocess. Calling this function checks
2945 * that the daemon responds to the ping message, without
2946 * affecting the daemon or attached block device(s) in any
2949 * @throws LibGuestFSException
2951 public void ping_daemon ()
2952 throws LibGuestFSException
2955 throw new LibGuestFSException ("ping_daemon: handle is closed");
2958 private native void _ping_daemon (long g)
2959 throws LibGuestFSException;
2962 * test if two files have equal contents
2964 * This compares the two files "file1" and "file2" and
2965 * returns true if their content is exactly equal, or false
2968 * The external cmp(1) program is used for the comparison.
2970 * @throws LibGuestFSException
2972 public boolean equal (String file1, String file2)
2973 throws LibGuestFSException
2976 throw new LibGuestFSException ("equal: handle is closed");
2977 return _equal (g, file1, file2);
2979 private native boolean _equal (long g, String file1, String file2)
2980 throws LibGuestFSException;
2983 * print the printable strings in a file
2985 * This runs the strings(1) command on a file and returns
2986 * the list of printable strings found.
2988 * Because of the message protocol, there is a transfer
2989 * limit of somewhere between 2MB and 4MB. To transfer
2990 * large files you should use FTP.
2992 * @throws LibGuestFSException
2994 public String[] strings (String path)
2995 throws LibGuestFSException
2998 throw new LibGuestFSException ("strings: handle is closed");
2999 return _strings (g, path);
3001 private native String[] _strings (long g, String path)
3002 throws LibGuestFSException;
3005 * print the printable strings in a file
3007 * This is like the "g.strings" command, but allows you to
3008 * specify the encoding.
3010 * See the strings(1) manpage for the full list of
3013 * Commonly useful encodings are "l" (lower case L) which
3014 * will show strings inside Windows/x86 files.
3016 * The returned strings are transcoded to UTF-8.
3018 * Because of the message protocol, there is a transfer
3019 * limit of somewhere between 2MB and 4MB. To transfer
3020 * large files you should use FTP.
3022 * @throws LibGuestFSException
3024 public String[] strings_e (String encoding, String path)
3025 throws LibGuestFSException
3028 throw new LibGuestFSException ("strings_e: handle is closed");
3029 return _strings_e (g, encoding, path);
3031 private native String[] _strings_e (long g, String encoding, String path)
3032 throws LibGuestFSException;
3035 * dump a file in hexadecimal
3037 * This runs "hexdump -C" on the given "path". The result
3038 * is the human-readable, canonical hex dump of the file.
3040 * Because of the message protocol, there is a transfer
3041 * limit of somewhere between 2MB and 4MB. To transfer
3042 * large files you should use FTP.
3044 * @throws LibGuestFSException
3046 public String hexdump (String path)
3047 throws LibGuestFSException
3050 throw new LibGuestFSException ("hexdump: handle is closed");
3051 return _hexdump (g, path);
3053 private native String _hexdump (long g, String path)
3054 throws LibGuestFSException;
3057 * zero unused inodes and disk blocks on ext2/3 filesystem
3059 * This runs the *zerofree* program on "device". This
3060 * program claims to zero unused inodes and disk blocks on
3061 * an ext2/3 filesystem, thus making it possible to
3062 * compress the filesystem more effectively.
3064 * You should not run this program if the filesystem is
3067 * It is possible that using this program can damage the
3068 * filesystem or data on the filesystem.
3070 * @throws LibGuestFSException
3072 public void zerofree (String device)
3073 throws LibGuestFSException
3076 throw new LibGuestFSException ("zerofree: handle is closed");
3077 _zerofree (g, device);
3079 private native void _zerofree (long g, String device)
3080 throws LibGuestFSException;
3083 * resize an LVM physical volume
3085 * This resizes (expands or shrinks) an existing LVM
3086 * physical volume to match the new size of the underlying
3089 * @throws LibGuestFSException
3091 public void pvresize (String device)
3092 throws LibGuestFSException
3095 throw new LibGuestFSException ("pvresize: handle is closed");
3096 _pvresize (g, device);
3098 private native void _pvresize (long g, String device)
3099 throws LibGuestFSException;
3102 * modify a single partition on a block device
3104 * This runs sfdisk(8) option to modify just the single
3105 * partition "n" (note: "n" counts from 1).
3107 * For other parameters, see "g.sfdisk". You should usually
3108 * pass 0 for the cyls/heads/sectors parameters.
3110 * This command is dangerous. Without careful use you can
3111 * easily destroy all your data.
3113 * @throws LibGuestFSException
3115 public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line)
3116 throws LibGuestFSException
3119 throw new LibGuestFSException ("sfdisk_N: handle is closed");
3120 _sfdisk_N (g, device, n, cyls, heads, sectors, line);
3122 private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line)
3123 throws LibGuestFSException;
3126 * display the partition table
3128 * This displays the partition table on "device", in the
3129 * human-readable output of the sfdisk(8) command. It is
3130 * not intended to be parsed.
3132 * @throws LibGuestFSException
3134 public String sfdisk_l (String device)
3135 throws LibGuestFSException
3138 throw new LibGuestFSException ("sfdisk_l: handle is closed");
3139 return _sfdisk_l (g, device);
3141 private native String _sfdisk_l (long g, String device)
3142 throws LibGuestFSException;
3145 * display the kernel geometry
3147 * This displays the kernel's idea of the geometry of
3150 * The result is in human-readable format, and not designed
3153 * @throws LibGuestFSException
3155 public String sfdisk_kernel_geometry (String device)
3156 throws LibGuestFSException
3159 throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
3160 return _sfdisk_kernel_geometry (g, device);
3162 private native String _sfdisk_kernel_geometry (long g, String device)
3163 throws LibGuestFSException;
3166 * display the disk geometry from the partition table
3168 * This displays the disk geometry of "device" read from
3169 * the partition table. Especially in the case where the
3170 * underlying block device has been resized, this can be
3171 * different from the kernel's idea of the geometry (see
3172 * "g.sfdisk_kernel_geometry").
3174 * The result is in human-readable format, and not designed
3177 * @throws LibGuestFSException
3179 public String sfdisk_disk_geometry (String device)
3180 throws LibGuestFSException
3183 throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
3184 return _sfdisk_disk_geometry (g, device);
3186 private native String _sfdisk_disk_geometry (long g, String device)
3187 throws LibGuestFSException;
3190 * activate or deactivate all volume groups
3192 * This command activates or (if "activate" is false)
3193 * deactivates all logical volumes in all volume groups. If
3194 * activated, then they are made known to the kernel, ie.
3195 * they appear as "/dev/mapper" devices. If deactivated,
3196 * then those devices disappear.
3198 * This command is the same as running "vgchange -a y|n"
3200 * @throws LibGuestFSException
3202 public void vg_activate_all (boolean activate)
3203 throws LibGuestFSException
3206 throw new LibGuestFSException ("vg_activate_all: handle is closed");
3207 _vg_activate_all (g, activate);
3209 private native void _vg_activate_all (long g, boolean activate)
3210 throws LibGuestFSException;
3213 * activate or deactivate some volume groups
3215 * This command activates or (if "activate" is false)
3216 * deactivates all logical volumes in the listed volume
3217 * groups "volgroups". If activated, then they are made
3218 * known to the kernel, ie. they appear as "/dev/mapper"
3219 * devices. If deactivated, then those devices disappear.
3221 * This command is the same as running "vgchange -a y|n
3224 * Note that if "volgroups" is an empty list then all
3225 * volume groups are activated or deactivated.
3227 * @throws LibGuestFSException
3229 public void vg_activate (boolean activate, String[] volgroups)
3230 throws LibGuestFSException
3233 throw new LibGuestFSException ("vg_activate: handle is closed");
3234 _vg_activate (g, activate, volgroups);
3236 private native void _vg_activate (long g, boolean activate, String[] volgroups)
3237 throws LibGuestFSException;
3240 * resize an LVM logical volume
3242 * This resizes (expands or shrinks) an existing LVM
3243 * logical volume to "mbytes". When reducing, data in the
3244 * reduced part is lost.
3246 * @throws LibGuestFSException
3248 public void lvresize (String device, int mbytes)
3249 throws LibGuestFSException
3252 throw new LibGuestFSException ("lvresize: handle is closed");
3253 _lvresize (g, device, mbytes);
3255 private native void _lvresize (long g, String device, int mbytes)
3256 throws LibGuestFSException;
3259 * resize an ext2/ext3 filesystem
3261 * This resizes an ext2 or ext3 filesystem to match the
3262 * size of the underlying device.
3264 * *Note:* It is sometimes required that you run
3265 * "g.e2fsck_f" on the "device" before calling this
3266 * command. For unknown reasons "resize2fs" sometimes gives
3267 * an error about this and sometimes not. In any case, it
3268 * is always safe to call "g.e2fsck_f" before calling this
3271 * @throws LibGuestFSException
3273 public void resize2fs (String device)
3274 throws LibGuestFSException
3277 throw new LibGuestFSException ("resize2fs: handle is closed");
3278 _resize2fs (g, device);
3280 private native void _resize2fs (long g, String device)
3281 throws LibGuestFSException;
3284 * find all files and directories
3286 * This command lists out all files and directories,
3287 * recursively, starting at "directory". It is essentially
3288 * equivalent to running the shell command "find directory
3289 * -print" but some post-processing happens on the output,
3292 * This returns a list of strings *without any prefix*.
3293 * Thus if the directory structure was:
3299 * then the returned list from "g.find" "/tmp" would be 4
3307 * If "directory" is not a directory, then this command
3310 * The returned list is sorted.
3312 * @throws LibGuestFSException
3314 public String[] find (String directory)
3315 throws LibGuestFSException
3318 throw new LibGuestFSException ("find: handle is closed");
3319 return _find (g, directory);
3321 private native String[] _find (long g, String directory)
3322 throws LibGuestFSException;
3325 * check an ext2/ext3 filesystem
3327 * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
3328 * filesystem checker on "device", noninteractively ("-p"),
3329 * even if the filesystem appears to be clean ("-f").
3331 * This command is only needed because of "g.resize2fs"
3332 * (q.v.). Normally you should use "g.fsck".
3334 * @throws LibGuestFSException
3336 public void e2fsck_f (String device)
3337 throws LibGuestFSException
3340 throw new LibGuestFSException ("e2fsck_f: handle is closed");
3341 _e2fsck_f (g, device);
3343 private native void _e2fsck_f (long g, String device)
3344 throws LibGuestFSException;
3347 * sleep for some seconds
3349 * Sleep for "secs" seconds.
3351 * @throws LibGuestFSException
3353 public void sleep (int secs)
3354 throws LibGuestFSException
3357 throw new LibGuestFSException ("sleep: handle is closed");
3360 private native void _sleep (long g, int secs)
3361 throws LibGuestFSException;
3366 * This command runs the ntfs-3g.probe(8) command which
3367 * probes an NTFS "device" for mountability. (Not all NTFS
3368 * volumes can be mounted read-write, and some cannot be
3371 * "rw" is a boolean flag. Set it to true if you want to
3372 * test if the volume can be mounted read-write. Set it to
3373 * false if you want to test if the volume can be mounted
3376 * The return value is an integer which 0 if the operation
3377 * would succeed, or some non-zero value documented in the
3378 * ntfs-3g.probe(8) manual page.
3380 * @throws LibGuestFSException
3382 public int ntfs_3g_probe (boolean rw, String device)
3383 throws LibGuestFSException
3386 throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
3387 return _ntfs_3g_probe (g, rw, device);
3389 private native int _ntfs_3g_probe (long g, boolean rw, String device)
3390 throws LibGuestFSException;
3393 * run a command via the shell
3395 * This call runs a command from the guest filesystem via
3396 * the guest's "/bin/sh".
3398 * This is like "g.command", but passes the command to:
3400 * /bin/sh -c "command"
3402 * Depending on the guest's shell, this usually results in
3403 * wildcards being expanded, shell expressions being
3404 * interpolated and so on.
3406 * All the provisos about "g.command" apply to this call.
3408 * @throws LibGuestFSException
3410 public String sh (String command)
3411 throws LibGuestFSException
3414 throw new LibGuestFSException ("sh: handle is closed");
3415 return _sh (g, command);
3417 private native String _sh (long g, String command)
3418 throws LibGuestFSException;
3421 * run a command via the shell returning lines
3423 * This is the same as "g.sh", but splits the result into a
3426 * See also: "g.command_lines"
3428 * @throws LibGuestFSException
3430 public String[] sh_lines (String command)
3431 throws LibGuestFSException
3434 throw new LibGuestFSException ("sh_lines: handle is closed");
3435 return _sh_lines (g, command);
3437 private native String[] _sh_lines (long g, String command)
3438 throws LibGuestFSException;
3441 * expand a wildcard path
3443 * This command searches for all the pathnames matching
3444 * "pattern" according to the wildcard expansion rules used
3447 * If no paths match, then this returns an empty list
3448 * (note: not an error).
3450 * It is just a wrapper around the C glob(3) function with
3451 * flags "GLOB_MARK|GLOB_BRACE". See that manual page for
3454 * @throws LibGuestFSException
3456 public String[] glob_expand (String pattern)
3457 throws LibGuestFSException
3460 throw new LibGuestFSException ("glob_expand: handle is closed");
3461 return _glob_expand (g, pattern);
3463 private native String[] _glob_expand (long g, String pattern)
3464 throws LibGuestFSException;
3467 * scrub (securely wipe) a device
3469 * This command writes patterns over "device" to make data
3470 * retrieval more difficult.
3472 * It is an interface to the scrub(1) program. See that
3473 * manual page for more details.
3475 * This command is dangerous. Without careful use you can
3476 * easily destroy all your data.
3478 * @throws LibGuestFSException
3480 public void scrub_device (String device)
3481 throws LibGuestFSException
3484 throw new LibGuestFSException ("scrub_device: handle is closed");
3485 _scrub_device (g, device);
3487 private native void _scrub_device (long g, String device)
3488 throws LibGuestFSException;
3491 * scrub (securely wipe) a file
3493 * This command writes patterns over a file to make data
3494 * retrieval more difficult.
3496 * The file is *removed* after scrubbing.
3498 * It is an interface to the scrub(1) program. See that
3499 * manual page for more details.
3501 * @throws LibGuestFSException
3503 public void scrub_file (String file)
3504 throws LibGuestFSException
3507 throw new LibGuestFSException ("scrub_file: handle is closed");
3508 _scrub_file (g, file);
3510 private native void _scrub_file (long g, String file)
3511 throws LibGuestFSException;
3514 * scrub (securely wipe) free space
3516 * This command creates the directory "dir" and then fills
3517 * it with files until the filesystem is full, and scrubs
3518 * the files as for "g.scrub_file", and deletes them. The
3519 * intention is to scrub any free space on the partition
3522 * It is an interface to the scrub(1) program. See that
3523 * manual page for more details.
3525 * @throws LibGuestFSException
3527 public void scrub_freespace (String dir)
3528 throws LibGuestFSException
3531 throw new LibGuestFSException ("scrub_freespace: handle is closed");
3532 _scrub_freespace (g, dir);
3534 private native void _scrub_freespace (long g, String dir)
3535 throws LibGuestFSException;