[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCHv2 1/3] mllib: add checking for btrfs subvolume



This is needed to skip btrfs subvolumes from output
of list_filesystems where device is needed.
---
 mllib/common_utils.ml  | 7 +++++++
 mllib/common_utils.mli | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 77b9acd..35f6545 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -922,3 +922,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 5b0b9bb..d2ed30c 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -330,3 +330,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. *)
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]