tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: block/dk devices and lseek()
rvp%SDF.ORG@localhost (RVP) writes:
>Are block and dk* (wedge) devices supposed to support lseek()?
When a disk device is opened, the DIOCGPARTINFO ioctl is used to
query the size of the disk and cache it in the vnode.
The dk driver doesn't represent a disk and doesn't support DIOCGPARTINFO.
It does support DIOCGWEDGEINFO, DIOCGDISKINFO and DIOCGSECTORSIZE +
DIOCGMEDIASIZE that would reveal the information.
The same is true for the dm driver.
But that's only half of the story.
>$ sudo stat -f '%N: %z' /dev/rsd0
>/dev/rsd0: 7849115648 # works
>$ sudo stat -f '%N: %z' /dev/sd0
>/dev/sd0: 0 # is this correct?
The stat command uses the lstat() system call, it does not
open a device, but only returns the cached size information
in the vnode.
A device that is open or where the vnode is still cached after an open
will reveal the size, otherwise you get a zero result. E.g.
# stat -f "%N: %z" /dev/raid0b
/dev/raid0b: 968884224
# stat -f "%N: %z" /dev/rraid0b
/dev/rraid0b: 0
# dd if=/dev/rraid0b of=/dev/null count=10
10+0 records in
10+0 records out
5120 bytes transferred in 0.014 secs (365714 bytes/sec)
# stat -f "%N: %z" /dev/rraid0b
/dev/rraid0b: 968884224
The root block device can also be special as it usually isn't opened
(with spec_open) and cannot be opened later as it is always busy, so
the size is never cached.
Home |
Main Index |
Thread Index |
Old Index