[pve-devel] [PATCH v2 container 6/9] add mount stage directory helpers
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Nov 13 10:33:16 CET 2019
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
No changes.
src/PVE/LXC.pm | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 6bea0b7..77b1a43 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -11,7 +11,7 @@ use File::Path;
use File::Spec;
use Cwd qw();
use Fcntl qw(O_RDONLY O_NOFOLLOW O_DIRECTORY);
-use Errno qw(ELOOP ENOTDIR EROFS ECONNREFUSED ENOSYS);
+use Errno qw(ELOOP ENOTDIR EROFS ECONNREFUSED ENOSYS EEXIST);
use IO::Socket::UNIX;
use PVE::Exception qw(raise_perm_exc);
@@ -1625,6 +1625,33 @@ sub __mountpoint_mount {
die "unsupported storage";
}
+# Create a directory in the mountpoint staging tempfs.
+sub get_staging_mount_path($) {
+ my ($opt) = @_;
+
+ my $target = get_staging_tempfs() . "/$opt";
+ if (!mkdir($target) && $! != EEXIST) {
+ die "failed to create directory $target: $!\n";
+ }
+
+ return $target;
+}
+
+# Mount /run/pve/mountpoints as tmpfs
+sub get_staging_tempfs() {
+ my $target = '/run/pve/mountpoints';
+ mkdir("/run/pve");
+ if (!mkdir($target)) {
+ return $target if $! == EEXIST;
+ die "failed to create directory $target: $!\n";
+ }
+
+ PVE::Tools::mount("none", $target, 'tmpfs', 0, "size=8k,mode=755")
+ or die "failed to mount $target as tmpfs: $!\n";
+
+ return $target;
+}
+
sub mkfs {
my ($dev, $rootuid, $rootgid) = @_;
--
2.20.1
More information about the pve-devel
mailing list