lkml.org 
[lkml]   [2013]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: How can I get the sector count in kernel?
Hi again :)

> I need the count of sector,but I don't know how to get it.
> Could you give me some favour?

First, you should ask yourself whether you really need this
drive-specific information.


Such information can (more or less) be gathered via the HDIO_GETGEO
ioctl. But be advised that this ioctl is known to be
unreliable/undesirable and will be handled differently
(and with differing reliability!!!) by various I/O layers.
E.g. this will be handled by a callback, which in the case of libata
will return values that are hard-coded for *LBA-specific* disk geometry
(255 heads).
Good luck if your disk happens to be using CHS or ECHS, where this value
likely is NOT the proper one. Especially in the case of ntfsclone /
partclone.ntfsfixboot combo this is a major nuisance (and you'll
probably end up having to manually specify the actually correct values
in order to finally get that f***in' thing to boot properly).

Also, you should make sure to be using the EDD BIOS service (see modinfo edd),
for the kernel to be able to forward actual BIOS-side drive geometry
information.

Another way to be gathering a geometry is by parsing geometry output
of fdisk / cfdisk.

HTH,

Andreas Mohr


\
 
 \ /
  Last update: 2013-11-10 23:21    [W:0.055 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site