Skip to contentSkip to conversation

random ioctls - are they supposed to be like this?

DISCUSSION Bill Nottingham 1 participant 1 message Aug 18, 2004

lore
Share & tools
lore
#0 lore raw

include/linux/random.h has:

#define RNDADDENTROPY _IOW( 'R', 0x03, int [2] )
#define RNDGETPOOL _IOR( 'R', 0x02, int [2] )

However, these seem to be used differently in practice. For example, the one user of RNDADDENTROPY I find does:

struct {
	int ent_count;
	int size;
	unsigned char data[size];
} entropy;

if (ioctl(fd, RNDADDENTROPY, &entropy) != 0) {
...

And, looking at the random driver, it does appear to expect this format.

Now, RNDGETPOOL in the kernel does:

if (get_user(size, p) ||

    put_user(random_state->poolinfo.poolwords, p++))
	return -EFAULT;

...
if (!copy_to_user(p, tmp, size * sizeof(__u32))) {
...
if(put_user(ent_count, p++))

	return -EFAULT;

Which obviously isn't going to work right if you
just pass in a two-int structure.

Am I reading this wrong, or are callers just supposed to know to use the other interface?

Bill