Linux文件系统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);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/22590.html