* Linux kernel API about sector count
@ 2013-11-11 12:31 韩磊
2013-11-11 13:05 ` Mihai Donțu
0 siblings, 1 reply; 5+ messages in thread
From: 韩磊 @ 2013-11-11 12:31 UTC (permalink / raw)
To: Linux Kernel Mailing List
Can you tell me the API about the count of sector in linux kernel?
which .h file and function?
Thank you!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Linux kernel API about sector count
2013-11-11 12:31 Linux kernel API about sector count 韩磊
@ 2013-11-11 13:05 ` Mihai Donțu
2013-11-11 13:17 ` 韩磊
0 siblings, 1 reply; 5+ messages in thread
From: Mihai Donțu @ 2013-11-11 13:05 UTC (permalink / raw)
To: 韩磊; +Cc: Linux Kernel Mailing List
On Mon, 11 Nov 2013 20:31:14 +0800 韩磊 wrote:
> Can you tell me the API about the count of sector in linux kernel?
>
> which .h file and function?
>
Looking at fdisk (util-linux) there are several ioctls:
* HDIO_GETGEO (linux/hdreg.h)
* BLKGETSIZE64 (linux/fs.h), sector size is assumed 512
The HDIO interface *seems* to be legacy:
http://www.mjmwired.net/kernel/Documentation/ioctl/hdio.txt
Also see:
https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/fdisks/fdisk.c
I hope this helps a bit.
--
Mihai Donțu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Linux kernel API about sector count
2013-11-11 13:05 ` Mihai Donțu
@ 2013-11-11 13:17 ` 韩磊
2013-11-12 2:52 ` 韩磊
0 siblings, 1 reply; 5+ messages in thread
From: 韩磊 @ 2013-11-11 13:17 UTC (permalink / raw)
To: Mihai Donțu; +Cc: Linux Kernel Mailing List
Thank you! I need disk's total count of sector,not the sector size.
2013/11/11 Mihai Donțu <mihai.dontu@gmail.com>:
> On Mon, 11 Nov 2013 20:31:14 +0800 韩磊 wrote:
>> Can you tell me the API about the count of sector in linux kernel?
>>
>> which .h file and function?
>>
>
> Looking at fdisk (util-linux) there are several ioctls:
> * HDIO_GETGEO (linux/hdreg.h)
> * BLKGETSIZE64 (linux/fs.h), sector size is assumed 512
>
> The HDIO interface *seems* to be legacy:
> http://www.mjmwired.net/kernel/Documentation/ioctl/hdio.txt
>
> Also see:
> https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/fdisks/fdisk.c
>
> I hope this helps a bit.
>
> --
> Mihai Donțu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Linux kernel API about sector count
2013-11-11 13:17 ` 韩磊
@ 2013-11-12 2:52 ` 韩磊
2013-11-12 4:54 ` Davidlohr Bueso
0 siblings, 1 reply; 5+ messages in thread
From: 韩磊 @ 2013-11-12 2:52 UTC (permalink / raw)
To: Mihai Donțu; +Cc: Linux Kernel Mailing List
I need a API in linux kernel about the disk's total count of
sector,not the sector size.
thank you!
2013/11/11 韩磊 <bonben1989@gmail.com>:
> Thank you! I need disk's total count of sector,not the sector size.
>
> 2013/11/11 Mihai Donțu <mihai.dontu@gmail.com>:
>> On Mon, 11 Nov 2013 20:31:14 +0800 韩磊 wrote:
>>> Can you tell me the API about the count of sector in linux kernel?
>>>
>>> which .h file and function?
>>>
>>
>> Looking at fdisk (util-linux) there are several ioctls:
>> * HDIO_GETGEO (linux/hdreg.h)
>> * BLKGETSIZE64 (linux/fs.h), sector size is assumed 512
>>
>> The HDIO interface *seems* to be legacy:
>> http://www.mjmwired.net/kernel/Documentation/ioctl/hdio.txt
>>
>> Also see:
>> https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/fdisks/fdisk.c
>>
>> I hope this helps a bit.
>>
>> --
>> Mihai Donțu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Linux kernel API about sector count
2013-11-12 2:52 ` 韩磊
@ 2013-11-12 4:54 ` Davidlohr Bueso
0 siblings, 0 replies; 5+ messages in thread
From: Davidlohr Bueso @ 2013-11-12 4:54 UTC (permalink / raw)
To: 韩磊; +Cc: Mihai Donțu, Linux Kernel Mailing List
On Tue, 2013-11-12 at 10:52 +0800, 韩磊 wrote:
> I need a API in linux kernel about the disk's total count of
> sector,not the sector size.
> thank you!
Have you even tried searching through the code? Take a look at how fdisk
or blockdev or any other tool that deals with devices get the total
sectors, ie:
blockdev --getsize /dev/sda1
Then follow the path for such ioctl in the in the kernel source.
>
>
> 2013/11/11 韩磊 <bonben1989@gmail.com>:
> > Thank you! I need disk's total count of sector,not the sector size.
> >
> > 2013/11/11 Mihai Donțu <mihai.dontu@gmail.com>:
> >> On Mon, 11 Nov 2013 20:31:14 +0800 韩磊 wrote:
> >>> Can you tell me the API about the count of sector in linux kernel?
> >>>
> >>> which .h file and function?
> >>>
> >>
> >> Looking at fdisk (util-linux) there are several ioctls:
> >> * HDIO_GETGEO (linux/hdreg.h)
> >> * BLKGETSIZE64 (linux/fs.h), sector size is assumed 512
> >>
> >> The HDIO interface *seems* to be legacy:
> >> http://www.mjmwired.net/kernel/Documentation/ioctl/hdio.txt
> >>
> >> Also see:
> >> https://git.kernel.org/cgit/utils/util-linux/util-linux.git/tree/fdisks/fdisk.c
> >>
> >> I hope this helps a bit.
> >>
> >> --
> >> Mihai Donțu
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-12 4:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-11 12:31 Linux kernel API about sector count 韩磊
2013-11-11 13:05 ` Mihai Donțu
2013-11-11 13:17 ` 韩磊
2013-11-12 2:52 ` 韩磊
2013-11-12 4:54 ` Davidlohr Bueso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®