Commit Graph

1026 Commits

Author SHA1 Message Date
Maxim Perevedentsev
f90185dfdf lvm: modify guestfs_is_lv to take mountable
Calling guestfs_is_lv on btrfs subvolume throws an error.
Here we workaround it by taking Mountable instead of Device
and returning 'false' for non-device mountables.
2016-07-08 13:21:42 +01:00
Matteo Cafasso
abf85b050e filesystem_walk: more information into tsk_dirent
Access, modification, last status change and creation time in
Unix format as for statns.

Number of links pointing to a given entry.

If the entry is a symbolic link, report the its target path.

A new flag (DIRENT_COMPRESSED 0x04) indicating whether the file is
compressed using native filesystem compression support.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-07-08 12:08:17 +02:00
Richard W.M. Jones
123dc018b8 mllib: Rename unshift -> push_front, push -> push_back etc.
The C++ function names are more regular.

Updates commit 1c57c71d46.
2016-07-08 09:56:47 +01:00
Richard W.M. Jones
442092a305 Replace 'xs := x :: !xs' with 'unshift x xs'.
In one case, I used prepend instead.
2016-07-07 18:13:07 +01:00
Matteo Cafasso
2d65129e7e Reserve entries to tsk_dirent struct
Already implemented entries.

tsk_inode
tsk_type
tsk_size
tsk_name
tsk_flags

Easy ones to add.

tsk_atime_sec
tsk_atime_nsec
tsk_mtime_sec
tsk_mtime_nsec
tsk_ctime_sec
tsk_ctime_nsec
tsk_blksize
tsk_blocks

Further ideas.

tsk_nlink
tsk_link_name

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-28 22:09:36 +01:00
Richard W.M. Jones
32cc27bb61 generator: filesystem_walk APIs added in 1.33.39 (not .37).
Updates commit 3de8abac4a and
commit 19e7a52f8f.
2016-06-23 08:30:48 +01:00
Matteo Cafasso
19e7a52f8f New API: filesystem_walk
Library's counterpart of the daemon's internal_filesystem_walk command.

It writes the daemon's command output on a temporary file and parses it,
deserialising the XDR formatted tsk_dirent structs.

It returns to the caller the list of tsk_dirent structs generated by the
internal_filesystem_walk command.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:43:51 +01:00
Matteo Cafasso
3de8abac4a New API: internal_filesystem_walk
- generator: Added tsk_dirent struct

The tsk_dirent struct contains the information gathered via TSK APIs.

The struct contains the following fields:
 * tsk_inode: inode of a file
 * tsk_type: type of file such as for dirwalk command
 * tsk_size: file size in bytes
 * tsk_name: path relative to its disk partition
 * tsk_flags: bitfield containing extra information
 * tsk_spare[1-5]: extra space for future usage

 - configure: Added libtsk compile-time check

Ensure libtsk is available at compile time.
If not, daemon routines depending on it won't be available.

 - API: internal_filesystem_walk

The internal_filesystem_walk command walks through the FS structures
of a disk partition and returns all the files or directories
which could be found.

The command is able to retrieve information regarding deleted
or unaccessible files where other commands such as stat or find
would fail.

The gathered list of tsk_dirent structs is serialised into XDR format
and written to a file by the appliance.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:43:51 +01:00
Matteo Cafasso
434f617bdd Improve download_inode documentation string.
The download_inode does not require the disk to be mounted
in order to work.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-06-22 18:40:55 +01:00
Richard W.M. Jones
6e79a3c84d Convert source so it can be compiled with OCaml '-safe-string' option.
OCaml 4.02 introduced the 'bytes' type, a mutable string intended to
replace the existing 'string' type for those cases where the byte
array can be mutated.  In future the 'string' type will become
immutable.  This is not the default now, but it can be forced using
the '-safe-string' compile option.

This commit changes the code so that it could be compiled using
'-safe-string' (but does not actually make that change).

If we detect OCaml < 4.02, we create a dummy 'Bytes' compatibility
module ((nearly) an alias for the 'String' module).  The only
significant difference from upstream OCaml is that you must write the
'bytes' type as 'Bytes.t' in interfaces, apart from that everything
else should work.
2016-06-16 15:22:04 +01:00
Richard W.M. Jones
66856b6ba0 generator: Use common OCaml rules for building the generator too.
Updates commit a3cb12ab2c.
2016-06-16 15:22:04 +01:00
Richard W.M. Jones
bbb83aeccc generator: Remove unnecessary 'chars' function.
String.make can be used instead, and that function has been around
since at least RHEL 6 era OCaml.
2016-06-14 17:00:26 +01:00
Richard W.M. Jones
07c34fa65f customize: Use C<> around parameter name in documentation.
Fixes commit a084758e83
and commit 7e8ed7cb21.
2016-06-13 15:17:46 +01:00
Richard W.M. Jones
4d6899ee91 ruby: Print exceptions thrown by event callbacks. 2016-06-10 14:25:38 +01:00
Richard W.M. Jones
6425a8824b customize: Add --uninstall operation (RHBZ#1343375). 2016-06-07 12:19:24 +01:00
Pino Toscano
5d1dfe89cd inspect: support the xbps package manager and its format
Associate the Void Linux distribution with it.
2016-05-24 17:54:47 +02:00
Pino Toscano
0251c0fcaa inspect: recognize the Void Linux distribution
Since Void Linux provides only an /etc/os-release with no VERSION_ID
field, then special-case it to avoid that the os-release parsing ignore
it.

This provides basic distro identification, and icon.
2016-05-24 17:54:47 +02:00
Pino Toscano
23ebc3d9eb tests: disable UUID change on ext journal_dev
Newer versions of e2fsprogs refuse modifying journal devices, causing
the test #1 of get_e2uuid to fail with:

  libguestfs: error: set_e2uuid: Cannot modify a journal device.

Since the test case just needs to verify get_e2uuid runs without
failing, run it without expecting a certain UUID set earlier.

Followup of commit da4812ab6b.
2016-05-20 13:27:40 +02:00
Pino Toscano
1c9e808eee fish: generate test-prep.sh with generator
Generate test-prep.sh using the generator, so the prepared disk types
tested are the same as the ones configured in prepopts.ml.
2016-05-19 19:06:00 +02:00
Pino Toscano
e3d429d37d New API: btrfs-filesystem-show (RHBZ#1164765)
Add a new API to list all the devices where a btrfs filesystem is
spanned.
2016-05-12 17:14:11 +02:00
Pino Toscano
873560f495 perl: use INT2PTR macro for casting back to guestfs_h * (RHBZ#1150298)
Use the right macro, which should avoid the warnings seen with Perl
headers on some architecture.
2016-05-09 10:04:15 +02:00
Pino Toscano
48116cfb4e python: use constants instead of raw values
Extend the internal libguestfsmod module with the CREATE values, so
there is no need to hardcode values in GuestFS.__init__.
2016-05-05 22:00:47 +01:00
Pino Toscano
43358290b3 python: PEP 8: miscellaneous coding fixes
python/guestfs.py:136:37: E712 comparison to True should be 'if cond is True:' or 'if cond:'
python/t/tests_helper.py:42:8: E713 test for membership should be 'not in'

No functional changes, as the new versions follow the suggested Python
coding style to do the same things.
2016-05-04 18:56:01 +02:00
Pino Toscano
060b724c49 python: PEP 8: avoid whitespace-only lines in docstrings
Tweak the docstring generation to avoid lines with only indentation
spaces.

No functional changes, only whitespaces removals.
2016-05-04 18:56:01 +02:00
Pino Toscano
6e34396661 python: PEP 8: avoid too long lines
Reindent Python scripts to make sure lines are not longer than 80
columns.

Regarding autogenerated code (guestfs.py and bindtests.py): add an
helper function to make sure comma-separated lists are wrapped at the
wanted length.

This produces only differences in the indentation of long Python lines,
with no behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
d8337077e3 python: PEP 8: break compound statements
Avoid compound statements, simply indenting their blocks.

No functional changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
f85e18f62f python: PEP 8: adapt empty lines
Add or remove empty lines to match the needed ones around
blocks/functions/etc.

This is just formatting, no behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
6105ee0c71 python: PEP 8: adapt whitespaces in lines
Add (after comma) or remove (before opening round bracket, and around
'=' in arguments) whitespaces according to the PEP 8 specification.

This is just code reformatting, with no behaviour changes; no content
changed beside whitespaces, so "git diff -w" gives an empty diff.
2016-05-04 18:56:01 +02:00
Pino Toscano
ae3224cf8a customize: remove "core" from description of --update
--update invokes a distribution update, updating all the installed
packages and not just some "core" ones.
2016-05-03 14:25:46 +02:00
Pino Toscano
57467ca88b php: support PHP 7
Adapt to the API changes in the newer versions of the Zend framework, in
particular regarding:
- strings handling
- resources handling (used for the guestfs_h pointer)
- iterating in hash maps
- data types for function arguments

Introduce helper macros to reduce greatly the amount of #if's all around
the generated C code.
2016-04-12 10:35:20 +02:00
Pino Toscano
4a337cd33b fish: improve formatting of help text of generated commands
In the generated description of the guestfish commands, wrap and indent
the help text, so it is a multiline string instead of a very long single
one.

This has no behaviour changes, only makes cmds.c more readable (and
easier to diff when the description of actions change).
2016-04-11 17:06:50 +02:00
Matteo Cafasso
7ecec1ee55 python: Fix bug in code generator
When a struct containing FChar fields is defined
in generator/structs.ml, the Python code generator will generate
code referencing a dirent struct instead of the correct one
thus breaking at compile time.

This bug was left unnoticed because the dirent struct is the only
one using FChar fields. Yet it prevents any other struct
from using such fields.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-04-01 17:14:53 +01:00
Matteo Cafasso
5fd0819ebc Rename icat command in download_inode
The "icat" name comes from the employed command line tool which might be
replaced at any time with a different implementation.

The command name is a bit confusing because it's similar to "cat" but
act as "download".

download_inode is more clear and descriptive.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-31 10:50:42 +02:00
Lars Kellogg-Stedman
c6512ead45 document behavior of --selinux-relabel
the description of the --selinux-relabel option suggests that it
perform an immediate relabel, when in fact it may (and probably will)
instead simply touch /.autorelabel on the image, which schedules a
relabel operation for the next time the image boots.  This can be
surprising because it results both in an extended initial boot time
*and* results in an automatic reboot (on some distributions).
2016-03-24 20:19:09 +00:00
Matteo Cafasso
d314d10e1f sleuthkit availability check renamed
>From 'available icat' to 'available sleuthkit'.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-08 21:13:10 +00:00
Cédric Bosdonnat
f5a9cdff2a api: add mountable_device and mountable_subvolume
These two functions allow the user to split the mountable strings
into a device and a subvolume if any. See this thread on the mailing
list for the rationale:

https://www.redhat.com/archives/libguestfs/2016-February/msg00247.html
2016-03-08 16:25:19 +01:00
Matteo Cafasso
acd3f235ae added icat API to retrieve deleted or inaccessible files
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-07 19:33:53 +00:00
Richard W.M. Jones
07c496c53c Use less stack.
GCC has two warnings related to large stack frames.  We were already
using the -Wframe-larger-than warning, but this reduces the threshold
from 10000 to 5000 bytes.

However that warning only covers the static part of frames (not
alloca).  So this change also enables -Wstack-usage=10000 which covers
both the static and dynamic usage (alloca and variable length arrays).

Multiple changes are made throughout the code to reduce frames to fit
within these new limits.

Note that stack allocation of large strings can be a security issue.
For example, we had code like:

 size_t len = strlen (fs->windows_systemroot) + 64;
 char software[len];
 snprintf (software, len, "%s/system32/config/software",
           fs->windows_systemroot);

where fs->windows_systemroot is guest controlled.  It's not clear what
the effects might be of allowing the guest to allocate potentially
very large stack frames, but at best it allows the guest to cause
libguestfs to segfault.  It turns out we are very lucky that
fs->windows_systemroot cannot be set arbitrarily large (see checks in
is_systemroot).

This commit changes those to large heap allocations instead.
2016-03-07 17:36:24 +00:00
Pino Toscano
e8408fe3c3 daemon: do not fail list-disk-labels w/o labels set
If there are no labels set for the disks, the directory with the
symlinks will not even exists, causing list-disk-labels to fail with
ENOENT.  In this situation, act as if the directory was there, but
empty.
2016-03-02 14:42:02 +01:00
Matteo Cafasso
61b0317c12 New API: ntfscat_i
Adding ntfscat_i command for downloading files based on their inode number.

This allows the dowload of files unaccessible otherwise from a NTFS guest disk image.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2016-03-01 09:06:10 +00:00
Pino Toscano
1225bb194e java: drop empty lines at end of pod-generated text
They are converted as additional empty paragraphs but adding nothing to
the generated API documentation.  Also avoids warnings about them by
javadoc.
2016-02-26 18:36:42 +01:00
Pino Toscano
3b427b90ac doc: add info on per-function needed feature
Document which feature, if any, is needed for a function; this should
help users in properly checking feature availability when using certain
functions.
2016-02-26 18:36:42 +01:00
Richard W.M. Jones
7b11fb16ec perl: Don't embed API number in Sys::Guestfs.
It means you have to rerun `make -C perl clean ; make' every time you
add an API, and is useless anyway.
2016-02-26 10:45:21 +00:00
Pino Toscano
20efe36582 src: print contents of structs and struct lists on tracing
It eases the debugging, instead of getting just the name of the struct
returned.
2016-02-24 13:47:18 +01:00
Pino Toscano
e58e603a71 fish: use the new structs-print.c to print structs
Use of the new code to print structs, making sure the layout is the same
as before.
2016-02-24 13:47:18 +01:00
Pino Toscano
2c0d16e82e src: generate code for printing contents of structs
Extend the generator to generate a source (and the header for it) with
functions that print the content of a guestfs struct.  The code is
modelled after the code for it in fish.ml, although made a bit more
generic (destination FILE*, line separator) so it can be used also in
the library, when tracing.

This just introduces the new code and builds it as part of the helper
libutils.la.
2016-02-24 13:47:18 +01:00
Richard W.M. Jones
ae3c051567 generator: Declare which input file(s) generate each output file. 2016-02-23 10:40:06 +00:00
Richard W.M. Jones
52b5ddf23e generator: Make the 'this file is generated' warning clearer.
Also rename the ~extra_inputs parameter as plain ~inputs.  We will use
~inputs more widely in following commit.
2016-02-23 10:40:06 +00:00
Richard W.M. Jones
9eb26a1748 generator: gobject: Remove parameters which are not used.
Revealed by adding typed interfaces in the previous commit.
2016-02-23 10:40:05 +00:00
Richard W.M. Jones
30d2a308c0 generator: Add interfaces to all modules.
Be explicit about what is exported from each module in the generator.
2016-02-23 10:40:05 +00:00