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;
32 import com.redhat.et.libguestfs.Dirent;
35 * The GuestFS object is a libguestfs handle.
39 public class GuestFS {
40 // Load the native code.
42 System.loadLibrary ("guestfs_jni");
46 * The native guestfs_h pointer.
51 * Create a libguestfs handle.
53 * @throws LibGuestFSException
55 public GuestFS () throws LibGuestFSException
59 private native long _create () throws LibGuestFSException;
62 * Close a libguestfs handle.
64 * You can also leave handles to be collected by the garbage
65 * collector, but this method ensures that the resources used
66 * by the handle are freed up immediately. If you call any
67 * other methods after closing the handle, you will get an
70 * @throws LibGuestFSException
72 public void close () throws LibGuestFSException
78 private native void _close (long g) throws LibGuestFSException;
80 public void finalize () throws LibGuestFSException
85 public void test0 (String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
86 throws LibGuestFSException
89 throw new LibGuestFSException ("test0: handle is closed");
90 _test0 (g, str, optstr, strlist, b, integer, filein, fileout);
92 private native void _test0 (long g, String str, String optstr, String[] strlist, boolean b, int integer, String filein, String fileout)
93 throws LibGuestFSException;
95 public int test0rint (String val)
96 throws LibGuestFSException
99 throw new LibGuestFSException ("test0rint: handle is closed");
100 return _test0rint (g, val);
102 private native int _test0rint (long g, String val)
103 throws LibGuestFSException;
105 public int test0rinterr ()
106 throws LibGuestFSException
109 throw new LibGuestFSException ("test0rinterr: handle is closed");
110 return _test0rinterr (g);
112 private native int _test0rinterr (long g)
113 throws LibGuestFSException;
115 public long test0rint64 (String val)
116 throws LibGuestFSException
119 throw new LibGuestFSException ("test0rint64: handle is closed");
120 return _test0rint64 (g, val);
122 private native long _test0rint64 (long g, String val)
123 throws LibGuestFSException;
125 public long test0rint64err ()
126 throws LibGuestFSException
129 throw new LibGuestFSException ("test0rint64err: handle is closed");
130 return _test0rint64err (g);
132 private native long _test0rint64err (long g)
133 throws LibGuestFSException;
135 public boolean test0rbool (String val)
136 throws LibGuestFSException
139 throw new LibGuestFSException ("test0rbool: handle is closed");
140 return _test0rbool (g, val);
142 private native boolean _test0rbool (long g, String val)
143 throws LibGuestFSException;
145 public boolean test0rboolerr ()
146 throws LibGuestFSException
149 throw new LibGuestFSException ("test0rboolerr: handle is closed");
150 return _test0rboolerr (g);
152 private native boolean _test0rboolerr (long g)
153 throws LibGuestFSException;
155 public String test0rconststring (String val)
156 throws LibGuestFSException
159 throw new LibGuestFSException ("test0rconststring: handle is closed");
160 return _test0rconststring (g, val);
162 private native String _test0rconststring (long g, String val)
163 throws LibGuestFSException;
165 public String test0rconststringerr ()
166 throws LibGuestFSException
169 throw new LibGuestFSException ("test0rconststringerr: handle is closed");
170 return _test0rconststringerr (g);
172 private native String _test0rconststringerr (long g)
173 throws LibGuestFSException;
175 public String test0rstring (String val)
176 throws LibGuestFSException
179 throw new LibGuestFSException ("test0rstring: handle is closed");
180 return _test0rstring (g, val);
182 private native String _test0rstring (long g, String val)
183 throws LibGuestFSException;
185 public String test0rstringerr ()
186 throws LibGuestFSException
189 throw new LibGuestFSException ("test0rstringerr: handle is closed");
190 return _test0rstringerr (g);
192 private native String _test0rstringerr (long g)
193 throws LibGuestFSException;
195 public String[] test0rstringlist (String val)
196 throws LibGuestFSException
199 throw new LibGuestFSException ("test0rstringlist: handle is closed");
200 return _test0rstringlist (g, val);
202 private native String[] _test0rstringlist (long g, String val)
203 throws LibGuestFSException;
205 public String[] test0rstringlisterr ()
206 throws LibGuestFSException
209 throw new LibGuestFSException ("test0rstringlisterr: handle is closed");
210 return _test0rstringlisterr (g);
212 private native String[] _test0rstringlisterr (long g)
213 throws LibGuestFSException;
215 public IntBool test0rintbool (String val)
216 throws LibGuestFSException
219 throw new LibGuestFSException ("test0rintbool: handle is closed");
220 return _test0rintbool (g, val);
222 private native IntBool _test0rintbool (long g, String val)
223 throws LibGuestFSException;
225 public IntBool test0rintboolerr ()
226 throws LibGuestFSException
229 throw new LibGuestFSException ("test0rintboolerr: handle is closed");
230 return _test0rintboolerr (g);
232 private native IntBool _test0rintboolerr (long g)
233 throws LibGuestFSException;
235 public PV[] test0rpvlist (String val)
236 throws LibGuestFSException
239 throw new LibGuestFSException ("test0rpvlist: handle is closed");
240 return _test0rpvlist (g, val);
242 private native PV[] _test0rpvlist (long g, String val)
243 throws LibGuestFSException;
245 public PV[] test0rpvlisterr ()
246 throws LibGuestFSException
249 throw new LibGuestFSException ("test0rpvlisterr: handle is closed");
250 return _test0rpvlisterr (g);
252 private native PV[] _test0rpvlisterr (long g)
253 throws LibGuestFSException;
255 public VG[] test0rvglist (String val)
256 throws LibGuestFSException
259 throw new LibGuestFSException ("test0rvglist: handle is closed");
260 return _test0rvglist (g, val);
262 private native VG[] _test0rvglist (long g, String val)
263 throws LibGuestFSException;
265 public VG[] test0rvglisterr ()
266 throws LibGuestFSException
269 throw new LibGuestFSException ("test0rvglisterr: handle is closed");
270 return _test0rvglisterr (g);
272 private native VG[] _test0rvglisterr (long g)
273 throws LibGuestFSException;
275 public LV[] test0rlvlist (String val)
276 throws LibGuestFSException
279 throw new LibGuestFSException ("test0rlvlist: handle is closed");
280 return _test0rlvlist (g, val);
282 private native LV[] _test0rlvlist (long g, String val)
283 throws LibGuestFSException;
285 public LV[] test0rlvlisterr ()
286 throws LibGuestFSException
289 throw new LibGuestFSException ("test0rlvlisterr: handle is closed");
290 return _test0rlvlisterr (g);
292 private native LV[] _test0rlvlisterr (long g)
293 throws LibGuestFSException;
295 public Stat test0rstat (String val)
296 throws LibGuestFSException
299 throw new LibGuestFSException ("test0rstat: handle is closed");
300 return _test0rstat (g, val);
302 private native Stat _test0rstat (long g, String val)
303 throws LibGuestFSException;
305 public Stat test0rstaterr ()
306 throws LibGuestFSException
309 throw new LibGuestFSException ("test0rstaterr: handle is closed");
310 return _test0rstaterr (g);
312 private native Stat _test0rstaterr (long g)
313 throws LibGuestFSException;
315 public StatVFS test0rstatvfs (String val)
316 throws LibGuestFSException
319 throw new LibGuestFSException ("test0rstatvfs: handle is closed");
320 return _test0rstatvfs (g, val);
322 private native StatVFS _test0rstatvfs (long g, String val)
323 throws LibGuestFSException;
325 public StatVFS test0rstatvfserr ()
326 throws LibGuestFSException
329 throw new LibGuestFSException ("test0rstatvfserr: handle is closed");
330 return _test0rstatvfserr (g);
332 private native StatVFS _test0rstatvfserr (long g)
333 throws LibGuestFSException;
335 public HashMap<String,String> test0rhashtable (String val)
336 throws LibGuestFSException
339 throw new LibGuestFSException ("test0rhashtable: handle is closed");
340 return _test0rhashtable (g, val);
342 private native HashMap<String,String> _test0rhashtable (long g, String val)
343 throws LibGuestFSException;
345 public HashMap<String,String> test0rhashtableerr ()
346 throws LibGuestFSException
349 throw new LibGuestFSException ("test0rhashtableerr: handle is closed");
350 return _test0rhashtableerr (g);
352 private native HashMap<String,String> _test0rhashtableerr (long g)
353 throws LibGuestFSException;
356 * launch the qemu subprocess
358 * Internally libguestfs is implemented by running a
359 * virtual machine using qemu(1).
361 * You should call this after configuring the handle (eg.
362 * adding drives) but before performing any actions.
364 * @throws LibGuestFSException
366 public void launch ()
367 throws LibGuestFSException
370 throw new LibGuestFSException ("launch: handle is closed");
373 private native void _launch (long g)
374 throws LibGuestFSException;
377 * wait until the qemu subprocess launches
379 * Internally libguestfs is implemented by running a
380 * virtual machine using qemu(1).
382 * You should call this after "g.launch" to wait for the
383 * launch to complete.
385 * @throws LibGuestFSException
387 public void wait_ready ()
388 throws LibGuestFSException
391 throw new LibGuestFSException ("wait_ready: handle is closed");
394 private native void _wait_ready (long g)
395 throws LibGuestFSException;
398 * kill the qemu subprocess
400 * This kills the qemu subprocess. You should never need to
403 * @throws LibGuestFSException
405 public void kill_subprocess ()
406 throws LibGuestFSException
409 throw new LibGuestFSException ("kill_subprocess: handle is closed");
410 _kill_subprocess (g);
412 private native void _kill_subprocess (long g)
413 throws LibGuestFSException;
416 * add an image to examine or modify
418 * This function adds a virtual machine disk image
419 * "filename" to the guest. The first time you call this
420 * function, the disk appears as IDE disk 0 ("/dev/sda") in
421 * the guest, the second time as "/dev/sdb", and so on.
423 * You don't necessarily need to be root when using
424 * libguestfs. However you obviously do need sufficient
425 * permissions to access the filename for whatever
426 * operations you want to perform (ie. read access if you
427 * just want to read the image or write access if you want
428 * to modify the image).
430 * This is equivalent to the qemu parameter "-drive
431 * file=filename,cache=off,if=virtio".
433 * Note that this call checks for the existence of
434 * "filename". This stops you from specifying other types
435 * of drive which are supported by qemu such as "nbd:" and
436 * "http:" URLs. To specify those, use the general
437 * "g.config" call instead.
439 * @throws LibGuestFSException
441 public void add_drive (String filename)
442 throws LibGuestFSException
445 throw new LibGuestFSException ("add_drive: handle is closed");
446 _add_drive (g, filename);
448 private native void _add_drive (long g, String filename)
449 throws LibGuestFSException;
452 * add a CD-ROM disk image to examine
454 * This function adds a virtual CD-ROM disk image to the
457 * This is equivalent to the qemu parameter "-cdrom
460 * Note that this call checks for the existence of
461 * "filename". This stops you from specifying other types
462 * of drive which are supported by qemu such as "nbd:" and
463 * "http:" URLs. To specify those, use the general
464 * "g.config" call instead.
466 * @throws LibGuestFSException
468 public void add_cdrom (String filename)
469 throws LibGuestFSException
472 throw new LibGuestFSException ("add_cdrom: handle is closed");
473 _add_cdrom (g, filename);
475 private native void _add_cdrom (long g, String filename)
476 throws LibGuestFSException;
479 * add a drive in snapshot mode (read-only)
481 * This adds a drive in snapshot mode, making it
482 * effectively read-only.
484 * Note that writes to the device are allowed, and will be
485 * seen for the duration of the guestfs handle, but they
486 * are written to a temporary file which is discarded as
487 * soon as the guestfs handle is closed. We don't currently
488 * have any method to enable changes to be committed,
489 * although qemu can support this.
491 * This is equivalent to the qemu parameter "-drive
492 * file=filename,snapshot=on,if=virtio".
494 * Note that this call checks for the existence of
495 * "filename". This stops you from specifying other types
496 * of drive which are supported by qemu such as "nbd:" and
497 * "http:" URLs. To specify those, use the general
498 * "g.config" call instead.
500 * @throws LibGuestFSException
502 public void add_drive_ro (String filename)
503 throws LibGuestFSException
506 throw new LibGuestFSException ("add_drive_ro: handle is closed");
507 _add_drive_ro (g, filename);
509 private native void _add_drive_ro (long g, String filename)
510 throws LibGuestFSException;
513 * add qemu parameters
515 * This can be used to add arbitrary qemu command line
516 * parameters of the form "-param value". Actually it's not
517 * quite arbitrary - we prevent you from setting some
518 * parameters which would interfere with parameters that we
521 * The first character of "param" string must be a "-"
524 * "value" can be NULL.
526 * @throws LibGuestFSException
528 public void config (String qemuparam, String qemuvalue)
529 throws LibGuestFSException
532 throw new LibGuestFSException ("config: handle is closed");
533 _config (g, qemuparam, qemuvalue);
535 private native void _config (long g, String qemuparam, String qemuvalue)
536 throws LibGuestFSException;
539 * set the qemu binary
541 * Set the qemu binary that we will use.
543 * The default is chosen when the library was compiled by
544 * the configure script.
546 * You can also override this by setting the
547 * "LIBGUESTFS_QEMU" environment variable.
549 * Setting "qemu" to "NULL" restores the default qemu
552 * @throws LibGuestFSException
554 public void set_qemu (String qemu)
555 throws LibGuestFSException
558 throw new LibGuestFSException ("set_qemu: handle is closed");
561 private native void _set_qemu (long g, String qemu)
562 throws LibGuestFSException;
565 * get the qemu binary
567 * Return the current qemu binary.
569 * This is always non-NULL. If it wasn't set already, then
570 * this will return the default qemu binary name.
572 * @throws LibGuestFSException
574 public String get_qemu ()
575 throws LibGuestFSException
578 throw new LibGuestFSException ("get_qemu: handle is closed");
579 return _get_qemu (g);
581 private native String _get_qemu (long g)
582 throws LibGuestFSException;
585 * set the search path
587 * Set the path that libguestfs searches for kernel and
590 * The default is "$libdir/guestfs" unless overridden by
591 * setting "LIBGUESTFS_PATH" environment variable.
593 * Setting "path" to "NULL" restores the default path.
595 * @throws LibGuestFSException
597 public void set_path (String path)
598 throws LibGuestFSException
601 throw new LibGuestFSException ("set_path: handle is closed");
604 private native void _set_path (long g, String path)
605 throws LibGuestFSException;
608 * get the search path
610 * Return the current search path.
612 * This is always non-NULL. If it wasn't set already, then
613 * this will return the default path.
615 * @throws LibGuestFSException
617 public String get_path ()
618 throws LibGuestFSException
621 throw new LibGuestFSException ("get_path: handle is closed");
622 return _get_path (g);
624 private native String _get_path (long g)
625 throws LibGuestFSException;
628 * add options to kernel command line
630 * This function is used to add additional options to the
631 * guest kernel command line.
633 * The default is "NULL" unless overridden by setting
634 * "LIBGUESTFS_APPEND" environment variable.
636 * Setting "append" to "NULL" means *no* additional options
637 * are passed (libguestfs always adds a few of its own).
639 * @throws LibGuestFSException
641 public void set_append (String append)
642 throws LibGuestFSException
645 throw new LibGuestFSException ("set_append: handle is closed");
646 _set_append (g, append);
648 private native void _set_append (long g, String append)
649 throws LibGuestFSException;
652 * get the additional kernel options
654 * Return the additional kernel options which are added to
655 * the guest kernel command line.
657 * If "NULL" then no options are added.
659 * @throws LibGuestFSException
661 public String get_append ()
662 throws LibGuestFSException
665 throw new LibGuestFSException ("get_append: handle is closed");
666 return _get_append (g);
668 private native String _get_append (long g)
669 throws LibGuestFSException;
674 * If "autosync" is true, this enables autosync. Libguestfs
675 * will make a best effort attempt to run "g.umount_all"
676 * followed by "g.sync" when the handle is closed (also if
677 * the program exits without closing handles).
679 * This is disabled by default (except in guestfish where
680 * it is enabled by default).
682 * @throws LibGuestFSException
684 public void set_autosync (boolean autosync)
685 throws LibGuestFSException
688 throw new LibGuestFSException ("set_autosync: handle is closed");
689 _set_autosync (g, autosync);
691 private native void _set_autosync (long g, boolean autosync)
692 throws LibGuestFSException;
697 * Get the autosync flag.
699 * @throws LibGuestFSException
701 public boolean get_autosync ()
702 throws LibGuestFSException
705 throw new LibGuestFSException ("get_autosync: handle is closed");
706 return _get_autosync (g);
708 private native boolean _get_autosync (long g)
709 throws LibGuestFSException;
714 * If "verbose" is true, this turns on verbose messages (to
717 * Verbose messages are disabled unless the environment
718 * variable "LIBGUESTFS_DEBUG" is defined and set to 1.
720 * @throws LibGuestFSException
722 public void set_verbose (boolean verbose)
723 throws LibGuestFSException
726 throw new LibGuestFSException ("set_verbose: handle is closed");
727 _set_verbose (g, verbose);
729 private native void _set_verbose (long g, boolean verbose)
730 throws LibGuestFSException;
735 * This returns the verbose messages flag.
737 * @throws LibGuestFSException
739 public boolean get_verbose ()
740 throws LibGuestFSException
743 throw new LibGuestFSException ("get_verbose: handle is closed");
744 return _get_verbose (g);
746 private native boolean _get_verbose (long g)
747 throws LibGuestFSException;
750 * is ready to accept commands
752 * This returns true iff this handle is ready to accept
753 * commands (in the "READY" state).
755 * For more information on states, see guestfs(3).
757 * @throws LibGuestFSException
759 public boolean is_ready ()
760 throws LibGuestFSException
763 throw new LibGuestFSException ("is_ready: handle is closed");
764 return _is_ready (g);
766 private native boolean _is_ready (long g)
767 throws LibGuestFSException;
770 * is in configuration state
772 * This returns true iff this handle is being configured
773 * (in the "CONFIG" state).
775 * For more information on states, see guestfs(3).
777 * @throws LibGuestFSException
779 public boolean is_config ()
780 throws LibGuestFSException
783 throw new LibGuestFSException ("is_config: handle is closed");
784 return _is_config (g);
786 private native boolean _is_config (long g)
787 throws LibGuestFSException;
790 * is launching subprocess
792 * This returns true iff this handle is launching the
793 * subprocess (in the "LAUNCHING" state).
795 * For more information on states, see guestfs(3).
797 * @throws LibGuestFSException
799 public boolean is_launching ()
800 throws LibGuestFSException
803 throw new LibGuestFSException ("is_launching: handle is closed");
804 return _is_launching (g);
806 private native boolean _is_launching (long g)
807 throws LibGuestFSException;
810 * is busy processing a command
812 * This returns true iff this handle is busy processing a
813 * command (in the "BUSY" state).
815 * For more information on states, see guestfs(3).
817 * @throws LibGuestFSException
819 public boolean is_busy ()
820 throws LibGuestFSException
823 throw new LibGuestFSException ("is_busy: handle is closed");
826 private native boolean _is_busy (long g)
827 throws LibGuestFSException;
830 * get the current state
832 * This returns the current state as an opaque integer.
833 * This is only useful for printing debug and internal
836 * For more information on states, see guestfs(3).
838 * @throws LibGuestFSException
840 public int get_state ()
841 throws LibGuestFSException
844 throw new LibGuestFSException ("get_state: handle is closed");
845 return _get_state (g);
847 private native int _get_state (long g)
848 throws LibGuestFSException;
853 * This sets the state to "BUSY". This is only used when
854 * implementing actions using the low-level API.
856 * For more information on states, see guestfs(3).
858 * @throws LibGuestFSException
860 public void set_busy ()
861 throws LibGuestFSException
864 throw new LibGuestFSException ("set_busy: handle is closed");
867 private native void _set_busy (long g)
868 throws LibGuestFSException;
873 * This sets the state to "READY". This is only used when
874 * implementing actions using the low-level API.
876 * For more information on states, see guestfs(3).
878 * @throws LibGuestFSException
880 public void set_ready ()
881 throws LibGuestFSException
884 throw new LibGuestFSException ("set_ready: handle is closed");
887 private native void _set_ready (long g)
888 throws LibGuestFSException;
891 * leave the busy state
893 * This sets the state to "READY", or if in "CONFIG" then
894 * it leaves the state as is. This is only used when
895 * implementing actions using the low-level API.
897 * For more information on states, see guestfs(3).
899 * @throws LibGuestFSException
901 public void end_busy ()
902 throws LibGuestFSException
905 throw new LibGuestFSException ("end_busy: handle is closed");
908 private native void _end_busy (long g)
909 throws LibGuestFSException;
912 * set memory allocated to the qemu subprocess
914 * This sets the memory size in megabytes allocated to the
915 * qemu subprocess. This only has any effect if called
918 * You can also change this by setting the environment
919 * variable "LIBGUESTFS_MEMSIZE" before the handle is
922 * For more information on the architecture of libguestfs,
925 * @throws LibGuestFSException
927 public void set_memsize (int memsize)
928 throws LibGuestFSException
931 throw new LibGuestFSException ("set_memsize: handle is closed");
932 _set_memsize (g, memsize);
934 private native void _set_memsize (long g, int memsize)
935 throws LibGuestFSException;
938 * get memory allocated to the qemu subprocess
940 * This gets the memory size in megabytes allocated to the
943 * If "g.set_memsize" was not called on this handle, and if
944 * "LIBGUESTFS_MEMSIZE" was not set, then this returns the
945 * compiled-in default value for memsize.
947 * For more information on the architecture of libguestfs,
950 * @throws LibGuestFSException
952 public int get_memsize ()
953 throws LibGuestFSException
956 throw new LibGuestFSException ("get_memsize: handle is closed");
957 return _get_memsize (g);
959 private native int _get_memsize (long g)
960 throws LibGuestFSException;
963 * mount a guest disk at a position in the filesystem
965 * Mount a guest disk at a position in the filesystem.
966 * Block devices are named "/dev/sda", "/dev/sdb" and so
967 * on, as they were added to the guest. If those block
968 * devices contain partitions, they will have the usual
969 * names (eg. "/dev/sda1"). Also LVM "/dev/VG/LV"-style
972 * The rules are the same as for mount(2): A filesystem
973 * must first be mounted on "/" before others can be
974 * mounted. Other filesystems can only be mounted on
975 * directories which already exist.
977 * The mounted filesystem is writable, if we have
978 * sufficient permissions on the underlying device.
980 * The filesystem options "sync" and "noatime" are set with
981 * this call, in order to improve reliability.
983 * @throws LibGuestFSException
985 public void mount (String device, String mountpoint)
986 throws LibGuestFSException
989 throw new LibGuestFSException ("mount: handle is closed");
990 _mount (g, device, mountpoint);
992 private native void _mount (long g, String device, String mountpoint)
993 throws LibGuestFSException;
996 * sync disks, writes are flushed through to the disk image
998 * This syncs the disk, so that any writes are flushed
999 * through to the underlying disk image.
1001 * You should always call this if you have modified a disk
1002 * image, before closing the handle.
1004 * @throws LibGuestFSException
1007 throws LibGuestFSException
1010 throw new LibGuestFSException ("sync: handle is closed");
1013 private native void _sync (long g)
1014 throws LibGuestFSException;
1017 * update file timestamps or create a new file
1019 * Touch acts like the touch(1) command. It can be used to
1020 * update the timestamps on a file, or, if the file does
1021 * not exist, to create a new zero-length file.
1023 * @throws LibGuestFSException
1025 public void touch (String path)
1026 throws LibGuestFSException
1029 throw new LibGuestFSException ("touch: handle is closed");
1032 private native void _touch (long g, String path)
1033 throws LibGuestFSException;
1036 * list the contents of a file
1038 * Return the contents of the file named "path".
1040 * Note that this function cannot correctly handle binary
1041 * files (specifically, files containing "\0" character
1042 * which is treated as end of string). For those you need
1043 * to use the "g.download" function which has a more
1044 * complex interface.
1046 * Because of the message protocol, there is a transfer
1047 * limit of somewhere between 2MB and 4MB. To transfer
1048 * large files you should use FTP.
1050 * @throws LibGuestFSException
1052 public String cat (String path)
1053 throws LibGuestFSException
1056 throw new LibGuestFSException ("cat: handle is closed");
1057 return _cat (g, path);
1059 private native String _cat (long g, String path)
1060 throws LibGuestFSException;
1063 * list the files in a directory (long format)
1065 * List the files in "directory" (relative to the root
1066 * directory, there is no cwd) in the format of 'ls -la'.
1068 * This command is mostly useful for interactive sessions.
1069 * It is *not* intended that you try to parse the output
1072 * @throws LibGuestFSException
1074 public String ll (String directory)
1075 throws LibGuestFSException
1078 throw new LibGuestFSException ("ll: handle is closed");
1079 return _ll (g, directory);
1081 private native String _ll (long g, String directory)
1082 throws LibGuestFSException;
1085 * list the files in a directory
1087 * List the files in "directory" (relative to the root
1088 * directory, there is no cwd). The '.' and '..' entries
1089 * are not returned, but hidden files are shown.
1091 * This command is mostly useful for interactive sessions.
1092 * Programs should probably use "g.readdir" instead.
1094 * @throws LibGuestFSException
1096 public String[] ls (String directory)
1097 throws LibGuestFSException
1100 throw new LibGuestFSException ("ls: handle is closed");
1101 return _ls (g, directory);
1103 private native String[] _ls (long g, String directory)
1104 throws LibGuestFSException;
1107 * list the block devices
1109 * List all the block devices.
1111 * The full block device names are returned, eg. "/dev/sda"
1113 * @throws LibGuestFSException
1115 public String[] list_devices ()
1116 throws LibGuestFSException
1119 throw new LibGuestFSException ("list_devices: handle is closed");
1120 return _list_devices (g);
1122 private native String[] _list_devices (long g)
1123 throws LibGuestFSException;
1126 * list the partitions
1128 * List all the partitions detected on all block devices.
1130 * The full partition device names are returned, eg.
1133 * This does not return logical volumes. For that you will
1134 * need to call "g.lvs".
1136 * @throws LibGuestFSException
1138 public String[] list_partitions ()
1139 throws LibGuestFSException
1142 throw new LibGuestFSException ("list_partitions: handle is closed");
1143 return _list_partitions (g);
1145 private native String[] _list_partitions (long g)
1146 throws LibGuestFSException;
1149 * list the LVM physical volumes (PVs)
1151 * List all the physical volumes detected. This is the
1152 * equivalent of the pvs(8) command.
1154 * This returns a list of just the device names that
1155 * contain PVs (eg. "/dev/sda2").
1157 * See also "g.pvs_full".
1159 * @throws LibGuestFSException
1161 public String[] pvs ()
1162 throws LibGuestFSException
1165 throw new LibGuestFSException ("pvs: handle is closed");
1168 private native String[] _pvs (long g)
1169 throws LibGuestFSException;
1172 * list the LVM volume groups (VGs)
1174 * List all the volumes groups detected. This is the
1175 * equivalent of the vgs(8) command.
1177 * This returns a list of just the volume group names that
1178 * were detected (eg. "VolGroup00").
1180 * See also "g.vgs_full".
1182 * @throws LibGuestFSException
1184 public String[] vgs ()
1185 throws LibGuestFSException
1188 throw new LibGuestFSException ("vgs: handle is closed");
1191 private native String[] _vgs (long g)
1192 throws LibGuestFSException;
1195 * list the LVM logical volumes (LVs)
1197 * List all the logical volumes detected. This is the
1198 * equivalent of the lvs(8) command.
1200 * This returns a list of the logical volume device names
1201 * (eg. "/dev/VolGroup00/LogVol00").
1203 * See also "g.lvs_full".
1205 * @throws LibGuestFSException
1207 public String[] lvs ()
1208 throws LibGuestFSException
1211 throw new LibGuestFSException ("lvs: handle is closed");
1214 private native String[] _lvs (long g)
1215 throws LibGuestFSException;
1218 * list the LVM physical volumes (PVs)
1220 * List all the physical volumes detected. This is the
1221 * equivalent of the pvs(8) command. The "full" version
1222 * includes all fields.
1224 * @throws LibGuestFSException
1226 public PV[] pvs_full ()
1227 throws LibGuestFSException
1230 throw new LibGuestFSException ("pvs_full: handle is closed");
1231 return _pvs_full (g);
1233 private native PV[] _pvs_full (long g)
1234 throws LibGuestFSException;
1237 * list the LVM volume groups (VGs)
1239 * List all the volumes groups detected. This is the
1240 * equivalent of the vgs(8) command. The "full" version
1241 * includes all fields.
1243 * @throws LibGuestFSException
1245 public VG[] vgs_full ()
1246 throws LibGuestFSException
1249 throw new LibGuestFSException ("vgs_full: handle is closed");
1250 return _vgs_full (g);
1252 private native VG[] _vgs_full (long g)
1253 throws LibGuestFSException;
1256 * list the LVM logical volumes (LVs)
1258 * List all the logical volumes detected. This is the
1259 * equivalent of the lvs(8) command. The "full" version
1260 * includes all fields.
1262 * @throws LibGuestFSException
1264 public LV[] lvs_full ()
1265 throws LibGuestFSException
1268 throw new LibGuestFSException ("lvs_full: handle is closed");
1269 return _lvs_full (g);
1271 private native LV[] _lvs_full (long g)
1272 throws LibGuestFSException;
1275 * read file as lines
1277 * Return the contents of the file named "path".
1279 * The file contents are returned as a list of lines.
1280 * Trailing "LF" and "CRLF" character sequences are *not*
1283 * Note that this function cannot correctly handle binary
1284 * files (specifically, files containing "\0" character
1285 * which is treated as end of line). For those you need to
1286 * use the "g.read_file" function which has a more complex
1289 * @throws LibGuestFSException
1291 public String[] read_lines (String path)
1292 throws LibGuestFSException
1295 throw new LibGuestFSException ("read_lines: handle is closed");
1296 return _read_lines (g, path);
1298 private native String[] _read_lines (long g, String path)
1299 throws LibGuestFSException;
1302 * create a new Augeas handle
1304 * Create a new Augeas handle for editing configuration
1305 * files. If there was any previous Augeas handle
1306 * associated with this guestfs session, then it is closed.
1308 * You must call this before using any other "g.aug_*"
1311 * "root" is the filesystem root. "root" must not be NULL,
1314 * The flags are the same as the flags defined in
1315 * <augeas.h>, the logical *or* of the following integers:
1317 * "AUG_SAVE_BACKUP" = 1
1318 * Keep the original file with a ".augsave" extension.
1320 * "AUG_SAVE_NEWFILE" = 2
1321 * Save changes into a file with extension ".augnew",
1322 * and do not overwrite original. Overrides
1323 * "AUG_SAVE_BACKUP".
1325 * "AUG_TYPE_CHECK" = 4
1326 * Typecheck lenses (can be expensive).
1328 * "AUG_NO_STDINC" = 8
1329 * Do not use standard load path for modules.
1331 * "AUG_SAVE_NOOP" = 16
1332 * Make save a no-op, just record what would have been
1335 * "AUG_NO_LOAD" = 32
1336 * Do not load the tree in "g.aug_init".
1338 * To close the handle, you can call "g.aug_close".
1340 * To find out more about Augeas, see <http://augeas.net/>.
1342 * @throws LibGuestFSException
1344 public void aug_init (String root, int flags)
1345 throws LibGuestFSException
1348 throw new LibGuestFSException ("aug_init: handle is closed");
1349 _aug_init (g, root, flags);
1351 private native void _aug_init (long g, String root, int flags)
1352 throws LibGuestFSException;
1355 * close the current Augeas handle
1357 * Close the current Augeas handle and free up any
1358 * resources used by it. After calling this, you have to
1359 * call "g.aug_init" again before you can use any other
1362 * @throws LibGuestFSException
1364 public void aug_close ()
1365 throws LibGuestFSException
1368 throw new LibGuestFSException ("aug_close: handle is closed");
1371 private native void _aug_close (long g)
1372 throws LibGuestFSException;
1375 * define an Augeas variable
1377 * Defines an Augeas variable "name" whose value is the
1378 * result of evaluating "expr". If "expr" is NULL, then
1379 * "name" is undefined.
1381 * On success this returns the number of nodes in "expr",
1382 * or 0 if "expr" evaluates to something which is not a
1385 * @throws LibGuestFSException
1387 public int aug_defvar (String name, String expr)
1388 throws LibGuestFSException
1391 throw new LibGuestFSException ("aug_defvar: handle is closed");
1392 return _aug_defvar (g, name, expr);
1394 private native int _aug_defvar (long g, String name, String expr)
1395 throws LibGuestFSException;
1398 * define an Augeas node
1400 * Defines a variable "name" whose value is the result of
1401 * evaluating "expr".
1403 * If "expr" evaluates to an empty nodeset, a node is
1404 * created, equivalent to calling "g.aug_set" "expr",
1405 * "value". "name" will be the nodeset containing that
1408 * On success this returns a pair containing the number of
1409 * nodes in the nodeset, and a boolean flag if a node was
1412 * @throws LibGuestFSException
1414 public IntBool aug_defnode (String name, String expr, String val)
1415 throws LibGuestFSException
1418 throw new LibGuestFSException ("aug_defnode: handle is closed");
1419 return _aug_defnode (g, name, expr, val);
1421 private native IntBool _aug_defnode (long g, String name, String expr, String val)
1422 throws LibGuestFSException;
1425 * look up the value of an Augeas path
1427 * Look up the value associated with "path". If "path"
1428 * matches exactly one node, the "value" is returned.
1430 * @throws LibGuestFSException
1432 public String aug_get (String path)
1433 throws LibGuestFSException
1436 throw new LibGuestFSException ("aug_get: handle is closed");
1437 return _aug_get (g, path);
1439 private native String _aug_get (long g, String path)
1440 throws LibGuestFSException;
1443 * set Augeas path to value
1445 * Set the value associated with "path" to "value".
1447 * @throws LibGuestFSException
1449 public void aug_set (String path, String val)
1450 throws LibGuestFSException
1453 throw new LibGuestFSException ("aug_set: handle is closed");
1454 _aug_set (g, path, val);
1456 private native void _aug_set (long g, String path, String val)
1457 throws LibGuestFSException;
1460 * insert a sibling Augeas node
1462 * Create a new sibling "label" for "path", inserting it
1463 * into the tree before or after "path" (depending on the
1464 * boolean flag "before").
1466 * "path" must match exactly one existing node in the tree,
1467 * and "label" must be a label, ie. not contain "/", "*" or
1468 * end with a bracketed index "[N]".
1470 * @throws LibGuestFSException
1472 public void aug_insert (String path, String label, boolean before)
1473 throws LibGuestFSException
1476 throw new LibGuestFSException ("aug_insert: handle is closed");
1477 _aug_insert (g, path, label, before);
1479 private native void _aug_insert (long g, String path, String label, boolean before)
1480 throws LibGuestFSException;
1483 * remove an Augeas path
1485 * Remove "path" and all of its children.
1487 * On success this returns the number of entries which were
1490 * @throws LibGuestFSException
1492 public int aug_rm (String path)
1493 throws LibGuestFSException
1496 throw new LibGuestFSException ("aug_rm: handle is closed");
1497 return _aug_rm (g, path);
1499 private native int _aug_rm (long g, String path)
1500 throws LibGuestFSException;
1505 * Move the node "src" to "dest". "src" must match exactly
1506 * one node. "dest" is overwritten if it exists.
1508 * @throws LibGuestFSException
1510 public void aug_mv (String src, String dest)
1511 throws LibGuestFSException
1514 throw new LibGuestFSException ("aug_mv: handle is closed");
1515 _aug_mv (g, src, dest);
1517 private native void _aug_mv (long g, String src, String dest)
1518 throws LibGuestFSException;
1521 * return Augeas nodes which match path
1523 * Returns a list of paths which match the path expression
1524 * "path". The returned paths are sufficiently qualified so
1525 * that they match exactly one node in the current tree.
1527 * @throws LibGuestFSException
1529 public String[] aug_match (String path)
1530 throws LibGuestFSException
1533 throw new LibGuestFSException ("aug_match: handle is closed");
1534 return _aug_match (g, path);
1536 private native String[] _aug_match (long g, String path)
1537 throws LibGuestFSException;
1540 * write all pending Augeas changes to disk
1542 * This writes all pending changes to disk.
1544 * The flags which were passed to "g.aug_init" affect
1545 * exactly how files are saved.
1547 * @throws LibGuestFSException
1549 public void aug_save ()
1550 throws LibGuestFSException
1553 throw new LibGuestFSException ("aug_save: handle is closed");
1556 private native void _aug_save (long g)
1557 throws LibGuestFSException;
1560 * load files into the tree
1562 * Load files into the tree.
1564 * See "aug_load" in the Augeas documentation for the full
1567 * @throws LibGuestFSException
1569 public void aug_load ()
1570 throws LibGuestFSException
1573 throw new LibGuestFSException ("aug_load: handle is closed");
1576 private native void _aug_load (long g)
1577 throws LibGuestFSException;
1580 * list Augeas nodes under a path
1582 * This is just a shortcut for listing "g.aug_match"
1583 * "path/*" and sorting the resulting nodes into
1584 * alphabetical order.
1586 * @throws LibGuestFSException
1588 public String[] aug_ls (String path)
1589 throws LibGuestFSException
1592 throw new LibGuestFSException ("aug_ls: handle is closed");
1593 return _aug_ls (g, path);
1595 private native String[] _aug_ls (long g, String path)
1596 throws LibGuestFSException;
1601 * Remove the single file "path".
1603 * @throws LibGuestFSException
1605 public void rm (String path)
1606 throws LibGuestFSException
1609 throw new LibGuestFSException ("rm: handle is closed");
1612 private native void _rm (long g, String path)
1613 throws LibGuestFSException;
1616 * remove a directory
1618 * Remove the single directory "path".
1620 * @throws LibGuestFSException
1622 public void rmdir (String path)
1623 throws LibGuestFSException
1626 throw new LibGuestFSException ("rmdir: handle is closed");
1629 private native void _rmdir (long g, String path)
1630 throws LibGuestFSException;
1633 * remove a file or directory recursively
1635 * Remove the file or directory "path", recursively
1636 * removing the contents if its a directory. This is like
1637 * the "rm -rf" shell command.
1639 * @throws LibGuestFSException
1641 public void rm_rf (String path)
1642 throws LibGuestFSException
1645 throw new LibGuestFSException ("rm_rf: handle is closed");
1648 private native void _rm_rf (long g, String path)
1649 throws LibGuestFSException;
1652 * create a directory
1654 * Create a directory named "path".
1656 * @throws LibGuestFSException
1658 public void mkdir (String path)
1659 throws LibGuestFSException
1662 throw new LibGuestFSException ("mkdir: handle is closed");
1665 private native void _mkdir (long g, String path)
1666 throws LibGuestFSException;
1669 * create a directory and parents
1671 * Create a directory named "path", creating any parent
1672 * directories as necessary. This is like the "mkdir -p"
1675 * @throws LibGuestFSException
1677 public void mkdir_p (String path)
1678 throws LibGuestFSException
1681 throw new LibGuestFSException ("mkdir_p: handle is closed");
1684 private native void _mkdir_p (long g, String path)
1685 throws LibGuestFSException;
1690 * Change the mode (permissions) of "path" to "mode". Only
1691 * numeric modes are supported.
1693 * @throws LibGuestFSException
1695 public void chmod (int mode, String path)
1696 throws LibGuestFSException
1699 throw new LibGuestFSException ("chmod: handle is closed");
1700 _chmod (g, mode, path);
1702 private native void _chmod (long g, int mode, String path)
1703 throws LibGuestFSException;
1706 * change file owner and group
1708 * Change the file owner to "owner" and group to "group".
1710 * Only numeric uid and gid are supported. If you want to
1711 * use names, you will need to locate and parse the
1712 * password file yourself (Augeas support makes this
1715 * @throws LibGuestFSException
1717 public void chown (int owner, int group, String path)
1718 throws LibGuestFSException
1721 throw new LibGuestFSException ("chown: handle is closed");
1722 _chown (g, owner, group, path);
1724 private native void _chown (long g, int owner, int group, String path)
1725 throws LibGuestFSException;
1728 * test if file or directory exists
1730 * This returns "true" if and only if there is a file,
1731 * directory (or anything) with the given "path" name.
1733 * See also "g.is_file", "g.is_dir", "g.stat".
1735 * @throws LibGuestFSException
1737 public boolean exists (String path)
1738 throws LibGuestFSException
1741 throw new LibGuestFSException ("exists: handle is closed");
1742 return _exists (g, path);
1744 private native boolean _exists (long g, String path)
1745 throws LibGuestFSException;
1748 * test if file exists
1750 * This returns "true" if and only if there is a file with
1751 * the given "path" name. Note that it returns false for
1752 * other objects like directories.
1754 * See also "g.stat".
1756 * @throws LibGuestFSException
1758 public boolean is_file (String path)
1759 throws LibGuestFSException
1762 throw new LibGuestFSException ("is_file: handle is closed");
1763 return _is_file (g, path);
1765 private native boolean _is_file (long g, String path)
1766 throws LibGuestFSException;
1769 * test if file exists
1771 * This returns "true" if and only if there is a directory
1772 * with the given "path" name. Note that it returns false
1773 * for other objects like files.
1775 * See also "g.stat".
1777 * @throws LibGuestFSException
1779 public boolean is_dir (String path)
1780 throws LibGuestFSException
1783 throw new LibGuestFSException ("is_dir: handle is closed");
1784 return _is_dir (g, path);
1786 private native boolean _is_dir (long g, String path)
1787 throws LibGuestFSException;
1790 * create an LVM physical volume
1792 * This creates an LVM physical volume on the named
1793 * "device", where "device" should usually be a partition
1794 * name such as "/dev/sda1".
1796 * @throws LibGuestFSException
1798 public void pvcreate (String device)
1799 throws LibGuestFSException
1802 throw new LibGuestFSException ("pvcreate: handle is closed");
1803 _pvcreate (g, device);
1805 private native void _pvcreate (long g, String device)
1806 throws LibGuestFSException;
1809 * create an LVM volume group
1811 * This creates an LVM volume group called "volgroup" from
1812 * the non-empty list of physical volumes "physvols".
1814 * @throws LibGuestFSException
1816 public void vgcreate (String volgroup, String[] physvols)
1817 throws LibGuestFSException
1820 throw new LibGuestFSException ("vgcreate: handle is closed");
1821 _vgcreate (g, volgroup, physvols);
1823 private native void _vgcreate (long g, String volgroup, String[] physvols)
1824 throws LibGuestFSException;
1827 * create an LVM volume group
1829 * This creates an LVM volume group called "logvol" on the
1830 * volume group "volgroup", with "size" megabytes.
1832 * @throws LibGuestFSException
1834 public void lvcreate (String logvol, String volgroup, int mbytes)
1835 throws LibGuestFSException
1838 throw new LibGuestFSException ("lvcreate: handle is closed");
1839 _lvcreate (g, logvol, volgroup, mbytes);
1841 private native void _lvcreate (long g, String logvol, String volgroup, int mbytes)
1842 throws LibGuestFSException;
1847 * This creates a filesystem on "device" (usually a
1848 * partition or LVM logical volume). The filesystem type is
1849 * "fstype", for example "ext3".
1851 * @throws LibGuestFSException
1853 public void mkfs (String fstype, String device)
1854 throws LibGuestFSException
1857 throw new LibGuestFSException ("mkfs: handle is closed");
1858 _mkfs (g, fstype, device);
1860 private native void _mkfs (long g, String fstype, String device)
1861 throws LibGuestFSException;
1864 * create partitions on a block device
1866 * This is a direct interface to the sfdisk(8) program for
1867 * creating partitions on block devices.
1869 * "device" should be a block device, for example
1872 * "cyls", "heads" and "sectors" are the number of
1873 * cylinders, heads and sectors on the device, which are
1874 * passed directly to sfdisk as the *-C*, *-H* and *-S*
1875 * parameters. If you pass 0 for any of these, then the
1876 * corresponding parameter is omitted. Usually for 'large'
1877 * disks, you can just pass 0 for these, but for small
1878 * (floppy-sized) disks, sfdisk (or rather, the kernel)
1879 * cannot work out the right geometry and you will need to
1882 * "lines" is a list of lines that we feed to "sfdisk". For
1883 * more information refer to the sfdisk(8) manpage.
1885 * To create a single partition occupying the whole disk,
1886 * you would pass "lines" as a single element list, when
1887 * the single element being the string "," (comma).
1889 * See also: "g.sfdisk_l", "g.sfdisk_N"
1891 * This command is dangerous. Without careful use you can
1892 * easily destroy all your data.
1894 * @throws LibGuestFSException
1896 public void sfdisk (String device, int cyls, int heads, int sectors, String[] lines)
1897 throws LibGuestFSException
1900 throw new LibGuestFSException ("sfdisk: handle is closed");
1901 _sfdisk (g, device, cyls, heads, sectors, lines);
1903 private native void _sfdisk (long g, String device, int cyls, int heads, int sectors, String[] lines)
1904 throws LibGuestFSException;
1909 * This call creates a file called "path". The contents of
1910 * the file is the string "content" (which can contain any
1911 * 8 bit data), with length "size".
1913 * As a special case, if "size" is 0 then the length is
1914 * calculated using "strlen" (so in this case the content
1915 * cannot contain embedded ASCII NULs).
1917 * *NB.* Owing to a bug, writing content containing ASCII
1918 * NUL characters does *not* work, even if the length is
1919 * specified. We hope to resolve this bug in a future
1920 * version. In the meantime use "g.upload".
1922 * Because of the message protocol, there is a transfer
1923 * limit of somewhere between 2MB and 4MB. To transfer
1924 * large files you should use FTP.
1926 * @throws LibGuestFSException
1928 public void write_file (String path, String content, int size)
1929 throws LibGuestFSException
1932 throw new LibGuestFSException ("write_file: handle is closed");
1933 _write_file (g, path, content, size);
1935 private native void _write_file (long g, String path, String content, int size)
1936 throws LibGuestFSException;
1939 * unmount a filesystem
1941 * This unmounts the given filesystem. The filesystem may
1942 * be specified either by its mountpoint (path) or the
1943 * device which contains the filesystem.
1945 * @throws LibGuestFSException
1947 public void umount (String pathordevice)
1948 throws LibGuestFSException
1951 throw new LibGuestFSException ("umount: handle is closed");
1952 _umount (g, pathordevice);
1954 private native void _umount (long g, String pathordevice)
1955 throws LibGuestFSException;
1958 * show mounted filesystems
1960 * This returns the list of currently mounted filesystems.
1961 * It returns the list of devices (eg. "/dev/sda1",
1964 * Some internal mounts are not shown.
1966 * @throws LibGuestFSException
1968 public String[] mounts ()
1969 throws LibGuestFSException
1972 throw new LibGuestFSException ("mounts: handle is closed");
1975 private native String[] _mounts (long g)
1976 throws LibGuestFSException;
1979 * unmount all filesystems
1981 * This unmounts all mounted filesystems.
1983 * Some internal mounts are not unmounted by this call.
1985 * @throws LibGuestFSException
1987 public void umount_all ()
1988 throws LibGuestFSException
1991 throw new LibGuestFSException ("umount_all: handle is closed");
1994 private native void _umount_all (long g)
1995 throws LibGuestFSException;
1998 * remove all LVM LVs, VGs and PVs
2000 * This command removes all LVM logical volumes, volume
2001 * groups and physical volumes.
2003 * This command is dangerous. Without careful use you can
2004 * easily destroy all your data.
2006 * @throws LibGuestFSException
2008 public void lvm_remove_all ()
2009 throws LibGuestFSException
2012 throw new LibGuestFSException ("lvm_remove_all: handle is closed");
2013 _lvm_remove_all (g);
2015 private native void _lvm_remove_all (long g)
2016 throws LibGuestFSException;
2019 * determine file type
2021 * This call uses the standard file(1) command to determine
2022 * the type or contents of the file. This also works on
2023 * devices, for example to find out whether a partition
2024 * contains a filesystem.
2026 * The exact command which runs is "file -bsL path". Note
2027 * in particular that the filename is not prepended to the
2028 * output (the "-b" option).
2030 * @throws LibGuestFSException
2032 public String file (String path)
2033 throws LibGuestFSException
2036 throw new LibGuestFSException ("file: handle is closed");
2037 return _file (g, path);
2039 private native String _file (long g, String path)
2040 throws LibGuestFSException;
2043 * run a command from the guest filesystem
2045 * This call runs a command from the guest filesystem. The
2046 * filesystem must be mounted, and must contain a
2047 * compatible operating system (ie. something Linux, with
2048 * the same or compatible processor architecture).
2050 * The single parameter is an argv-style list of arguments.
2051 * The first element is the name of the program to run.
2052 * Subsequent elements are parameters. The list must be
2053 * non-empty (ie. must contain a program name). Note that
2054 * the command runs directly, and is *not* invoked via the
2055 * shell (see "g.sh").
2057 * The return value is anything printed to *stdout* by the
2060 * If the command returns a non-zero exit status, then this
2061 * function returns an error message. The error message
2062 * string is the content of *stderr* from the command.
2064 * The $PATH environment variable will contain at least
2065 * "/usr/bin" and "/bin". If you require a program from
2066 * another location, you should provide the full path in
2067 * the first parameter.
2069 * Shared libraries and data files required by the program
2070 * must be available on filesystems which are mounted in
2071 * the correct places. It is the caller's responsibility to
2072 * ensure all filesystems that are needed are mounted at
2073 * the right locations.
2075 * Because of the message protocol, there is a transfer
2076 * limit of somewhere between 2MB and 4MB. To transfer
2077 * large files you should use FTP.
2079 * @throws LibGuestFSException
2081 public String command (String[] arguments)
2082 throws LibGuestFSException
2085 throw new LibGuestFSException ("command: handle is closed");
2086 return _command (g, arguments);
2088 private native String _command (long g, String[] arguments)
2089 throws LibGuestFSException;
2092 * run a command, returning lines
2094 * This is the same as "g.command", but splits the result
2095 * into a list of lines.
2097 * See also: "g.sh_lines"
2099 * Because of the message protocol, there is a transfer
2100 * limit of somewhere between 2MB and 4MB. To transfer
2101 * large files you should use FTP.
2103 * @throws LibGuestFSException
2105 public String[] command_lines (String[] arguments)
2106 throws LibGuestFSException
2109 throw new LibGuestFSException ("command_lines: handle is closed");
2110 return _command_lines (g, arguments);
2112 private native String[] _command_lines (long g, String[] arguments)
2113 throws LibGuestFSException;
2116 * get file information
2118 * Returns file information for the given "path".
2120 * This is the same as the stat(2) system call.
2122 * @throws LibGuestFSException
2124 public Stat stat (String path)
2125 throws LibGuestFSException
2128 throw new LibGuestFSException ("stat: handle is closed");
2129 return _stat (g, path);
2131 private native Stat _stat (long g, String path)
2132 throws LibGuestFSException;
2135 * get file information for a symbolic link
2137 * Returns file information for the given "path".
2139 * This is the same as "g.stat" except that if "path" is a
2140 * symbolic link, then the link is stat-ed, not the file it
2143 * This is the same as the lstat(2) system call.
2145 * @throws LibGuestFSException
2147 public Stat lstat (String path)
2148 throws LibGuestFSException
2151 throw new LibGuestFSException ("lstat: handle is closed");
2152 return _lstat (g, path);
2154 private native Stat _lstat (long g, String path)
2155 throws LibGuestFSException;
2158 * get file system statistics
2160 * Returns file system statistics for any mounted file
2161 * system. "path" should be a file or directory in the
2162 * mounted file system (typically it is the mount point
2163 * itself, but it doesn't need to be).
2165 * This is the same as the statvfs(2) system call.
2167 * @throws LibGuestFSException
2169 public StatVFS statvfs (String path)
2170 throws LibGuestFSException
2173 throw new LibGuestFSException ("statvfs: handle is closed");
2174 return _statvfs (g, path);
2176 private native StatVFS _statvfs (long g, String path)
2177 throws LibGuestFSException;
2180 * get ext2/ext3/ext4 superblock details
2182 * This returns the contents of the ext2, ext3 or ext4
2183 * filesystem superblock on "device".
2185 * It is the same as running "tune2fs -l device". See
2186 * tune2fs(8) manpage for more details. The list of fields
2187 * returned isn't clearly defined, and depends on both the
2188 * version of "tune2fs" that libguestfs was built against,
2189 * and the filesystem itself.
2191 * @throws LibGuestFSException
2193 public HashMap<String,String> tune2fs_l (String device)
2194 throws LibGuestFSException
2197 throw new LibGuestFSException ("tune2fs_l: handle is closed");
2198 return _tune2fs_l (g, device);
2200 private native HashMap<String,String> _tune2fs_l (long g, String device)
2201 throws LibGuestFSException;
2204 * set block device to read-only
2206 * Sets the block device named "device" to read-only.
2208 * This uses the blockdev(8) command.
2210 * @throws LibGuestFSException
2212 public void blockdev_setro (String device)
2213 throws LibGuestFSException
2216 throw new LibGuestFSException ("blockdev_setro: handle is closed");
2217 _blockdev_setro (g, device);
2219 private native void _blockdev_setro (long g, String device)
2220 throws LibGuestFSException;
2223 * set block device to read-write
2225 * Sets the block device named "device" to read-write.
2227 * This uses the blockdev(8) command.
2229 * @throws LibGuestFSException
2231 public void blockdev_setrw (String device)
2232 throws LibGuestFSException
2235 throw new LibGuestFSException ("blockdev_setrw: handle is closed");
2236 _blockdev_setrw (g, device);
2238 private native void _blockdev_setrw (long g, String device)
2239 throws LibGuestFSException;
2242 * is block device set to read-only
2244 * Returns a boolean indicating if the block device is
2245 * read-only (true if read-only, false if not).
2247 * This uses the blockdev(8) command.
2249 * @throws LibGuestFSException
2251 public boolean blockdev_getro (String device)
2252 throws LibGuestFSException
2255 throw new LibGuestFSException ("blockdev_getro: handle is closed");
2256 return _blockdev_getro (g, device);
2258 private native boolean _blockdev_getro (long g, String device)
2259 throws LibGuestFSException;
2262 * get sectorsize of block device
2264 * This returns the size of sectors on a block device.
2265 * Usually 512, but can be larger for modern devices.
2267 * (Note, this is not the size in sectors, use
2268 * "g.blockdev_getsz" for that).
2270 * This uses the blockdev(8) command.
2272 * @throws LibGuestFSException
2274 public int blockdev_getss (String device)
2275 throws LibGuestFSException
2278 throw new LibGuestFSException ("blockdev_getss: handle is closed");
2279 return _blockdev_getss (g, device);
2281 private native int _blockdev_getss (long g, String device)
2282 throws LibGuestFSException;
2285 * get blocksize of block device
2287 * This returns the block size of a device.
2289 * (Note this is different from both *size in blocks* and
2290 * *filesystem block size*).
2292 * This uses the blockdev(8) command.
2294 * @throws LibGuestFSException
2296 public int blockdev_getbsz (String device)
2297 throws LibGuestFSException
2300 throw new LibGuestFSException ("blockdev_getbsz: handle is closed");
2301 return _blockdev_getbsz (g, device);
2303 private native int _blockdev_getbsz (long g, String device)
2304 throws LibGuestFSException;
2307 * set blocksize of block device
2309 * This sets the block size of a device.
2311 * (Note this is different from both *size in blocks* and
2312 * *filesystem block size*).
2314 * This uses the blockdev(8) command.
2316 * @throws LibGuestFSException
2318 public void blockdev_setbsz (String device, int blocksize)
2319 throws LibGuestFSException
2322 throw new LibGuestFSException ("blockdev_setbsz: handle is closed");
2323 _blockdev_setbsz (g, device, blocksize);
2325 private native void _blockdev_setbsz (long g, String device, int blocksize)
2326 throws LibGuestFSException;
2329 * get total size of device in 512-byte sectors
2331 * This returns the size of the device in units of 512-byte
2332 * sectors (even if the sectorsize isn't 512 bytes ...
2335 * See also "g.blockdev_getss" for the real sector size of
2336 * the device, and "g.blockdev_getsize64" for the more
2337 * useful *size in bytes*.
2339 * This uses the blockdev(8) command.
2341 * @throws LibGuestFSException
2343 public long blockdev_getsz (String device)
2344 throws LibGuestFSException
2347 throw new LibGuestFSException ("blockdev_getsz: handle is closed");
2348 return _blockdev_getsz (g, device);
2350 private native long _blockdev_getsz (long g, String device)
2351 throws LibGuestFSException;
2354 * get total size of device in bytes
2356 * This returns the size of the device in bytes.
2358 * See also "g.blockdev_getsz".
2360 * This uses the blockdev(8) command.
2362 * @throws LibGuestFSException
2364 public long blockdev_getsize64 (String device)
2365 throws LibGuestFSException
2368 throw new LibGuestFSException ("blockdev_getsize64: handle is closed");
2369 return _blockdev_getsize64 (g, device);
2371 private native long _blockdev_getsize64 (long g, String device)
2372 throws LibGuestFSException;
2375 * flush device buffers
2377 * This tells the kernel to flush internal buffers
2378 * associated with "device".
2380 * This uses the blockdev(8) command.
2382 * @throws LibGuestFSException
2384 public void blockdev_flushbufs (String device)
2385 throws LibGuestFSException
2388 throw new LibGuestFSException ("blockdev_flushbufs: handle is closed");
2389 _blockdev_flushbufs (g, device);
2391 private native void _blockdev_flushbufs (long g, String device)
2392 throws LibGuestFSException;
2395 * reread partition table
2397 * Reread the partition table on "device".
2399 * This uses the blockdev(8) command.
2401 * @throws LibGuestFSException
2403 public void blockdev_rereadpt (String device)
2404 throws LibGuestFSException
2407 throw new LibGuestFSException ("blockdev_rereadpt: handle is closed");
2408 _blockdev_rereadpt (g, device);
2410 private native void _blockdev_rereadpt (long g, String device)
2411 throws LibGuestFSException;
2414 * upload a file from the local machine
2416 * Upload local file "filename" to "remotefilename" on the
2419 * "filename" can also be a named pipe.
2421 * See also "g.download".
2423 * @throws LibGuestFSException
2425 public void upload (String filename, String remotefilename)
2426 throws LibGuestFSException
2429 throw new LibGuestFSException ("upload: handle is closed");
2430 _upload (g, filename, remotefilename);
2432 private native void _upload (long g, String filename, String remotefilename)
2433 throws LibGuestFSException;
2436 * download a file to the local machine
2438 * Download file "remotefilename" and save it as "filename"
2439 * on the local machine.
2441 * "filename" can also be a named pipe.
2443 * See also "g.upload", "g.cat".
2445 * @throws LibGuestFSException
2447 public void download (String remotefilename, String filename)
2448 throws LibGuestFSException
2451 throw new LibGuestFSException ("download: handle is closed");
2452 _download (g, remotefilename, filename);
2454 private native void _download (long g, String remotefilename, String filename)
2455 throws LibGuestFSException;
2458 * compute MD5, SHAx or CRC checksum of file
2460 * This call computes the MD5, SHAx or CRC checksum of the
2461 * file named "path".
2463 * The type of checksum to compute is given by the
2464 * "csumtype" parameter which must have one of the
2468 * Compute the cyclic redundancy check (CRC) specified
2469 * by POSIX for the "cksum" command.
2472 * Compute the MD5 hash (using the "md5sum" program).
2475 * Compute the SHA1 hash (using the "sha1sum" program).
2478 * Compute the SHA224 hash (using the "sha224sum"
2482 * Compute the SHA256 hash (using the "sha256sum"
2486 * Compute the SHA384 hash (using the "sha384sum"
2490 * Compute the SHA512 hash (using the "sha512sum"
2493 * The checksum is returned as a printable string.
2495 * @throws LibGuestFSException
2497 public String checksum (String csumtype, String path)
2498 throws LibGuestFSException
2501 throw new LibGuestFSException ("checksum: handle is closed");
2502 return _checksum (g, csumtype, path);
2504 private native String _checksum (long g, String csumtype, String path)
2505 throws LibGuestFSException;
2508 * unpack tarfile to directory
2510 * This command uploads and unpacks local file "tarfile"
2511 * (an *uncompressed* tar file) into "directory".
2513 * To upload a compressed tarball, use "g.tgz_in".
2515 * @throws LibGuestFSException
2517 public void tar_in (String tarfile, String directory)
2518 throws LibGuestFSException
2521 throw new LibGuestFSException ("tar_in: handle is closed");
2522 _tar_in (g, tarfile, directory);
2524 private native void _tar_in (long g, String tarfile, String directory)
2525 throws LibGuestFSException;
2528 * pack directory into tarfile
2530 * This command packs the contents of "directory" and
2531 * downloads it to local file "tarfile".
2533 * To download a compressed tarball, use "g.tgz_out".
2535 * @throws LibGuestFSException
2537 public void tar_out (String directory, String tarfile)
2538 throws LibGuestFSException
2541 throw new LibGuestFSException ("tar_out: handle is closed");
2542 _tar_out (g, directory, tarfile);
2544 private native void _tar_out (long g, String directory, String tarfile)
2545 throws LibGuestFSException;
2548 * unpack compressed tarball to directory
2550 * This command uploads and unpacks local file "tarball" (a
2551 * *gzip compressed* tar file) into "directory".
2553 * To upload an uncompressed tarball, use "g.tar_in".
2555 * @throws LibGuestFSException
2557 public void tgz_in (String tarball, String directory)
2558 throws LibGuestFSException
2561 throw new LibGuestFSException ("tgz_in: handle is closed");
2562 _tgz_in (g, tarball, directory);
2564 private native void _tgz_in (long g, String tarball, String directory)
2565 throws LibGuestFSException;
2568 * pack directory into compressed tarball
2570 * This command packs the contents of "directory" and
2571 * downloads it to local file "tarball".
2573 * To download an uncompressed tarball, use "g.tar_out".
2575 * @throws LibGuestFSException
2577 public void tgz_out (String directory, String tarball)
2578 throws LibGuestFSException
2581 throw new LibGuestFSException ("tgz_out: handle is closed");
2582 _tgz_out (g, directory, tarball);
2584 private native void _tgz_out (long g, String directory, String tarball)
2585 throws LibGuestFSException;
2588 * mount a guest disk, read-only
2590 * This is the same as the "g.mount" command, but it mounts
2591 * the filesystem with the read-only (*-o ro*) flag.
2593 * @throws LibGuestFSException
2595 public void mount_ro (String device, String mountpoint)
2596 throws LibGuestFSException
2599 throw new LibGuestFSException ("mount_ro: handle is closed");
2600 _mount_ro (g, device, mountpoint);
2602 private native void _mount_ro (long g, String device, String mountpoint)
2603 throws LibGuestFSException;
2606 * mount a guest disk with mount options
2608 * This is the same as the "g.mount" command, but it allows
2609 * you to set the mount options as for the mount(8) *-o*
2612 * @throws LibGuestFSException
2614 public void mount_options (String options, String device, String mountpoint)
2615 throws LibGuestFSException
2618 throw new LibGuestFSException ("mount_options: handle is closed");
2619 _mount_options (g, options, device, mountpoint);
2621 private native void _mount_options (long g, String options, String device, String mountpoint)
2622 throws LibGuestFSException;
2625 * mount a guest disk with mount options and vfstype
2627 * This is the same as the "g.mount" command, but it allows
2628 * you to set both the mount options and the vfstype as for
2629 * the mount(8) *-o* and *-t* flags.
2631 * @throws LibGuestFSException
2633 public void mount_vfs (String options, String vfstype, String device, String mountpoint)
2634 throws LibGuestFSException
2637 throw new LibGuestFSException ("mount_vfs: handle is closed");
2638 _mount_vfs (g, options, vfstype, device, mountpoint);
2640 private native void _mount_vfs (long g, String options, String vfstype, String device, String mountpoint)
2641 throws LibGuestFSException;
2644 * debugging and internals
2646 * The "g.debug" command exposes some internals of
2647 * "guestfsd" (the guestfs daemon) that runs inside the
2650 * There is no comprehensive help for this command. You
2651 * have to look at the file "daemon/debug.c" in the
2652 * libguestfs source to find out what you can do.
2654 * @throws LibGuestFSException
2656 public String debug (String subcmd, String[] extraargs)
2657 throws LibGuestFSException
2660 throw new LibGuestFSException ("debug: handle is closed");
2661 return _debug (g, subcmd, extraargs);
2663 private native String _debug (long g, String subcmd, String[] extraargs)
2664 throws LibGuestFSException;
2667 * remove an LVM logical volume
2669 * Remove an LVM logical volume "device", where "device" is
2670 * the path to the LV, such as "/dev/VG/LV".
2672 * You can also remove all LVs in a volume group by
2673 * specifying the VG name, "/dev/VG".
2675 * @throws LibGuestFSException
2677 public void lvremove (String device)
2678 throws LibGuestFSException
2681 throw new LibGuestFSException ("lvremove: handle is closed");
2682 _lvremove (g, device);
2684 private native void _lvremove (long g, String device)
2685 throws LibGuestFSException;
2688 * remove an LVM volume group
2690 * Remove an LVM volume group "vgname", (for example "VG").
2692 * This also forcibly removes all logical volumes in the
2693 * volume group (if any).
2695 * @throws LibGuestFSException
2697 public void vgremove (String vgname)
2698 throws LibGuestFSException
2701 throw new LibGuestFSException ("vgremove: handle is closed");
2702 _vgremove (g, vgname);
2704 private native void _vgremove (long g, String vgname)
2705 throws LibGuestFSException;
2708 * remove an LVM physical volume
2710 * This wipes a physical volume "device" so that LVM will
2711 * no longer recognise it.
2713 * The implementation uses the "pvremove" command which
2714 * refuses to wipe physical volumes that contain any volume
2715 * groups, so you have to remove those first.
2717 * @throws LibGuestFSException
2719 public void pvremove (String device)
2720 throws LibGuestFSException
2723 throw new LibGuestFSException ("pvremove: handle is closed");
2724 _pvremove (g, device);
2726 private native void _pvremove (long g, String device)
2727 throws LibGuestFSException;
2730 * set the ext2/3/4 filesystem label
2732 * This sets the ext2/3/4 filesystem label of the
2733 * filesystem on "device" to "label". Filesystem labels are
2734 * limited to 16 characters.
2736 * You can use either "g.tune2fs_l" or "g.get_e2label" to
2737 * return the existing label on a filesystem.
2739 * @throws LibGuestFSException
2741 public void set_e2label (String device, String label)
2742 throws LibGuestFSException
2745 throw new LibGuestFSException ("set_e2label: handle is closed");
2746 _set_e2label (g, device, label);
2748 private native void _set_e2label (long g, String device, String label)
2749 throws LibGuestFSException;
2752 * get the ext2/3/4 filesystem label
2754 * This returns the ext2/3/4 filesystem label of the
2755 * filesystem on "device".
2757 * @throws LibGuestFSException
2759 public String get_e2label (String device)
2760 throws LibGuestFSException
2763 throw new LibGuestFSException ("get_e2label: handle is closed");
2764 return _get_e2label (g, device);
2766 private native String _get_e2label (long g, String device)
2767 throws LibGuestFSException;
2770 * set the ext2/3/4 filesystem UUID
2772 * This sets the ext2/3/4 filesystem UUID of the filesystem
2773 * on "device" to "uuid". The format of the UUID and
2774 * alternatives such as "clear", "random" and "time" are
2775 * described in the tune2fs(8) manpage.
2777 * You can use either "g.tune2fs_l" or "g.get_e2uuid" to
2778 * return the existing UUID of a filesystem.
2780 * @throws LibGuestFSException
2782 public void set_e2uuid (String device, String uuid)
2783 throws LibGuestFSException
2786 throw new LibGuestFSException ("set_e2uuid: handle is closed");
2787 _set_e2uuid (g, device, uuid);
2789 private native void _set_e2uuid (long g, String device, String uuid)
2790 throws LibGuestFSException;
2793 * get the ext2/3/4 filesystem UUID
2795 * This returns the ext2/3/4 filesystem UUID of the
2796 * filesystem on "device".
2798 * @throws LibGuestFSException
2800 public String get_e2uuid (String device)
2801 throws LibGuestFSException
2804 throw new LibGuestFSException ("get_e2uuid: handle is closed");
2805 return _get_e2uuid (g, device);
2807 private native String _get_e2uuid (long g, String device)
2808 throws LibGuestFSException;
2811 * run the filesystem checker
2813 * This runs the filesystem checker (fsck) on "device"
2814 * which should have filesystem type "fstype".
2816 * The returned integer is the status. See fsck(8) for the
2817 * list of status codes from "fsck".
2821 * * Multiple status codes can be summed together.
2823 * * A non-zero return code can mean "success", for
2824 * example if errors have been corrected on the
2827 * * Checking or repairing NTFS volumes is not supported
2830 * This command is entirely equivalent to running "fsck -a
2831 * -t fstype device".
2833 * @throws LibGuestFSException
2835 public int fsck (String fstype, String device)
2836 throws LibGuestFSException
2839 throw new LibGuestFSException ("fsck: handle is closed");
2840 return _fsck (g, fstype, device);
2842 private native int _fsck (long g, String fstype, String device)
2843 throws LibGuestFSException;
2846 * write zeroes to the device
2848 * This command writes zeroes over the first few blocks of
2851 * How many blocks are zeroed isn't specified (but it's
2852 * *not* enough to securely wipe the device). It should be
2853 * sufficient to remove any partition tables, filesystem
2854 * superblocks and so on.
2856 * See also: "g.scrub_device".
2858 * @throws LibGuestFSException
2860 public void zero (String device)
2861 throws LibGuestFSException
2864 throw new LibGuestFSException ("zero: handle is closed");
2867 private native void _zero (long g, String device)
2868 throws LibGuestFSException;
2873 * This command installs GRUB (the Grand Unified
2874 * Bootloader) on "device", with the root directory being
2877 * @throws LibGuestFSException
2879 public void grub_install (String root, String device)
2880 throws LibGuestFSException
2883 throw new LibGuestFSException ("grub_install: handle is closed");
2884 _grub_install (g, root, device);
2886 private native void _grub_install (long g, String root, String device)
2887 throws LibGuestFSException;
2892 * This copies a file from "src" to "dest" where "dest" is
2893 * either a destination filename or destination directory.
2895 * @throws LibGuestFSException
2897 public void cp (String src, String dest)
2898 throws LibGuestFSException
2901 throw new LibGuestFSException ("cp: handle is closed");
2904 private native void _cp (long g, String src, String dest)
2905 throws LibGuestFSException;
2908 * copy a file or directory recursively
2910 * This copies a file or directory from "src" to "dest"
2911 * recursively using the "cp -a" command.
2913 * @throws LibGuestFSException
2915 public void cp_a (String src, String dest)
2916 throws LibGuestFSException
2919 throw new LibGuestFSException ("cp_a: handle is closed");
2920 _cp_a (g, src, dest);
2922 private native void _cp_a (long g, String src, String dest)
2923 throws LibGuestFSException;
2928 * This moves a file from "src" to "dest" where "dest" is
2929 * either a destination filename or destination directory.
2931 * @throws LibGuestFSException
2933 public void mv (String src, String dest)
2934 throws LibGuestFSException
2937 throw new LibGuestFSException ("mv: handle is closed");
2940 private native void _mv (long g, String src, String dest)
2941 throws LibGuestFSException;
2944 * drop kernel page cache, dentries and inodes
2946 * This instructs the guest kernel to drop its page cache,
2947 * and/or dentries and inode caches. The parameter
2948 * "whattodrop" tells the kernel what precisely to drop,
2949 * see <http://linux-mm.org/Drop_Caches>
2951 * Setting "whattodrop" to 3 should drop everything.
2953 * This automatically calls sync(2) before the operation,
2954 * so that the maximum guest memory is freed.
2956 * @throws LibGuestFSException
2958 public void drop_caches (int whattodrop)
2959 throws LibGuestFSException
2962 throw new LibGuestFSException ("drop_caches: handle is closed");
2963 _drop_caches (g, whattodrop);
2965 private native void _drop_caches (long g, int whattodrop)
2966 throws LibGuestFSException;
2969 * return kernel messages
2971 * This returns the kernel messages ("dmesg" output) from
2972 * the guest kernel. This is sometimes useful for extended
2973 * debugging of problems.
2975 * Another way to get the same information is to enable
2976 * verbose messages with "g.set_verbose" or by setting the
2977 * environment variable "LIBGUESTFS_DEBUG=1" before running
2980 * @throws LibGuestFSException
2982 public String dmesg ()
2983 throws LibGuestFSException
2986 throw new LibGuestFSException ("dmesg: handle is closed");
2989 private native String _dmesg (long g)
2990 throws LibGuestFSException;
2993 * ping the guest daemon
2995 * This is a test probe into the guestfs daemon running
2996 * inside the qemu subprocess. Calling this function checks
2997 * that the daemon responds to the ping message, without
2998 * affecting the daemon or attached block device(s) in any
3001 * @throws LibGuestFSException
3003 public void ping_daemon ()
3004 throws LibGuestFSException
3007 throw new LibGuestFSException ("ping_daemon: handle is closed");
3010 private native void _ping_daemon (long g)
3011 throws LibGuestFSException;
3014 * test if two files have equal contents
3016 * This compares the two files "file1" and "file2" and
3017 * returns true if their content is exactly equal, or false
3020 * The external cmp(1) program is used for the comparison.
3022 * @throws LibGuestFSException
3024 public boolean equal (String file1, String file2)
3025 throws LibGuestFSException
3028 throw new LibGuestFSException ("equal: handle is closed");
3029 return _equal (g, file1, file2);
3031 private native boolean _equal (long g, String file1, String file2)
3032 throws LibGuestFSException;
3035 * print the printable strings in a file
3037 * This runs the strings(1) command on a file and returns
3038 * the list of printable strings found.
3040 * Because of the message protocol, there is a transfer
3041 * limit of somewhere between 2MB and 4MB. To transfer
3042 * large files you should use FTP.
3044 * @throws LibGuestFSException
3046 public String[] strings (String path)
3047 throws LibGuestFSException
3050 throw new LibGuestFSException ("strings: handle is closed");
3051 return _strings (g, path);
3053 private native String[] _strings (long g, String path)
3054 throws LibGuestFSException;
3057 * print the printable strings in a file
3059 * This is like the "g.strings" command, but allows you to
3060 * specify the encoding.
3062 * See the strings(1) manpage for the full list of
3065 * Commonly useful encodings are "l" (lower case L) which
3066 * will show strings inside Windows/x86 files.
3068 * The returned strings are transcoded to UTF-8.
3070 * Because of the message protocol, there is a transfer
3071 * limit of somewhere between 2MB and 4MB. To transfer
3072 * large files you should use FTP.
3074 * @throws LibGuestFSException
3076 public String[] strings_e (String encoding, String path)
3077 throws LibGuestFSException
3080 throw new LibGuestFSException ("strings_e: handle is closed");
3081 return _strings_e (g, encoding, path);
3083 private native String[] _strings_e (long g, String encoding, String path)
3084 throws LibGuestFSException;
3087 * dump a file in hexadecimal
3089 * This runs "hexdump -C" on the given "path". The result
3090 * is the human-readable, canonical hex dump of the file.
3092 * Because of the message protocol, there is a transfer
3093 * limit of somewhere between 2MB and 4MB. To transfer
3094 * large files you should use FTP.
3096 * @throws LibGuestFSException
3098 public String hexdump (String path)
3099 throws LibGuestFSException
3102 throw new LibGuestFSException ("hexdump: handle is closed");
3103 return _hexdump (g, path);
3105 private native String _hexdump (long g, String path)
3106 throws LibGuestFSException;
3109 * zero unused inodes and disk blocks on ext2/3 filesystem
3111 * This runs the *zerofree* program on "device". This
3112 * program claims to zero unused inodes and disk blocks on
3113 * an ext2/3 filesystem, thus making it possible to
3114 * compress the filesystem more effectively.
3116 * You should not run this program if the filesystem is
3119 * It is possible that using this program can damage the
3120 * filesystem or data on the filesystem.
3122 * @throws LibGuestFSException
3124 public void zerofree (String device)
3125 throws LibGuestFSException
3128 throw new LibGuestFSException ("zerofree: handle is closed");
3129 _zerofree (g, device);
3131 private native void _zerofree (long g, String device)
3132 throws LibGuestFSException;
3135 * resize an LVM physical volume
3137 * This resizes (expands or shrinks) an existing LVM
3138 * physical volume to match the new size of the underlying
3141 * @throws LibGuestFSException
3143 public void pvresize (String device)
3144 throws LibGuestFSException
3147 throw new LibGuestFSException ("pvresize: handle is closed");
3148 _pvresize (g, device);
3150 private native void _pvresize (long g, String device)
3151 throws LibGuestFSException;
3154 * modify a single partition on a block device
3156 * This runs sfdisk(8) option to modify just the single
3157 * partition "n" (note: "n" counts from 1).
3159 * For other parameters, see "g.sfdisk". You should usually
3160 * pass 0 for the cyls/heads/sectors parameters.
3162 * This command is dangerous. Without careful use you can
3163 * easily destroy all your data.
3165 * @throws LibGuestFSException
3167 public void sfdisk_N (String device, int partnum, int cyls, int heads, int sectors, String line)
3168 throws LibGuestFSException
3171 throw new LibGuestFSException ("sfdisk_N: handle is closed");
3172 _sfdisk_N (g, device, partnum, cyls, heads, sectors, line);
3174 private native void _sfdisk_N (long g, String device, int partnum, int cyls, int heads, int sectors, String line)
3175 throws LibGuestFSException;
3178 * display the partition table
3180 * This displays the partition table on "device", in the
3181 * human-readable output of the sfdisk(8) command. It is
3182 * not intended to be parsed.
3184 * @throws LibGuestFSException
3186 public String sfdisk_l (String device)
3187 throws LibGuestFSException
3190 throw new LibGuestFSException ("sfdisk_l: handle is closed");
3191 return _sfdisk_l (g, device);
3193 private native String _sfdisk_l (long g, String device)
3194 throws LibGuestFSException;
3197 * display the kernel geometry
3199 * This displays the kernel's idea of the geometry of
3202 * The result is in human-readable format, and not designed
3205 * @throws LibGuestFSException
3207 public String sfdisk_kernel_geometry (String device)
3208 throws LibGuestFSException
3211 throw new LibGuestFSException ("sfdisk_kernel_geometry: handle is closed");
3212 return _sfdisk_kernel_geometry (g, device);
3214 private native String _sfdisk_kernel_geometry (long g, String device)
3215 throws LibGuestFSException;
3218 * display the disk geometry from the partition table
3220 * This displays the disk geometry of "device" read from
3221 * the partition table. Especially in the case where the
3222 * underlying block device has been resized, this can be
3223 * different from the kernel's idea of the geometry (see
3224 * "g.sfdisk_kernel_geometry").
3226 * The result is in human-readable format, and not designed
3229 * @throws LibGuestFSException
3231 public String sfdisk_disk_geometry (String device)
3232 throws LibGuestFSException
3235 throw new LibGuestFSException ("sfdisk_disk_geometry: handle is closed");
3236 return _sfdisk_disk_geometry (g, device);
3238 private native String _sfdisk_disk_geometry (long g, String device)
3239 throws LibGuestFSException;
3242 * activate or deactivate all volume groups
3244 * This command activates or (if "activate" is false)
3245 * deactivates all logical volumes in all volume groups. If
3246 * activated, then they are made known to the kernel, ie.
3247 * they appear as "/dev/mapper" devices. If deactivated,
3248 * then those devices disappear.
3250 * This command is the same as running "vgchange -a y|n"
3252 * @throws LibGuestFSException
3254 public void vg_activate_all (boolean activate)
3255 throws LibGuestFSException
3258 throw new LibGuestFSException ("vg_activate_all: handle is closed");
3259 _vg_activate_all (g, activate);
3261 private native void _vg_activate_all (long g, boolean activate)
3262 throws LibGuestFSException;
3265 * activate or deactivate some volume groups
3267 * This command activates or (if "activate" is false)
3268 * deactivates all logical volumes in the listed volume
3269 * groups "volgroups". If activated, then they are made
3270 * known to the kernel, ie. they appear as "/dev/mapper"
3271 * devices. If deactivated, then those devices disappear.
3273 * This command is the same as running "vgchange -a y|n
3276 * Note that if "volgroups" is an empty list then all
3277 * volume groups are activated or deactivated.
3279 * @throws LibGuestFSException
3281 public void vg_activate (boolean activate, String[] volgroups)
3282 throws LibGuestFSException
3285 throw new LibGuestFSException ("vg_activate: handle is closed");
3286 _vg_activate (g, activate, volgroups);
3288 private native void _vg_activate (long g, boolean activate, String[] volgroups)
3289 throws LibGuestFSException;
3292 * resize an LVM logical volume
3294 * This resizes (expands or shrinks) an existing LVM
3295 * logical volume to "mbytes". When reducing, data in the
3296 * reduced part is lost.
3298 * @throws LibGuestFSException
3300 public void lvresize (String device, int mbytes)
3301 throws LibGuestFSException
3304 throw new LibGuestFSException ("lvresize: handle is closed");
3305 _lvresize (g, device, mbytes);
3307 private native void _lvresize (long g, String device, int mbytes)
3308 throws LibGuestFSException;
3311 * resize an ext2/ext3 filesystem
3313 * This resizes an ext2 or ext3 filesystem to match the
3314 * size of the underlying device.
3316 * *Note:* It is sometimes required that you run
3317 * "g.e2fsck_f" on the "device" before calling this
3318 * command. For unknown reasons "resize2fs" sometimes gives
3319 * an error about this and sometimes not. In any case, it
3320 * is always safe to call "g.e2fsck_f" before calling this
3323 * @throws LibGuestFSException
3325 public void resize2fs (String device)
3326 throws LibGuestFSException
3329 throw new LibGuestFSException ("resize2fs: handle is closed");
3330 _resize2fs (g, device);
3332 private native void _resize2fs (long g, String device)
3333 throws LibGuestFSException;
3336 * find all files and directories
3338 * This command lists out all files and directories,
3339 * recursively, starting at "directory". It is essentially
3340 * equivalent to running the shell command "find directory
3341 * -print" but some post-processing happens on the output,
3344 * This returns a list of strings *without any prefix*.
3345 * Thus if the directory structure was:
3351 * then the returned list from "g.find" "/tmp" would be 4
3359 * If "directory" is not a directory, then this command
3362 * The returned list is sorted.
3364 * @throws LibGuestFSException
3366 public String[] find (String directory)
3367 throws LibGuestFSException
3370 throw new LibGuestFSException ("find: handle is closed");
3371 return _find (g, directory);
3373 private native String[] _find (long g, String directory)
3374 throws LibGuestFSException;
3377 * check an ext2/ext3 filesystem
3379 * This runs "e2fsck -p -f device", ie. runs the ext2/ext3
3380 * filesystem checker on "device", noninteractively ("-p"),
3381 * even if the filesystem appears to be clean ("-f").
3383 * This command is only needed because of "g.resize2fs"
3384 * (q.v.). Normally you should use "g.fsck".
3386 * @throws LibGuestFSException
3388 public void e2fsck_f (String device)
3389 throws LibGuestFSException
3392 throw new LibGuestFSException ("e2fsck_f: handle is closed");
3393 _e2fsck_f (g, device);
3395 private native void _e2fsck_f (long g, String device)
3396 throws LibGuestFSException;
3399 * sleep for some seconds
3401 * Sleep for "secs" seconds.
3403 * @throws LibGuestFSException
3405 public void sleep (int secs)
3406 throws LibGuestFSException
3409 throw new LibGuestFSException ("sleep: handle is closed");
3412 private native void _sleep (long g, int secs)
3413 throws LibGuestFSException;
3418 * This command runs the ntfs-3g.probe(8) command which
3419 * probes an NTFS "device" for mountability. (Not all NTFS
3420 * volumes can be mounted read-write, and some cannot be
3423 * "rw" is a boolean flag. Set it to true if you want to
3424 * test if the volume can be mounted read-write. Set it to
3425 * false if you want to test if the volume can be mounted
3428 * The return value is an integer which 0 if the operation
3429 * would succeed, or some non-zero value documented in the
3430 * ntfs-3g.probe(8) manual page.
3432 * @throws LibGuestFSException
3434 public int ntfs_3g_probe (boolean rw, String device)
3435 throws LibGuestFSException
3438 throw new LibGuestFSException ("ntfs_3g_probe: handle is closed");
3439 return _ntfs_3g_probe (g, rw, device);
3441 private native int _ntfs_3g_probe (long g, boolean rw, String device)
3442 throws LibGuestFSException;
3445 * run a command via the shell
3447 * This call runs a command from the guest filesystem via
3448 * the guest's "/bin/sh".
3450 * This is like "g.command", but passes the command to:
3452 * /bin/sh -c "command"
3454 * Depending on the guest's shell, this usually results in
3455 * wildcards being expanded, shell expressions being
3456 * interpolated and so on.
3458 * All the provisos about "g.command" apply to this call.
3460 * @throws LibGuestFSException
3462 public String sh (String command)
3463 throws LibGuestFSException
3466 throw new LibGuestFSException ("sh: handle is closed");
3467 return _sh (g, command);
3469 private native String _sh (long g, String command)
3470 throws LibGuestFSException;
3473 * run a command via the shell returning lines
3475 * This is the same as "g.sh", but splits the result into a
3478 * See also: "g.command_lines"
3480 * @throws LibGuestFSException
3482 public String[] sh_lines (String command)
3483 throws LibGuestFSException
3486 throw new LibGuestFSException ("sh_lines: handle is closed");
3487 return _sh_lines (g, command);
3489 private native String[] _sh_lines (long g, String command)
3490 throws LibGuestFSException;
3493 * expand a wildcard path
3495 * This command searches for all the pathnames matching
3496 * "pattern" according to the wildcard expansion rules used
3499 * If no paths match, then this returns an empty list
3500 * (note: not an error).
3502 * It is just a wrapper around the C glob(3) function with
3503 * flags "GLOB_MARK|GLOB_BRACE". See that manual page for
3506 * @throws LibGuestFSException
3508 public String[] glob_expand (String pattern)
3509 throws LibGuestFSException
3512 throw new LibGuestFSException ("glob_expand: handle is closed");
3513 return _glob_expand (g, pattern);
3515 private native String[] _glob_expand (long g, String pattern)
3516 throws LibGuestFSException;
3519 * scrub (securely wipe) a device
3521 * This command writes patterns over "device" to make data
3522 * retrieval more difficult.
3524 * It is an interface to the scrub(1) program. See that
3525 * manual page for more details.
3527 * This command is dangerous. Without careful use you can
3528 * easily destroy all your data.
3530 * @throws LibGuestFSException
3532 public void scrub_device (String device)
3533 throws LibGuestFSException
3536 throw new LibGuestFSException ("scrub_device: handle is closed");
3537 _scrub_device (g, device);
3539 private native void _scrub_device (long g, String device)
3540 throws LibGuestFSException;
3543 * scrub (securely wipe) a file
3545 * This command writes patterns over a file to make data
3546 * retrieval more difficult.
3548 * The file is *removed* after scrubbing.
3550 * It is an interface to the scrub(1) program. See that
3551 * manual page for more details.
3553 * @throws LibGuestFSException
3555 public void scrub_file (String file)
3556 throws LibGuestFSException
3559 throw new LibGuestFSException ("scrub_file: handle is closed");
3560 _scrub_file (g, file);
3562 private native void _scrub_file (long g, String file)
3563 throws LibGuestFSException;
3566 * scrub (securely wipe) free space
3568 * This command creates the directory "dir" and then fills
3569 * it with files until the filesystem is full, and scrubs
3570 * the files as for "g.scrub_file", and deletes them. The
3571 * intention is to scrub any free space on the partition
3574 * It is an interface to the scrub(1) program. See that
3575 * manual page for more details.
3577 * @throws LibGuestFSException
3579 public void scrub_freespace (String dir)
3580 throws LibGuestFSException
3583 throw new LibGuestFSException ("scrub_freespace: handle is closed");
3584 _scrub_freespace (g, dir);
3586 private native void _scrub_freespace (long g, String dir)
3587 throws LibGuestFSException;
3590 * create a temporary directory
3592 * This command creates a temporary directory. The
3593 * "template" parameter should be a full pathname for the
3594 * temporary directory name with the final six characters
3597 * For example: "/tmp/myprogXXXXXX" or
3598 * "/Temp/myprogXXXXXX", the second one being suitable for
3599 * Windows filesystems.
3601 * The name of the temporary directory that was created is
3604 * The temporary directory is created with mode 0700 and is
3607 * The caller is responsible for deleting the temporary
3608 * directory and its contents after use.
3610 * See also: mkdtemp(3)
3612 * @throws LibGuestFSException
3614 public String mkdtemp (String template)
3615 throws LibGuestFSException
3618 throw new LibGuestFSException ("mkdtemp: handle is closed");
3619 return _mkdtemp (g, template);
3621 private native String _mkdtemp (long g, String template)
3622 throws LibGuestFSException;
3625 * count lines in a file
3627 * This command counts the lines in a file, using the "wc
3628 * -l" external command.
3630 * @throws LibGuestFSException
3632 public int wc_l (String path)
3633 throws LibGuestFSException
3636 throw new LibGuestFSException ("wc_l: handle is closed");
3637 return _wc_l (g, path);
3639 private native int _wc_l (long g, String path)
3640 throws LibGuestFSException;
3643 * count words in a file
3645 * This command counts the words in a file, using the "wc
3646 * -w" external command.
3648 * @throws LibGuestFSException
3650 public int wc_w (String path)
3651 throws LibGuestFSException
3654 throw new LibGuestFSException ("wc_w: handle is closed");
3655 return _wc_w (g, path);
3657 private native int _wc_w (long g, String path)
3658 throws LibGuestFSException;
3661 * count characters in a file
3663 * This command counts the characters in a file, using the
3664 * "wc -c" external command.
3666 * @throws LibGuestFSException
3668 public int wc_c (String path)
3669 throws LibGuestFSException
3672 throw new LibGuestFSException ("wc_c: handle is closed");
3673 return _wc_c (g, path);
3675 private native int _wc_c (long g, String path)
3676 throws LibGuestFSException;
3679 * return first 10 lines of a file
3681 * This command returns up to the first 10 lines of a file
3682 * as a list of strings.
3684 * Because of the message protocol, there is a transfer
3685 * limit of somewhere between 2MB and 4MB. To transfer
3686 * large files you should use FTP.
3688 * @throws LibGuestFSException
3690 public String[] head (String path)
3691 throws LibGuestFSException
3694 throw new LibGuestFSException ("head: handle is closed");
3695 return _head (g, path);
3697 private native String[] _head (long g, String path)
3698 throws LibGuestFSException;
3701 * return first N lines of a file
3703 * If the parameter "nrlines" is a positive number, this
3704 * returns the first "nrlines" lines of the file "path".
3706 * If the parameter "nrlines" is a negative number, this
3707 * returns lines from the file "path", excluding the last
3710 * If the parameter "nrlines" is zero, this returns an
3713 * Because of the message protocol, there is a transfer
3714 * limit of somewhere between 2MB and 4MB. To transfer
3715 * large files you should use FTP.
3717 * @throws LibGuestFSException
3719 public String[] head_n (int nrlines, String path)
3720 throws LibGuestFSException
3723 throw new LibGuestFSException ("head_n: handle is closed");
3724 return _head_n (g, nrlines, path);
3726 private native String[] _head_n (long g, int nrlines, String path)
3727 throws LibGuestFSException;
3730 * return last 10 lines of a file
3732 * This command returns up to the last 10 lines of a file
3733 * as a list of strings.
3735 * Because of the message protocol, there is a transfer
3736 * limit of somewhere between 2MB and 4MB. To transfer
3737 * large files you should use FTP.
3739 * @throws LibGuestFSException
3741 public String[] tail (String path)
3742 throws LibGuestFSException
3745 throw new LibGuestFSException ("tail: handle is closed");
3746 return _tail (g, path);
3748 private native String[] _tail (long g, String path)
3749 throws LibGuestFSException;
3752 * return last N lines of a file
3754 * If the parameter "nrlines" is a positive number, this
3755 * returns the last "nrlines" lines of the file "path".
3757 * If the parameter "nrlines" is a negative number, this
3758 * returns lines from the file "path", starting with the
3759 * "-nrlines"th line.
3761 * If the parameter "nrlines" is zero, this returns an
3764 * Because of the message protocol, there is a transfer
3765 * limit of somewhere between 2MB and 4MB. To transfer
3766 * large files you should use FTP.
3768 * @throws LibGuestFSException
3770 public String[] tail_n (int nrlines, String path)
3771 throws LibGuestFSException
3774 throw new LibGuestFSException ("tail_n: handle is closed");
3775 return _tail_n (g, nrlines, path);
3777 private native String[] _tail_n (long g, int nrlines, String path)
3778 throws LibGuestFSException;
3781 * report file system disk space usage
3783 * This command runs the "df" command to report disk space
3786 * This command is mostly useful for interactive sessions.
3787 * It is *not* intended that you try to parse the output
3788 * string. Use "statvfs" from programs.
3790 * @throws LibGuestFSException
3793 throws LibGuestFSException
3796 throw new LibGuestFSException ("df: handle is closed");
3799 private native String _df (long g)
3800 throws LibGuestFSException;
3803 * report file system disk space usage (human readable)
3805 * This command runs the "df -h" command to report disk
3806 * space used in human-readable format.
3808 * This command is mostly useful for interactive sessions.
3809 * It is *not* intended that you try to parse the output
3810 * string. Use "statvfs" from programs.
3812 * @throws LibGuestFSException
3814 public String df_h ()
3815 throws LibGuestFSException
3818 throw new LibGuestFSException ("df_h: handle is closed");
3821 private native String _df_h (long g)
3822 throws LibGuestFSException;
3825 * estimate file space usage
3827 * This command runs the "du -s" command to estimate file
3828 * space usage for "path".
3830 * "path" can be a file or a directory. If "path" is a
3831 * directory then the estimate includes the contents of the
3832 * directory and all subdirectories (recursively).
3834 * The result is the estimated size in *kilobytes* (ie.
3835 * units of 1024 bytes).
3837 * @throws LibGuestFSException
3839 public long du (String path)
3840 throws LibGuestFSException
3843 throw new LibGuestFSException ("du: handle is closed");
3844 return _du (g, path);
3846 private native long _du (long g, String path)
3847 throws LibGuestFSException;
3850 * list files in an initrd
3852 * This command lists out files contained in an initrd.
3854 * The files are listed without any initial "/" character.
3855 * The files are listed in the order they appear (not
3856 * necessarily alphabetical). Directory names are listed as
3859 * Old Linux kernels (2.4 and earlier) used a compressed
3860 * ext2 filesystem as initrd. We *only* support the newer
3861 * initramfs format (compressed cpio files).
3863 * @throws LibGuestFSException
3865 public String[] initrd_list (String path)
3866 throws LibGuestFSException
3869 throw new LibGuestFSException ("initrd_list: handle is closed");
3870 return _initrd_list (g, path);
3872 private native String[] _initrd_list (long g, String path)
3873 throws LibGuestFSException;
3876 * mount a file using the loop device
3878 * This command lets you mount "file" (a filesystem image
3879 * in a file) on a mount point. It is entirely equivalent
3880 * to the command "mount -o loop file mountpoint".
3882 * @throws LibGuestFSException
3884 public void mount_loop (String file, String mountpoint)
3885 throws LibGuestFSException
3888 throw new LibGuestFSException ("mount_loop: handle is closed");
3889 _mount_loop (g, file, mountpoint);
3891 private native void _mount_loop (long g, String file, String mountpoint)
3892 throws LibGuestFSException;
3895 * create a swap partition
3897 * Create a swap partition on "device".
3899 * @throws LibGuestFSException
3901 public void mkswap (String device)
3902 throws LibGuestFSException
3905 throw new LibGuestFSException ("mkswap: handle is closed");
3906 _mkswap (g, device);
3908 private native void _mkswap (long g, String device)
3909 throws LibGuestFSException;
3912 * create a swap partition with a label
3914 * Create a swap partition on "device" with label "label".
3916 * @throws LibGuestFSException
3918 public void mkswap_L (String label, String device)
3919 throws LibGuestFSException
3922 throw new LibGuestFSException ("mkswap_L: handle is closed");
3923 _mkswap_L (g, label, device);
3925 private native void _mkswap_L (long g, String label, String device)
3926 throws LibGuestFSException;
3929 * create a swap partition with an explicit UUID
3931 * Create a swap partition on "device" with UUID "uuid".
3933 * @throws LibGuestFSException
3935 public void mkswap_U (String uuid, String device)
3936 throws LibGuestFSException
3939 throw new LibGuestFSException ("mkswap_U: handle is closed");
3940 _mkswap_U (g, uuid, device);
3942 private native void _mkswap_U (long g, String uuid, String device)
3943 throws LibGuestFSException;
3946 * make block, character or FIFO devices
3948 * This call creates block or character special devices, or
3949 * named pipes (FIFOs).
3951 * The "mode" parameter should be the mode, using the
3952 * standard constants. "devmajor" and "devminor" are the
3953 * device major and minor numbers, only used when creating
3954 * block and character special devices.
3956 * @throws LibGuestFSException
3958 public void mknod (int mode, int devmajor, int devminor, String path)
3959 throws LibGuestFSException
3962 throw new LibGuestFSException ("mknod: handle is closed");
3963 _mknod (g, mode, devmajor, devminor, path);
3965 private native void _mknod (long g, int mode, int devmajor, int devminor, String path)
3966 throws LibGuestFSException;
3969 * make FIFO (named pipe)
3971 * This call creates a FIFO (named pipe) called "path" with
3972 * mode "mode". It is just a convenient wrapper around
3975 * @throws LibGuestFSException
3977 public void mkfifo (int mode, String path)
3978 throws LibGuestFSException
3981 throw new LibGuestFSException ("mkfifo: handle is closed");
3982 _mkfifo (g, mode, path);
3984 private native void _mkfifo (long g, int mode, String path)
3985 throws LibGuestFSException;
3988 * make block device node
3990 * This call creates a block device node called "path" with
3991 * mode "mode" and device major/minor "devmajor" and
3992 * "devminor". It is just a convenient wrapper around
3995 * @throws LibGuestFSException
3997 public void mknod_b (int mode, int devmajor, int devminor, String path)
3998 throws LibGuestFSException
4001 throw new LibGuestFSException ("mknod_b: handle is closed");
4002 _mknod_b (g, mode, devmajor, devminor, path);
4004 private native void _mknod_b (long g, int mode, int devmajor, int devminor, String path)
4005 throws LibGuestFSException;
4008 * make char device node
4010 * This call creates a char device node called "path" with
4011 * mode "mode" and device major/minor "devmajor" and
4012 * "devminor". It is just a convenient wrapper around
4015 * @throws LibGuestFSException
4017 public void mknod_c (int mode, int devmajor, int devminor, String path)
4018 throws LibGuestFSException
4021 throw new LibGuestFSException ("mknod_c: handle is closed");
4022 _mknod_c (g, mode, devmajor, devminor, path);
4024 private native void _mknod_c (long g, int mode, int devmajor, int devminor, String path)
4025 throws LibGuestFSException;
4028 * set file mode creation mask (umask)
4030 * This function sets the mask used for creating new files
4031 * and device nodes to "mask & 0777".
4033 * Typical umask values would be 022 which creates new
4034 * files with permissions like "-rw-r--r--" or
4035 * "-rwxr-xr-x", and 002 which creates new files with
4036 * permissions like "-rw-rw-r--" or "-rwxrwxr-x".
4038 * The default umask is 022. This is important because it
4039 * means that directories and device nodes will be created
4040 * with 0644 or 0755 mode even if you specify 0777.
4042 * See also umask(2), "g.mknod", "g.mkdir".
4044 * This call returns the previous umask.
4046 * @throws LibGuestFSException
4048 public int umask (int mask)
4049 throws LibGuestFSException
4052 throw new LibGuestFSException ("umask: handle is closed");
4053 return _umask (g, mask);
4055 private native int _umask (long g, int mask)
4056 throws LibGuestFSException;
4059 * read directories entries
4061 * This returns the list of directory entries in directory
4064 * All entries in the directory are returned, including "."
4065 * and "..". The entries are *not* sorted, but returned in
4066 * the same order as the underlying filesystem.
4068 * This function is primarily intended for use by programs.
4069 * To get a simple list of names, use "g.ls". To get a
4070 * printable directory for human consumption, use "g.ll".
4072 * @throws LibGuestFSException
4074 public Dirent[] readdir (String dir)
4075 throws LibGuestFSException
4078 throw new LibGuestFSException ("readdir: handle is closed");
4079 return _readdir (g, dir);
4081 private native Dirent[] _readdir (long g, String dir)
4082 throws LibGuestFSException;