[lxc-devel] [lxd/master] Add GetOwner stub for Windows (fixes #2438)
techtonik on Github
lxc-bot at linuxcontainers.org
Sat Oct 1 05:28:21 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 355 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161001/a6b329a6/attachment.bin>
-------------- next part --------------
From 93a5fb887faa4fd1f13abe0c61b6759787626742 Mon Sep 17 00:00:00 2001
From: anatoly techtonik <techtonik at gmail.com>
Date: Sat, 1 Oct 2016 08:25:24 +0300
Subject: [PATCH] Add GetOwner stub for Windows (fixes #2438)
Signed-off-by: anatoly techtonik <techtonik at gmail.com>
---
client.go | 4 +---
shared/util_linux.go | 7 +++++++
shared/util_windows.go | 11 +++++++++++
3 files changed, 19 insertions(+), 3 deletions(-)
create mode 100644 shared/util_windows.go
diff --git a/client.go b/client.go
index 58586a3..2afa6ca 100644
--- a/client.go
+++ b/client.go
@@ -1883,9 +1883,7 @@ func (c *Client) RecursivePushFile(container string, source string, target strin
}
defer f.Close()
- mode := fInfo.Mode()
- uid := int(fInfo.Sys().(*syscall.Stat_t).Uid)
- gid := int(fInfo.Sys().(*syscall.Stat_t).Gid)
+ mode, uid, gid := shared.GetOwner(fInfo)
return c.PushFile(container, targetPath, gid, uid, fmt.Sprintf("0%o", mode), f)
}
diff --git a/shared/util_linux.go b/shared/util_linux.go
index 51e0e43..1a5d94a 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -322,6 +322,13 @@ func GetFileStat(p string) (uid int, gid int, major int, minor int,
return
}
+func GetOwner(fInfo os.FileInfo) (os.FileMode, int, int) {
+ mode := fInfo.Mode()
+ uid := int(fInfo.Sys().(*syscall.Stat_t).Uid)
+ gid := int(fInfo.Sys().(*syscall.Stat_t).Gid)
+ return mode, uid, gid
+}
+
func IsMountPoint(name string) bool {
_, err := exec.LookPath("mountpoint")
if err == nil {
diff --git a/shared/util_windows.go b/shared/util_windows.go
new file mode 100644
index 0000000..b123c88
--- /dev/null
+++ b/shared/util_windows.go
@@ -0,0 +1,11 @@
+// +build windows
+
+package shared
+
+import (
+ "os"
+)
+
+func GetOwner(fInfo os.FileInfo) (os.FileMode, int, int) {
+ return os.FileMode(0), -1, -1
+}
More information about the lxc-devel
mailing list