Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lseek to end on partition raw device returns 0

Hi Toby,
On Dec,Wednesday 15 2010, at 5:12 PM, Toby Karyadi wrote:

> Hi all,
> Does anyone know why doing lseek(fd, 0, SEEK_END), where fd is a
> descriptor to a raw disk partition, always returns 0 on current? This is
> not the behavior I noticed with netbsd-5.1. Does anyone else notice
> this? I am using the 201012071900Z/amd64 version of the HEAD (5.99.41),
> downloaded from I'm just dabbling with unix system
> programming, so I might be just blowing hot air here, but it seems like
> a bug to me. 
> I was trying to setup lvm on raidframe and couldn't get pass 'lvm
> pvcreate' to setup the raid partition. Doing 'lvm pvcreate -v -v -v
> /dev/rraid0d' showed that lseek(fd, 0, SEEK_END) always returns 0 and I
> got the error '/dev/rraid0d: Skipping: Too small to hold a PV' (well
> it's 0 byte). This detection is done in
> src/external/gpl2/lvm2/dist/lib/filters/filter_netbsd.c, which calls
> dev_get_size() which is implemented in device/dev-io.c using lseek. 
> The code snippet towards the end of the emai shows the problem quickly.
> It takes a filename as the first argument. On current, if you use a
> regular file it'll return the actual size, but passing any raw device
> partition (e.g. /dev/rwd0a, /dev/rraid0d) will always return 0. On 5.1,
> passing a raw device name will return the partition size in bytes. 
> I might be able to hack around the lvm problem using ioctl to get the
> size of the partition, but this seems like a bug with lseek. Thanks for
> any comments, help, or patch. 

Thanks for awesome debug report I looked at your problem and can you please 
test this patch[1], I would like to commit it if you can't reproduce your 
with it.




Home | Main Index | Thread Index | Old Index