[lxc-devel] [lxd/master] xattrs: use syscall library
brauner on Github
lxc-bot at linuxcontainers.org
Tue Sep 13 07:52:14 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 471 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160913/befd1c63/attachment.bin>
-------------- next part --------------
From b0bf4d24573b246f6a5c2fe881ecc14bbda8ebcc Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at canonical.com>
Date: Tue, 13 Sep 2016 09:50:32 +0200
Subject: [PATCH] xattrs: use syscall library
golang/x/sys/unix library is not yet packaged. So let's use the deprecated
syscall library for now.
Signed-off-by: Christian Brauner <christian.brauner at canonical.com>
---
shared/util_linux.go | 9 ++++-----
shared/util_test.go | 10 +++++-----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/shared/util_linux.go b/shared/util_linux.go
index 35daf13..51e0e43 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -6,7 +6,6 @@ package shared
import (
"errors"
"fmt"
- "golang.org/x/sys/unix"
"os"
"os/exec"
"strings"
@@ -393,7 +392,7 @@ func SetSize(fd int, width int, height int) (err error) {
// associated with the link itself are retrieved.
func llistxattr(path string, list []byte) (sz int, err error) {
var _p0 *byte
- _p0, err = unix.BytePtrFromString(path)
+ _p0, err = syscall.BytePtrFromString(path)
if err != nil {
return
}
@@ -403,7 +402,7 @@ func llistxattr(path string, list []byte) (sz int, err error) {
} else {
_p1 = unsafe.Pointer(nil)
}
- r0, _, e1 := unix.Syscall(unix.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(list)))
+ r0, _, e1 := syscall.Syscall(syscall.SYS_LLISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(list)))
sz = int(r0)
if e1 != 0 {
err = e1
@@ -461,7 +460,7 @@ func GetAllXattr(path string) (xattrs map[string]string, err error) {
// second, to actually store the extended attributes in the
// buffer. Also, check if the size of the extended attribute
// hasn't changed between the two calls.
- pre, err = unix.Getxattr(path, xattr, nil)
+ pre, err = syscall.Getxattr(path, xattr, nil)
if err != nil || pre < 0 {
return nil, err
}
@@ -470,7 +469,7 @@ func GetAllXattr(path string) (xattrs map[string]string, err error) {
}
dest = make([]byte, pre)
- post, err = unix.Getxattr(path, xattr, dest)
+ post, err = syscall.Getxattr(path, xattr, dest)
if err != nil || post < 0 {
return nil, err
}
diff --git a/shared/util_test.go b/shared/util_test.go
index 386a7a3..c469846 100644
--- a/shared/util_test.go
+++ b/shared/util_test.go
@@ -4,10 +4,10 @@ import (
"bytes"
"crypto/rand"
"fmt"
- "golang.org/x/sys/unix"
"io/ioutil"
"os"
"strings"
+ "syscall"
"testing"
)
@@ -35,8 +35,8 @@ func TestGetAllXattr(t *testing.T) {
defer os.Remove(xattrDir)
for k, v := range testxattr {
- err = unix.Setxattr(xattrFile.Name(), k, []byte(v), 0)
- if err == unix.ENOTSUP {
+ err = syscall.Setxattr(xattrFile.Name(), k, []byte(v), 0)
+ if err == syscall.ENOTSUP {
t.Log(err)
return
}
@@ -44,8 +44,8 @@ func TestGetAllXattr(t *testing.T) {
t.Error(err)
return
}
- err = unix.Setxattr(xattrDir, k, []byte(v), 0)
- if err == unix.ENOTSUP {
+ err = syscall.Setxattr(xattrDir, k, []byte(v), 0)
+ if err == syscall.ENOTSUP {
t.Log(err)
return
}
More information about the lxc-devel
mailing list