summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-cp2-5422/recipes-phosphor/virtual-media/virtual-media/0011-virtual-media.3-Upd-Split-SmbShare-to-NetDevShare-an.patch
blob: e6d693fde39669ea6c234dfc40d17c92d6028d95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From 36cb2a2adc06483e65278e367d2146934cfaf080 Mon Sep 17 00:00:00 2001
From: Alexandr Ilenko <AIlenko@IBS.RU>
Date: Mon, 20 Jun 2022 09:53:41 +0300
Subject: [PATCH 11/20] virtual-media.3: Upd: Split "SmbShare" to "NetDevShare"
 and "CifsShare"

---
 src/netdev.hpp | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/netdev.hpp b/src/netdev.hpp
index 064b340..47d39a1 100644
--- a/src/netdev.hpp
+++ b/src/netdev.hpp
@@ -11,8 +11,19 @@
 
 namespace fs = std::filesystem;
 
-class SmbShare
+class NetDevShare
 {
+  public:
+    NetDevShare(const fs::path& mountDir) : mountDir(mountDir)
+    {
+    }
+    ~NetDevShare() = default;
+
+    virtual const char* getMountType() const = 0;
+
+    virtual bool mount(const fs::path& remote, bool rw,
+               const std::unique_ptr<utils::CredentialsProvider>& credentials) = 0;
+
   protected:
     std::string mountDir;
 
@@ -21,14 +32,23 @@ class SmbShare
     {
         return username.find(',') == std::string::npos;
     }
+};
 
+class SmbShare : public NetDevShare
+{
+    static constexpr const char* mountType = "cifs";
   public:
-    SmbShare(const fs::path& mountDir) : mountDir(mountDir)
+    SmbShare(const fs::path& mountDir) : NetDevShare(mountDir)
+    {
+    }
+
+    virtual const char* getMountType() const override
     {
+        return mountType;
     }
 
     bool mount(const fs::path& remote, bool rw,
-               const std::unique_ptr<utils::CredentialsProvider>& credentials)
+               const std::unique_ptr<utils::CredentialsProvider>& credentials) override
     {
         LogMsg(Logger::Debug, "Trying to mount remote : ", remote);
 
@@ -82,7 +102,7 @@ class SmbShare
     {
         options += "," + version;
 
-        auto ec = ::mount(remote.c_str(), mountDir.c_str(), "cifs", 0,
+        auto ec = ::mount(remote.c_str(), mountDir.c_str(), mountType, 0,
                           options.c_str());
         utils::secureCleanup(options);
 
-- 
2.35.1