diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml index 966069209..69118da41 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -942,3 +942,10 @@ let inspect_mount_root g ?mount_opts_fn root = let inspect_mount_root_ro = inspect_mount_root ~mount_opts_fn:(fun _ -> "ro") + +let is_btrfs_subvolume g fs = + try + ignore (g#mountable_subvolume fs); true + with Guestfs.Error msg as exn -> + if g#last_errno () = Guestfs.Errno.errno_EINVAL then false + else raise exn diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli index 44b3018a2..9b1086cc8 100644 --- a/mllib/common_utils.mli +++ b/mllib/common_utils.mli @@ -368,3 +368,6 @@ val inspect_mount_root : Guestfs.guestfs -> ?mount_opts_fn:(string -> string) -> val inspect_mount_root_ro : Guestfs.guestfs -> string -> unit (** Like [inspect_mount_root], but mounting every mount point as read-only. *) + +val is_btrfs_subvolume : Guestfs.guestfs -> string -> bool +(** Checks if a filesystem is a btrfs subvolume. *)