LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-19-2014, 03:13 AM   #1
xianyu1337
LQ Newbie
 
Registered: May 2014
Posts: 1

Rep: Reputation: Disabled
traverse all the disks or get hd_struct by device name in kernel module


hi.

I'm writing a kernel module(on linux 2.6.32), to get the disk_stats of all the disks(not partition) in use. In other words, I'm getting the data just like what /sys/block/sda/stat shows, but in kernel module.

(NOTE: By 'not partition', I mean we just handle sda and ignore sda1/sda2/etc, for example.)

Is there anything like for_each_netdev or for_each_possible_cpu for block device? Beacuse there may be multiple disks and I need a way to traverse them. Or at the latest, how can I get the related data structure with the block device's name(like sda)?

I know we can get a disk's disk_stats from the disk's hd_struct, but how could I get this hd_struct?

I have read linux2.6.32/block/genhd.c, and I know the content of file /sys/block/sda/stat is generated by diskstats_show. But how does the second argument come?

Please help me. thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to (re)-enable wi-fi device in kernel module Phoenix_Swelter Linux - Hardware 28 06-04-2013 09:04 AM
Kernel Module question: how to know if device is supported by module mustafaupk Programming 3 04-02-2013 12:00 AM
[Q] HOW TO rmmod with malfunction device driver kernel module. jspking Linux - General 2 04-08-2012 02:16 AM
A simple Linux Kernel Device Module jhwilliams Programming 1 08-07-2007 06:37 PM
Character Device kernel(2.4.18) - module problem shibdas Programming 2 11-11-2004 03:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration