sendfile from char device?

Matthew Kirkwood (matthew@hairy.beasts.org)
Mon, 19 Feb 2001 14:04:04 +0000 (GMT)


Hi,

I'm looking for a fast way to initialise a file to zeroes
(without holes) and reckoned that sendfile from /dev/zero
would be the way to go.

But, unfortunately, sendfile (in 2.2 and 2.4) appears not
to support sendfile(2)ing a device:

$ cat foo.c
main()
{
if(sendfile(1, 0, 0, 1024) < 0)
perror("failed");
}
$ cc foo.c
$ ./a.out </etc/passwd >/dev/null
$ ./a.out </dev/zero >/tmp/test
failed: Invalid argument

I haven't played the printk game, but it looks like it may
be tripping up on the fact that devices don't support locks.
Or is it the lack of a ->readpage() method on /dev/zero?

Matthew.

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