Re: Struct Super_Operations Changes in 2.6.25 Kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Thu, Apr 15, 2010 at 8:32 AM, Abhijit Pawar <abhijitcpawar@xxxxxxxxx> wrote:
Hi List,
I am trying to learn the filesystem development and doing some study.
I have been working on a sample filesystem module and built a normal super_operations struct. It was working on older kernel of 2.6 series till 2.6.25 and above. I realized that there were changes made in this structure and following fields were removed.
1. read_inode
2. put_inode

I read on google but there wasnt anything specific mentioned what we need to use instead. They also removed iget and suggested to use iget_lock.

Can anyone please let me know what I need to do in order to compile module?
Here is my current structure and errors.

Structure:

static const struct super_operations myfs_sops = {
    .alloc_inode    = myfs_alloc_inode,
    .destroy_inode    = myfs_destroy_inode,
    .read_inode    = myfs_read_inode,
    .put_inode    = myfs_put_inode,
    .write_inode    = myfs_write_inode,
    .delete_inode    = myfs_delete_inode,
    .put_super    = myfs_put_super,
    .write_super    = myfs_write_super,
    .statfs        = myfs_statfs,
    .clear_inode    = myfs_clear_inode,
}; 



errors:
error: unknown field ‘read_inode’ specified in initializer
error: unknown field ‘put_inode’ specified in initializer
error: implicit declaration of function ‘iget’


Your help would be highly appreciated. Also can you please let me know how should I approach the filesystem development. I am currently reading Steve D. Pate's filesystem book, but I am not very sure if it fits for current kernel. However the book is clearing lots of concept.
Please let me know how to develop a sample filesystem.

iget and read_inode calls are deprecated now. The idea of was to merge iget() code into read_inode()  to avoid duplication in filesystem code, among other benefits.

You have to change myfs_read_inode decleration & definition  to:

Decleration :
struct inode *myfs_iget(struct super_block *, unsigned long );

Definition :

struct inode *myfs_iget(struct super_block *sb, unsigned long ino)
{
            struct inode *inode;
          
            inode = iget_locked(sb, ino);
            if(!inode)
                         return ERR_PTR(-ENOMEM);
            if(!(inode->i_state & I_NEW))
                          return inode;

            // Your implementation specific code like initializeing atime, ctime, mtime, address_space mapping etc. ( depends on what you wanna do with a new inode )
       
            unlock_new_inode(inode);
            return inode;  
           
}

Then,

Change ".read_inode    = myfs_read_inode"  into  ".read_inode = myfs_iget"

Then,

Wherever you call iget in your kernel module, replace that with myfs_iget. And make sure that you check for error values after calling myfs_iget because myfs_iget can "potentially" fail.

Regards,
Venkatram Tummala


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux