public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* How to mount own file system in linux
@ 2006-07-19  8:49 Chinmaya Mishra
  2006-07-19  8:56 ` Pekka Enberg
  0 siblings, 1 reply; 2+ messages in thread
From: Chinmaya Mishra @ 2006-07-19  8:49 UTC (permalink / raw)
  To: Linux Kernel

Hi all,
        I want to create new file system in linux 2.6.10 kernel just to 
print the super block information.
Can you suggest me where I can get some good documents to proceed or any 
dummy code if any.

I have tried this with the following code but it gives some warning 
messages during compilation. The file system is registered but during 
the mount command segmentation fault occurs.

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/fs.h>
#include <linux/sched.h>

static struct super_block *rfs_read_super( struct super_block *sb, void 
*buf, int size);
static struct file_system_type rfs = {"rfs", 0, rfs_read_super, NULL};
/*--------------------------------------------------------------------------------------------*/ 

static struct super_block *rfs_read_super( struct super_block *sb, void 
*buf, int size) {
       printk("rkfs: read_super returning a valid super_block\n" );
       sb->s_blocksize = 1024;
       sb->s_blocksize_bits = 10;
       return sb;
}
/*--------------------------------------------------------------------------------------------*/ 

int init_module(void) {
       int err;
       err = register_filesystem(&rfs);
       printk("rkfs: file system registered\n" );
       return err;
}
/*--------------------------------------------------------------------------------------------*/ 

void cleanup_module(void) {
       unregister_filesystem(&rfs);
       printk("rkfs: file system unregistered\n" );
}
/*--------------------------------------------------------------------------------------------*/ 

MODULE_LICENSE("GPL");

regards,
chinmaya


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to mount own file system in linux
  2006-07-19  8:49 How to mount own file system in linux Chinmaya Mishra
@ 2006-07-19  8:56 ` Pekka Enberg
  0 siblings, 0 replies; 2+ messages in thread
From: Pekka Enberg @ 2006-07-19  8:56 UTC (permalink / raw)
  To: chinmaya; +Cc: Linux Kernel

Hi,

On 7/19/06, Chinmaya Mishra <chinmaya4@gmail.com> wrote:
> Can you suggest me where I can get some good documents to proceed or any
> dummy code if any.

See fs/ramfs/ for an example. There's also Documentation/filesystems/vfs.txt.

On 7/19/06, Chinmaya Mishra <chinmaya4@gmail.com> wrote:
> I have tried this with the following code but it gives some warning
> messages during compilation. The file system is registered but during
> the mount command segmentation fault occurs.

So maybe pay attention to the warnings?

> static struct super_block *rfs_read_super( struct super_block *sb, void
> *buf, int size);
> static struct file_system_type rfs = {"rfs", 0, rfs_read_super, NULL};

There's no read_super in struct file_system_type. See
include/linux/fs.h for details.

> int init_module(void) {

[snip]

> void cleanup_module(void) {

[snip]

This is the old way. You really want to be using module_init and
module_exit macros.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-19  8:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-19  8:49 How to mount own file system in linux Chinmaya Mishra
2006-07-19  8:56 ` Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox