diff options
author | Jason King <jason.brian.king@gmail.com> | 2018-12-13 10:43:17 -0800 |
---|---|---|
committer | Joshua M. Clulow <josh@sysmgr.org> | 2018-12-13 10:43:17 -0800 |
commit | de6af22ae73ba8d72672288621ff50b88f2cf5fd (patch) | |
tree | bde5b53305ed41efdddef5f400ff6cba8ca51b8b /usr/src/uts | |
parent | 03270635d68df6a0392fb8f4b7c04acad764648b (diff) | |
download | illumos-gate-de6af22ae73ba8d72672288621ff50b88f2cf5fd.tar.gz |
9971 Make getrandom(2) a public interface
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Andy Fiddaman <omnios@citrus-it.net>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr/src/uts')
-rw-r--r-- | usr/src/uts/common/os/sysent.c | 50 | ||||
-rw-r--r-- | usr/src/uts/common/sys/random.h | 7 | ||||
-rw-r--r-- | usr/src/uts/common/syscall/getrandom.c | 6 |
3 files changed, 31 insertions, 32 deletions
diff --git a/usr/src/uts/common/os/sysent.c b/usr/src/uts/common/os/sysent.c index b3861dec03..f1b6f2616c 100644 --- a/usr/src/uts/common/os/sysent.c +++ b/usr/src/uts/common/os/sysent.c @@ -23,7 +23,7 @@ * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Milan Jurik. All rights reserved. * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. - * Copyright (c) 2015, Joyent, Inc. + * Copyright (c) 2018, Joyent, Inc. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -329,13 +329,13 @@ int getsockopt(int, int, int, void *, socklen_t *, int); int setsockopt(int, int, int, void *, socklen_t *, int); int sockconfig(int, void *, void *, void *, void *); ssize_t sendfilev(int, int, const struct sendfilevec *, int, size_t *); -int getrandom(void *, size_t, int); +ssize_t getrandom(void *, size_t, unsigned int); typedef int64_t (*llfcn_t)(); /* for casting one-word returns */ /* * Sysent initialization macros. - * These take the name string of the system call even though that isn't + * These take the name string of the system call even though that isn't * currently used in the sysent entry. This might be useful someday. * * Initialization macro for system calls which take their args in the C style. @@ -517,7 +517,7 @@ struct sysent sysent[NSYSCALL] = /* 66 */ SYSENT_CI("fstatat", fstatat, 4), /* 67 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("fstatat64", fstatat64, 4)), + SYSENT_CI("fstatat64", fstatat64, 4)), /* 68 */ SYSENT_CI("openat", openat, 4), /* 69 */ IF_LP64( SYSENT_NOSYS(), @@ -584,7 +584,7 @@ struct sysent sysent[NSYSCALL] = /* 123 */ SYSENT_CL("preadv", preadv, 5), /* 124 */ SYSENT_CL("pwritev", pwritev, 5), /* 125 */ SYSENT_LOADABLE(), /* (was fxstat) */ - /* 126 */ SYSENT_CI("getrandom", getrandom, 3), + /* 126 */ SYSENT_CL("getrandom", getrandom, 3), /* 127 */ SYSENT_CI("mmapobj", mmapobjsys, 5), /* 128 */ IF_LP64( SYSENT_CI("setrlimit", setrlimit64, 2), @@ -651,7 +651,7 @@ struct sysent sysent[NSYSCALL] = /* 178 */ SYSENT_LOADABLE(), /* kaio */ /* 179 */ SYSENT_LOADABLE(), /* cpc */ /* 180 */ SYSENT_CI("lgrpsys", lgrpsys, 3), - /* 181 */ SYSENT_CI("rusagesys", rusagesys, 5), + /* 181 */ SYSENT_CI("rusagesys", rusagesys, 5), /* 182 */ SYSENT_LOADABLE(), /* portfs */ /* 183 */ SYSENT_CI("pollsys", pollsys, 4), /* 184 */ SYSENT_CI("labelsys", labelsys, 5), @@ -700,31 +700,31 @@ struct sysent sysent[NSYSCALL] = SYSENT_AP("smmaplf32", smmaplf32, 7)), /* 215 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("stat64", stat64, 2)), + SYSENT_CI("stat64", stat64, 2)), /* 216 */ IF_LP64( SYSENT_NOSYS(), SYSENT_CI("lstat64", lstat64, 2)), /* 217 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("fstat64", fstat64, 2)), + SYSENT_CI("fstat64", fstat64, 2)), /* 218 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("statvfs64", statvfs64, 2)), + SYSENT_CI("statvfs64", statvfs64, 2)), /* 219 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("fstatvfs64", fstatvfs64, 2)), + SYSENT_CI("fstatvfs64", fstatvfs64, 2)), /* 220 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("setrlimit64", setrlimit64, 2)), + SYSENT_CI("setrlimit64", setrlimit64, 2)), /* 221 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("getrlimit64", getrlimit64, 2)), + SYSENT_CI("getrlimit64", getrlimit64, 2)), /* 222 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("pread64", pread64, 5)), + SYSENT_CI("pread64", pread64, 5)), /* 223 */ IF_LP64( SYSENT_NOSYS(), - SYSENT_CI("pwrite64", pwrite64, 5)), + SYSENT_CI("pwrite64", pwrite64, 5)), /* 224 */ SYSENT_LOADABLE(), /* (was creat64) */ /* 225 */ IF_LP64( SYSENT_NOSYS(), @@ -888,7 +888,7 @@ struct sysent sysent32[NSYSCALL] = /* 64 */ SYSENT_CI("renameat", renameat, 4), /* 65 */ SYSENT_CI("unlinkat", unlinkat, 3), /* 66 */ SYSENT_CI("fstatat", fstatat32, 4), - /* 67 */ SYSENT_CI("fstatat64", fstatat64_32, 4), + /* 67 */ SYSENT_CI("fstatat64", fstatat64_32, 4), /* 68 */ SYSENT_CI("openat", openat32, 4), /* 69 */ SYSENT_CI("openat64", openat64, 4), /* 70 */ SYSENT_CI("tasksys", tasksys, 5), @@ -1042,16 +1042,16 @@ struct sysent sysent32[NSYSCALL] = * Syscalls 213-225: 32-bit system call support for large files. */ /* 213 */ SYSENT_CI("getdents64", getdents64, 3), - /* 214 */ SYSENT_AP("smmaplf32", smmaplf32, 7), - /* 215 */ SYSENT_CI("stat64", stat64_32, 2), - /* 216 */ SYSENT_CI("lstat64", lstat64_32, 2), - /* 217 */ SYSENT_CI("fstat64", fstat64_32, 2), - /* 218 */ SYSENT_CI("statvfs64", statvfs64_32, 2), - /* 219 */ SYSENT_CI("fstatvfs64", fstatvfs64_32, 2), - /* 220 */ SYSENT_CI("setrlimit64", setrlimit64, 2), - /* 221 */ SYSENT_CI("getrlimit64", getrlimit64, 2), - /* 222 */ SYSENT_CI("pread64", pread64, 5), - /* 223 */ SYSENT_CI("pwrite64", pwrite64, 5), + /* 214 */ SYSENT_AP("smmaplf32", smmaplf32, 7), + /* 215 */ SYSENT_CI("stat64", stat64_32, 2), + /* 216 */ SYSENT_CI("lstat64", lstat64_32, 2), + /* 217 */ SYSENT_CI("fstat64", fstat64_32, 2), + /* 218 */ SYSENT_CI("statvfs64", statvfs64_32, 2), + /* 219 */ SYSENT_CI("fstatvfs64", fstatvfs64_32, 2), + /* 220 */ SYSENT_CI("setrlimit64", setrlimit64, 2), + /* 221 */ SYSENT_CI("getrlimit64", getrlimit64, 2), + /* 222 */ SYSENT_CI("pread64", pread64, 5), + /* 223 */ SYSENT_CI("pwrite64", pwrite64, 5), /* 224 */ SYSENT_LOADABLE32(), /* (was creat64) */ /* 225 */ SYSENT_CI("open64", open64, 3), /* 226 */ SYSENT_LOADABLE32(), /* rpcsys */ diff --git a/usr/src/uts/common/sys/random.h b/usr/src/uts/common/sys/random.h index 6a0d421a15..7bee6dd0b6 100644 --- a/usr/src/uts/common/sys/random.h +++ b/usr/src/uts/common/sys/random.h @@ -23,7 +23,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2015, Joyent, Inc. + * Copyright (c) 2018, Joyent, Inc. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. */ @@ -68,12 +68,11 @@ extern int random_get_pseudo_bytes(uint8_t *, size_t); #endif /* _KERNEL */ /* - * Flags for the getrandom system call. Note, we may want to move these - * definitions if we expose getrandom(2) into a public system call. + * Flags for the getrandom(2) system call. */ #define GRND_NONBLOCK 0x0001 /* O_NONBLOCK equiv */ #define GRND_RANDOM 0x0002 /* Use /dev/random, not /dev/urandom */ -extern int getrandom(void *, size_t, int); +extern ssize_t getrandom(void *, size_t, unsigned int); #ifdef __cplusplus } diff --git a/usr/src/uts/common/syscall/getrandom.c b/usr/src/uts/common/syscall/getrandom.c index af4454a154..555cc99694 100644 --- a/usr/src/uts/common/syscall/getrandom.c +++ b/usr/src/uts/common/syscall/getrandom.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2015, Joyent, Inc. + * Copyright (c) 2018, Joyent, Inc. */ /* @@ -36,8 +36,8 @@ #define MAXRANDBYTES 1024 #define MAXURANDBYTES INT_MAX -int -getrandom(void *bufp, size_t buflen, int flags) +ssize_t +getrandom(void *bufp, size_t buflen, unsigned int flags) { int out = 0; uint8_t rbytes[128]; |