歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux文件系統omfs的普通文件創建和刪除

Omfs的普通文件的創建刪除與目錄創建刪除的動作非常類似,下面僅僅描述一下:

相關閱讀:Linux文件系統omfs的目錄創建和刪除 http://www.linuxidc.com/Linux/2012-02/54025.htm

在omfs_create處下斷點:

Breakpoint 3, omfs_create (dir=0xdde13c20, dentry=0xdf6f6440, mode=33188,

nd=0xddbe1eb8) at fs/omfs/dir.c:304

函數調用堆棧如下:

#0  omfs_create (dir=0xdde13c20, dentry=0xdf6f6440, mode=33188, nd=0xddbe1eb8)

    at fs/omfs/dir.c:304

#1  0xc029e952 in vfs_create (dir=0xdde13c20, dentry=0xdf6f6440, mode=33188,

    nd=0xddbe1eb8) at fs/namei.c:1418

#2  0xc029ebe5 in __open_namei_create (nd=0xddbe1eb8, path=0xddbe1f18,

    open_flag=35137, mode=420) at fs/namei.c:1513

#3  0xc029f119 in do_last (nd=0xddbe1eb8, path=0xddbe1f18, open_flag=35137,

    acc_mode=34, mode=438, pathname=0xd784f000 "aaaa") at fs/namei.c:1696

#4  0xc029f513 in do_filp_open (dfd=-100, pathname=0xd784f000 "aaaa",

    open_flag=35137, mode=438, acc_mode=34) at fs/namei.c:1835

#5  0xc028f239 in do_sys_open (dfd=-100, filename=0xbfe8392a "aaaa",

    flags=35137, mode=438) at fs/open.c:1052

#6  0xc028f2a7 in sys_open (filename=0xbfe8392a "aaaa", flags=35137, mode=438)

    at fs/open.c:1073

#7  0xc0104657 in ?? () at arch/x86/kernel/entry_32.S:457

 

Omfs_createàomfs_add_node(dir, dentry, mode | S_IFREG);

區別如下:

在omfs_new_inode中:

         switch (mode & S_IFMT) {

         case S_IFDIR:

                   inode->i_op = &omfs_dir_inops;

                   inode->i_fop = &omfs_dir_operations;

                   inode->i_size = sbi->s_sys_blocksize;

                   inc_nlink(inode);

                   break;

         case S_IFREG:

                   inode->i_op = &omfs_file_inops;

                   inode->i_fop = &omfs_file_operations;

                   inode->i_size = 0;

                   break;

         }

 

在omfs_make_empty中:

         if (inode->i_mode & S_IFDIR) {

                   memset(&bh->b_data[OMFS_DIR_START], 0xff,

                            sbi->s_sys_blocksize - OMFS_DIR_START);

         } else

                   omfs_make_empty_table(bh, OMFS_EXTENT_START);

 

#define OMFS_EXTENT_START 0x1d0

 

對於文件的inode,我們會在inode中寫入omfs_extent信息:

         oe->e_next = ~cpu_to_be64(0ULL);

         oe->e_extent_count = cpu_to_be32(1),

         oe->e_fill = cpu_to_be32(0x22),

         oe->e_entry.e_cluster = ~cpu_to_be64(0ULL);

         oe->e_entry.e_blocks = ~cpu_to_be64(0ULL);

Copyright © Linux教程網 All Rights Reserved