CIFS/SMB supports directly mounting subdirectories, so it makes sense to
also allow the --subdir parameter for these storages. The subdir
parameter was moved from CephFSPlugin.pm to Plugin.pm, because it isn't
specific to CephFS anymore.
Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
-sub cifs_is_mounted {
- my ($server, $share, $mountpoint, $mountdata) = @_;
+sub cifs_is_mounted : prototype($$) {
+ my ($scfg, $mountdata) = @_;
+
+ my $mountpoint = $scfg->{path};
+ my $server = $scfg->{server};
+ my $share = $scfg->{share};
+ my $subdir = $scfg->{subdir} // "/";
$server = "[$server]" if Net::IP::ip_is_ipv6($server);
$server = "[$server]" if Net::IP::ip_is_ipv6($server);
- my $source = "//${server}/$share";
+ my $source = "//${server}/$share$subdir";
$mountdata = PVE::ProcFSTools::parse_proc_mounts() if !$mountdata;
return $mountpoint if grep {
$mountdata = PVE::ProcFSTools::parse_proc_mounts() if !$mountdata;
return $mountpoint if grep {
-sub cifs_mount {
- my ($server, $share, $mountpoint, $storeid, $smbver, $user, $domain) = @_;
+sub cifs_mount : prototype($$$$$) {
+ my ($scfg, $storeid, $smbver, $user, $domain) = @_;
+
+ my $mountpoint = $scfg->{path};
+ my $server = $scfg->{server};
+ my $share = $scfg->{share};
+ my $subdir = $scfg->{subdir} // "/";
$server = "[$server]" if Net::IP::ip_is_ipv6($server);
$server = "[$server]" if Net::IP::ip_is_ipv6($server);
- my $source = "//${server}/$share";
+ my $source = "//${server}/$share$subdir";
my $cmd = ['/bin/mount', '-t', 'cifs', $source, $mountpoint, '-o', 'soft', '-o'];
my $cmd = ['/bin/mount', '-t', 'cifs', $source, $mountpoint, '-o', 'soft', '-o'];
'content-dirs' => { optional => 1 },
server => { fixed => 1 },
share => { fixed => 1 },
'content-dirs' => { optional => 1 },
server => { fixed => 1 },
share => { fixed => 1 },
+ subdir => { optional => 1 },
nodes => { optional => 1 },
disable => { optional => 1 },
maxfiles => { optional => 1 },
nodes => { optional => 1 },
disable => { optional => 1 },
maxfiles => { optional => 1 },
$cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
if !$cache->{mountdata};
$cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
if !$cache->{mountdata};
- my $path = $scfg->{path};
- my $server = $scfg->{server};
- my $share = $scfg->{share};
-
- if !cifs_is_mounted($server, $share, $path, $cache->{mountdata});
+ if !cifs_is_mounted($scfg, $cache->{mountdata});
return $class->SUPER::status($storeid, $scfg, $cache);
}
return $class->SUPER::status($storeid, $scfg, $cache);
}
if !$cache->{mountdata};
my $path = $scfg->{path};
if !$cache->{mountdata};
my $path = $scfg->{path};
- my $server = $scfg->{server};
- my $share = $scfg->{share};
- if (!cifs_is_mounted($server, $share, $path, $cache->{mountdata})) {
+ if (!cifs_is_mounted($scfg, $cache->{mountdata})) {
mkpath $path if !(defined($scfg->{mkdir}) && !$scfg->{mkdir});
die "unable to activate storage '$storeid' - " .
"directory '$path' does not exist\n" if ! -d $path;
mkpath $path if !(defined($scfg->{mkdir}) && !$scfg->{mkdir});
die "unable to activate storage '$storeid' - " .
"directory '$path' does not exist\n" if ! -d $path;
- cifs_mount($server, $share, $path, $storeid, $scfg->{smbversion},
+ cifs_mount($scfg, $storeid, $scfg->{smbversion},
$scfg->{username}, $scfg->{domain});
}
$scfg->{username}, $scfg->{domain});
}
if !$cache->{mountdata};
my $path = $scfg->{path};
if !$cache->{mountdata};
my $path = $scfg->{path};
- my $server = $scfg->{server};
- my $share = $scfg->{share};
- if (cifs_is_mounted($server, $share, $path, $cache->{mountdata})) {
+ if (cifs_is_mounted($scfg, $cache->{mountdata})) {
my $cmd = ['/bin/umount', $path];
run_command($cmd, errmsg => 'umount error');
}
my $cmd = ['/bin/umount', $path];
run_command($cmd, errmsg => 'umount error');
}
description => "Mount CephFS through FUSE.",
type => 'boolean',
},
description => "Mount CephFS through FUSE.",
type => 'boolean',
},
- subdir => {
- description => "Subdir to mount.",
- type => 'string', format => 'pve-storage-path',
- },
'fs-name' => {
description => "The Ceph filesystem name.",
type => 'string', format => 'pve-configid',
'fs-name' => {
description => "The Ceph filesystem name.",
type => 'string', format => 'pve-configid',
type => 'boolean',
optional => 1,
},
type => 'boolean',
optional => 1,
},
+ subdir => {
+ description => "Subdir to mount.",
+ type => 'string', format => 'pve-storage-path',
+ optional => 1,
+ },
'format' => {
description => "Default image format.",
type => 'string', format => 'pve-storage-format',
'format' => {
description => "Default image format.",
type => 'string', format => 'pve-storage-format',