]> git.datanom.net - omvzfs.git/blob - patches/filesystemmgmt.patch
Patches to OMV core
[omvzfs.git] / patches / filesystemmgmt.patch
1 --- omv/filesystemmgmt.inc.org 2014-09-18 09:39:59.956015279 +0200
2 +++ omv/filesystemmgmt.inc 2014-09-18 15:36:01.981792621 +0200
3 @@ -83,7 +83,7 @@
4 if (!in_array($objectv['type'], array("ext", "ext2", "ext3",
5 "ext4", "xfs", "jfs", "iso9660", "msdos", "ntfs", "udf",
6 "umsdos", "vfat", "ufs", "reiserfs", "btrfs", "hfsplus",
7 - "zfs")))
8 + "zfs", "zfs_member")))
9 continue;
10 // Use the devicefile to get the filesystem details because vfat
11 // filesystems do not have a valid UUID. Any idea why?
12 @@ -117,24 +117,46 @@
13 // exists, then check if it is referenced by any other object,
14 // e.g. by a shared folder configuration object.
15 if (FALSE !== ($meObject = OMVRpc::exec("FsTab", "getByFsName",
16 - array("id" => $fs->getDeviceFile()), $context))) {
17 - $xpath = sprintf("//mntentref[contains(.,'%s')]",
18 - $meObject['uuid']);
19 - if (TRUE === $xmlConfig->exists($xpath))
20 - $object['_used'] = TRUE;
21 - }
22 + array("id" => $fs->getDeviceFile()), $context))) {
23 + if (strcmp($object['type'], "zfs_member") === 0) {
24 + //This is a zfs filesystem which uses another format for UUID.
25 + //The UUID of the filesystem is stored in the fsname property.
26 + $xpath = "//system/fstab/mntent[fsname='" . $object['uuid'] . "']";
27 + $zfs_obj = $xmlConfig->get($xpath);
28 + if (!is_null($zfs_obj)) {
29 + $xpath = sprintf("//mntentref[contains(.,'%s')]",$zfs_obj['uuid']);
30 + if (TRUE === $xmlConfig->exists($xpath)) {
31 + $object['_used'] = TRUE;
32 + }
33 + }
34 + } else {
35 + $xpath = sprintf("//mntentref[contains(.,'%s')]",
36 + $meObject['uuid']);
37 + if (TRUE === $xmlConfig->exists($xpath))
38 + $object['_used'] = TRUE;
39 + }
40 + }
41 // Mark the device where the operating system is installed on
42 // as used and read-only.
43 if (OMVSystem::isRootDeviceFile($object['devicefile'])) {
44 $object['_used'] = TRUE;
45 $object['_readonly'] = TRUE;
46 }
47 + //zfs filesystems are not detected by the isMounted method, but can be
48 + //probed via /proc/mounts
49 + $zfs_mounted = FALSE;
50 + if (strcmp($object['type'], "zfs_member") === 0) {
51 + $cmd = "cat /proc/mounts | grep '^" . $object['label'] . "[[:space:]]' 2>&1";
52 + $this->exec($cmd, $output, $result);
53 + if (count($output) === 1)
54 + $zfs_mounted = TRUE;
55 + }
56 // If the filesystem is mounted then try to get more
57 // informations about it. Note,it is not possible to get
58 // details from unmounted filesystems, because on most kinds
59 // of systems doing so requires very nonportable intimate
60 // knowledge of filesystem structures. See man (1) df.
61 - if (TRUE === $fs->isMounted()) {
62 + if ((TRUE === $fs->isMounted()) || ($zfs_mounted)) {
63 $object['mounted'] = TRUE;
64 // Get some more filesystem details if possible.
65 if (FALSE !== ($fsStats = $fs->getStatistics())) {
66 @@ -183,8 +205,8 @@
67 "includeRoot":{"type":"boolean","optional":true}
68 }
69 }');
70 - // Get list of mount points, except bind mounts.
71 - $xpath = "//system/fstab/mntent[not(contains(opts,'bind'))]";
72 + // Get list of mount points, except bind mounts and zfs mountpoints
73 + $xpath = "//system/fstab/mntent[not(contains(opts,'bind') or contains(type,'zfs'))]";
74 $objects = $xmlConfig->getList($xpath);
75 if (is_null($objects)) {
76 throw new OMVException(OMVErrorMsg::E_CONFIG_GET_OBJECT_FAILED,
77 @@ -344,7 +366,7 @@
78 // exist anymore. This is necessary to be able remove invalid mount
79 // point configuration objects. Mark such filesystem as missing.
80 $xpath = "//system/fstab/mntent[not(contains(opts,'bind') or ".
81 - "contains(opts,'loop'))]";
82 + "contains(opts,'loop') or contains(type,'zfs'))]";
83 $mntents = $xmlConfig->getList($xpath);
84 if(is_null($mntents)) {
85 throw new OMVException(OMVErrorMsg::E_CONFIG_GET_OBJECT_FAILED,
This page took 0.065249 seconds and 6 git commands to generate.