1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
From 3b19f4af4398d71eb3dd58041d4aff94e05efb6d Mon Sep 17 00:00:00 2001
From: Robert Millan <rmh@debian.org>
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 <parted/debug.h>
#include <ctype.h>
+#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
@@ -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*
|