random ioctls - are they supposed to be like this?

From: Bill Nottingham
Date: Wed Aug 18 2004 - 15:46:12 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/