15
15
class OMVModuleZFSUtil {
16
16
17
17
public static function getZFSShares ($ context ,$ name ,$ dir ){
18
- $ objects = Rpc::call ("FsTab " ,"enumerateEntries " ,[],$ context );
19
- $ result =NULL ;
20
- foreach ($ objects as $ object ){
21
- if ($ object ['fsname ' ]==$ name && $ object ['dir ' ]==$ dir && $ object ['type ' ]=='zfs ' ){
22
- $ result =$ object ;
23
- }
24
- }
25
- return $ result ;
18
+ $ object = Rpc::call ("FsTab " ,"getByFsName " ,["fsname " =>$ name ],$ context );
19
+ $ result =NULL ;
20
+ if ($ object ['type ' ]=='zfs ' and $ object ['dir ' ]==$ dir ){
21
+ $ result =$ object ;
22
+ }
23
+ return $ result ;
26
24
}
27
25
/**
28
26
* Returns the quota (if set) of a filesystem.
@@ -117,22 +115,6 @@ public static function setGPTLabel($disk) {
117
115
$ cmd = "parted -s " . $ disk . " mklabel gpt 2>&1 " ;
118
116
OMVModuleZFSUtil::exec ($ cmd ,$ out ,$ res );
119
117
}
120
-
121
- /**
122
- * Manages relocation of ZFS filesystem mountpoints in the OMV backend.
123
- * Needed when the user changes mountpoint of a filesystem in the GUI.
124
- *
125
- */
126
- public static function relocateFilesystem ($ context ,$ name ) {
127
- $ poolname = OMVModuleZFSUtil::getPoolname ($ name );
128
- $ pooluuid = OMVModuleZFSUtil::getUUIDbyName ($ poolname );
129
- $ ds = new OMVModuleZFSDataset ($ name );
130
- $ dir = $ ds ->getMountPoint ();
131
- $ object =OMVModuleZFSUtil::getZFSShares ($ context ,$ pooluuid ,$ dir );
132
- $ object ['dir ' ] = $ property ['value ' ];
133
- Rpc::call ("FsTab " ,"set " , $ object , $ context );
134
- return null ;
135
- }
136
118
137
119
/**
138
120
* Clears all ZFS labels on specified devices.
@@ -236,10 +218,9 @@ public static function getDevByPath($path) {
236
218
*/
237
219
public static function deleteShares ($ context ,$ dispatcher ,$ name ) {
238
220
$ poolname = OMVModuleZFSUtil::getPoolname ($ name );
239
- $ pooluuid = OMVModuleZFSUtil::getUUIDbyName ($ poolname );
240
221
$ ds = new OMVModuleZFSDataset ($ name );
241
222
$ dir = $ ds ->getMountPoint ();
242
- $ mountpoint =OMVModuleZFSUtil::getZFSShares ($ context ,$ pooluuid ,$ dir );
223
+ $ mountpoint =OMVModuleZFSUtil::getZFSShares ($ context ,$ poolname ,$ dir );
243
224
$ mntentuuid = $ mountpoint ['uuid ' ];
244
225
$ shares =Rpc::call ("ShareMgmt " ,"enumerateSharedFolders " , [], $ context );
245
226
$ objects =[];
@@ -254,7 +235,7 @@ public static function deleteShares($context,$dispatcher,$name) {
254
235
}
255
236
}
256
237
foreach ($ objects as $ object ) {
257
- Rpc::call ("FsTab " ,"delete " , ["uuid " =>$ object ['uuid ' ]], $ context );
238
+ Rpc::call ("ShareMgmt " ,"delete " , ["uuid " =>$ object ['uuid ' ]], $ context );
258
239
}
259
240
260
241
$ dispatcher ->notify (OMV_NOTIFY_DELETE ,"org.openmediavault.system.shares.sharedfolder " ,$ object );
@@ -362,6 +343,7 @@ public static function addMissingOMVMntEnt($context) {
362
343
Rpc::call ("FsTab " ,"set " , $ object , $ context );
363
344
}
364
345
}
346
+
365
347
return null ;
366
348
}
367
349
@@ -626,6 +608,11 @@ public static function SizeTobytes($humanformat) {
626
608
return $ num ;
627
609
}
628
610
611
+ public static function isReferenced ($ mntent ) {
612
+ $ mntent = $ db ->get ("conf.system.filesystem.mountpoint " ,$ mntent ['uuid ' ]);
613
+ if ($ db ->isReferenced ($ mntent ))
614
+ return true ;
615
+ }
629
616
}
630
617
631
618
?>
0 commit comments