[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20131110214535.GA30532@rhlx01.hs-esslingen.de>
Date: Sun, 10 Nov 2013 22:45:35 +0100
From: Andreas Mohr <andi@...as.de>
To: =?GB2312?B?uqvA2g==?= <bonben1989@...il.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists