Bug 487227 - fdisk doesn't handle large sectors properly
Summary: fdisk doesn't handle large sectors properly
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux-ng
Version: rawhide
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 463632 614404 618062 696265
TreeView+ depends on / blocked
 
Reported: 2009-02-24 21:31 UTC by Eric Sandeen
Modified: 2011-04-13 17:57 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2009-03-19 14:11:52 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
potential patch (1.76 KB, patch)
2009-02-24 21:45 UTC, Eric Sandeen
no flags Details | Diff

Description Eric Sandeen 2009-02-24 21:31:32 UTC
fdisk (at least with the -u option) does not handle sector sizes other than 512 correctly:

# modprobe scsi_debug sector_size=4096 
# fdisk -u /dev/sdd
Note: sector size is 4096 (not 512)
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x4afdb02f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (32-16383, default 32): 
Using default value 32
Last sector, +sectors or +size{K,M,G} (32-16383, default 16383): 
Using default value 16383

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
# dmesg | tail -n 2
 sdd: sdd1
sdd: p1 size 130816 limited to end of disk

# fdisk -l /dev/sdd
Note: sector size is 4096 (not 512)

Disk /dev/sdd: 8 MB, 8388608 bytes
8 heads, 32 sectors/track, 8 cylinders
Units = cylinders of 256 * 4096 = 1048576 bytes
Disk identifier: 0x4afdb02f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1          64       65408   83  Linux

I think the only problem is that it is suggesting a default of last sector based on 512-byte sectors, not the 4k sectors.

I'll attach a patch that may be reasonable ...

-Eric

Comment 1 Eric Sandeen 2009-02-24 21:45:02 UTC
Created attachment 333094 [details]
potential patch

potential patch; made "sector_factor" a global, and use it in place of "sector_size/512"; also modify the limit in add_partition by this amount.

Comment 2 Karel Zak 2009-02-26 15:09:59 UTC
Applied to upstream tree.
http://git.kernel.org/?p=utils/util-linux-ng/util-linux-ng.git

I found some others places in util-linux-ng where is mess around hard sectors.

Thanks!


Note You need to log in before you can comment on or make changes to this bug.