sendfile from char device?

From: Matthew Kirkwood (matthew@hairy.beasts.org)
Date: Mon Feb 19 2001 - 09:04:04 EST


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/



This archive was generated by hypermail 2b29 : Fri Feb 23 2001 - 21:00:19 EST