Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
f7922033
K
Kernel
项目概览
openeuler
/
Kernel
1 年多 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f7922033
编写于
3月 25, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 25, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
btrfs_mkdir
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
dcea7915
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
119 deletion
+65
-119
fs/btrfs/super.c
fs/btrfs/super.c
+65
-119
未找到文件。
fs/btrfs/super.c
浏览文件 @
f7922033
...
...
@@ -18,124 +18,6 @@ static struct inode_operations btrfs_dir_inode_operations;
static
struct
super_operations
btrfs_super_ops
;
static
struct
file_operations
btrfs_dir_file_operations
;
#if 0
/* some random number */
static struct super_operations ramfs_ops;
static struct backing_dev_info ramfs_backing_dev_info = {
.ra_pages = 0, /* No readahead */
.capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK |
BDI_CAP_MAP_DIRECT | BDI_CAP_MAP_COPY |
BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP,
};
struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
{
struct inode * inode = new_inode(sb);
if (inode) {
inode->i_mode = mode;
inode->i_uid = current->fsuid;
inode->i_gid = current->fsgid;
inode->i_blocks = 0;
inode->i_mapping->a_ops = &ramfs_aops;
inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
switch (mode & S_IFMT) {
default:
init_special_inode(inode, mode, dev);
break;
case S_IFREG:
inode->i_op = &ramfs_file_inode_operations;
inode->i_fop = &ramfs_file_operations;
break;
case S_IFDIR:
inode->i_op = &ramfs_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
/* directory inodes start off with i_nlink == 2 (for "." entry) */
inc_nlink(inode);
break;
case S_IFLNK:
inode->i_op = &page_symlink_inode_operations;
break;
}
}
return inode;
}
/*
* File creation. Allocate an inode, and we're done..
*/
/* SMP-safe */
static int
ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
{
struct inode * inode = ramfs_get_inode(dir->i_sb, mode, dev);
int error = -ENOSPC;
if (inode) {
if (dir->i_mode & S_ISGID) {
inode->i_gid = dir->i_gid;
if (S_ISDIR(mode))
inode->i_mode |= S_ISGID;
}
d_instantiate(dentry, inode);
dget(dentry); /* Extra count - pin the dentry in core */
error = 0;
dir->i_mtime = dir->i_ctime = CURRENT_TIME;
}
return error;
}
static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
{
int retval = ramfs_mknod(dir, dentry, mode | S_IFDIR, 0);
if (!retval)
inc_nlink(dir);
return retval;
}
static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
{
return ramfs_mknod(dir, dentry, mode | S_IFREG, 0);
}
static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
{
struct inode *inode;
int error = -ENOSPC;
inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
if (inode) {
int l = strlen(symname)+1;
error = page_symlink(inode, symname, l);
if (!error) {
if (dir->i_mode & S_ISGID)
inode->i_gid = dir->i_gid;
d_instantiate(dentry, inode);
dget(dentry);
dir->i_mtime = dir->i_ctime = CURRENT_TIME;
} else
iput(inode);
}
return error;
}
static struct inode_operations ramfs_dir_inode_operations = {
.create = ramfs_create,
.lookup = simple_lookup,
.link = simple_link,
.unlink = simple_unlink,
.symlink = ramfs_symlink,
.mkdir = ramfs_mkdir,
.rmdir = simple_rmdir,
.mknod = ramfs_mknod,
.rename = simple_rename,
};
#endif
static
void
btrfs_read_locked_inode
(
struct
inode
*
inode
)
{
struct
btrfs_path
path
;
...
...
@@ -533,9 +415,11 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
inode
->
i_ino
=
objectid
;
inode
->
i_blocks
=
0
;
inode
->
i_mtime
=
inode
->
i_atime
=
inode
->
i_ctime
=
CURRENT_TIME_SEC
;
/* FIXME do this on link */
if
(
mode
&
S_IFDIR
)
inode
->
i_size
=
3
;
fill_inode_item
(
&
inode_item
,
inode
);
key
.
objectid
=
objectid
;
key
.
flags
=
0
;
key
.
offset
=
0
;
...
...
@@ -603,6 +487,67 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
return
err
;
}
static
int
btrfs_make_empty_dir
(
struct
btrfs_trans_handle
*
trans
,
struct
inode
*
inode
,
struct
inode
*
dir
)
{
struct
btrfs_root
*
root
=
btrfs_sb
(
inode
->
i_sb
);
int
ret
;
char
buf
[
2
];
buf
[
0
]
=
'.'
;
buf
[
1
]
=
'.'
;
ret
=
btrfs_insert_dir_item
(
trans
,
root
,
buf
,
1
,
inode
->
i_ino
,
inode
->
i_ino
,
1
);
if
(
ret
)
goto
error
;
ret
=
btrfs_insert_dir_item
(
trans
,
root
,
buf
,
2
,
inode
->
i_ino
,
dir
->
i_ino
,
1
);
error:
return
ret
;
}
static
int
btrfs_mkdir
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
int
mode
)
{
struct
inode
*
inode
;
struct
btrfs_trans_handle
*
trans
;
struct
btrfs_root
*
root
=
btrfs_sb
(
dir
->
i_sb
);
int
err
=
0
;
int
drop_on_err
=
0
;
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
if
(
IS_ERR
(
trans
))
{
err
=
PTR_ERR
(
trans
);
goto
out_unlock
;
}
inode
=
btrfs_new_inode
(
trans
,
dir
,
S_IFDIR
|
mode
);
if
(
IS_ERR
(
inode
))
{
err
=
PTR_ERR
(
inode
);
goto
out_fail
;
}
drop_on_err
=
1
;
inode
->
i_op
=
&
btrfs_dir_inode_operations
;
inode
->
i_fop
=
&
btrfs_dir_file_operations
;
err
=
btrfs_make_empty_dir
(
trans
,
inode
,
dir
);
if
(
err
)
goto
out_fail
;
err
=
btrfs_add_link
(
trans
,
dentry
,
inode
);
if
(
err
)
goto
out_fail
;
d_instantiate
(
dentry
,
inode
);
mark_inode_dirty
(
inode
);
drop_on_err
=
0
;
out_fail:
btrfs_end_transaction
(
trans
,
root
);
out_unlock:
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
if
(
drop_on_err
)
iput
(
inode
);
return
err
;
}
static
int
btrfs_sync_fs
(
struct
super_block
*
sb
,
int
wait
)
{
struct
btrfs_trans_handle
*
trans
;
...
...
@@ -661,6 +606,7 @@ static struct inode_operations btrfs_dir_inode_operations = {
.
lookup
=
btrfs_lookup
,
.
create
=
btrfs_create
,
.
unlink
=
btrfs_unlink
,
.
mkdir
=
btrfs_mkdir
,
};
static
struct
file_operations
btrfs_dir_file_operations
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录