tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Cannot mmap character device
Hello
the mmap(2) page explicitely notes that we may map character devices.
Anyone can tell me why this fails?
# cat test.c
#include <err.h>
#include <fcntl.h>
#include <sys/mman.h>
int
main(void)
{
int fd;
void *map;
if ((fd = open("/dev/rxbd1a", O_RDONLY, 0)) == -1)
err(1, "open /dev/rxbd1a failed");
map = mmap(NULL, 4096, PROT_READ, MAP_FILE, fd, 8192);
if (map == MAP_FAILED)
err(1, "mmap /dev/rxbd1a failed");
return 0;
}
# cc -Wall -ansi -o test test.c
# ./test
test: mmap /dev/rxbd1a failed: Invalid argument
# ls -l /dev/*xbd1a
crw-r----- 1 root backups 142, 8 Nov 17 2006 /dev/rxbd1a
brw-r----- 1 root backups 142, 8 Nov 17 2006 /dev/xbd1a
# mount|grep xbd1a
/dev/xbd1a on /htdocs2 type ffs (log, local)
--
Emmanuel Dreyfus
manu%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index