linux文件系统omfs的普通文件创建和删除

 

Omfs的普通文件的创建删除与目录创建删除的动作非常类似,下面仅仅描述一下:

 

在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);

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值