From 3b19f4af4398d71eb3dd58041d4aff94e05efb6d Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 28 Mar 2014 17:09:50 +0000 Subject: Detection of ZFS volumes (ZVOL) ZFS volumes (ZVOL) are the ZFS equivalent of Logical Volumes in LVM. They implement a block device which can be used for swap or legacy filesystems. Bug-Debian: http://bugs.debian.org/635384 Forwarded: no Last-Update: 2011-07-30 Patch-Name: freebsd-zvol.patch --- libparted/arch/freebsd.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/libparted/arch/freebsd.c b/libparted/arch/freebsd.c index 4c690e5f..a60b43f8 100644 --- a/libparted/arch/freebsd.c +++ b/libparted/arch/freebsd.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -1134,12 +1135,51 @@ _probe_kern_disks () return 1; } +static int +_probe_zfs_volumes () +{ + DIR* pool_dir; + DIR* zvol_dir; + struct dirent* pool_dent; + struct dirent* zvol_dent; + char buf[PATH_MAX]; + struct stat st; + + pool_dir = opendir ("/dev/zvol"); + if (!pool_dir) + return 0; + + while ((pool_dent = readdir (pool_dir))) { + if (strcmp (pool_dent->d_name, ".") == 0 || strcmp (pool_dent->d_name, "..") == 0) + continue; + + snprintf (buf, sizeof (buf), "/dev/zvol/%s", pool_dent->d_name); + zvol_dir = opendir (buf); + + while ((zvol_dent = readdir (zvol_dir))) { + if (strcmp (zvol_dent->d_name, ".") == 0 || strcmp (zvol_dent->d_name, "..") == 0) + continue; + + snprintf (buf, sizeof (buf), "/dev/zvol/%s/%s", pool_dent->d_name, zvol_dent->d_name); + if (stat (buf, &st) != 0) + continue; + _ped_device_probe (buf); + } + closedir (zvol_dir); + } + closedir (pool_dir); + + return 1; +} + static void freebsd_probe_all () { _probe_standard_devices (); _probe_kern_disks (); + + _probe_zfs_volumes (); } static char*