95 Commits

Author SHA1 Message Date
Matthew Booth
d9f77f214b fuse: Add missing #include to guestmount.c
Fix compilation failure on F17
2012-04-04 14:26:51 +01:00
Richard W.M. Jones
c6f09fac06 New APIs: mount-local, mount-local-run, umount-local (FUSE support in the API).
Add FUSE support directly to the API.  Instead of needing to use the
external 'guestmount' command, you can mount the libguestfs filesystem
space on a local mountpoint using an API call from any language.

Note that although mount-local-run is marked as Cancellable, the
current implementation does not support it, but it would be relatively
simple to add it.
2012-03-29 16:45:01 +01:00
Richard W.M. Jones
f76a88011a Replace 'int' with 'size_t' passim.
Analyze all uses of 'int' in the code, and replace with 'size_t' where
appropriate.
2012-03-13 08:23:56 +00:00
Wanlong Gao
d60d5c091f guestmount: use O_ACCMODE instead of hard coding
Change hard code 3 to O_ACCMODE.
it'll be more sensible.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-01-30 10:56:59 +00:00
Wanlong Gao
0042898880 guestmount: remove tailing spaces
just do a cleanup.
remove the tailing spaces.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-01-30 10:56:11 +00:00
Richard W.M. Jones
08840bab44 Tempus fugit.
Update all copyright dates to 2012.
2012-01-18 22:05:02 +00:00
Richard W.M. Jones
ae45cee728 fuse: Return EXIT_FAILURE if fuse_main fails.
fuse_main can return any non-zero value on error.  In particular on
certain sorts of error such as unsupported -o options it returns 1
(not -1).

Therefore make sure any non-zero return is turned into EXIT_FAILURE.

(Thanks Pádraig Brady)
2011-12-09 15:30:23 +00:00
Richard Jones
47963bc9cc 32 bit: Fix printf off_t. 2011-11-11 20:26:49 +00:00
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Richard W.M. Jones
b0eabcca60 guestmount: Fix --live option (RHBZ#744795). 2011-10-26 20:53:30 +01:00
Richard W.M. Jones
33a2c184e1 Remove local LIBGUESTFS_PATH detection from guestfish and guestmount.
Remove the hack that let you run ./fish/guestfish or
./fuse/guestmount.  You now have to do:

  ./run ./fish/guestfish
or
  ./run ./fuse/guestmount

to run these programs without installing.
2011-04-16 08:32:48 +01:00
Jim Meyering
6740028b33 Include string.h and libintl.h, as needed.
* df/df.c: As above.
* df/main.c: As above.
* df/output.c: As above.
* fuse/guestmount.c: As above.
* inspector/virt-inspector.c: As above.
* rescue/virt-rescue.c: As above.
2011-04-13 14:26:06 +01:00
Richard W.M. Jones
b8e1dee73a Add /etc/libguestfs-tools.conf configuration file.
This allows the default for --ro or --rw to be controlled for the
three tools guestfish, guestmount and virt-rescue.
2011-03-31 15:42:13 +01:00
Richard W.M. Jones
3824935411 fuse: Document -w flag in --help output. 2011-03-30 16:32:33 +01:00
Richard W.M. Jones
0d6fd9e1d2 fuse: Fix getxattr, listxattr calls and add a regression test (RHBZ#691389).
The documentation for the getxattr and listxattr calls is not very
clear and as a result we were always returning something different
from that which the Linux kernel would usually return.

This fixes these calls, at least far enough that both the 'getfattr'
and 'getfacl' programs now work fine on FUSE-mounted filesystems.

Note that SELinux attrs are *not* passed through.  This appears to be
a known bug between SELinux and FUSE.  For more information see:

http://www.spinics.net/lists/selinux/msg09460.html
2011-03-28 14:49:48 +01:00
Richard W.M. Jones
a20e5c00c3 fish: Add guestfish --live, guestmount --live options.
The other programs have the variable, but the flag is not enabled
either because it doesn't make sense or because the implications are
not well understood.
2011-02-03 18:50:45 +00:00
Richard W.M. Jones
85c0bf5308 fuse: Add more tracing for calls into guestmount functions. 2010-12-19 12:04:43 +00:00
Richard W.M. Jones
de419e4bac fuse: Fix emulation of open call.
We were being over-complex in this call.  All the FUSE API requires
this call to do is to check permissions.
2010-12-07 14:49:34 +00:00
Richard W.M. Jones
2c4a7ef92a fish: Add --rw option (does nothing yet).
This adds the guestfish --rw option, intended in future
to be required for writing to disk images.

At the moment this does not change the default and so does
nothing.  This patch is intended for backporting to the
stable branches so that we can start to introduce scripts
which use 'guestfish --rw'.
2010-11-08 10:21:48 +00:00
Richard W.M. Jones
a232e62dcf fish: '-i' option automatically handles whole-disk encryption.
This feature is also available in guestmount because of the
shared option parsing code.

You don't need to do anything to enable it, just using -i
will attempt decryption of encrypted partitions.

Only works for simple Fedora whole-disk encryption.  It's a
work-in-progress to make it work for other types of encryption.
2010-11-05 11:39:24 +00:00
Richard W.M. Jones
39052d270f fuse: Use guestfs_last_errno instead of errno-reversal-hack. 2010-11-03 18:49:00 +00:00
Richard W.M. Jones
c66d6f215e Unify guestfish and guestmount options processing (RHBZ#642932).
In guestfish, factor out the processing of the options -a, -c,
-d, -i, -m, -n, -r, -v, -V, -x into a separate set of files:
options.c, options.h, inspect.c, virt.c.

Change guestmount so that it uses these same files (from the
../fish directory) to process the same options.

This unifies the handling of these options between the two programs.
It also adds the useful inspection feature to guestmount, so you
can now do:

  guestmount -d Guest -i --ro mnt/
2010-10-27 12:04:16 +01:00
Richard W.M. Jones
f48cd1f262 Enable autosync by default. 2010-10-27 10:59:45 +01:00
Richard W.M. Jones
44c5ee1163 fuse: Specify format of disks (RHBZ#642934,CVE-2010-3851).
For command line disk images, specify the format using --format option
in the same way as for guestfish.
2010-10-22 17:45:06 +01:00
Richard Jones
4932fdca3c build: Don't add version extra string to the version number.
If this string was non-empty, then it broke a lot of things because
autoconf and other parts of the build system were expecting this
string to contain a simple MAJOR.MINOR.RELEASE version number.

This requires changes to guestfish and guestmount so they use the
guestfs_version API to fetch the version from the library.  (The
Perl tools were already doing it this way).  In a way this is more
accurate, because it's no longer hard-coded in the binary, but
fetched from the dynamically linked libguestfs.so.
2010-08-27 13:38:49 +01:00
Richard Jones
9735484c35 fuse: Implement write syscall (RHBZ#592883). 2010-05-20 10:30:12 +01:00
Matthew Booth
c0d73e0e60 Fix build error in fuse/guestmount.c.
guestmount.c: In function 'main':
guestmount.c:899: error: implicit declaration of function 'setlocale'
[-Wimplicit-function-declaration]

guestmount.c wasn't including locale.h.
2010-04-14 11:13:04 +01:00
Richard Jones
1f0f0df9b1 Remove some unused variables.
Since we have to compile with -Wno-unused-variables, we don't
spot unused variables in code.  I found these by compiling the
code in Ubuntu.
2010-02-15 15:55:38 +00:00
Richard Jones
f93cbe5756 Use mount-options instead of mount to avoid implicit -o sync.
guestfs_mount adds -o sync implicitly.  This causes a very large
performance problem for write-intensive programs (eg. virt-v2v).

Document this as a "gotcha".

Change the tests, guestfish, Sys::Guestfs::Lib, guestmount to use
mount-options instead.

(Note that this gotcha does not affect mount-ro).

The source of the performance problem was first identified by
Matthew Booth.
2010-02-10 10:46:23 +00:00
Richard Jones
a6025c11d9 Set locale in C programs so l10n works (RHBZ#559962).
This commit adds the calls to setlocale &c to all of the current
C programs.

It also adds l10n support to hivexget and hivexml which lacked them
previously.

To test this, try:

LANG=pa_IN.UTF-8 guestfish --cmd-help

(You can only do this test after installing the package, or at
least the 'pa.mo' mo-file in the correct place).
2010-01-29 15:11:59 +00:00
Jim Meyering
4d45c45f09 maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 in "usage", too
Convert by running these commands:
perl -pi -e 's/\b(usage ?)\(1\)/$1(EXIT_FAILURE)/' \
  fish/fish.c fuse/guestmount.c
perl -pi -e 's/\b(usage ?)\(0\)/$1(EXIT_SUCCESS)/' \
  fish/fish.c fuse/guestmount.c
* fish/fish.c (main): Replace 0/1 with EXIT_SUCCESS/EXIT_FAILURE.
* fuse/guestmount.c (main): Likewise.
2009-11-20 12:14:32 +00:00
Jim Meyering
c372c7c23a maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit
Convert all uses automatically, via these two commands:
git grep -l '\<exit *(1)' \
  | grep -vEf .x-sc_prohibit_magic_number_exit \
  | xargs --no-run-if-empty \
    perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/'
git grep -l '\<exit *(0)' \
  | grep -vEf .x-sc_prohibit_magic_number_exit \
  | xargs --no-run-if-empty \
  perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/'
* .x-sc_prohibit_magic_number_exit: New file.

Edit (RWMJ): Don't change Java code.
2009-11-20 12:14:14 +00:00
Richard Jones
83eb2cf2fd fuse/RHEL: Don't require UTIME_{NOW,OMIT} to be defined.
These macros don't exist on RHEL/CentOS 5.4.  If the feature
is missing then just don't implement it in the FUSE layer.
2009-11-18 17:33:17 +00:00
Richard Jones
f5a3da1483 generator: Fix API of functions that return RBufferOut
(NB: The API / ABI doesn't actually change here - it's just made much
simpler to use).

The API for RBufferOut functions was unexpectedly hard to use in the
case where a zero-length buffer might be returned.  For discussion on
this see:

https://www.redhat.com/archives/libguestfs/2009-November/thread.html#00115

This commit ensures that in the zero-length buffer case, the return
value is never NULL.  Thus code is now able to just check if the return
value == NULL to indicate an error, which is simpler for all concerned.

The implementation of this is, however, more complex because we have
to be careful about this case inside both the daemon and the library
code, which is what this commit does.

This has passed a full round of tests.
2009-11-18 10:37:10 +00:00
Richard Jones
336275ee6d fuse: Fix read for empty files.
Error handling for the guestfs_pread call was incorrect, which
meant that empty files could produce spurious error messages.
2009-11-17 20:14:47 +00:00
Richard Jones
dcd08dd356 fuse: Fix cache invalidation in rename operation.
We need to invalidate both parameters, otherwise the old (moved)
file can appear that it still exists after the move.
2009-11-17 17:47:47 +00:00
Richard Jones
a15f118e3b fuse: Fix hard link creation.
The parameters were swapped.  We also need to invalidate the
cache for both parameters.
2009-11-17 17:47:47 +00:00
Richard Jones
366339d41b fuse: Fix symlink creation (RHBZ#538069).
The parameters were swapped, preventing symlinks from being created.
2009-11-17 17:47:42 +00:00
Richard Jones
ade327a7af Don't export STREQ and friends in <guestfs.h>
Move these to private header file(s) and other places as required
since these aren't part of the public API.
2009-11-10 17:09:12 +00:00
Jim Meyering
b9de2dc611 avoid "syntax-check" failure: hide cast of argument to free
* fuse/guestmount.c (fg_readlink): Perform cast in a
 separate statement to hide it from "make syntax-check".
2009-11-10 17:00:18 +01:00
Jim Meyering
9a8889e4d0 use STREQ, not strcmp: part 1
git grep -l 'strcmp *([^=]*== *0'|xargs \
  perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
2009-11-09 22:34:16 +01:00
Jim Meyering
e645763007 indent with spaces, not TABs
* HACKING: Expand indentation TABs.
* configure.ac: Likewise.
* daemon/daemon.h: Likewise.
* daemon/guestfsd.c: Likewise.
* fuse/guestmount.c: Likewise.
* hivex/LICENSE: Likewise.
* src/generator.ml: Likewise.
* tools/virt-win-reg: Likewise.
2009-11-09 20:19:42 +01:00
Richard W.M. Jones
e1f5472395 Fixes for compiling on 32 bit. 2009-11-06 09:14:55 +00:00
Richard Jones
aad55a71f6 Comment out code which provokes strange gcc optimization error. 2009-11-03 16:44:47 +00:00
Richard Jones
429de22541 FUSE filesystem support.
This implements FUSE filesystem support so that any libguestfs-
accessible disk image can be mounted as a local filesystem.

Note: file writes (ie. write(2) system call) is not yet implemented.

The API needs more test coverage, particularly lesser-used system
calls.

The big unresolved issue is UID/GID mapping between guest filesystem
IDs and the host.  It's not easy to automate this because you need
extra details about the guest itself in order to get to its
UID->username map (eg. /etc/passwd from the guest).
2009-11-03 15:57:26 +00:00