From: Petr Uzel <petr.uzel@suse.cz>
To: Davidlohr Bueso <dave@gnu.org>
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH 2/5] fdisk: add total sectors
Date: Mon, 4 Jun 2012 16:14:12 +0200 [thread overview]
Message-ID: <20120604141412.GC9264@foxbat.suse.cz> (raw)
In-Reply-To: <1338747320.2864.11.camel@offbook>
[-- Attachment #1: Type: text/plain, Size: 2575 bytes --]
On Sun, Jun 03, 2012 at 08:15:20PM +0200, Davidlohr Bueso wrote:
> From: Davidlohr Bueso <dave@gnu.org>
>
> Add the total_sectors variable to the context structure. This is the initial geometry information.
>
> Signed-off-by: Davidlohr Bueso <dave@gnu.org>
> ---
> fdisk/fdisk.c | 21 ++++++++-------------
> fdisk/fdisk.h | 5 ++++-
> fdisk/fdiskdoslabel.c | 4 ++--
> fdisk/utils.c | 12 ++++++++++++
> 4 files changed, 26 insertions(+), 16 deletions(-)
>
> diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
> index d7ff2e5..654d8f3 100644
> --- a/fdisk/fdisk.c
> +++ b/fdisk/fdisk.c
> @@ -145,7 +145,6 @@ unsigned int heads,
> units_per_sector = 1,
> display_in_cyl_units = 0;
>
> -sector_t total_number_of_sectors; /* in logical sectors */
> unsigned long grain = DEFAULT_SECTOR_SIZE;
> enum labeltype disklabel; /* Current disklabel */
>
> @@ -400,8 +399,8 @@ void update_units(void)
>
> void warn_limits(struct fdisk_context *cxt)
> {
> - if (total_number_of_sectors > UINT_MAX && !nowarn) {
> - unsigned long long bytes = total_number_of_sectors * cxt->sector_size;
> + if (cxt->total_sectors > UINT_MAX && !nowarn) {
> + unsigned long long bytes = cxt->total_sectors * cxt->sector_size;
> int giga = bytes / 1000000000;
> int hectogiga = (giga + 50) / 100;
>
> @@ -509,7 +508,7 @@ update_sector_offset(struct fdisk_context *cxt)
> sector_offset = x / cxt->sector_size;
>
> /* don't use huge offset on small devices */
> - if (total_number_of_sectors <= sector_offset * 4)
> + if (cxt->total_sectors <= sector_offset * 4)
> sector_offset = cxt->phy_sector_size / cxt->sector_size;
>
> /* use 1MiB grain always when possible */
> @@ -517,7 +516,7 @@ update_sector_offset(struct fdisk_context *cxt)
> grain = 2048 * 512;
>
> /* don't use huge grain on small devices */
> - if (total_number_of_sectors <= (grain * 4 / cxt->sector_size))
> + if (cxt->total_sectors <= (grain * 4 / cxt->sector_size))
> grain = cxt->phy_sector_size;
> }
> }
> @@ -540,13 +539,9 @@ get_geometry(struct fdisk_context *cxt, struct geom *g) {
> pt_sectors ? pt_sectors :
> kern_sectors ? kern_sectors : 63;
>
> - /* get number of 512-byte sectors, and convert it the real sectors */
> - if (blkdev_get_sectors(cxt->dev_fd, &nsects) == 0)
> - total_number_of_sectors = (nsects / (cxt->sector_size >> 9));
This leaves 'nsect' as unused variable.
Otherwise it looks good to me.
Petr
--
Petr Uzel
IRC: ptr_uzl @ freenode
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
prev parent reply other threads:[~2012-06-04 14:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-03 18:15 [PATCH 2/5] fdisk: add total sectors Davidlohr Bueso
2012-06-04 14:14 ` Petr Uzel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120604141412.GC9264@foxbat.suse.cz \
--to=petr.uzel@suse.cz \
--cc=dave@gnu.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).