eec66977bd35c9d7ce3c20c6f2663371806c0f0e
[libguestfs.git] / guestfs-actions.pod
1 =head2 guestfs_cat
2
3  char *guestfs_cat (guestfs_h *handle,
4                 const char *path);
5
6 Return the contents of the file named C<path>.
7
8 Note that this function cannot correctly handle binary files
9 (specifically, files containing C<\0> character which is treated
10 as end of string).  For those you need to use the C<guestfs_read>
11 function which has a more complex interface.
12
13 This function returns a string or NULL on error.  The caller
14 must free the returned string after use.
15
16 Because of the message protocol, there is a transfer limit 
17 of somewhere between 2MB and 4MB.  To transfer large files you should use
18 FTP.
19
20 =head2 guestfs_ll
21
22  char *guestfs_ll (guestfs_h *handle,
23                 const char *directory);
24
25 List the files in C<directory> (relative to the root directory,
26 there is no cwd) in the format of 'ls -la'.
27
28 This command is mostly useful for interactive sessions.  It
29 is I<not> intended that you try to parse the output string.
30
31 This function returns a string or NULL on error.  The caller
32 must free the returned string after use.
33
34 =head2 guestfs_ls
35
36  char **guestfs_ls (guestfs_h *handle,
37                 const char *directory);
38
39 List the files in C<directory> (relative to the root directory,
40 there is no cwd).  The '.' and '..' entries are not returned, but
41 hidden files are shown.
42
43 This command is mostly useful for interactive sessions.  Programs
44 should probably use C<guestfs_readdir> instead.
45
46 This function returns a NULL-terminated array of strings
47 (like L<environ(3)>), or NULL if there was an error.
48
49 The caller must free the strings I<and> the array after use.
50
51 =head2 guestfs_mount
52
53  int guestfs_mount (guestfs_h *handle,
54                 const char *device,
55                 const char *mountpoint);
56
57 Mount a guest disk at a position in the filesystem.  Block devices
58 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
59 the guest.  If those block devices contain partitions, they will have
60 the usual names (eg. C</dev/sda1>).  Also LVM C</dev/VG/LV>-style
61 names can be used.
62
63 The rules are the same as for L<mount(2)>:  A filesystem must
64 first be mounted on C</> before others can be mounted.  Other
65 filesystems can only be mounted on directories which already
66 exist.
67
68 The mounted filesystem is writable, if we have sufficient permissions
69 on the underlying device.
70
71 The filesystem options C<sync> and C<noatime> are set with this
72 call, in order to improve reliability.
73
74 This function returns 0 on success or -1 on error.
75
76 =head2 guestfs_sync
77
78  int guestfs_sync (guestfs_h *handle);
79
80 This syncs the disk, so that any writes are flushed through to the
81 underlying disk image.
82
83 You should always call this if you have modified a disk image, before
84 calling C<guestfs_close>.
85
86 This function returns 0 on success or -1 on error.
87
88 =head2 guestfs_touch
89
90  int guestfs_touch (guestfs_h *handle,
91                 const char *path);
92
93 Touch acts like the L<touch(1)> command.  It can be used to
94 update the timestamps on a file, or, if the file does not exist,
95 to create a new zero-length file.
96
97 This function returns 0 on success or -1 on error.
98