LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Accessing and performing operations on Base level kernel structure (https://www.linuxquestions.org/questions/programming-9/accessing-and-performing-operations-on-base-level-kernel-structure-857529/)

ankur0921 01-20-2011 08:38 AM

Accessing and performing operations on Base level kernel structure
 
Dear All,

We all know linux kernel base layer is made up of structures, in which every object of kernel is well defined. Structure members correspond to object properties required to define object behavior.

For example if we take case of File system.It composed of four objects , superblock objects, inode objects, file objects and dentry object.Each having well defined structure which is being operated by system call handler and by system call service routine in the kernel mode.

Now my question is even in kernel mode we do not have some mechanism by which we can get access to pointer of these structures.We have some macro.

If I want to manipulate structure on my on way, or performing some more operation defined by me.For example after the crash of Hard Disk Drive, having ext2/3 file system, If i want to know all the inode pointers, and block details.

Can I have some way out to do desired operation ??

Can anybody suggest me some mechanism to operate on these base label structures, even in kernel mode ..

All suggestions are welcomed.

Thanks & Regards.

Ankur

Nominal Animal 01-20-2011 11:45 AM

You need a Linux kernel debugger, for example kdb, and a kernel with debugging enabled (CONFIG_KDB=y). If you have a serial or ethernet connection to another machine, you can also use kgdb from the other machine. The starting point for further Linux kernel debugging information is here.

Hope this helps,
Nominal Animal

ankur0921 01-23-2011 12:54 AM

Dear Nominal Animal,

Thanks for the information, you have provided.But All this I knew earlier.I asked how to take base level structure pointers under our control to perform desired task ?

If you knew please help me in this regard.

Ankur

Nominal Animal 01-23-2011 04:32 AM

Quote:

Originally Posted by ankur0921 (Post 4231603)
Now my question is even in kernel mode we do not have some mechanism by which we can get access to pointer of these structures.We have some macro.

If I want to manipulate structure on my on way, or performing some more operation defined by me.

I don't really understand what you mean; a macro is a perfectly useful mechanism. I assume you have read Documentation/kdb.mm (part of KDB patches), which describes how to access those structures using KDB. There may be ready-made KDB "packages" (macros for KDB) that let you access the structures in an easier manner, but in any case, you can unravel the kernel macros yourself and do the necessary accesses directly yourself.

One way you can unravel the kernel access macros and inline functions is to write a small test function, and compile it to symbolic assembly in the kernel tree.

Perhaps you can give a more detailed description on what you actually want to accomplish?
Nominal Animal

ankur0921 01-26-2011 12:53 AM

Dear Nominal Animal,

I am struggling with the installation of KDB with Fedora Core 5.In fact I am not getting the proper documentation of KDB.Even stated on the sgi website or stated by you.It would be a great help if you can provide me the link of documentation you have stated.Or it you have some good documents, please do the great favor by mailing me at smile.ankur@gmail.com.

It would be a great help in my work.

Thanks and Regards.

Ankur

TheIndependentAquarius 01-26-2011 04:58 AM

Does this help a bit: http://bobcares.com/blog/?p=188 for installation of Kdb?


All times are GMT -5. The time now is 03:51 AM.