void liblustre_init_random()
{
- int _rand_dev_fd;
int seed[2];
struct timeval tv;
#ifdef LIBLUSTRE_USE_URANDOM
+ int _rand_dev_fd;
_rand_dev_fd = syscall(SYS_open, "/dev/urandom", O_RDONLY);
if (_rand_dev_fd >= 0) {
if (syscall(SYS_read, _rand_dev_fd,
ll_srand(tv.tv_sec ^ __swab32(seed[0]), tv.tv_usec ^__swab32(getpid()));
}
-void get_random_bytes(void *buf, int size)
-{
- int *p = buf;
- int rem;
- LASSERT(size >= 0);
-
- rem = min((unsigned long)buf & (sizeof(int) - 1), size);
- if (rem) {
- int val = ll_rand();
- memcpy(buf, &val, rem);
- p = buf + rem;
- size -= rem;
- }
-
- while (size >= sizeof(int)) {
- *p = ll_rand();
- size -= sizeof(int);
- p++;
- }
- buf = p;
- if (size) {
- int val = ll_rand();
- memcpy(buf, &val, size);
- }
-}
-
static void init_capability(int *res)
{
#ifdef HAVE_LIBCAP
strncpy(current->comm, comm, sizeof(current->comm));
current->pid = getpid();
+ current->gid = getgid();
current->fsuid = geteuid();
current->fsgid = getegid();
memset(¤t->pending, 0, sizeof(current->pending));
return 0;
}
-void generate_random_uuid(unsigned char uuid_out[16])
-{
- get_random_bytes(uuid_out, sizeof(uuid_out));
-}
-
int init_lib_portals()
{
int rc;