kata-containers/agent/patches/0005-mount-support-mount-block-device.patch
holyfei c709612f2a kata-containers: modify kata-containers version
Fix #I4KI81
reason: modify kata-containers version and update
it to 1.11.1

Signed-off-by: holyfei <yangfeiyu20092010@163.com>
2021-11-30 20:08:25 +08:00

43 lines
1.5 KiB
Diff

From 8c9f9be2a9c195d0bc12b43c491adaacb7bb8154 Mon Sep 17 00:00:00 2001
From: holyfei <yangfeiyu20092010@163.com>
Date: Tue, 18 Aug 2020 10:42:38 +0800
Subject: [PATCH 05/16] mount: support mount block device
reason: modify mountStorage to support mount block device
"-v /dev/blockdevice:/home/test"
Signed-off-by: yangfeiyu <yangfeiyu2@huawei.com>
---
mount.go | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/mount.go b/mount.go
index f0c3efe..a05d4a6 100644
--- a/mount.go
+++ b/mount.go
@@ -364,7 +364,20 @@ func commonStorageHandler(storage pb.Storage) (string, error) {
func mountStorage(storage pb.Storage) error {
flags, options := parseMountFlagsAndOptions(storage.Options)
- return mount(storage.Source, storage.MountPoint, storage.Fstype, flags, options)
+ var fsType = storage.Fstype
+ if (storage.Driver == driverSCSIType || storage.Driver == driverBlkType) && strings.Contains(storage.Fstype, "bind") {
+ cs := strings.Split(storage.Fstype, "-")
+ if len(cs) == 2 && cs[1] != "" {
+ fsType = cs[1]
+ // here we temporarily discard the bind option,
+ // in order to be able to mount the file system of the block device.
+ // and then reset `storage.Fstype` to "bind" which pass through to the libcontainer pkg.
+ flags = flags &^ flagList["bind"]
+ storage.Fstype = "bind"
+ }
+ }
+
+ return mount(storage.Source, storage.MountPoint, fsType, flags, options)
}
// addStorages takes a list of storages passed by the caller, and perform the
--
2.14.3 (Apple Git-98)