mmap() vs. character special file
- From: Dmitry Pryanishnikov <dmitry@xxxxxxxxxxxxxx>
- Date: Sat, 24 Jun 2006 01:27:05 +0300 (EEST)
Hello!
mmap(2) manpage has the following title:
NAME
mmap -- allocate memory, or map files or devices into memory
I'm curious about mmap()ing devices (particularly, HDD slices). The manpage
mentions character special files only once:
[EINVAL] MAP_ANON has not been specified and fd did not refer-
ence a regular or character special file.
So it looks like one should be able to mmap() a character special file (w/o MAP_ANON, of course). However, if I try to issue:
if ((fd=open(argv[1], O_RDWR)) == -1)
err(EX_NOINPUT, "Can't open %s for readind and writing", argv[1]);
if ((diskp=mmap(NULL, label_offset + sizeof (struct disklabel),
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED)
err(EX_IOERR, "Can't mmap() file");
against /dev/adXsY (adXsY and adXsYZ are _not_ mounted), I'm getting EINVAL
from mmap(). Is mmap()ping a disk slice/partition impossible by design, or it
just isn't implemented yet? IMHO manpage doesn't reply to this question.
Sincerely, Dmitry
--
Atlantis ISP, System Administrator
e-mail: dmitry@xxxxxxxxxxxxxx
nic-hdl: LYNX-RIPE
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: mmap() vs. character special file
- From: Peter Jeremy
- Re: mmap() vs. character special file
- From: Stanislav Sedov
- Re: mmap() vs. character special file
- Prev by Date: Re: Virtual device driver programming
- Next by Date: Re: mmap() vs. character special file
- Previous by thread: Buses, devices and modules
- Next by thread: Re: mmap() vs. character special file
- Index(es):