os/user: Use Entersyscall.

From-SVN: r188496
This commit is contained in:
Ian Lance Taylor 2012-06-13 05:56:09 +00:00
parent 57d195e224
commit 73b5b93a59
1 changed files with 6 additions and 1 deletions

View File

@ -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) {
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())
} }