LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2011, 12:14 PM   #1
ankur0921
LQ Newbie
 
Registered: May 2009
Posts: 25

Rep: Reputation: 0
Thumbs up Macro to access Kernel objectys structure


Dear All,

Can anybody help me out by telling the exact macro name and location, by which I can gain control over the following kernel base level structure

1. strct super_block of Virtual File System, for super block object.
2. strct inode for inode ofject of VFS.
3 file structure for file object of VFS.

in addition to these if you know location to access other kernel structure.Please let me know.My main objective is to get the access to the structure pointer of these structure by which i can have access over the individual fields o these structure.

If you know some other mechanism to do same please let me know.

Thanks & Regards.

ankur
 
Old 01-30-2011, 10:06 PM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
See if you get something from here: http://www.gnugeneration.com/books/l...20/kernel-api/
 
1 members found this post helpful.
Old 01-31-2011, 09:02 AM   #3
ankur0921
LQ Newbie
 
Registered: May 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Cool

Dear Anisha,

Thanks for the link you have provided its the good link.I didnt receive my purposeful information fron the same but I got from thehttp://www.gnugeneration.com/books/linux/2.6.20/filesystems/re44.html .But the thing is how these API can be implemented.Here only description has been provided, from which header fil it can be taken.. and other such type of information has not been provided here.Do you have some idea or some reference documents.If you have kindlt provide.. In the wait of that.

Thanks for providing the useful link..

ankur
 
Old 01-31-2011, 10:09 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
There are two ways to search for the header files:
1. To Google extensively with appropriate keywords.
2. To search the follwing path:
Code:
anisha@linux-dpjj:/usr/src/linux-2.6.31.5-0.1> grep -r get_super *
arch/parisc/hpux/sys_hpux.c:	s = user_get_super(dev);
arch/s390/hypfs/inode.c:static int hypfs_get_super(struct file_system_type *fst, int flags,
arch/s390/hypfs/inode.c:	.get_sb		= hypfs_get_super,
drivers/parport/parport_pc.c:static int get_superio_dma(struct parport *p)
drivers/parport/parport_pc.c:static int get_superio_irq(struct parport *p)
drivers/parport/parport_pc.c:		pb->irq = get_superio_irq(pb);
drivers/parport/parport_pc.c:		p->dma = get_superio_dma(p);
drivers/parport/ChangeLog:	(get_superio_dma): Likewise.
drivers/parport/ChangeLog:	(get_superio_irq): Likewise.
drivers/misc/ibmasm/ibmasmfs.c:static int ibmasmfs_get_super(struct file_system_type *fst,
drivers/misc/ibmasm/ibmasmfs.c:	.get_sb         = ibmasmfs_get_super,
drivers/block/pktcdvd.c:		sb = get_super(pkt_bdev);
fs/super.c: *	get_super - get the superblock of a device
fs/super.c:struct super_block * get_super(struct block_device *bdev)
fs/super.c:EXPORT_SYMBOL(get_super);
fs/super.c:struct super_block * user_get_super(dev_t dev)
fs/super.c:        s = user_get_super(new_decode_dev(dev));
fs/jbd2/journal.c:static int journal_get_superblock(journal_t *journal)
fs/jbd2/journal.c:	err = journal_get_superblock(journal);
fs/jbd2/journal.c:	err = journal_get_superblock(journal);
fs/reiserfs/super.c:static int get_super_block(struct file_system_type *fs_type,
fs/reiserfs/super.c:	.get_sb = get_super_block,
fs/reiserfs/procfs.c: *  . use get_super() in procfs.c
fs/block_dev.c:	struct super_block *sb = get_super(bdev);
fs/block_dev.c:		sb = get_super(bdev);
fs/block_dev.c:	sb = get_super(bdev);
fs/block_dev.c:	struct super_block *sb = get_super(bdev);
fs/block_dev.c:		 * no need to lock the super, get_super holds the
fs/fs-writeback.c:			/* we're making our own get_super here */
fs/compat.c:	sb = user_get_super(new_decode_dev(dev));
fs/quota/quota.c:	sb = get_super(bdev);
fs/nfs/super.c:		nfs_fscache_get_super_cookie(s, data);
fs/nfs/super.c:		nfs_fscache_get_super_cookie(s, data);
fs/nfs/fscache.c:void nfs_fscache_get_super_cookie(struct super_block *sb,
fs/nfs/fscache.h:extern void nfs_fscache_get_super_cookie(struct super_block *,
fs/nfs/fscache.h:static inline void nfs_fscache_get_super_cookie(
fs/jbd/journal.c:static int journal_get_superblock(journal_t *journal)
fs/jbd/journal.c:	err = journal_get_superblock(journal);
fs/jbd/journal.c:	err = journal_get_superblock(journal);
include/linux/reiserfs_fs.h:					   called. saves calls to reiserfs_get_super
include/linux/fs.h:extern struct super_block *get_super(struct block_device *);
include/linux/fs.h:extern struct super_block *user_get_super(dev_t);
 
1 members found this post helpful.
Old 01-31-2011, 10:52 AM   #5
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
<posted irrelevant stuff unknowingly>
 
Old 02-01-2011, 12:20 AM   #6
ankur0921
LQ Newbie
 
Registered: May 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Dear Anisha,

Thanks for your great help.I am obliged to you.

Ankur
 
Old 02-01-2011, 12:26 AM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Most welcome, I *think* the way to include that particular header file would be:
Code:
#include <linux/fs>
 
1 members found this post helpful.
Old 02-01-2011, 07:18 AM   #8
ankur0921
LQ Newbie
 
Registered: May 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Arrow

Hi All,

Can anybody help me where I am making wrong.I tried it all possible way..

Program :
#include<stdio.h>
#include</usr/include/sys/vfs.h>
int main()
{
char *path="/dev/hda1";
struct super_block *sb;
printf("Path = %s",path);
sb=get_super(path);
printf("Block size in bytes = %ld",sb->s_blocksize);
}

Error:
sp.c: In function ‘main’:
sp.c:8: warning: assignment makes pointer from integer without a cast
sp.c:9: error: dereferencing pointer to incomplete type

Thanks & Regards.

ankur
 
Old 02-01-2011, 07:56 AM   #9
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Code:
struct super_block * get_super(struct block_device *bdev)
and you have passed a char* to it???

Put your code in [code] tags and create a new thread for it.
 
1 members found this post helpful.
Old 02-02-2011, 12:20 AM   #10
ankur0921
LQ Newbie
 
Registered: May 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Arrow Error again

Dear All,

Below is a test program, with error produced.I understand that block_device pointer *bd sholuld get initialized.Program should produce initialization error for *bd. Compiler is producing '->'.I am not understanding why ?

Can anybody help me to get this program working fine ?
I have doubt of its working in user space as this program is accessing the kernel resources.

If anybody can provide me working code would be a great help, just to initiate things.Just a working this or any other kernel-API Code, would be a great help.

[#include<stdio.h>
#include</usr/include/sys/vfs.h>
int main()
{
//struct super_block * get_super (struct block_device *bdev);
struct block_device *bd;
printf("Block size in bytes = %ld",*get_super(bd)->s_blocksize);
}]

error:
sp.c: In function ‘main’:
sp.c:7: error: invalid type argument of ‘->’

Thanks & Regards.

ankur
 
Old 02-02-2011, 12:33 AM   #11
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Did you understand the last line of post number 9?

and bookmark the following links for future:
1. http://ugweb.cs.ualberta.ca/~rod/tut...messagesC.html
2. http://www.gnu.org/s/libc/manual/htm...rror-Reporting

Last edited by Aquarius_Girl; 02-02-2011 at 12:45 AM.
 
Old 02-02-2011, 04:32 AM   #12
ankur0921
LQ Newbie
 
Registered: May 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Arrow

Anisha,

Its fine it become complicated, but its the direct way to implement, even if we are doing same with another variable at the place of *get_super(bd), i mean same type of pointer.Same error is being produced, even sometime s_blocksize is unrecognized.I have check same field with structure .So at least this error should not get produced.What you say? Do you ever tried some 2.6 kernel API , if yes kindly provide the way how you had done that or code.

Regards.

ankur

Last edited by ankur0921; 02-02-2011 at 04:33 AM.
 
  


Reply



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
how to access Inode structure of file Pratik dhamdhere Linux - Kernel 3 11-18-2010 11:50 PM
Way to convert Macro Defined functions from linux Kernel in Visual C++ Kunsheng Programming 5 06-29-2009 09:25 AM
script or macro to access web action_owl Linux - General 2 02-16-2009 11:01 AM
Program or process to read MS Access .mdb w/ macro? gub Linux - Software 2 01-06-2008 01:38 PM
#defining a macro inside a macro? saravkrish Programming 1 05-24-2005 09:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 AM.

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
Open Source Consulting | Domain Registration