Commit 73b5b93a by Ian Lance Taylor

os/user: Use Entersyscall.

From-SVN: r188496
parent 57d195e2
...@@ -73,11 +73,14 @@ func lookup(uid int, username string, lookupByName bool) (*User, error) { ...@@ -73,11 +73,14 @@ func lookup(uid int, username string, lookupByName bool) (*User, error) {
const bufSize = 1024 const bufSize = 1024
buf := make([]byte, bufSize) buf := make([]byte, bufSize)
if lookupByName { if lookupByName {
rv := libc_getpwnam_r(syscall.StringBytePtr(username), p := syscall.StringBytePtr(username)
syscall.Entersyscall()
rv := libc_getpwnam_r(p,
&pwd, &pwd,
&buf[0], &buf[0],
bufSize, bufSize,
&result) &result)
syscall.Exitsyscall()
if rv != 0 { if rv != 0 {
return nil, fmt.Errorf("user: lookup username %s: %s", username, syscall.GetErrno()) return nil, fmt.Errorf("user: lookup username %s: %s", username, syscall.GetErrno())
} }
...@@ -85,11 +88,13 @@ func lookup(uid int, username string, lookupByName bool) (*User, error) { ...@@ -85,11 +88,13 @@ func lookup(uid int, username string, lookupByName bool) (*User, error) {
return nil, UnknownUserError(username) return nil, UnknownUserError(username)
} }
} else { } else {
syscall.Entersyscall()
rv := libc_getpwuid_r(syscall.Uid_t(uid), rv := libc_getpwuid_r(syscall.Uid_t(uid),
&pwd, &pwd,
&buf[0], &buf[0],
bufSize, bufSize,
&result) &result)
syscall.Exitsyscall()
if rv != 0 { if rv != 0 {
return nil, fmt.Errorf("user: lookup userid %d: %s", uid, syscall.GetErrno()) return nil, fmt.Errorf("user: lookup userid %d: %s", uid, syscall.GetErrno())
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment