bug-parted
[Top][All Lists]
Advanced

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

Re: [PATCH] libparted: use ioctl(BLKPBSZGET) to get phys sector size


From: Yang Bai
Subject: Re: [PATCH] libparted: use ioctl(BLKPBSZGET) to get phys sector size
Date: Sat, 20 Oct 2012 22:49:19 +0800

ping. Any comments?

Please cc to me since I am not in these 2 mailing lists.

Thanks,
Yang

On Wed, Oct 17, 2012 at 10:27 PM, Yang Bai <address@hidden> wrote:
> Before, we use ioctl(BLKSSZGET) to get a disk's sector size and use this
> value as both logical and physical sector size, but this value is just
> the logical sector size. For physical sector size, we should use
> ioctl(BLKPBSZGET). Since the popular of 4K AF hard disks, the logical
> sector size if different from the physical one. Without blkid, we cant
> get the right info about the disk so we could not align right the
> partitions on this disk.
> This patch has been tested on 2.6.32 kernel and we can get the right
> sector sizes without blkid.
>
> Signed-off-by: Yang Bai <address@hidden>
> ---
>  libparted/arch/linux.c |    7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index e2c4139..9452977 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -203,6 +203,7 @@ struct hd_driveid {
>  #define BLKGETSIZE _IO(0x12,96) /* return device size */
>  #define BLKFLSBUF  _IO(0x12,97) /* flush buffer cache */
>  #define BLKSSZGET  _IO(0x12,104) /* get block device sector size */
> +#define BLKPBSZGET _IO(0x12,123) /* get device physical sector size */
>  #define BLKGETLASTSECT  _IO(0x12,108) /* get last sector of block device */
>  #define BLKSETLASTSECT  _IO(0x12,109) /* set last sector of block device */
>
> @@ -659,6 +660,7 @@ _device_set_sector_size (PedDevice* dev)
>  {
>          LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
>          int sector_size;
> +        int phys_sector_size;
>
>          dev->sector_size = PED_SECTOR_SIZE_DEFAULT;
>          dev->phys_sector_size = PED_SECTOR_SIZE_DEFAULT;
> @@ -670,7 +672,8 @@ _device_set_sector_size (PedDevice* dev)
>                  return;
>          }
>
> -        if (ioctl (arch_specific->fd, BLKSSZGET, &sector_size)) {
> +        if (ioctl(arch_specific->fd, BLKSSZGET, &sector_size) ||
> +            ioctl(arch_specific->fd, BLKPBSZGET, &phys_sector_size)) {
>                  ped_exception_throw (
>                          PED_EXCEPTION_WARNING,
>                          PED_EXCEPTION_OK,
> @@ -679,7 +682,7 @@ _device_set_sector_size (PedDevice* dev)
>                          dev->path, strerror (errno), 
> PED_SECTOR_SIZE_DEFAULT);
>          } else {
>                  dev->sector_size = (long long)sector_size;
> -                dev->phys_sector_size = dev->sector_size;
> +                dev->phys_sector_size = (long long)phys_sector_size;
>          }
>
>  #if USE_BLKID
> --
> 1.7.10.4
>



-- 
    """
    Keep It Simple,Stupid.
    """

Chinese Name: 白杨
Nick Name: Hamo
Homepage: http://hamobai.com/
GPG KEY ID: 0xA4691A33
Key fingerprint = 09D5 2D78 8E2B 0995 CF8E  4331 33C4 3D24 A469 1A33



reply via email to

[Prev in Thread] Current Thread [Next in Thread]