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
432 * @throws LibGuestFSException
434 public void add_drive (String filename)
435 throws LibGuestFSException
438 throw new LibGuestFSException ("add_drive: handle is closed");
439 _add_drive (g, filename);
441 private native void _add_drive (long g, String filename)
442 throws LibGuestFSException;
445 * add a CD-ROM disk image to examine
447 * This function adds a virtual CD-ROM disk image to the
450 * This is equivalent to the qemu parameter "-cdrom
453 * @throws LibGuestFSException
455 public void add_cdrom (String filename)
456 throws LibGuestFSException
459 throw new LibGuestFSException ("add_cdrom: handle is closed");
460 _add_cdrom (g, filename);
462 private native void _add_cdrom (long g, String filename)
463 throws LibGuestFSException;
466 * add qemu parameters
468 * This can be used to add arbitrary qemu command line
469 * parameters of the form "-param value". Actually it's not
470 * quite arbitrary - we prevent you from setting some
471 * parameters which would interfere with parameters that we
474 * The first character of "param" string must be a "-"
477 * "value" can be NULL.
479 * @throws LibGuestFSException
481 public void config (String qemuparam, String qemuvalue)
482 throws LibGuestFSException
485 throw new LibGuestFSException ("config: handle is closed");
486 _config (g, qemuparam, qemuvalue);
488 private native void _config (long g, String qemuparam, String qemuvalue)
489 throws LibGuestFSException;
492 * set the qemu binary
494 * Set the qemu binary that we will use.
496 * The default is chosen when the library was compiled by
497 * the configure script.
499 * You can also override this by setting the
500 * "LIBGUESTFS_QEMU" environment variable.
502 * Setting "qemu" to "NULL" restores the default qemu
505 * @throws LibGuestFSException
507 public void set_qemu (String qemu)
508 throws LibGuestFSException
511 throw new LibGuestFSException ("set_qemu: handle is closed");
514 private native void _set_qemu (long g, String qemu)
515 throws LibGuestFSException;
518 * get the qemu binary
520 * Return the current qemu binary.
522 * This is always non-NULL. If it wasn't set already, then
523 * this will return the default qemu binary name.
525 * @throws LibGuestFSException
527 public String get_qemu ()
528 throws LibGuestFSException
531 throw new LibGuestFSException ("get_qemu: handle is closed");
532 return _get_qemu (g);
534 private native String _get_qemu (long g)
535 throws LibGuestFSException;
538 * set the search path
540 * Set the path that libguestfs searches for kernel and
543 * The default is "$libdir/guestfs" unless overridden by
544 * setting "LIBGUESTFS_PATH" environment variable.
546 * Setting "path" to "NULL" restores the default path.
548 * @throws LibGuestFSException
550 public void set_path (String path)
551 throws LibGuestFSException
554 throw new LibGuestFSException ("set_path: handle is closed");
557 private native void _set_path (long g, String path)
558 throws LibGuestFSException;
561 * get the search path
563 * Return the current search path.
565 * This is always non-NULL. If it wasn't set already, then
566 * this will return the default path.
568 * @throws LibGuestFSException
570 public String get_path ()
571 throws LibGuestFSException
574 throw new LibGuestFSException ("get_path: handle is closed");
575 return _get_path (g);
577 private native String _get_path (long g)
578 throws LibGuestFSException;
581 * add options to kernel command line
583 * This function is used to add additional options to the
584 * guest kernel command line.
586 * The default is "NULL" unless overridden by setting
587 * "LIBGUESTFS_APPEND" environment variable.
589 * Setting "append" to "NULL" means *no* additional options
590 * are passed (libguestfs always adds a few of its own).
592 * @throws LibGuestFSException
594 public void set_append (String append)
595 throws LibGuestFSException
598 throw new LibGuestFSException ("set_append: handle is closed");
599 _set_append (g, append);
601 private native void _set_append (long g, String append)
602 throws LibGuestFSException;
605 * get the additional kernel options
607 * Return the additional kernel options which are added to
608 * the guest kernel command line.
610 * If "NULL" then no options are added.
612 * @throws LibGuestFSException
614 public String get_append ()
615 throws LibGuestFSException
618 throw new LibGuestFSException ("get_append: handle is closed");
619 return _get_append (g);
621 private native String _get_append (long g)
622 throws LibGuestFSException;
627 * If "autosync" is true, this enables autosync. Libguestfs
628 * will make a best effort attempt to run "g.umount_all"
629 * followed by "g.sync" when the handle is closed (also if
630 * the program exits without closing handles).
632 * This is disabled by default (except in guestfish where
633 * it is enabled by default).
635 * @throws LibGuestFSException
637 public void set_autosync (boolean autosync)
638 throws LibGuestFSException
641 throw new LibGuestFSException ("set_autosync: handle is closed");
642 _set_autosync (g, autosync);
644 private native void _set_autosync (long g, boolean autosync)
645 throws LibGuestFSException;
650 * Get the autosync flag.
652 * @throws LibGuestFSException
654 public boolean get_autosync ()
655 throws LibGuestFSException
658 throw new LibGuestFSException ("get_autosync: handle is closed");
659 return _get_autosync (g);
661 private native boolean _get_autosync (long g)
662 throws LibGuestFSException;
667 * If "verbose" is true, this turns on verbose messages (to
670 * Verbose messages are disabled unless the environment
671 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
673 * @throws LibGuestFSException
675 public void set_verbose (boolean verbose)
676 throws LibGuestFSException
679 throw new LibGuestFSException ("set_verbose: handle is closed");
680 _set_verbose (g, verbose);
682 private native void _set_verbose (long g, boolean verbose)
683 throws LibGuestFSException;
688 * This returns the verbose messages flag.
690 * @throws LibGuestFSException
692 public boolean get_verbose ()
693 throws LibGuestFSException
696 throw new LibGuestFSException ("get_verbose: handle is closed");
697 return _get_verbose (g);
699 private native boolean _get_verbose (long g)
700 throws LibGuestFSException;
703 * is ready to accept commands
705 * This returns true iff this handle is ready to accept
706 * commands (in the "READY" state).
708 * For more information on states, see guestfs(3).
710 * @throws LibGuestFSException
712 public boolean is_ready ()
713 throws LibGuestFSException
716 throw new LibGuestFSException ("is_ready: handle is closed");
717 return _is_ready (g);
719 private native boolean _is_ready (long g)
720 throws LibGuestFSException;
723 * is in configuration state
725 * This returns true iff this handle is being configured
726 * (in the "CONFIG" state).
728 * For more information on states, see guestfs(3).
730 * @throws LibGuestFSException
732 public boolean is_config ()
733 throws LibGuestFSException
736 throw new LibGuestFSException ("is_config: handle is closed");
737 return _is_config (g);
739 private native boolean _is_config (long g)
740 throws LibGuestFSException;
743 * is launching subprocess
745 * This returns true iff this handle is launching the
746 * subprocess (in the "LAUNCHING" state).
748 * For more information on states, see guestfs(3).
750 * @throws LibGuestFSException
752 public boolean is_launching ()
753 throws LibGuestFSException
756 throw new LibGuestFSException ("is_launching: handle is closed");
757 return _is_launching (g);
759 private native boolean _is_launching (long g)
760 throws LibGuestFSException;
763 * is busy processing a command
765 * This returns true iff this handle is busy processing a
766 * command (in the "BUSY" state).
768 * For more information on states, see guestfs(3).
770 * @throws LibGuestFSException
772 public boolean is_busy ()
773 throws LibGuestFSException
776 throw new LibGuestFSException ("is_busy: handle is closed");
779 private native boolean _is_busy (long g)
780 throws LibGuestFSException;
783 * get the current state
785 * This returns the current state as an opaque integer.
786 * This is only useful for printing debug and internal
789 * For more information on states, see guestfs(3).
791 * @throws LibGuestFSException
793 public int get_state ()
794 throws LibGuestFSException
797 throw new LibGuestFSException ("get_state: handle is closed");
798 return _get_state (g);
800 private native int _get_state (long g)
801 throws LibGuestFSException;
806 * This sets the state to "BUSY". This is only used when
807 * implementing actions using the low-level API.
809 * For more information on states, see guestfs(3).
811 * @throws LibGuestFSException
813 public void set_busy ()
814 throws LibGuestFSException
817 throw new LibGuestFSException ("set_busy: handle is closed");
820 private native void _set_busy (long g)
821 throws LibGuestFSException;
826 * This sets the state to "READY". This is only used when
827 * implementing actions using the low-level API.
829 * For more information on states, see guestfs(3).
831 * @throws LibGuestFSException
833 public void set_ready ()
834 throws LibGuestFSException
837 throw new LibGuestFSException ("set_ready: handle is closed");
840 private native void _set_ready (long g)
841 throws LibGuestFSException;
844 * leave the busy state
846 * This sets the state to "READY", or if in "CONFIG" then
847 * it leaves the state as is. This is only used when
848 * implementing actions using the low-level API.
850 * For more information on states, see guestfs(3).
852 * @throws LibGuestFSException
854 public void end_busy ()
855 throws LibGuestFSException
858 throw new LibGuestFSException ("end_busy: handle is closed");
861 private native void _end_busy (long g)
862 throws LibGuestFSException;
865 * mount a guest disk at a position in the filesystem
867 * Mount a guest disk at a position in the filesystem.
868 * Block devices are named "/dev/sda", "/dev/sdb" and so
869 * on, as they were added to the guest. If those block
870 * devices contain partitions, they will have the usual
871 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
874 * The rules are the same as for mount(2): A filesystem
875 * must first be mounted on "/" before others can be
876 * mounted. Other filesystems can only be mounted on
877 * directories which already exist.
879 * The mounted filesystem is writable, if we have
880 * sufficient permissions on the underlying device.
882 * The filesystem options "sync" and "noatime" are set with
883 * this call, in order to improve reliability.
885 * @throws LibGuestFSException
887 public void mount (String device, String mountpoint)
888 throws LibGuestFSException
891 throw new LibGuestFSException ("mount: handle is closed");
892 _mount (g, device, mountpoint);
894 private native void _mount (long g, String device, String mountpoint)
895 throws LibGuestFSException;
898 * sync disks, writes are flushed through to the disk image
900 * This syncs the disk, so that any writes are flushed
901 * through to the underlying disk image.
903 * You should always call this if you have modified a disk
904 * image, before closing the handle.
906 * @throws LibGuestFSException
909 throws LibGuestFSException
912 throw new LibGuestFSException ("sync: handle is closed");
915 private native void _sync (long g)
916 throws LibGuestFSException;
919 * update file timestamps or create a new file
921 * Touch acts like the touch(1) command. It can be used to
922 * update the timestamps on a file, or, if the file does
923 * not exist, to create a new zero-length file.
925 * @throws LibGuestFSException
927 public void touch (String path)
928 throws LibGuestFSException
931 throw new LibGuestFSException ("touch: handle is closed");
934 private native void _touch (long g, String path)
935 throws LibGuestFSException;
938 * list the contents of a file
940 * Return the contents of the file named "path".
942 * Note that this function cannot correctly handle binary
943 * files (specifically, files containing "\0" character
944 * which is treated as end of string). For those you need
945 * to use the "g.download" function which has a more
948 * Because of the message protocol, there is a transfer
949 * limit of somewhere between 2MB and 4MB. To transfer
950 * large files you should use FTP.
952 * @throws LibGuestFSException
954 public String cat (String path)
955 throws LibGuestFSException
958 throw new LibGuestFSException ("cat: handle is closed");
959 return _cat (g, path);
961 private native String _cat (long g, String path)
962 throws LibGuestFSException;
965 * list the files in a directory (long format)
967 * List the files in "directory" (relative to the root
968 * directory, there is no cwd) in the format of 'ls -la'.
970 * This command is mostly useful for interactive sessions.
971 * It is *not* intended that you try to parse the output
974 * @throws LibGuestFSException
976 public String ll (String directory)
977 throws LibGuestFSException
980 throw new LibGuestFSException ("ll: handle is closed");
981 return _ll (g, directory);
983 private native String _ll (long g, String directory)
984 throws LibGuestFSException;
987 * list the files in a directory
989 * List the files in "directory" (relative to the root
990 * directory, there is no cwd). The '.' and '..' entries
991 * are not returned, but hidden files are shown.
993 * This command is mostly useful for interactive sessions.
994 * Programs should probably use "g.readdir" instead.
996 * @throws LibGuestFSException
998 public String[] ls (String directory)
999 throws LibGuestFSException
1002 throw new LibGuestFSException ("ls: handle is closed");
1003 return _ls (g, directory);
1005 private native String[] _ls (long g, String directory)
1006 throws LibGuestFSException;
1009 * list the block devices
1011 * List all the block devices.
1013 * The full block device names are returned, eg. "/dev/sda"
1015 * @throws LibGuestFSException
1017 public String[] list_devices ()
1018 throws LibGuestFSException
1021 throw new LibGuestFSException ("list_devices: handle is closed");
1022 return _list_devices (g);
1024 private native String[] _list_devices (long g)
1025 throws LibGuestFSException;
1028 * list the partitions
1030 * List all the partitions detected on all block devices.
1032 * The full partition device names are returned, eg.
1035 * This does not return logical volumes. For that you will
1036 * need to call "g.lvs".
1038 * @throws LibGuestFSException
1040 public String[] list_partitions ()
1041 throws LibGuestFSException
1044 throw new LibGuestFSException ("list_partitions: handle is closed");
1045 return _list_partitions (g);
1047 private native String[] _list_partitions (long g)
1048 throws LibGuestFSException;
1051 * list the LVM physical volumes (PVs)
1053 * List all the physical volumes detected. This is the
1054 * equivalent of the pvs(8) command.
1056 * This returns a list of just the device names that
1057 * contain PVs (eg. "/dev/sda2").
1059 * See also "g.pvs_full".
1061 * @throws LibGuestFSException
1063 public String[] pvs ()
1064 throws LibGuestFSException
1067 throw new LibGuestFSException ("pvs: handle is closed");
1070 private native String[] _pvs (long g)
1071 throws LibGuestFSException;
1074 * list the LVM volume groups (VGs)
1076 * List all the volumes groups detected. This is the
1077 * equivalent of the vgs(8) command.
1079 * This returns a list of just the volume group names that
1080 * were detected (eg. "VolGroup00").
1082 * See also "g.vgs_full".
1084 * @throws LibGuestFSException
1086 public String[] vgs ()
1087 throws LibGuestFSException
1090 throw new LibGuestFSException ("vgs: handle is closed");
1093 private native String[] _vgs (long g)
1094 throws LibGuestFSException;
1097 * list the LVM logical volumes (LVs)
1099 * List all the logical volumes detected. This is the
1100 * equivalent of the lvs(8) command.
1102 * This returns a list of the logical volume device names
1103 * (eg. "/dev/VolGroup00/LogVol00").
1105 * See also "g.lvs_full".
1107 * @throws LibGuestFSException
1109 public String[] lvs ()
1110 throws LibGuestFSException
1113 throw new LibGuestFSException ("lvs: handle is closed");
1116 private native String[] _lvs (long g)
1117 throws LibGuestFSException;
1120 * list the LVM physical volumes (PVs)
1122 * List all the physical volumes detected. This is the
1123 * equivalent of the pvs(8) command. The "full" version
1124 * includes all fields.
1126 * @throws LibGuestFSException
1128 public PV[] pvs_full ()
1129 throws LibGuestFSException
1132 throw new LibGuestFSException ("pvs_full: handle is closed");
1133 return _pvs_full (g);
1135 private native PV[] _pvs_full (long g)
1136 throws LibGuestFSException;
1139 * list the LVM volume groups (VGs)
1141 * List all the volumes groups detected. This is the
1142 * equivalent of the vgs(8) command. The "full" version
1143 * includes all fields.
1145 * @throws LibGuestFSException
1147 public VG[] vgs_full ()
1148 throws LibGuestFSException
1151 throw new LibGuestFSException ("vgs_full: handle is closed");
1152 return _vgs_full (g);
1154 private native VG[] _vgs_full (long g)
1155 throws LibGuestFSException;
1158 * list the LVM logical volumes (LVs)
1160 * List all the logical volumes detected. This is the
1161 * equivalent of the lvs(8) command. The "full" version
1162 * includes all fields.
1164 * @throws LibGuestFSException
1166 public LV[] lvs_full ()
1167 throws LibGuestFSException
1170 throw new LibGuestFSException ("lvs_full: handle is closed");
1171 return _lvs_full (g);
1173 private native LV[] _lvs_full (long g)
1174 throws LibGuestFSException;
1177 * read file as lines
1179 * Return the contents of the file named "path".
1181 * The file contents are returned as a list of lines.
1182 * Trailing "LF" and "CRLF" character sequences are *not*
1185 * Note that this function cannot correctly handle binary
1186 * files (specifically, files containing "\0" character
1187 * which is treated as end of line). For those you need to
1188 * use the "g.read_file" function which has a more complex
1191 * @throws LibGuestFSException
1193 public String[] read_lines (String path)
1194 throws LibGuestFSException
1197 throw new LibGuestFSException ("read_lines: handle is closed");
1198 return _read_lines (g, path);
1200 private native String[] _read_lines (long g, String path)
1201 throws LibGuestFSException;
1204 * create a new Augeas handle
1206 * Create a new Augeas handle for editing configuration
1207 * files. If there was any previous Augeas handle
1208 * associated with this guestfs session, then it is closed.
1210 * You must call this before using any other "g.aug_*"
1213 * "root" is the filesystem root. "root" must not be NULL,
1216 * The flags are the same as the flags defined in
1217 * <augeas.h>, the logical *or* of the following integers:
1219 * "AUG_SAVE_BACKUP" = 1
1220 * Keep the original file with a ".augsave" extension.
1222 * "AUG_SAVE_NEWFILE" = 2
1223 * Save changes into a file with extension ".augnew",
1224 * and do not overwrite original. Overrides
1225 * "AUG_SAVE_BACKUP".
1227 * "AUG_TYPE_CHECK" = 4
1228 * Typecheck lenses (can be expensive).
1230 * "AUG_NO_STDINC" = 8
1231 * Do not use standard load path for modules.
1233 * "AUG_SAVE_NOOP" = 16
1234 * Make save a no-op, just record what would have been
1237 * "AUG_NO_LOAD" = 32
1238 * Do not load the tree in "g.aug_init".
1240 * To close the handle, you can call "g.aug_close".
1242 * To find out more about Augeas, see <http://augeas.net/>.
1244 * @throws LibGuestFSException
1246 public void aug_init (String root, int flags)
1247 throws LibGuestFSException
1250 throw new LibGuestFSException ("aug_init: handle is closed");
1251 _aug_init (g, root, flags);
1253 private native void _aug_init (long g, String root, int flags)
1254 throws LibGuestFSException;
1257 * close the current Augeas handle
1259 * Close the current Augeas handle and free up any
1260 * resources used by it. After calling this, you have to
1261 * call "g.aug_init" again before you can use any other
1264 * @throws LibGuestFSException
1266 public void aug_close ()
1267 throws LibGuestFSException
1270 throw new LibGuestFSException ("aug_close: handle is closed");
1273 private native void _aug_close (long g)
1274 throws LibGuestFSException;
1277 * define an Augeas variable
1279 * Defines an Augeas variable "name" whose value is the
1280 * result of evaluating "expr". If "expr" is NULL, then
1281 * "name" is undefined.
1283 * On success this returns the number of nodes in "expr",
1284 * or 0 if "expr" evaluates to something which is not a
1287 * @throws LibGuestFSException
1289 public int aug_defvar (String name, String expr)
1290 throws LibGuestFSException
1293 throw new LibGuestFSException ("aug_defvar: handle is closed");
1294 return _aug_defvar (g, name, expr);
1296 private native int _aug_defvar (long g, String name, String expr)
1297 throws LibGuestFSException;
1300 * define an Augeas node
1302 * Defines a variable "name" whose value is the result of
1303 * evaluating "expr".
1305 * If "expr" evaluates to an empty nodeset, a node is
1306 * created, equivalent to calling "g.aug_set" "expr",
1307 * "value". "name" will be the nodeset containing that
1310 * On success this returns a pair containing the number of
1311 * nodes in the nodeset, and a boolean flag if a node was
1314 * @throws LibGuestFSException
1316 public IntBool aug_defnode (String name, String expr, String val)
1317 throws LibGuestFSException
1320 throw new LibGuestFSException ("aug_defnode: handle is closed");
1321 return _aug_defnode (g, name, expr, val);
1323 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1324 throws LibGuestFSException;
1327 * look up the value of an Augeas path
1329 * Look up the value associated with "path". If "path"
1330 * matches exactly one node, the "value" is returned.
1332 * @throws LibGuestFSException
1334 public String aug_get (String path)
1335 throws LibGuestFSException
1338 throw new LibGuestFSException ("aug_get: handle is closed");
1339 return _aug_get (g, path);
1341 private native String _aug_get (long g, String path)
1342 throws LibGuestFSException;
1345 * set Augeas path to value
1347 * Set the value associated with "path" to "value".
1349 * @throws LibGuestFSException
1351 public void aug_set (String path, String val)
1352 throws LibGuestFSException
1355 throw new LibGuestFSException ("aug_set: handle is closed");
1356 _aug_set (g, path, val);
1358 private native void _aug_set (long g, String path, String val)
1359 throws LibGuestFSException;
1362 * insert a sibling Augeas node
1364 * Create a new sibling "label" for "path", inserting it
1365 * into the tree before or after "path" (depending on the
1366 * boolean flag "before").
1368 * "path" must match exactly one existing node in the tree,
1369 * and "label" must be a label, ie. not contain "/", "*" or
1370 * end with a bracketed index "[N]".
1372 * @throws LibGuestFSException
1374 public void aug_insert (String path, String label, boolean before)
1375 throws LibGuestFSException
1378 throw new LibGuestFSException ("aug_insert: handle is closed");
1379 _aug_insert (g, path, label, before);
1381 private native void _aug_insert (long g, String path, String label, boolean before)
1382 throws LibGuestFSException;
1385 * remove an Augeas path
1387 * Remove "path" and all of its children.
1389 * On success this returns the number of entries which were
1392 * @throws LibGuestFSException
1394 public int aug_rm (String path)
1395 throws LibGuestFSException
1398 throw new LibGuestFSException ("aug_rm: handle is closed");
1399 return _aug_rm (g, path);
1401 private native int _aug_rm (long g, String path)
1402 throws LibGuestFSException;
1407 * Move the node "src" to "dest". "src" must match exactly
1408 * one node. "dest" is overwritten if it exists.
1410 * @throws LibGuestFSException
1412 public void aug_mv (String src, String dest)
1413 throws LibGuestFSException
1416 throw new LibGuestFSException ("aug_mv: handle is closed");
1417 _aug_mv (g, src, dest);
1419 private native void _aug_mv (long g, String src, String dest)
1420 throws LibGuestFSException;
1423 * return Augeas nodes which match path
1425 * Returns a list of paths which match the path expression
1426 * "path". The returned paths are sufficiently qualified so
1427 * that they match exactly one node in the current tree.
1429 * @throws LibGuestFSException
1431 public String[] aug_match (String path)
1432 throws LibGuestFSException
1435 throw new LibGuestFSException ("aug_match: handle is closed");
1436 return _aug_match (g, path);
1438 private native String[] _aug_match (long g, String path)
1439 throws LibGuestFSException;
1442 * write all pending Augeas changes to disk
1444 * This writes all pending changes to disk.
1446 * The flags which were passed to "g.aug_init" affect
1447 * exactly how files are saved.
1449 * @throws LibGuestFSException
1451 public void aug_save ()
1452 throws LibGuestFSException
1455 throw new LibGuestFSException ("aug_save: handle is closed");
1458 private native void _aug_save (long g)
1459 throws LibGuestFSException;
1462 * load files into the tree
1464 * Load files into the tree.
1466 * See "aug_load" in the Augeas documentation for the full
1469 * @throws LibGuestFSException
1471 public void aug_load ()
1472 throws LibGuestFSException
1475 throw new LibGuestFSException ("aug_load: handle is closed");
1478 private native void _aug_load (long g)
1479 throws LibGuestFSException;
1482 * list Augeas nodes under a path
1484 * This is just a shortcut for listing "g.aug_match"
1485 * "path/*" and sorting the resulting nodes into
1486 * alphabetical order.
1488 * @throws LibGuestFSException
1490 public String[] aug_ls (String path)
1491 throws LibGuestFSException
1494 throw new LibGuestFSException ("aug_ls: handle is closed");
1495 return _aug_ls (g, path);
1497 private native String[] _aug_ls (long g, String path)
1498 throws LibGuestFSException;
1503 * Remove the single file "path".
1505 * @throws LibGuestFSException
1507 public void rm (String path)
1508 throws LibGuestFSException
1511 throw new LibGuestFSException ("rm: handle is closed");
1514 private native void _rm (long g, String path)
1515 throws LibGuestFSException;
1518 * remove a directory
1520 * Remove the single directory "path".
1522 * @throws LibGuestFSException
1524 public void rmdir (String path)
1525 throws LibGuestFSException
1528 throw new LibGuestFSException ("rmdir: handle is closed");
1531 private native void _rmdir (long g, String path)
1532 throws LibGuestFSException;
1535 * remove a file or directory recursively
1537 * Remove the file or directory "path", recursively
1538 * removing the contents if its a directory. This is like
1539 * the "rm -rf" shell command.
1541 * @throws LibGuestFSException
1543 public void rm_rf (String path)
1544 throws LibGuestFSException
1547 throw new LibGuestFSException ("rm_rf: handle is closed");
1550 private native void _rm_rf (long g, String path)
1551 throws LibGuestFSException;
1554 * create a directory
1556 * Create a directory named "path".
1558 * @throws LibGuestFSException
1560 public void mkdir (String path)
1561 throws LibGuestFSException
1564 throw new LibGuestFSException ("mkdir: handle is closed");
1567 private native void _mkdir (long g, String path)
1568 throws LibGuestFSException;
1571 * create a directory and parents
1573 * Create a directory named "path", creating any parent
1574 * directories as necessary. This is like the "mkdir -p"
1577 * @throws LibGuestFSException
1579 public void mkdir_p (String path)
1580 throws LibGuestFSException
1583 throw new LibGuestFSException ("mkdir_p: handle is closed");
1586 private native void _mkdir_p (long g, String path)
1587 throws LibGuestFSException;
1592 * Change the mode (permissions) of "path" to "mode". Only
1593 * numeric modes are supported.
1595 * @throws LibGuestFSException
1597 public void chmod (int mode, String path)
1598 throws LibGuestFSException
1601 throw new LibGuestFSException ("chmod: handle is closed");
1602 _chmod (g, mode, path);
1604 private native void _chmod (long g, int mode, String path)
1605 throws LibGuestFSException;
1608 * change file owner and group
1610 * Change the file owner to "owner" and group to "group".
1612 * Only numeric uid and gid are supported. If you want to
1613 * use names, you will need to locate and parse the
1614 * password file yourself (Augeas support makes this
1617 * @throws LibGuestFSException
1619 public void chown (int owner, int group, String path)
1620 throws LibGuestFSException
1623 throw new LibGuestFSException ("chown: handle is closed");
1624 _chown (g, owner, group, path);
1626 private native void _chown (long g, int owner, int group, String path)
1627 throws LibGuestFSException;
1630 * test if file or directory exists
1632 * This returns "true" if and only if there is a file,
1633 * directory (or anything) with the given "path" name.
1635 * See also "g.is_file", "g.is_dir", "g.stat".
1637 * @throws LibGuestFSException
1639 public boolean exists (String path)
1640 throws LibGuestFSException
1643 throw new LibGuestFSException ("exists: handle is closed");
1644 return _exists (g, path);
1646 private native boolean _exists (long g, String path)
1647 throws LibGuestFSException;
1650 * test if file exists
1652 * This returns "true" if and only if there is a file with
1653 * the given "path" name. Note that it returns false for
1654 * other objects like directories.
1656 * See also "g.stat".
1658 * @throws LibGuestFSException
1660 public boolean is_file (String path)
1661 throws LibGuestFSException
1664 throw new LibGuestFSException ("is_file: handle is closed");
1665 return _is_file (g, path);
1667 private native boolean _is_file (long g, String path)
1668 throws LibGuestFSException;
1671 * test if file exists
1673 * This returns "true" if and only if there is a directory
1674 * with the given "path" name. Note that it returns false
1675 * for other objects like files.
1677 * See also "g.stat".
1679 * @throws LibGuestFSException
1681 public boolean is_dir (String path)
1682 throws LibGuestFSException
1685 throw new LibGuestFSException ("is_dir: handle is closed");
1686 return _is_dir (g, path);
1688 private native boolean _is_dir (long g, String path)
1689 throws LibGuestFSException;
1692 * create an LVM physical volume
1694 * This creates an LVM physical volume on the named
1695 * "device", where "device" should usually be a partition
1696 * name such as "/dev/sda1".
1698 * @throws LibGuestFSException
1700 public void pvcreate (String device)
1701 throws LibGuestFSException
1704 throw new LibGuestFSException ("pvcreate: handle is closed");
1705 _pvcreate (g, device);
1707 private native void _pvcreate (long g, String device)
1708 throws LibGuestFSException;
1711 * create an LVM volume group
1713 * This creates an LVM volume group called "volgroup" from
1714 * the non-empty list of physical volumes "physvols".
1716 * @throws LibGuestFSException
1718 public void vgcreate (String volgroup, String[] physvols)
1719 throws LibGuestFSException
1722 throw new LibGuestFSException ("vgcreate: handle is closed");
1723 _vgcreate (g, volgroup, physvols);
1725 private native void _vgcreate (long g, String volgroup, String[] physvols)
1726 throws LibGuestFSException;
1729 * create an LVM volume group
1731 * This creates an LVM volume group called "logvol" on the
1732 * volume group "volgroup", with "size" megabytes.
1734 * @throws LibGuestFSException
1736 public void lvcreate (String logvol, String volgroup, int mbytes)
1737 throws LibGuestFSException
1740 throw new LibGuestFSException ("lvcreate: handle is closed");
1741 _lvcreate (g, logvol, volgroup, mbytes);
1743 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1744 throws LibGuestFSException;
1749 * This creates a filesystem on "device" (usually a
1750 * partition or LVM logical volume). The filesystem type is
1751 * "fstype", for example "ext3".
1753 * @throws LibGuestFSException
1755 public void mkfs (String fstype, String device)
1756 throws LibGuestFSException
1759 throw new LibGuestFSException ("mkfs: handle is closed");
1760 _mkfs (g, fstype, device);
1762 private native void _mkfs (long g, String fstype, String device)
1763 throws LibGuestFSException;
1766 * create partitions on a block device
1768 * This is a direct interface to the sfdisk(8) program for
1769 * creating partitions on block devices.
1771 * "device" should be a block device, for example
1774 * "cyls", "heads" and "sectors" are the number of
1775 * cylinders, heads and sectors on the device, which are
1776 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1777 * parameters. If you pass 0 for any of these, then the
1778 * corresponding parameter is omitted. Usually for 'large'
1779 * disks, you can just pass 0 for these, but for small
1780 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1781 * cannot work out the right geometry and you will need to
1784 * "lines" is a list of lines that we feed to "sfdisk". For
1785 * more information refer to the sfdisk(8) manpage.
1787 * To create a single partition occupying the whole disk,
1788 * you would pass "lines" as a single element list, when
1789 * the single element being the string "," (comma).
1791 * See also: "g.sfdisk_l", "g.sfdisk_N"
1793 * This command is dangerous. Without careful use you can
1794 * easily destroy all your data.
1796 * @throws LibGuestFSException
1798 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1799 throws LibGuestFSException
1802 throw new LibGuestFSException ("sfdisk: handle is closed");
1803 _sfdisk (g, device, cyls, heads, sectors, lines);
1805 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1806 throws LibGuestFSException;
1811 * This call creates a file called "path". The contents of
1812 * the file is the string "content" (which can contain any
1813 * 8 bit data), with length "size".
1815 * As a special case, if "size" is 0 then the length is
1816 * calculated using "strlen" (so in this case the content
1817 * cannot contain embedded ASCII NULs).
1819 * *NB.* Owing to a bug, writing content containing ASCII
1820 * NUL characters does *not* work, even if the length is
1821 * specified. We hope to resolve this bug in a future
1822 * version. In the meantime use "g.upload".
1824 * Because of the message protocol, there is a transfer
1825 * limit of somewhere between 2MB and 4MB. To transfer
1826 * large files you should use FTP.
1828 * @throws LibGuestFSException
1830 public void write_file (String path, String content, int size)
1831 throws LibGuestFSException
1834 throw new LibGuestFSException ("write_file: handle is closed");
1835 _write_file (g, path, content, size);
1837 private native void _write_file (long g, String path, String content, int size)
1838 throws LibGuestFSException;
1841 * unmount a filesystem
1843 * This unmounts the given filesystem. The filesystem may
1844 * be specified either by its mountpoint (path) or the
1845 * device which contains the filesystem.
1847 * @throws LibGuestFSException
1849 public void umount (String pathordevice)
1850 throws LibGuestFSException
1853 throw new LibGuestFSException ("umount: handle is closed");
1854 _umount (g, pathordevice);
1856 private native void _umount (long g, String pathordevice)
1857 throws LibGuestFSException;
1860 * show mounted filesystems
1862 * This returns the list of currently mounted filesystems.
1863 * It returns the list of devices (eg. "/dev/sda1",
1866 * Some internal mounts are not shown.
1868 * @throws LibGuestFSException
1870 public String[] mounts ()
1871 throws LibGuestFSException
1874 throw new LibGuestFSException ("mounts: handle is closed");
1877 private native String[] _mounts (long g)
1878 throws LibGuestFSException;
1881 * unmount all filesystems
1883 * This unmounts all mounted filesystems.
1885 * Some internal mounts are not unmounted by this call.
1887 * @throws LibGuestFSException
1889 public void umount_all ()
1890 throws LibGuestFSException
1893 throw new LibGuestFSException ("umount_all: handle is closed");
1896 private native void _umount_all (long g)
1897 throws LibGuestFSException;
1900 * remove all LVM LVs, VGs and PVs
1902 * This command removes all LVM logical volumes, volume
1903 * groups and physical volumes.
1905 * This command is dangerous. Without careful use you can
1906 * easily destroy all your data.
1908 * @throws LibGuestFSException
1910 public void lvm_remove_all ()
1911 throws LibGuestFSException
1914 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
1915 _lvm_remove_all (g);
1917 private native void _lvm_remove_all (long g)
1918 throws LibGuestFSException;
1921 * determine file type
1923 * This call uses the standard file(1) command to determine
1924 * the type or contents of the file. This also works on
1925 * devices, for example to find out whether a partition
1926 * contains a filesystem.
1928 * The exact command which runs is "file -bsL path". Note
1929 * in particular that the filename is not prepended to the
1930 * output (the "-b" option).
1932 * @throws LibGuestFSException
1934 public String file (String path)
1935 throws LibGuestFSException
1938 throw new LibGuestFSException ("file: handle is closed");
1939 return _file (g, path);
1941 private native String _file (long g, String path)
1942 throws LibGuestFSException;
1945 * run a command from the guest filesystem
1947 * This call runs a command from the guest filesystem. The
1948 * filesystem must be mounted, and must contain a
1949 * compatible operating system (ie. something Linux, with
1950 * the same or compatible processor architecture).
1952 * The single parameter is an argv-style list of arguments.
1953 * The first element is the name of the program to run.
1954 * Subsequent elements are parameters. The list must be
1955 * non-empty (ie. must contain a program name).
1957 * The return value is anything printed to *stdout* by the
1960 * If the command returns a non-zero exit status, then this
1961 * function returns an error message. The error message
1962 * string is the content of *stderr* from the command.
1964 * The $PATH environment variable will contain at least
1965 * "/usr/bin" and "/bin". If you require a program from
1966 * another location, you should provide the full path in
1967 * the first parameter.
1969 * Shared libraries and data files required by the program
1970 * must be available on filesystems which are mounted in
1971 * the correct places. It is the caller's responsibility to
1972 * ensure all filesystems that are needed are mounted at
1973 * the right locations.
1975 * Because of the message protocol, there is a transfer
1976 * limit of somewhere between 2MB and 4MB. To transfer
1977 * large files you should use FTP.
1979 * @throws LibGuestFSException
1981 public String command (String[] arguments)
1982 throws LibGuestFSException
1985 throw new LibGuestFSException ("command: handle is closed");
1986 return _command (g, arguments);
1988 private native String _command (long g, String[] arguments)
1989 throws LibGuestFSException;
1992 * run a command, returning lines
1994 * This is the same as "g.command", but splits the result
1995 * into a list of lines.
1997 * Because of the message protocol, there is a transfer
1998 * limit of somewhere between 2MB and 4MB. To transfer
1999 * large files you should use FTP.
2001 * @throws LibGuestFSException
2003 public String[] command_lines (String[] arguments)
2004 throws LibGuestFSException
2007 throw new LibGuestFSException ("command_lines: handle is closed");
2008 return _command_lines (g, arguments);
2010 private native String[] _command_lines (long g, String[] arguments)
2011 throws LibGuestFSException;
2014 * get file information
2016 * Returns file information for the given "path".
2018 * This is the same as the stat(2) system call.
2020 * @throws LibGuestFSException
2022 public Stat stat (String path)
2023 throws LibGuestFSException
2026 throw new LibGuestFSException ("stat: handle is closed");
2027 return _stat (g, path);
2029 private native Stat _stat (long g, String path)
2030 throws LibGuestFSException;
2033 * get file information for a symbolic link
2035 * Returns file information for the given "path".
2037 * This is the same as "g.stat" except that if "path" is a
2038 * symbolic link, then the link is stat-ed, not the file it
2041 * This is the same as the lstat(2) system call.
2043 * @throws LibGuestFSException
2045 public Stat lstat (String path)
2046 throws LibGuestFSException
2049 throw new LibGuestFSException ("lstat: handle is closed");
2050 return _lstat (g, path);
2052 private native Stat _lstat (long g, String path)
2053 throws LibGuestFSException;
2056 * get file system statistics
2058 * Returns file system statistics for any mounted file
2059 * system. "path" should be a file or directory in the
2060 * mounted file system (typically it is the mount point
2061 * itself, but it doesn't need to be).
2063 * This is the same as the statvfs(2) system call.
2065 * @throws LibGuestFSException
2067 public StatVFS statvfs (String path)
2068 throws LibGuestFSException
2071 throw new LibGuestFSException ("statvfs: handle is closed");
2072 return _statvfs (g, path);
2074 private native StatVFS _statvfs (long g, String path)
2075 throws LibGuestFSException;
2078 * get ext2/ext3/ext4 superblock details
2080 * This returns the contents of the ext2, ext3 or ext4
2081 * filesystem superblock on "device".
2083 * It is the same as running "tune2fs -l device". See
2084 * tune2fs(8) manpage for more details. The list of fields
2085 * returned isn't clearly defined, and depends on both the
2086 * version of "tune2fs" that libguestfs was built against,
2087 * and the filesystem itself.
2089 * @throws LibGuestFSException
2091 public HashMap<String,String> tune2fs_l (String device)
2092 throws LibGuestFSException
2095 throw new LibGuestFSException ("tune2fs_l: handle is closed");
2096 return _tune2fs_l (g, device);
2098 private native HashMap<String,String> _tune2fs_l (long g, String device)
2099 throws LibGuestFSException;
2102 * set block device to read-only
2104 * Sets the block device named "device" to read-only.
2106 * This uses the blockdev(8) command.
2108 * @throws LibGuestFSException
2110 public void blockdev_setro (String device)
2111 throws LibGuestFSException
2114 throw new LibGuestFSException ("blockdev_setro: handle is closed");
2115 _blockdev_setro (g, device);
2117 private native void _blockdev_setro (long g, String device)
2118 throws LibGuestFSException;
2121 * set block device to read-write
2123 * Sets the block device named "device" to read-write.
2125 * This uses the blockdev(8) command.
2127 * @throws LibGuestFSException
2129 public void blockdev_setrw (String device)
2130 throws LibGuestFSException
2133 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
2134 _blockdev_setrw (g, device);
2136 private native void _blockdev_setrw (long g, String device)
2137 throws LibGuestFSException;
2140 * is block device set to read-only
2142 * Returns a boolean indicating if the block device is
2143 * read-only (true if read-only, false if not).
2145 * This uses the blockdev(8) command.
2147 * @throws LibGuestFSException
2149 public boolean blockdev_getro (String device)
2150 throws LibGuestFSException
2153 throw new LibGuestFSException ("blockdev_getro: handle is closed");
2154 return _blockdev_getro (g, device);
2156 private native boolean _blockdev_getro (long g, String device)
2157 throws LibGuestFSException;
2160 * get sectorsize of block device
2162 * This returns the size of sectors on a block device.
2163 * Usually 512, but can be larger for modern devices.
2165 * (Note, this is not the size in sectors, use
2166 * "g.blockdev_getsz" for that).
2168 * This uses the blockdev(8) command.
2170 * @throws LibGuestFSException
2172 public int blockdev_getss (String device)
2173 throws LibGuestFSException
2176 throw new LibGuestFSException ("blockdev_getss: handle is closed");
2177 return _blockdev_getss (g, device);
2179 private native int _blockdev_getss (long g, String device)
2180 throws LibGuestFSException;
2183 * get blocksize of block device
2185 * This returns the block size of a device.
2187 * (Note this is different from both *size in blocks* and
2188 * *filesystem block size*).
2190 * This uses the blockdev(8) command.
2192 * @throws LibGuestFSException
2194 public int blockdev_getbsz (String device)
2195 throws LibGuestFSException
2198 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
2199 return _blockdev_getbsz (g, device);
2201 private native int _blockdev_getbsz (long g, String device)
2202 throws LibGuestFSException;
2205 * set blocksize of block device
2207 * This sets the block size of a device.
2209 * (Note this is different from both *size in blocks* and
2210 * *filesystem block size*).
2212 * This uses the blockdev(8) command.
2214 * @throws LibGuestFSException
2216 public void blockdev_setbsz (String device, int blocksize)
2217 throws LibGuestFSException
2220 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
2221 _blockdev_setbsz (g, device, blocksize);
2223 private native void _blockdev_setbsz (long g, String device, int blocksize)
2224 throws LibGuestFSException;
2227 * get total size of device in 512-byte sectors
2229 * This returns the size of the device in units of 512-byte
2230 * sectors (even if the sectorsize isn't 512 bytes ...
2233 * See also "g.blockdev_getss" for the real sector size of
2234 * the device, and "g.blockdev_getsize64" for the more
2235 * useful *size in bytes*.
2237 * This uses the blockdev(8) command.
2239 * @throws LibGuestFSException
2241 public long blockdev_getsz (String device)
2242 throws LibGuestFSException
2245 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
2246 return _blockdev_getsz (g, device);
2248 private native long _blockdev_getsz (long g, String device)
2249 throws LibGuestFSException;
2252 * get total size of device in bytes
2254 * This returns the size of the device in bytes.
2256 * See also "g.blockdev_getsz".
2258 * This uses the blockdev(8) command.
2260 * @throws LibGuestFSException
2262 public long blockdev_getsize64 (String device)
2263 throws LibGuestFSException
2266 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2267 return _blockdev_getsize64 (g, device);
2269 private native long _blockdev_getsize64 (long g, String device)
2270 throws LibGuestFSException;
2273 * flush device buffers
2275 * This tells the kernel to flush internal buffers
2276 * associated with "device".
2278 * This uses the blockdev(8) command.
2280 * @throws LibGuestFSException
2282 public void blockdev_flushbufs (String device)
2283 throws LibGuestFSException
2286 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2287 _blockdev_flushbufs (g, device);
2289 private native void _blockdev_flushbufs (long g, String device)
2290 throws LibGuestFSException;
2293 * reread partition table
2295 * Reread the partition table on "device".
2297 * This uses the blockdev(8) command.
2299 * @throws LibGuestFSException
2301 public void blockdev_rereadpt (String device)
2302 throws LibGuestFSException
2305 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2306 _blockdev_rereadpt (g, device);
2308 private native void _blockdev_rereadpt (long g, String device)
2309 throws LibGuestFSException;
2312 * upload a file from the local machine
2314 * Upload local file "filename" to "remotefilename" on the
2317 * "filename" can also be a named pipe.
2319 * See also "g.download".
2321 * @throws LibGuestFSException
2323 public void upload (String filename, String remotefilename)
2324 throws LibGuestFSException
2327 throw new LibGuestFSException ("upload: handle is closed");
2328 _upload (g, filename, remotefilename);
2330 private native void _upload (long g, String filename, String remotefilename)
2331 throws LibGuestFSException;
2334 * download a file to the local machine
2336 * Download file "remotefilename" and save it as "filename"
2337 * on the local machine.
2339 * "filename" can also be a named pipe.
2341 * See also "g.upload", "g.cat".
2343 * @throws LibGuestFSException
2345 public void download (String remotefilename, String filename)
2346 throws LibGuestFSException
2349 throw new LibGuestFSException ("download: handle is closed");
2350 _download (g, remotefilename, filename);
2352 private native void _download (long g, String remotefilename, String filename)
2353 throws LibGuestFSException;
2356 * compute MD5, SHAx or CRC checksum of file
2358 * This call computes the MD5, SHAx or CRC checksum of the
2359 * file named "path".
2361 * The type of checksum to compute is given by the
2362 * "csumtype" parameter which must have one of the
2366 * Compute the cyclic redundancy check (CRC) specified
2367 * by POSIX for the "cksum" command.
2370 * Compute the MD5 hash (using the "md5sum" program).
2373 * Compute the SHA1 hash (using the "sha1sum" program).
2376 * Compute the SHA224 hash (using the "sha224sum"
2380 * Compute the SHA256 hash (using the "sha256sum"
2384 * Compute the SHA384 hash (using the "sha384sum"
2388 * Compute the SHA512 hash (using the "sha512sum"
2391 * The checksum is returned as a printable string.
2393 * @throws LibGuestFSException
2395 public String checksum (String csumtype, String path)
2396 throws LibGuestFSException
2399 throw new LibGuestFSException ("checksum: handle is closed");
2400 return _checksum (g, csumtype, path);
2402 private native String _checksum (long g, String csumtype, String path)
2403 throws LibGuestFSException;
2406 * unpack tarfile to directory
2408 * This command uploads and unpacks local file "tarfile"
2409 * (an *uncompressed* tar file) into "directory".
2411 * To upload a compressed tarball, use "g.tgz_in".
2413 * @throws LibGuestFSException
2415 public void tar_in (String tarfile, String directory)
2416 throws LibGuestFSException
2419 throw new LibGuestFSException ("tar_in: handle is closed");
2420 _tar_in (g, tarfile, directory);
2422 private native void _tar_in (long g, String tarfile, String directory)
2423 throws LibGuestFSException;
2426 * pack directory into tarfile
2428 * This command packs the contents of "directory" and
2429 * downloads it to local file "tarfile".
2431 * To download a compressed tarball, use "g.tgz_out".
2433 * @throws LibGuestFSException
2435 public void tar_out (String directory, String tarfile)
2436 throws LibGuestFSException
2439 throw new LibGuestFSException ("tar_out: handle is closed");
2440 _tar_out (g, directory, tarfile);
2442 private native void _tar_out (long g, String directory, String tarfile)
2443 throws LibGuestFSException;
2446 * unpack compressed tarball to directory
2448 * This command uploads and unpacks local file "tarball" (a
2449 * *gzip compressed* tar file) into "directory".
2451 * To upload an uncompressed tarball, use "g.tar_in".
2453 * @throws LibGuestFSException
2455 public void tgz_in (String tarball, String directory)
2456 throws LibGuestFSException
2459 throw new LibGuestFSException ("tgz_in: handle is closed");
2460 _tgz_in (g, tarball, directory);
2462 private native void _tgz_in (long g, String tarball, String directory)
2463 throws LibGuestFSException;
2466 * pack directory into compressed tarball
2468 * This command packs the contents of "directory" and
2469 * downloads it to local file "tarball".
2471 * To download an uncompressed tarball, use "g.tar_out".
2473 * @throws LibGuestFSException
2475 public void tgz_out (String directory, String tarball)
2476 throws LibGuestFSException
2479 throw new LibGuestFSException ("tgz_out: handle is closed");
2480 _tgz_out (g, directory, tarball);
2482 private native void _tgz_out (long g, String directory, String tarball)
2483 throws LibGuestFSException;
2486 * mount a guest disk, read-only
2488 * This is the same as the "g.mount" command, but it mounts
2489 * the filesystem with the read-only (*-o ro*) flag.
2491 * @throws LibGuestFSException
2493 public void mount_ro (String device, String mountpoint)
2494 throws LibGuestFSException
2497 throw new LibGuestFSException ("mount_ro: handle is closed");
2498 _mount_ro (g, device, mountpoint);
2500 private native void _mount_ro (long g, String device, String mountpoint)
2501 throws LibGuestFSException;
2504 * mount a guest disk with mount options
2506 * This is the same as the "g.mount" command, but it allows
2507 * you to set the mount options as for the mount(8) *-o*
2510 * @throws LibGuestFSException
2512 public void mount_options (String options, String device, String mountpoint)
2513 throws LibGuestFSException
2516 throw new LibGuestFSException ("mount_options: handle is closed");
2517 _mount_options (g, options, device, mountpoint);
2519 private native void _mount_options (long g, String options, String device, String mountpoint)
2520 throws LibGuestFSException;
2523 * mount a guest disk with mount options and vfstype
2525 * This is the same as the "g.mount" command, but it allows
2526 * you to set both the mount options and the vfstype as for
2527 * the mount(8) *-o* and *-t* flags.
2529 * @throws LibGuestFSException
2531 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2532 throws LibGuestFSException
2535 throw new LibGuestFSException ("mount_vfs: handle is closed");
2536 _mount_vfs (g, options, vfstype, device, mountpoint);
2538 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2539 throws LibGuestFSException;
2542 * debugging and internals
2544 * The "g.debug" command exposes some internals of
2545 * "guestfsd" (the guestfs daemon) that runs inside the
2548 * There is no comprehensive help for this command. You
2549 * have to look at the file "daemon/debug.c" in the
2550 * libguestfs source to find out what you can do.
2552 * @throws LibGuestFSException
2554 public String debug (String subcmd, String[] extraargs)
2555 throws LibGuestFSException
2558 throw new LibGuestFSException ("debug: handle is closed");
2559 return _debug (g, subcmd, extraargs);
2561 private native String _debug (long g, String subcmd, String[] extraargs)
2562 throws LibGuestFSException;
2565 * remove an LVM logical volume
2567 * Remove an LVM logical volume "device", where "device" is
2568 * the path to the LV, such as "/dev/VG/LV".
2570 * You can also remove all LVs in a volume group by
2571 * specifying the VG name, "/dev/VG".
2573 * @throws LibGuestFSException
2575 public void lvremove (String device)
2576 throws LibGuestFSException
2579 throw new LibGuestFSException ("lvremove: handle is closed");
2580 _lvremove (g, device);
2582 private native void _lvremove (long g, String device)
2583 throws LibGuestFSException;
2586 * remove an LVM volume group
2588 * Remove an LVM volume group "vgname", (for example "VG").
2590 * This also forcibly removes all logical volumes in the
2591 * volume group (if any).
2593 * @throws LibGuestFSException
2595 public void vgremove (String vgname)
2596 throws LibGuestFSException
2599 throw new LibGuestFSException ("vgremove: handle is closed");
2600 _vgremove (g, vgname);
2602 private native void _vgremove (long g, String vgname)
2603 throws LibGuestFSException;
2606 * remove an LVM physical volume
2608 * This wipes a physical volume "device" so that LVM will
2609 * no longer recognise it.
2611 * The implementation uses the "pvremove" command which
2612 * refuses to wipe physical volumes that contain any volume
2613 * groups, so you have to remove those first.
2615 * @throws LibGuestFSException
2617 public void pvremove (String device)
2618 throws LibGuestFSException
2621 throw new LibGuestFSException ("pvremove: handle is closed");
2622 _pvremove (g, device);
2624 private native void _pvremove (long g, String device)
2625 throws LibGuestFSException;
2628 * set the ext2/3/4 filesystem label
2630 * This sets the ext2/3/4 filesystem label of the
2631 * filesystem on "device" to "label". Filesystem labels are
2632 * limited to 16 characters.
2634 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2635 * return the existing label on a filesystem.
2637 * @throws LibGuestFSException
2639 public void set_e2label (String device, String label)
2640 throws LibGuestFSException
2643 throw new LibGuestFSException ("set_e2label: handle is closed");
2644 _set_e2label (g, device, label);
2646 private native void _set_e2label (long g, String device, String label)
2647 throws LibGuestFSException;
2650 * get the ext2/3/4 filesystem label
2652 * This returns the ext2/3/4 filesystem label of the
2653 * filesystem on "device".
2655 * @throws LibGuestFSException
2657 public String get_e2label (String device)
2658 throws LibGuestFSException
2661 throw new LibGuestFSException ("get_e2label: handle is closed");
2662 return _get_e2label (g, device);
2664 private native String _get_e2label (long g, String device)
2665 throws LibGuestFSException;
2668 * set the ext2/3/4 filesystem UUID
2670 * This sets the ext2/3/4 filesystem UUID of the filesystem
2671 * on "device" to "uuid". The format of the UUID and
2672 * alternatives such as "clear", "random" and "time" are
2673 * described in the tune2fs(8) manpage.
2675 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2676 * return the existing UUID of a filesystem.
2678 * @throws LibGuestFSException
2680 public void set_e2uuid (String device, String uuid)
2681 throws LibGuestFSException
2684 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2685 _set_e2uuid (g, device, uuid);
2687 private native void _set_e2uuid (long g, String device, String uuid)
2688 throws LibGuestFSException;
2691 * get the ext2/3/4 filesystem UUID
2693 * This returns the ext2/3/4 filesystem UUID of the
2694 * filesystem on "device".
2696 * @throws LibGuestFSException
2698 public String get_e2uuid (String device)
2699 throws LibGuestFSException
2702 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2703 return _get_e2uuid (g, device);
2705 private native String _get_e2uuid (long g, String device)
2706 throws LibGuestFSException;
2709 * run the filesystem checker
2711 * This runs the filesystem checker (fsck) on "device"
2712 * which should have filesystem type "fstype".
2714 * The returned integer is the status. See fsck(8) for the
2715 * list of status codes from "fsck".
2719 * * Multiple status codes can be summed together.
2721 * * A non-zero return code can mean "success", for
2722 * example if errors have been corrected on the
2725 * * Checking or repairing NTFS volumes is not supported
2728 * This command is entirely equivalent to running "fsck -a
2729 * -t fstype device".
2731 * @throws LibGuestFSException
2733 public int fsck (String fstype, String device)
2734 throws LibGuestFSException
2737 throw new LibGuestFSException ("fsck: handle is closed");
2738 return _fsck (g, fstype, device);
2740 private native int _fsck (long g, String fstype, String device)
2741 throws LibGuestFSException;
2744 * write zeroes to the device
2746 * This command writes zeroes over the first few blocks of
2749 * How many blocks are zeroed isn't specified (but it's
2750 * *not* enough to securely wipe the device). It should be
2751 * sufficient to remove any partition tables, filesystem
2752 * superblocks and so on.
2754 * @throws LibGuestFSException
2756 public void zero (String device)
2757 throws LibGuestFSException
2760 throw new LibGuestFSException ("zero: handle is closed");
2763 private native void _zero (long g, String device)
2764 throws LibGuestFSException;
2769 * This command installs GRUB (the Grand Unified
2770 * Bootloader) on "device", with the root directory being
2773 * @throws LibGuestFSException
2775 public void grub_install (String root, String device)
2776 throws LibGuestFSException
2779 throw new LibGuestFSException ("grub_install: handle is closed");
2780 _grub_install (g, root, device);
2782 private native void _grub_install (long g, String root, String device)
2783 throws LibGuestFSException;
2788 * This copies a file from "src" to "dest" where "dest" is
2789 * either a destination filename or destination directory.
2791 * @throws LibGuestFSException
2793 public void cp (String src, String dest)
2794 throws LibGuestFSException
2797 throw new LibGuestFSException ("cp: handle is closed");
2800 private native void _cp (long g, String src, String dest)
2801 throws LibGuestFSException;
2804 * copy a file or directory recursively
2806 * This copies a file or directory from "src" to "dest"
2807 * recursively using the "cp -a" command.
2809 * @throws LibGuestFSException
2811 public void cp_a (String src, String dest)
2812 throws LibGuestFSException
2815 throw new LibGuestFSException ("cp_a: handle is closed");
2816 _cp_a (g, src, dest);
2818 private native void _cp_a (long g, String src, String dest)
2819 throws LibGuestFSException;
2824 * This moves a file from "src" to "dest" where "dest" is
2825 * either a destination filename or destination directory.
2827 * @throws LibGuestFSException
2829 public void mv (String src, String dest)
2830 throws LibGuestFSException
2833 throw new LibGuestFSException ("mv: handle is closed");
2836 private native void _mv (long g, String src, String dest)
2837 throws LibGuestFSException;
2840 * drop kernel page cache, dentries and inodes
2842 * This instructs the guest kernel to drop its page cache,
2843 * and/or dentries and inode caches. The parameter
2844 * "whattodrop" tells the kernel what precisely to drop,
2845 * see <http://linux-mm.org/Drop_Caches>
2847 * Setting "whattodrop" to 3 should drop everything.
2849 * This automatically calls sync(2) before the operation,
2850 * so that the maximum guest memory is freed.
2852 * @throws LibGuestFSException
2854 public void drop_caches (int whattodrop)
2855 throws LibGuestFSException
2858 throw new LibGuestFSException ("drop_caches: handle is closed");
2859 _drop_caches (g, whattodrop);
2861 private native void _drop_caches (long g, int whattodrop)
2862 throws LibGuestFSException;
2865 * return kernel messages
2867 * This returns the kernel messages ("dmesg" output) from
2868 * the guest kernel. This is sometimes useful for extended
2869 * debugging of problems.
2871 * Another way to get the same information is to enable
2872 * verbose messages with "g.set_verbose" or by setting the
2873 * environment variable "LIBGUESTFS_DEBUG=1" before running
2876 * @throws LibGuestFSException
2878 public String dmesg ()
2879 throws LibGuestFSException
2882 throw new LibGuestFSException ("dmesg: handle is closed");
2885 private native String _dmesg (long g)
2886 throws LibGuestFSException;
2889 * ping the guest daemon
2891 * This is a test probe into the guestfs daemon running
2892 * inside the qemu subprocess. Calling this function checks
2893 * that the daemon responds to the ping message, without
2894 * affecting the daemon or attached block device(s) in any
2897 * @throws LibGuestFSException
2899 public void ping_daemon ()
2900 throws LibGuestFSException
2903 throw new LibGuestFSException ("ping_daemon: handle is closed");
2906 private native void _ping_daemon (long g)
2907 throws LibGuestFSException;
2910 * test if two files have equal contents
2912 * This compares the two files "file1" and "file2" and
2913 * returns true if their content is exactly equal, or false
2916 * The external cmp(1) program is used for the comparison.
2918 * @throws LibGuestFSException
2920 public boolean equal (String file1, String file2)
2921 throws LibGuestFSException
2924 throw new LibGuestFSException ("equal: handle is closed");
2925 return _equal (g, file1, file2);
2927 private native boolean _equal (long g, String file1, String file2)
2928 throws LibGuestFSException;
2931 * print the printable strings in a file
2933 * This runs the strings(1) command on a file and returns
2934 * the list of printable strings found.
2936 * Because of the message protocol, there is a transfer
2937 * limit of somewhere between 2MB and 4MB. To transfer
2938 * large files you should use FTP.
2940 * @throws LibGuestFSException
2942 public String[] strings (String path)
2943 throws LibGuestFSException
2946 throw new LibGuestFSException ("strings: handle is closed");
2947 return _strings (g, path);
2949 private native String[] _strings (long g, String path)
2950 throws LibGuestFSException;
2953 * print the printable strings in a file
2955 * This is like the "g.strings" command, but allows you to
2956 * specify the encoding.
2958 * See the strings(1) manpage for the full list of
2961 * Commonly useful encodings are "l" (lower case L) which
2962 * will show strings inside Windows/x86 files.
2964 * The returned strings are transcoded to UTF-8.
2966 * Because of the message protocol, there is a transfer
2967 * limit of somewhere between 2MB and 4MB. To transfer
2968 * large files you should use FTP.
2970 * @throws LibGuestFSException
2972 public String[] strings_e (String encoding, String path)
2973 throws LibGuestFSException
2976 throw new LibGuestFSException ("strings_e: handle is closed");
2977 return _strings_e (g, encoding, path);
2979 private native String[] _strings_e (long g, String encoding, String path)
2980 throws LibGuestFSException;
2983 * dump a file in hexadecimal
2985 * This runs "hexdump -C" on the given "path". The result
2986 * is the human-readable, canonical hex dump of the file.
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 hexdump (String path)
2995 throws LibGuestFSException
2998 throw new LibGuestFSException ("hexdump: handle is closed");
2999 return _hexdump (g, path);
3001 private native String _hexdump (long g, String path)
3002 throws LibGuestFSException;
3005 * zero unused inodes and disk blocks on ext2/3 filesystem
3007 * This runs the *zerofree* program on "device". This
3008 * program claims to zero unused inodes and disk blocks on
3009 * an ext2/3 filesystem, thus making it possible to
3010 * compress the filesystem more effectively.
3012 * You should not run this program if the filesystem is
3015 * It is possible that using this program can damage the
3016 * filesystem or data on the filesystem.
3018 * @throws LibGuestFSException
3020 public void zerofree (String device)
3021 throws LibGuestFSException
3024 throw new LibGuestFSException ("zerofree: handle is closed");
3025 _zerofree (g, device);
3027 private native void _zerofree (long g, String device)
3028 throws LibGuestFSException;
3031 * resize an LVM physical volume
3033 * This resizes (expands or shrinks) an existing LVM
3034 * physical volume to match the new size of the underlying
3037 * @throws LibGuestFSException
3039 public void pvresize (String device)
3040 throws LibGuestFSException
3043 throw new LibGuestFSException ("pvresize: handle is closed");
3044 _pvresize (g, device);
3046 private native void _pvresize (long g, String device)
3047 throws LibGuestFSException;
3050 * modify a single partition on a block device
3052 * This runs sfdisk(8) option to modify just the single
3053 * partition "n" (note: "n" counts from 1).
3055 * For other parameters, see "g.sfdisk". You should usually
3056 * pass 0 for the cyls/heads/sectors parameters.
3058 * This command is dangerous. Without careful use you can
3059 * easily destroy all your data.
3061 * @throws LibGuestFSException
3063 public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line)
3064 throws LibGuestFSException
3067 throw new LibGuestFSException ("sfdisk_N: handle is closed");
3068 _sfdisk_N (g, device, n, cyls, heads, sectors, line);
3070 private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line)
3071 throws LibGuestFSException;
3074 * display the partition table
3076 * This displays the partition table on "device", in the
3077 * human-readable output of the sfdisk(8) command. It is
3078 * not intended to be parsed.
3080 * @throws LibGuestFSException
3082 public String sfdisk_l (String device)
3083 throws LibGuestFSException
3086 throw new LibGuestFSException ("sfdisk_l: handle is closed");
3087 return _sfdisk_l (g, device);
3089 private native String _sfdisk_l (long g, String device)
3090 throws LibGuestFSException;
3093 * display the kernel geometry
3095 * This displays the kernel's idea of the geometry of
3098 * The result is in human-readable format, and not designed
3101 * @throws LibGuestFSException
3103 public String sfdisk_kernel_geometry (String device)
3104 throws LibGuestFSException
3107 throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
3108 return _sfdisk_kernel_geometry (g, device);
3110 private native String _sfdisk_kernel_geometry (long g, String device)
3111 throws LibGuestFSException;
3114 * display the disk geometry from the partition table
3116 * This displays the disk geometry of "device" read from
3117 * the partition table. Especially in the case where the
3118 * underlying block device has been resized, this can be
3119 * different from the kernel's idea of the geometry (see
3120 * "g.sfdisk_kernel_geometry").
3122 * The result is in human-readable format, and not designed
3125 * @throws LibGuestFSException
3127 public String sfdisk_disk_geometry (String device)
3128 throws LibGuestFSException
3131 throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
3132 return _sfdisk_disk_geometry (g, device);
3134 private native String _sfdisk_disk_geometry (long g, String device)
3135 throws LibGuestFSException;
3138 * activate or deactivate all volume groups
3140 * This command activates or (if "activate" is false)
3141 * deactivates all logical volumes in all volume groups. If
3142 * activated, then they are made known to the kernel, ie.
3143 * they appear as "/dev/mapper" devices. If deactivated,
3144 * then those devices disappear.
3146 * This command is the same as running "vgchange -a y|n"
3148 * @throws LibGuestFSException
3150 public void vg_activate_all (boolean activate)
3151 throws LibGuestFSException
3154 throw new LibGuestFSException ("vg_activate_all: handle is closed");
3155 _vg_activate_all (g, activate);
3157 private native void _vg_activate_all (long g, boolean activate)
3158 throws LibGuestFSException;
3161 * activate or deactivate some volume groups
3163 * This command activates or (if "activate" is false)
3164 * deactivates all logical volumes in the listed volume
3165 * groups "volgroups". If activated, then they are made
3166 * known to the kernel, ie. they appear as "/dev/mapper"
3167 * devices. If deactivated, then those devices disappear.
3169 * This command is the same as running "vgchange -a y|n
3172 * Note that if "volgroups" is an empty list then all
3173 * volume groups are activated or deactivated.
3175 * @throws LibGuestFSException
3177 public void vg_activate (boolean activate, String[] volgroups)
3178 throws LibGuestFSException
3181 throw new LibGuestFSException ("vg_activate: handle is closed");
3182 _vg_activate (g, activate, volgroups);
3184 private native void _vg_activate (long g, boolean activate, String[] volgroups)
3185 throws LibGuestFSException;
3188 * resize an LVM logical volume
3190 * This resizes (expands or shrinks) an existing LVM
3191 * logical volume to "mbytes". When reducing, data in the
3192 * reduced part is lost.
3194 * @throws LibGuestFSException
3196 public void lvresize (String device, int mbytes)
3197 throws LibGuestFSException
3200 throw new LibGuestFSException ("lvresize: handle is closed");
3201 _lvresize (g, device, mbytes);
3203 private native void _lvresize (long g, String device, int mbytes)
3204 throws LibGuestFSException;
3207 * resize an ext2/ext3 filesystem
3209 * This resizes an ext2 or ext3 filesystem to match the
3210 * size of the underlying device.
3212 * *Note:* It is sometimes required that you run
3213 * "g.e2fsck_f" on the "device" before calling this
3214 * command. For unknown reasons "resize2fs" sometimes gives
3215 * an error about this and sometimes not. In any case, it
3216 * is always safe to call "g.e2fsck_f" before calling this
3219 * @throws LibGuestFSException
3221 public void resize2fs (String device)
3222 throws LibGuestFSException
3225 throw new LibGuestFSException ("resize2fs: handle is closed");
3226 _resize2fs (g, device);
3228 private native void _resize2fs (long g, String device)
3229 throws LibGuestFSException;
3232 * find all files and directories
3234 * This command lists out all files and directories,
3235 * recursively, starting at "directory". It is essentially
3236 * equivalent to running the shell command "find directory
3237 * -print" but some post-processing happens on the output,
3240 * This returns a list of strings *without any prefix*.
3241 * Thus if the directory structure was:
3247 * then the returned list from "g.find" "/tmp" would be 4
3255 * If "directory" is not a directory, then this command
3258 * The returned list is sorted.
3260 * @throws LibGuestFSException
3262 public String[] find (String directory)
3263 throws LibGuestFSException
3266 throw new LibGuestFSException ("find: handle is closed");
3267 return _find (g, directory);
3269 private native String[] _find (long g, String directory)
3270 throws LibGuestFSException;
3273 * check an ext2/ext3 filesystem
3275 * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
3276 * filesystem checker on "device", noninteractively ("-p"),
3277 * even if the filesystem appears to be clean ("-f").
3279 * This command is only needed because of "g.resize2fs"
3280 * (q.v.). Normally you should use "g.fsck".
3282 * @throws LibGuestFSException
3284 public void e2fsck_f (String device)
3285 throws LibGuestFSException
3288 throw new LibGuestFSException ("e2fsck_f: handle is closed");
3289 _e2fsck_f (g, device);
3291 private native void _e2fsck_f (long g, String device)
3292 throws LibGuestFSException;