linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ronghua Zhang <rz5b@cs.virginia.edu>
To: linux-fsdevel@vger.kernel.org, kernelnewbies@nl.linux.org
Subject: problems in implementing a new file system
Date: Mon, 17 Feb 2003 17:43:02 -0500 (EST)	[thread overview]
Message-ID: <Pine.GSO.4.51.0302171727420.13225@mamba.cs.Virginia.EDU> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1722 bytes --]

I am implementing a new file system. As a prototype, only read_super and
read_inode are implmented. What suprises me is that, when read_inode is
called to read in root inode , inode->i_sb is _not_ the super block
pointer passed to read_super function call. Can anybody kindly help me
find the problem? My code is the following:

#include <linux/config.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/snet_fs.h>

static struct super_operations snet_sops = {
    read_inode:     snet_read_inode,
};

void snet_read_inode(struct inode *inode)
{
    SNETFS_DEBUG("snet_read_inode, ino = %lu, sb = %p\n", inode->i_ino,
                 inode->i_sb);
    if (inode->i_ino == 1){
        inode->i_mode = S_IFDIR;
    }
}

struct super_block * snet_read_super(struct super_block * sb, void * data,
                                     int silent)
{
    SNETFS_DEBUG("snet_read_super() called, sb = %p\n", sb);
    sb->s_magic = SNET_SUPER_MAGIC;
    sb->s_op = &snet_sops;
    sb->s_root = d_alloc_root(iget(sb, 1));
    if (!sb->s_root){
        printk("snet_read_super: get root inode failed\n");
        return NULL;
    }

    return sb;
}

static DECLARE_FSTYPE(snet_fs_type, "simple", snet_read_super, 0);

static int __init init_snet_fs(void)
{
    return register_filesystem(&snet_fs_type);
}

static void __exit exit_snet_fs(void)
{
    unregister_filesystem(&snet_fs_type);
}

EXPORT_NO_SYMBOLS;

module_init(init_snet_fs)
module_exit(exit_snet_fs)


To test it, I first insmod snet.o, then run mount /dev/zero /mnt -t
simple. dmesg show the following:
snet_read_super() called, sb = d1f86800
snet_read_inode() called, sb = c02cd4a0

notice that two sb are different, which should not be.

Thanks.

rz

[-- Attachment #2: Type: TEXT/PLAIN, Size: 1361 bytes --]

#include <linux/config.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/snet_fs.h>

static struct super_operations snet_sops = {
	read_inode:     snet_read_inode,
};

void snet_read_inode(struct inode *inode)
{
	SNETFS_DEBUG("snet_read_inode, ino = %lu, sb = %p\n", inode->i_ino,
	             inode->i_sb);
	if (SNET_IS_RESERVED_DIR(inode->i_ino)){
		inode->i_mode = S_IFDIR;
	}
}

struct super_block * snet_read_super(struct super_block * sb, void * data, 
                                     int silent)
{	
	SNETFS_DEBUG("snet_read_super() called, sb = %p\n", sb);
	sb->s_magic = SNET_SUPER_MAGIC;
	sb->s_op = &snet_sops;
	sb->s_root = d_alloc_root(iget(sb, SNET_ROOT_INO));
	if (!sb->s_root){
		printk("snet_read_super: get root inode failed\n");
		return NULL; 
	}

	/* TODO: allocate the first page for /, /raw, /event, /proc */
	SNETFS_DEBUG("snet_read_super() done\n");
	return sb;
}

static DECLARE_FSTYPE(snet_fs_type, "simple", snet_read_super, 0);

static int __init init_snet_fs(void)
{
	SNETFS_DEBUG("init_snet_fs() called\n");

	return register_filesystem(&snet_fs_type);
}

static void __exit exit_snet_fs(void)
{
	SNETFS_DEBUG("exit_snet_fs() called\n");
	unregister_filesystem(&snet_fs_type);
}

EXPORT_NO_SYMBOLS;

module_init(init_snet_fs)
module_exit(exit_snet_fs)


             reply	other threads:[~2003-02-17 22:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-17 22:43 Ronghua Zhang [this message]
2003-02-17 22:53 ` problems in implementing a new file system Ronghua Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.51.0302171727420.13225@mamba.cs.Virginia.EDU \
    --to=rz5b@cs.virginia.edu \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).