[pve-devel] [PATCH v3 container 08/12] add mount stage directory helpers
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Nov 19 10:34:40 CET 2019
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
No changes to v2.
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 3ad807d..70a3b0a 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);
@@ -1648,6 +1648,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