Re: [Libguestfs] [PATCH v8 2/3] New API: filesystem_walk

Richard W.M. Jones
2016-06-15T14:04:43Z

On Mon, Jun 13, 2016 at 07:50:53PM +0300, Matteo Cafasso
wrote:
> +=item 'tsk_flags'
> +
> +Bitfield containing extra information regarding the entry.
> +
> +The first bit controls the allocation state of the entry.
> +If set to C<1>, the file is allocated and visible within the
filesystem.
> +Otherwise, the file has been deleted.
> +Under certain circumstances, the function C<download_inode>
> +can be used to recover deleted files.
> +
> +The second bit reports whether the metadata structure of the file
> +has been reallocated.
> +Filesystem such as NTFS and Ext2 or greater, separate the file name
> +from the metadata structure.
> +The bit is set to C<1> when the file name is in an unallocated state
> +and the metadata structure is in an allocated one.
> +This generally implies the metadata has been reallocated to a new file.
> +Therefore, information such as file type and file size
> +might not correspond with the ones of the original deleted entry.

Probably better to give actual values rather than "the first bit"
and so on.

eg:

=item 'tsk_flags'

Bitfield containing extra information about this entry.  It
contains the logical OR of the following values:

=over 4

=item 0x0001

If set, the file is allocated and visible within the filesystem
[etc etc]

=item 0x0002

[etc etc]

=back

> +/* Deserialise the file content and populate the dirent list.
> + * Return the number of deserialised dirents, -1 on error.
> + */
> +static int
> +deserialise_dirent_list (guestfs_h *g, FILE *fp,
> +                         struct guestfs_tsk_dirent_list *dirents)
> +{
> +  XDR xdr;
> +  bool_t ret = 0;

I don't know where 'bool_t' comes from, but don't use it.  Put
#include <stdbool.h> at the top of the file, and use the C99
'bool'
type and 'true' and 'false' values.  See:

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html

> +  return (ret == TRUE) ? 0 : -1;

You can just write:

  return ret ? 0 : -1;

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.