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 * 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).
2003 * The return value is anything printed to *stdout* by the
2006 * If the command returns a non-zero exit status, then this
2007 * function returns an error message. The error message
2008 * string is the content of *stderr* from the command.
2010 * The $PATH environment variable will contain at least
2011 * "/usr/bin" and "/bin". If you require a program from
2012 * another location, you should provide the full path in
2013 * the first parameter.
2015 * Shared libraries and data files required by the program
2016 * must be available on filesystems which are mounted in
2017 * the correct places. It is the caller's responsibility to
2018 * ensure all filesystems that are needed are mounted at
2019 * the right locations.
2021 * Because of the message protocol, there is a transfer
2022 * limit of somewhere between 2MB and 4MB. To transfer
2023 * large files you should use FTP.
2025 * @throws LibGuestFSException
2027 public String command (String[] arguments)
2028 throws LibGuestFSException
2031 throw new LibGuestFSException ("command: handle is closed");
2032 return _command (g, arguments);
2034 private native String _command (long g, String[] arguments)
2035 throws LibGuestFSException;
2038 * run a command, returning lines
2040 * This is the same as "g.command", but splits the result
2041 * into a list of lines.
2043 * Because of the message protocol, there is a transfer
2044 * limit of somewhere between 2MB and 4MB. To transfer
2045 * large files you should use FTP.
2047 * @throws LibGuestFSException
2049 public String[] command_lines (String[] arguments)
2050 throws LibGuestFSException
2053 throw new LibGuestFSException ("command_lines: handle is closed");
2054 return _command_lines (g, arguments);
2056 private native String[] _command_lines (long g, String[] arguments)
2057 throws LibGuestFSException;
2060 * get file information
2062 * Returns file information for the given "path".
2064 * This is the same as the stat(2) system call.
2066 * @throws LibGuestFSException
2068 public Stat stat (String path)
2069 throws LibGuestFSException
2072 throw new LibGuestFSException ("stat: handle is closed");
2073 return _stat (g, path);
2075 private native Stat _stat (long g, String path)
2076 throws LibGuestFSException;
2079 * get file information for a symbolic link
2081 * Returns file information for the given "path".
2083 * This is the same as "g.stat" except that if "path" is a
2084 * symbolic link, then the link is stat-ed, not the file it
2087 * This is the same as the lstat(2) system call.
2089 * @throws LibGuestFSException
2091 public Stat lstat (String path)
2092 throws LibGuestFSException
2095 throw new LibGuestFSException ("lstat: handle is closed");
2096 return _lstat (g, path);
2098 private native Stat _lstat (long g, String path)
2099 throws LibGuestFSException;
2102 * get file system statistics
2104 * Returns file system statistics for any mounted file
2105 * system. "path" should be a file or directory in the
2106 * mounted file system (typically it is the mount point
2107 * itself, but it doesn't need to be).
2109 * This is the same as the statvfs(2) system call.
2111 * @throws LibGuestFSException
2113 public StatVFS statvfs (String path)
2114 throws LibGuestFSException
2117 throw new LibGuestFSException ("statvfs: handle is closed");
2118 return _statvfs (g, path);
2120 private native StatVFS _statvfs (long g, String path)
2121 throws LibGuestFSException;
2124 * get ext2/ext3/ext4 superblock details
2126 * This returns the contents of the ext2, ext3 or ext4
2127 * filesystem superblock on "device".
2129 * It is the same as running "tune2fs -l device". See
2130 * tune2fs(8) manpage for more details. The list of fields
2131 * returned isn't clearly defined, and depends on both the
2132 * version of "tune2fs" that libguestfs was built against,
2133 * and the filesystem itself.
2135 * @throws LibGuestFSException
2137 public HashMap<String,String> tune2fs_l (String device)
2138 throws LibGuestFSException
2141 throw new LibGuestFSException ("tune2fs_l: handle is closed");
2142 return _tune2fs_l (g, device);
2144 private native HashMap<String,String> _tune2fs_l (long g, String device)
2145 throws LibGuestFSException;
2148 * set block device to read-only
2150 * Sets the block device named "device" to read-only.
2152 * This uses the blockdev(8) command.
2154 * @throws LibGuestFSException
2156 public void blockdev_setro (String device)
2157 throws LibGuestFSException
2160 throw new LibGuestFSException ("blockdev_setro: handle is closed");
2161 _blockdev_setro (g, device);
2163 private native void _blockdev_setro (long g, String device)
2164 throws LibGuestFSException;
2167 * set block device to read-write
2169 * Sets the block device named "device" to read-write.
2171 * This uses the blockdev(8) command.
2173 * @throws LibGuestFSException
2175 public void blockdev_setrw (String device)
2176 throws LibGuestFSException
2179 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
2180 _blockdev_setrw (g, device);
2182 private native void _blockdev_setrw (long g, String device)
2183 throws LibGuestFSException;
2186 * is block device set to read-only
2188 * Returns a boolean indicating if the block device is
2189 * read-only (true if read-only, false if not).
2191 * This uses the blockdev(8) command.
2193 * @throws LibGuestFSException
2195 public boolean blockdev_getro (String device)
2196 throws LibGuestFSException
2199 throw new LibGuestFSException ("blockdev_getro: handle is closed");
2200 return _blockdev_getro (g, device);
2202 private native boolean _blockdev_getro (long g, String device)
2203 throws LibGuestFSException;
2206 * get sectorsize of block device
2208 * This returns the size of sectors on a block device.
2209 * Usually 512, but can be larger for modern devices.
2211 * (Note, this is not the size in sectors, use
2212 * "g.blockdev_getsz" for that).
2214 * This uses the blockdev(8) command.
2216 * @throws LibGuestFSException
2218 public int blockdev_getss (String device)
2219 throws LibGuestFSException
2222 throw new LibGuestFSException ("blockdev_getss: handle is closed");
2223 return _blockdev_getss (g, device);
2225 private native int _blockdev_getss (long g, String device)
2226 throws LibGuestFSException;
2229 * get blocksize of block device
2231 * This returns the block size of a device.
2233 * (Note this is different from both *size in blocks* and
2234 * *filesystem block size*).
2236 * This uses the blockdev(8) command.
2238 * @throws LibGuestFSException
2240 public int blockdev_getbsz (String device)
2241 throws LibGuestFSException
2244 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
2245 return _blockdev_getbsz (g, device);
2247 private native int _blockdev_getbsz (long g, String device)
2248 throws LibGuestFSException;
2251 * set blocksize of block device
2253 * This sets the block size of a device.
2255 * (Note this is different from both *size in blocks* and
2256 * *filesystem block size*).
2258 * This uses the blockdev(8) command.
2260 * @throws LibGuestFSException
2262 public void blockdev_setbsz (String device, int blocksize)
2263 throws LibGuestFSException
2266 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
2267 _blockdev_setbsz (g, device, blocksize);
2269 private native void _blockdev_setbsz (long g, String device, int blocksize)
2270 throws LibGuestFSException;
2273 * get total size of device in 512-byte sectors
2275 * This returns the size of the device in units of 512-byte
2276 * sectors (even if the sectorsize isn't 512 bytes ...
2279 * See also "g.blockdev_getss" for the real sector size of
2280 * the device, and "g.blockdev_getsize64" for the more
2281 * useful *size in bytes*.
2283 * This uses the blockdev(8) command.
2285 * @throws LibGuestFSException
2287 public long blockdev_getsz (String device)
2288 throws LibGuestFSException
2291 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
2292 return _blockdev_getsz (g, device);
2294 private native long _blockdev_getsz (long g, String device)
2295 throws LibGuestFSException;
2298 * get total size of device in bytes
2300 * This returns the size of the device in bytes.
2302 * See also "g.blockdev_getsz".
2304 * This uses the blockdev(8) command.
2306 * @throws LibGuestFSException
2308 public long blockdev_getsize64 (String device)
2309 throws LibGuestFSException
2312 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2313 return _blockdev_getsize64 (g, device);
2315 private native long _blockdev_getsize64 (long g, String device)
2316 throws LibGuestFSException;
2319 * flush device buffers
2321 * This tells the kernel to flush internal buffers
2322 * associated with "device".
2324 * This uses the blockdev(8) command.
2326 * @throws LibGuestFSException
2328 public void blockdev_flushbufs (String device)
2329 throws LibGuestFSException
2332 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2333 _blockdev_flushbufs (g, device);
2335 private native void _blockdev_flushbufs (long g, String device)
2336 throws LibGuestFSException;
2339 * reread partition table
2341 * Reread the partition table on "device".
2343 * This uses the blockdev(8) command.
2345 * @throws LibGuestFSException
2347 public void blockdev_rereadpt (String device)
2348 throws LibGuestFSException
2351 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2352 _blockdev_rereadpt (g, device);
2354 private native void _blockdev_rereadpt (long g, String device)
2355 throws LibGuestFSException;
2358 * upload a file from the local machine
2360 * Upload local file "filename" to "remotefilename" on the
2363 * "filename" can also be a named pipe.
2365 * See also "g.download".
2367 * @throws LibGuestFSException
2369 public void upload (String filename, String remotefilename)
2370 throws LibGuestFSException
2373 throw new LibGuestFSException ("upload: handle is closed");
2374 _upload (g, filename, remotefilename);
2376 private native void _upload (long g, String filename, String remotefilename)
2377 throws LibGuestFSException;
2380 * download a file to the local machine
2382 * Download file "remotefilename" and save it as "filename"
2383 * on the local machine.
2385 * "filename" can also be a named pipe.
2387 * See also "g.upload", "g.cat".
2389 * @throws LibGuestFSException
2391 public void download (String remotefilename, String filename)
2392 throws LibGuestFSException
2395 throw new LibGuestFSException ("download: handle is closed");
2396 _download (g, remotefilename, filename);
2398 private native void _download (long g, String remotefilename, String filename)
2399 throws LibGuestFSException;
2402 * compute MD5, SHAx or CRC checksum of file
2404 * This call computes the MD5, SHAx or CRC checksum of the
2405 * file named "path".
2407 * The type of checksum to compute is given by the
2408 * "csumtype" parameter which must have one of the
2412 * Compute the cyclic redundancy check (CRC) specified
2413 * by POSIX for the "cksum" command.
2416 * Compute the MD5 hash (using the "md5sum" program).
2419 * Compute the SHA1 hash (using the "sha1sum" program).
2422 * Compute the SHA224 hash (using the "sha224sum"
2426 * Compute the SHA256 hash (using the "sha256sum"
2430 * Compute the SHA384 hash (using the "sha384sum"
2434 * Compute the SHA512 hash (using the "sha512sum"
2437 * The checksum is returned as a printable string.
2439 * @throws LibGuestFSException
2441 public String checksum (String csumtype, String path)
2442 throws LibGuestFSException
2445 throw new LibGuestFSException ("checksum: handle is closed");
2446 return _checksum (g, csumtype, path);
2448 private native String _checksum (long g, String csumtype, String path)
2449 throws LibGuestFSException;
2452 * unpack tarfile to directory
2454 * This command uploads and unpacks local file "tarfile"
2455 * (an *uncompressed* tar file) into "directory".
2457 * To upload a compressed tarball, use "g.tgz_in".
2459 * @throws LibGuestFSException
2461 public void tar_in (String tarfile, String directory)
2462 throws LibGuestFSException
2465 throw new LibGuestFSException ("tar_in: handle is closed");
2466 _tar_in (g, tarfile, directory);
2468 private native void _tar_in (long g, String tarfile, String directory)
2469 throws LibGuestFSException;
2472 * pack directory into tarfile
2474 * This command packs the contents of "directory" and
2475 * downloads it to local file "tarfile".
2477 * To download a compressed tarball, use "g.tgz_out".
2479 * @throws LibGuestFSException
2481 public void tar_out (String directory, String tarfile)
2482 throws LibGuestFSException
2485 throw new LibGuestFSException ("tar_out: handle is closed");
2486 _tar_out (g, directory, tarfile);
2488 private native void _tar_out (long g, String directory, String tarfile)
2489 throws LibGuestFSException;
2492 * unpack compressed tarball to directory
2494 * This command uploads and unpacks local file "tarball" (a
2495 * *gzip compressed* tar file) into "directory".
2497 * To upload an uncompressed tarball, use "g.tar_in".
2499 * @throws LibGuestFSException
2501 public void tgz_in (String tarball, String directory)
2502 throws LibGuestFSException
2505 throw new LibGuestFSException ("tgz_in: handle is closed");
2506 _tgz_in (g, tarball, directory);
2508 private native void _tgz_in (long g, String tarball, String directory)
2509 throws LibGuestFSException;
2512 * pack directory into compressed tarball
2514 * This command packs the contents of "directory" and
2515 * downloads it to local file "tarball".
2517 * To download an uncompressed tarball, use "g.tar_out".
2519 * @throws LibGuestFSException
2521 public void tgz_out (String directory, String tarball)
2522 throws LibGuestFSException
2525 throw new LibGuestFSException ("tgz_out: handle is closed");
2526 _tgz_out (g, directory, tarball);
2528 private native void _tgz_out (long g, String directory, String tarball)
2529 throws LibGuestFSException;
2532 * mount a guest disk, read-only
2534 * This is the same as the "g.mount" command, but it mounts
2535 * the filesystem with the read-only (*-o ro*) flag.
2537 * @throws LibGuestFSException
2539 public void mount_ro (String device, String mountpoint)
2540 throws LibGuestFSException
2543 throw new LibGuestFSException ("mount_ro: handle is closed");
2544 _mount_ro (g, device, mountpoint);
2546 private native void _mount_ro (long g, String device, String mountpoint)
2547 throws LibGuestFSException;
2550 * mount a guest disk with mount options
2552 * This is the same as the "g.mount" command, but it allows
2553 * you to set the mount options as for the mount(8) *-o*
2556 * @throws LibGuestFSException
2558 public void mount_options (String options, String device, String mountpoint)
2559 throws LibGuestFSException
2562 throw new LibGuestFSException ("mount_options: handle is closed");
2563 _mount_options (g, options, device, mountpoint);
2565 private native void _mount_options (long g, String options, String device, String mountpoint)
2566 throws LibGuestFSException;
2569 * mount a guest disk with mount options and vfstype
2571 * This is the same as the "g.mount" command, but it allows
2572 * you to set both the mount options and the vfstype as for
2573 * the mount(8) *-o* and *-t* flags.
2575 * @throws LibGuestFSException
2577 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2578 throws LibGuestFSException
2581 throw new LibGuestFSException ("mount_vfs: handle is closed");
2582 _mount_vfs (g, options, vfstype, device, mountpoint);
2584 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2585 throws LibGuestFSException;
2588 * debugging and internals
2590 * The "g.debug" command exposes some internals of
2591 * "guestfsd" (the guestfs daemon) that runs inside the
2594 * There is no comprehensive help for this command. You
2595 * have to look at the file "daemon/debug.c" in the
2596 * libguestfs source to find out what you can do.
2598 * @throws LibGuestFSException
2600 public String debug (String subcmd, String[] extraargs)
2601 throws LibGuestFSException
2604 throw new LibGuestFSException ("debug: handle is closed");
2605 return _debug (g, subcmd, extraargs);
2607 private native String _debug (long g, String subcmd, String[] extraargs)
2608 throws LibGuestFSException;
2611 * remove an LVM logical volume
2613 * Remove an LVM logical volume "device", where "device" is
2614 * the path to the LV, such as "/dev/VG/LV".
2616 * You can also remove all LVs in a volume group by
2617 * specifying the VG name, "/dev/VG".
2619 * @throws LibGuestFSException
2621 public void lvremove (String device)
2622 throws LibGuestFSException
2625 throw new LibGuestFSException ("lvremove: handle is closed");
2626 _lvremove (g, device);
2628 private native void _lvremove (long g, String device)
2629 throws LibGuestFSException;
2632 * remove an LVM volume group
2634 * Remove an LVM volume group "vgname", (for example "VG").
2636 * This also forcibly removes all logical volumes in the
2637 * volume group (if any).
2639 * @throws LibGuestFSException
2641 public void vgremove (String vgname)
2642 throws LibGuestFSException
2645 throw new LibGuestFSException ("vgremove: handle is closed");
2646 _vgremove (g, vgname);
2648 private native void _vgremove (long g, String vgname)
2649 throws LibGuestFSException;
2652 * remove an LVM physical volume
2654 * This wipes a physical volume "device" so that LVM will
2655 * no longer recognise it.
2657 * The implementation uses the "pvremove" command which
2658 * refuses to wipe physical volumes that contain any volume
2659 * groups, so you have to remove those first.
2661 * @throws LibGuestFSException
2663 public void pvremove (String device)
2664 throws LibGuestFSException
2667 throw new LibGuestFSException ("pvremove: handle is closed");
2668 _pvremove (g, device);
2670 private native void _pvremove (long g, String device)
2671 throws LibGuestFSException;
2674 * set the ext2/3/4 filesystem label
2676 * This sets the ext2/3/4 filesystem label of the
2677 * filesystem on "device" to "label". Filesystem labels are
2678 * limited to 16 characters.
2680 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2681 * return the existing label on a filesystem.
2683 * @throws LibGuestFSException
2685 public void set_e2label (String device, String label)
2686 throws LibGuestFSException
2689 throw new LibGuestFSException ("set_e2label: handle is closed");
2690 _set_e2label (g, device, label);
2692 private native void _set_e2label (long g, String device, String label)
2693 throws LibGuestFSException;
2696 * get the ext2/3/4 filesystem label
2698 * This returns the ext2/3/4 filesystem label of the
2699 * filesystem on "device".
2701 * @throws LibGuestFSException
2703 public String get_e2label (String device)
2704 throws LibGuestFSException
2707 throw new LibGuestFSException ("get_e2label: handle is closed");
2708 return _get_e2label (g, device);
2710 private native String _get_e2label (long g, String device)
2711 throws LibGuestFSException;
2714 * set the ext2/3/4 filesystem UUID
2716 * This sets the ext2/3/4 filesystem UUID of the filesystem
2717 * on "device" to "uuid". The format of the UUID and
2718 * alternatives such as "clear", "random" and "time" are
2719 * described in the tune2fs(8) manpage.
2721 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2722 * return the existing UUID of a filesystem.
2724 * @throws LibGuestFSException
2726 public void set_e2uuid (String device, String uuid)
2727 throws LibGuestFSException
2730 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2731 _set_e2uuid (g, device, uuid);
2733 private native void _set_e2uuid (long g, String device, String uuid)
2734 throws LibGuestFSException;
2737 * get the ext2/3/4 filesystem UUID
2739 * This returns the ext2/3/4 filesystem UUID of the
2740 * filesystem on "device".
2742 * @throws LibGuestFSException
2744 public String get_e2uuid (String device)
2745 throws LibGuestFSException
2748 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2749 return _get_e2uuid (g, device);
2751 private native String _get_e2uuid (long g, String device)
2752 throws LibGuestFSException;
2755 * run the filesystem checker
2757 * This runs the filesystem checker (fsck) on "device"
2758 * which should have filesystem type "fstype".
2760 * The returned integer is the status. See fsck(8) for the
2761 * list of status codes from "fsck".
2765 * * Multiple status codes can be summed together.
2767 * * A non-zero return code can mean "success", for
2768 * example if errors have been corrected on the
2771 * * Checking or repairing NTFS volumes is not supported
2774 * This command is entirely equivalent to running "fsck -a
2775 * -t fstype device".
2777 * @throws LibGuestFSException
2779 public int fsck (String fstype, String device)
2780 throws LibGuestFSException
2783 throw new LibGuestFSException ("fsck: handle is closed");
2784 return _fsck (g, fstype, device);
2786 private native int _fsck (long g, String fstype, String device)
2787 throws LibGuestFSException;
2790 * write zeroes to the device
2792 * This command writes zeroes over the first few blocks of
2795 * How many blocks are zeroed isn't specified (but it's
2796 * *not* enough to securely wipe the device). It should be
2797 * sufficient to remove any partition tables, filesystem
2798 * superblocks and so on.
2800 * @throws LibGuestFSException
2802 public void zero (String device)
2803 throws LibGuestFSException
2806 throw new LibGuestFSException ("zero: handle is closed");
2809 private native void _zero (long g, String device)
2810 throws LibGuestFSException;
2815 * This command installs GRUB (the Grand Unified
2816 * Bootloader) on "device", with the root directory being
2819 * @throws LibGuestFSException
2821 public void grub_install (String root, String device)
2822 throws LibGuestFSException
2825 throw new LibGuestFSException ("grub_install: handle is closed");
2826 _grub_install (g, root, device);
2828 private native void _grub_install (long g, String root, String device)
2829 throws LibGuestFSException;
2834 * This copies a file from "src" to "dest" where "dest" is
2835 * either a destination filename or destination directory.
2837 * @throws LibGuestFSException
2839 public void cp (String src, String dest)
2840 throws LibGuestFSException
2843 throw new LibGuestFSException ("cp: handle is closed");
2846 private native void _cp (long g, String src, String dest)
2847 throws LibGuestFSException;
2850 * copy a file or directory recursively
2852 * This copies a file or directory from "src" to "dest"
2853 * recursively using the "cp -a" command.
2855 * @throws LibGuestFSException
2857 public void cp_a (String src, String dest)
2858 throws LibGuestFSException
2861 throw new LibGuestFSException ("cp_a: handle is closed");
2862 _cp_a (g, src, dest);
2864 private native void _cp_a (long g, String src, String dest)
2865 throws LibGuestFSException;
2870 * This moves a file from "src" to "dest" where "dest" is
2871 * either a destination filename or destination directory.
2873 * @throws LibGuestFSException
2875 public void mv (String src, String dest)
2876 throws LibGuestFSException
2879 throw new LibGuestFSException ("mv: handle is closed");
2882 private native void _mv (long g, String src, String dest)
2883 throws LibGuestFSException;
2886 * drop kernel page cache, dentries and inodes
2888 * This instructs the guest kernel to drop its page cache,
2889 * and/or dentries and inode caches. The parameter
2890 * "whattodrop" tells the kernel what precisely to drop,
2891 * see <http://linux-mm.org/Drop_Caches>
2893 * Setting "whattodrop" to 3 should drop everything.
2895 * This automatically calls sync(2) before the operation,
2896 * so that the maximum guest memory is freed.
2898 * @throws LibGuestFSException
2900 public void drop_caches (int whattodrop)
2901 throws LibGuestFSException
2904 throw new LibGuestFSException ("drop_caches: handle is closed");
2905 _drop_caches (g, whattodrop);
2907 private native void _drop_caches (long g, int whattodrop)
2908 throws LibGuestFSException;
2911 * return kernel messages
2913 * This returns the kernel messages ("dmesg" output) from
2914 * the guest kernel. This is sometimes useful for extended
2915 * debugging of problems.
2917 * Another way to get the same information is to enable
2918 * verbose messages with "g.set_verbose" or by setting the
2919 * environment variable "LIBGUESTFS_DEBUG=1" before running
2922 * @throws LibGuestFSException
2924 public String dmesg ()
2925 throws LibGuestFSException
2928 throw new LibGuestFSException ("dmesg: handle is closed");
2931 private native String _dmesg (long g)
2932 throws LibGuestFSException;
2935 * ping the guest daemon
2937 * This is a test probe into the guestfs daemon running
2938 * inside the qemu subprocess. Calling this function checks
2939 * that the daemon responds to the ping message, without
2940 * affecting the daemon or attached block device(s) in any
2943 * @throws LibGuestFSException
2945 public void ping_daemon ()
2946 throws LibGuestFSException
2949 throw new LibGuestFSException ("ping_daemon: handle is closed");
2952 private native void _ping_daemon (long g)
2953 throws LibGuestFSException;
2956 * test if two files have equal contents
2958 * This compares the two files "file1" and "file2" and
2959 * returns true if their content is exactly equal, or false
2962 * The external cmp(1) program is used for the comparison.
2964 * @throws LibGuestFSException
2966 public boolean equal (String file1, String file2)
2967 throws LibGuestFSException
2970 throw new LibGuestFSException ("equal: handle is closed");
2971 return _equal (g, file1, file2);
2973 private native boolean _equal (long g, String file1, String file2)
2974 throws LibGuestFSException;
2977 * print the printable strings in a file
2979 * This runs the strings(1) command on a file and returns
2980 * the list of printable strings found.
2982 * Because of the message protocol, there is a transfer
2983 * limit of somewhere between 2MB and 4MB. To transfer
2984 * large files you should use FTP.
2986 * @throws LibGuestFSException
2988 public String[] strings (String path)
2989 throws LibGuestFSException
2992 throw new LibGuestFSException ("strings: handle is closed");
2993 return _strings (g, path);
2995 private native String[] _strings (long g, String path)
2996 throws LibGuestFSException;
2999 * print the printable strings in a file
3001 * This is like the "g.strings" command, but allows you to
3002 * specify the encoding.
3004 * See the strings(1) manpage for the full list of
3007 * Commonly useful encodings are "l" (lower case L) which
3008 * will show strings inside Windows/x86 files.
3010 * The returned strings are transcoded to UTF-8.
3012 * Because of the message protocol, there is a transfer
3013 * limit of somewhere between 2MB and 4MB. To transfer
3014 * large files you should use FTP.
3016 * @throws LibGuestFSException
3018 public String[] strings_e (String encoding, String path)
3019 throws LibGuestFSException
3022 throw new LibGuestFSException ("strings_e: handle is closed");
3023 return _strings_e (g, encoding, path);
3025 private native String[] _strings_e (long g, String encoding, String path)
3026 throws LibGuestFSException;
3029 * dump a file in hexadecimal
3031 * This runs "hexdump -C" on the given "path". The result
3032 * is the human-readable, canonical hex dump of the file.
3034 * Because of the message protocol, there is a transfer
3035 * limit of somewhere between 2MB and 4MB. To transfer
3036 * large files you should use FTP.
3038 * @throws LibGuestFSException
3040 public String hexdump (String path)
3041 throws LibGuestFSException
3044 throw new LibGuestFSException ("hexdump: handle is closed");
3045 return _hexdump (g, path);
3047 private native String _hexdump (long g, String path)
3048 throws LibGuestFSException;
3051 * zero unused inodes and disk blocks on ext2/3 filesystem
3053 * This runs the *zerofree* program on "device". This
3054 * program claims to zero unused inodes and disk blocks on
3055 * an ext2/3 filesystem, thus making it possible to
3056 * compress the filesystem more effectively.
3058 * You should not run this program if the filesystem is
3061 * It is possible that using this program can damage the
3062 * filesystem or data on the filesystem.
3064 * @throws LibGuestFSException
3066 public void zerofree (String device)
3067 throws LibGuestFSException
3070 throw new LibGuestFSException ("zerofree: handle is closed");
3071 _zerofree (g, device);
3073 private native void _zerofree (long g, String device)
3074 throws LibGuestFSException;
3077 * resize an LVM physical volume
3079 * This resizes (expands or shrinks) an existing LVM
3080 * physical volume to match the new size of the underlying
3083 * @throws LibGuestFSException
3085 public void pvresize (String device)
3086 throws LibGuestFSException
3089 throw new LibGuestFSException ("pvresize: handle is closed");
3090 _pvresize (g, device);
3092 private native void _pvresize (long g, String device)
3093 throws LibGuestFSException;
3096 * modify a single partition on a block device
3098 * This runs sfdisk(8) option to modify just the single
3099 * partition "n" (note: "n" counts from 1).
3101 * For other parameters, see "g.sfdisk". You should usually
3102 * pass 0 for the cyls/heads/sectors parameters.
3104 * This command is dangerous. Without careful use you can
3105 * easily destroy all your data.
3107 * @throws LibGuestFSException
3109 public void sfdisk_N (String device, int n, int cyls, int heads, int sectors, String line)
3110 throws LibGuestFSException
3113 throw new LibGuestFSException ("sfdisk_N: handle is closed");
3114 _sfdisk_N (g, device, n, cyls, heads, sectors, line);
3116 private native void _sfdisk_N (long g, String device, int n, int cyls, int heads, int sectors, String line)
3117 throws LibGuestFSException;
3120 * display the partition table
3122 * This displays the partition table on "device", in the
3123 * human-readable output of the sfdisk(8) command. It is
3124 * not intended to be parsed.
3126 * @throws LibGuestFSException
3128 public String sfdisk_l (String device)
3129 throws LibGuestFSException
3132 throw new LibGuestFSException ("sfdisk_l: handle is closed");
3133 return _sfdisk_l (g, device);
3135 private native String _sfdisk_l (long g, String device)
3136 throws LibGuestFSException;
3139 * display the kernel geometry
3141 * This displays the kernel's idea of the geometry of
3144 * The result is in human-readable format, and not designed
3147 * @throws LibGuestFSException
3149 public String sfdisk_kernel_geometry (String device)
3150 throws LibGuestFSException
3153 throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
3154 return _sfdisk_kernel_geometry (g, device);
3156 private native String _sfdisk_kernel_geometry (long g, String device)
3157 throws LibGuestFSException;
3160 * display the disk geometry from the partition table
3162 * This displays the disk geometry of "device" read from
3163 * the partition table. Especially in the case where the
3164 * underlying block device has been resized, this can be
3165 * different from the kernel's idea of the geometry (see
3166 * "g.sfdisk_kernel_geometry").
3168 * The result is in human-readable format, and not designed
3171 * @throws LibGuestFSException
3173 public String sfdisk_disk_geometry (String device)
3174 throws LibGuestFSException
3177 throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
3178 return _sfdisk_disk_geometry (g, device);
3180 private native String _sfdisk_disk_geometry (long g, String device)
3181 throws LibGuestFSException;
3184 * activate or deactivate all volume groups
3186 * This command activates or (if "activate" is false)
3187 * deactivates all logical volumes in all volume groups. If
3188 * activated, then they are made known to the kernel, ie.
3189 * they appear as "/dev/mapper" devices. If deactivated,
3190 * then those devices disappear.
3192 * This command is the same as running "vgchange -a y|n"
3194 * @throws LibGuestFSException
3196 public void vg_activate_all (boolean activate)
3197 throws LibGuestFSException
3200 throw new LibGuestFSException ("vg_activate_all: handle is closed");
3201 _vg_activate_all (g, activate);
3203 private native void _vg_activate_all (long g, boolean activate)
3204 throws LibGuestFSException;
3207 * activate or deactivate some volume groups
3209 * This command activates or (if "activate" is false)
3210 * deactivates all logical volumes in the listed volume
3211 * groups "volgroups". If activated, then they are made
3212 * known to the kernel, ie. they appear as "/dev/mapper"
3213 * devices. If deactivated, then those devices disappear.
3215 * This command is the same as running "vgchange -a y|n
3218 * Note that if "volgroups" is an empty list then all
3219 * volume groups are activated or deactivated.
3221 * @throws LibGuestFSException
3223 public void vg_activate (boolean activate, String[] volgroups)
3224 throws LibGuestFSException
3227 throw new LibGuestFSException ("vg_activate: handle is closed");
3228 _vg_activate (g, activate, volgroups);
3230 private native void _vg_activate (long g, boolean activate, String[] volgroups)
3231 throws LibGuestFSException;
3234 * resize an LVM logical volume
3236 * This resizes (expands or shrinks) an existing LVM
3237 * logical volume to "mbytes". When reducing, data in the
3238 * reduced part is lost.
3240 * @throws LibGuestFSException
3242 public void lvresize (String device, int mbytes)
3243 throws LibGuestFSException
3246 throw new LibGuestFSException ("lvresize: handle is closed");
3247 _lvresize (g, device, mbytes);
3249 private native void _lvresize (long g, String device, int mbytes)
3250 throws LibGuestFSException;
3253 * resize an ext2/ext3 filesystem
3255 * This resizes an ext2 or ext3 filesystem to match the
3256 * size of the underlying device.
3258 * *Note:* It is sometimes required that you run
3259 * "g.e2fsck_f" on the "device" before calling this
3260 * command. For unknown reasons "resize2fs" sometimes gives
3261 * an error about this and sometimes not. In any case, it
3262 * is always safe to call "g.e2fsck_f" before calling this
3265 * @throws LibGuestFSException
3267 public void resize2fs (String device)
3268 throws LibGuestFSException
3271 throw new LibGuestFSException ("resize2fs: handle is closed");
3272 _resize2fs (g, device);
3274 private native void _resize2fs (long g, String device)
3275 throws LibGuestFSException;
3278 * find all files and directories
3280 * This command lists out all files and directories,
3281 * recursively, starting at "directory". It is essentially
3282 * equivalent to running the shell command "find directory
3283 * -print" but some post-processing happens on the output,
3286 * This returns a list of strings *without any prefix*.
3287 * Thus if the directory structure was:
3293 * then the returned list from "g.find" "/tmp" would be 4
3301 * If "directory" is not a directory, then this command
3304 * The returned list is sorted.
3306 * @throws LibGuestFSException
3308 public String[] find (String directory)
3309 throws LibGuestFSException
3312 throw new LibGuestFSException ("find: handle is closed");
3313 return _find (g, directory);
3315 private native String[] _find (long g, String directory)
3316 throws LibGuestFSException;
3319 * check an ext2/ext3 filesystem
3321 * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
3322 * filesystem checker on "device", noninteractively ("-p"),
3323 * even if the filesystem appears to be clean ("-f").
3325 * This command is only needed because of "g.resize2fs"
3326 * (q.v.). Normally you should use "g.fsck".
3328 * @throws LibGuestFSException
3330 public void e2fsck_f (String device)
3331 throws LibGuestFSException
3334 throw new LibGuestFSException ("e2fsck_f: handle is closed");
3335 _e2fsck_f (g, device);
3337 private native void _e2fsck_f (long g, String device)
3338 throws LibGuestFSException;