29 Commits

Author SHA1 Message Date
Richard W.M. Jones
3c1554e7f2 lib: Add new app2_class field for classifying applications
Existing virt-v2v code uses some simple heuristics for detecting
Windows anti-virus software:

7520185504/convert/windows.ml

Replicate exactly this code as a new field in the struct returned by
guestfs_inspect_get_applications2.  Because of limitations with the
API, we must use one of the existing spare fields in the struct, and
it must have the same type (a string), so we are limited in the design
of this new API.  I chose to return a primary classification for the
application, with the only classification possible so far being
"antivirus" (or "" if not).  This allows the possibility of future
expansion of use of this field if we need to in future.

Fixes: https://issues.redhat.com/browse/RHEL-125846
2025-11-04 15:56:33 +00:00
Richard W.M. Jones
a73f248369 daemon: Rewrite {pvs,vgs,lvs}-full APIs in OCaml
These were previously written in very convoluted C which had to deal
with parsing the crazy output of the "lvm" command.  In fact the
parsing was so complex that it was generated by the generator.  It's
easier to do this in OCaml.

These are basically legacy APIs.  They cannot be expanded and LVM
already supports many more fields.  We should replace these with APIs
for getting single named fields from LVM.
2025-04-16 21:12:49 +01:00
Richard W.M. Jones
5a16d1120f generator: Use new FDevice type for the pvs-full pv_name field
Remove the code which did explicit reverse device name translation,
and use the generator's code instead.
2025-04-16 12:27:07 +01:00
Richard W.M. Jones
72cfaff5c5 Update copyright dates for 2025
Automated using this command:

perl -pi.bak -e 's/(20[012][0-9])-20[12][01234]/$1-2025/g' `git ls-files`
2025-02-16 17:00:46 +00:00
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
61d4891ef4 mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
The new module ‘Std_utils’ contains only functions which are pure
OCaml and depend only on the OCaml stdlib.  Therefore these functions
may be used by the generator.

The new module is moved to ‘common/mlstdutils’.

This also removes the "<stdlib>" hack, and the code which copied the
library around.

Also ‘Guestfs_config’, ‘Libdir’ and ‘StringMap’ modules are moved
since these are essentially the same.

The bulk of this change is just updating files which use
‘open Common_utils’ to add ‘open Std_utils’ where necessary.
2017-07-10 17:01:59 +01:00
Matteo Cafasso
d00dc913aa New API: internal_yara_scan
The internal_yara_scan runs the Yara engine with the previously loaded
rules against the given file.

For each rule matching against the scanned file, a struct containing
the file name and the rule identifier is returned.

The gathered list of yara_detection structs is serialised into XDR format
and written to a file.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
2017-05-02 13:34:42 +01:00
Richard W.M. Jones
152657178d generator: Move failwithf to mllib.
A useful function.  This is just code motion.
2017-02-04 15:13:29 +00:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +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
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
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
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Hu Tao
f265371868 New API: btfs_scrub_status
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-02-16 18:05:30 +00:00
Hu Tao
88dbae4cbf New API: btrfs_balance_status
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2015-02-16 18:05:30 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Hu Tao
2b7f7810ed New API: btrfs_qgroup_show
btrfs_qgroup_show shows all qgroups on a btrfs filesystem.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-12-15 16:22:46 +00:00
Richard W.M. Jones
8664337cc3 New APIs: Implement stat calls that return nanosecond timestamps (RHBZ#1144891).
The existing APIs guestfs_stat, guestfs_lstat and guestfs_lstatlist
return a stat structure that contains atime, mtime and ctime fields
that store only the timestamp in seconds.

Modern filesystems can store timestamps down to nanosecond
granularity, and the ordinary glibc stat(2) wrapper will return these
in "hidden" stat fields:

  struct timespec st_atim;            /* Time of last access.  */
  struct timespec st_mtim;            /* Time of last modification.  */
  struct timespec st_ctim;            /* Time of last status change.  */

with the following macros defined for backwards compatibility:

  #define st_atime st_atim.tv_sec
  #define st_mtime st_mtim.tv_sec
  #define st_ctime st_ctim.tv_sec

It is not possible to redefine guestfs_stat to return a longer struct
guestfs_stat with room for the extra nanosecond fields, because that
would break the ABI of guestfs_lstatlist as it returns an array
containing consecutive stat structs (not pointers).  Changing the
return type of guestfs_stat would break API.  Changing the generator
to support symbol versioning is judged to be too intrusive.

Therefore this adds a new struct (guestfs_statns) and new APIs:

  guestfs_statns
  guestfs_lstatns
  guestfs_lstatnslist

which return the new struct (or array of structs in the last case).

The old APIs may of course still be used, forever, but are deprecated
and shouldn't be used in new programs.

Because virt tools are compiled with -DGUESTFS_WARN_DEPRECATED=1, I
have updated all the places calling the deprecated functions.  This
has revealed some areas for improvement: in particular virt-diff and
virt-ls could be changed to print the nanosecond fields.

FUSE now returns nanoseconds in stat calls where available, fixing
https://bugzilla.redhat.com/show_bug.cgi?id=1144891

Notes about the implementation:

- guestfs_internal_lstatlist has been removed and replaced by
  guestfs_internal_lstatnslist.  As the former was an internal API no
  one should have been calling it, or indeed can call it unless they
  start defining their own header files.

- guestfs_stat and guestfs_lstat have been changed into library-side
  functions.  They, along with guestfs_lstatlist, are now implemented
  as wrappers around the new functions which just throw away the
  nanosecond fields.
2014-09-22 15:47:48 +01:00
Richard W.M. Jones
544b087d4b generator: Sort the structs.
Sort the structs when generating code.  Since the structs are
logically indepedent of each other, this should have no effect except
to make generated files list the structs in a different order.

However this also fixes the following build problem:

  File "convert_linux.ml", line 322, characters 43-50:
  Error: This expression has type G.stat = Guestfs.stat
    but an expression was expected of type G.dirent = Guestfs.dirent

It turns out the OCaml bindings don't like the fact that we have
two structs with a common field name (dirent.ino and stat.ino).

In OCaml < 4.01, this means that any attempt to reference stat.ino
would fail because dirent.ino appears second in the file, overriding
stat.ino.

Sorting the structs has the side effect of making stat.ino appear
second, thus resolving the build failure above.

In OCaml >= 4.01 the compiler now uses some disambiguation rules based
on the known types to resolve this problem, so accessing either field
would work no matter what order they are listed in.

See:

http://ocaml.org/releases/4.01.0.html
http://www.lexifi.com/blog/type-based-selection-label-and-constructors
http://www.lexifi.com/blog/ocaml-extensions-lexifi-overidding-record-labels-and-constructors
2014-07-01 16:21:54 +01:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Matthew Booth
7d976657e6 New internal API: internal_parse_mountable 2013-02-12 15:51:06 +00:00
Richard W.M. Jones
0d18a8b407 Update copyright dates for 2013. 2013-02-02 13:56:19 +00:00
Matthew Booth
27b995c841 Make internal-only functions and structures private
Certain functions are intended to be internal only, but we currently
export them anyway. This change moves them into a separate section of
guestfs.h protected by a GUESTFS_PRIVATE variable. This change also
enables private structs, but doesn't implement any.

This change only affects the C api. Language bindings aren't affected,
but probably should be in the future.
2013-01-30 17:27:01 +00:00
John Eckersberg
bafd822914 lib: Add inspect_list_applications2 method (RHBZ#859949)
RWMJ:
- Fix memory leak in guestfs__inspect_list_applications wrapper.
- Don't document app2_spare* fields.
2012-11-01 18:22:01 +00:00
Richard W.M. Jones
eb185eef29 generator: Use an OCaml struct to store the structs.
This just makes it simpler to add extra fields to each struct.

This is code motion.
2012-10-30 12:32:30 +00:00
Richard W.M. Jones
d331fd70e2 generator: Rename 'generator_*' as '*'.
This is a simple renaming of the files/modules.

Note that in OCaml, module names are derived from filenames by
capitalizing the first letter.  Thus the old module names had the form
"Generator_api_versions".  The new modules names have the form
"Api_versions".
2012-09-02 19:47:33 +01:00