Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FengXiao2002
Linux Imx
提交
5f443fd2
L
Linux Imx
项目概览
FengXiao2002
/
Linux Imx
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
Linux Imx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f443fd2
编写于
3月 27, 2007
作者:
C
Chris Mason
提交者:
David Woodhouse
3月 27, 2007
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
btrfs_rmdir
Signed-off-by:
N
Chris Mason
<
chris.mason@oracle.com
>
上级
9773a788
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
93 addition
and
13 deletion
+93
-13
fs/btrfs/super.c
fs/btrfs/super.c
+93
-13
未找到文件。
fs/btrfs/super.c
浏览文件 @
5f443fd2
...
...
@@ -81,11 +81,12 @@ static void btrfs_read_locked_inode(struct inode *inode)
return
;
}
static
int
btrfs_unlink
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
static
int
btrfs_unlink_trans
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
struct
inode
*
dir
,
struct
dentry
*
dentry
)
{
struct
btrfs_path
path
;
struct
btrfs_root
*
root
;
struct
btrfs_trans_handle
*
trans
;
const
char
*
name
=
dentry
->
d_name
.
name
;
int
name_len
=
dentry
->
d_name
.
len
;
int
ret
;
...
...
@@ -93,10 +94,6 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
struct
btrfs_dir_item
*
di
;
btrfs_init_path
(
&
path
);
root
=
btrfs_sb
(
dir
->
i_sb
);
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
ret
=
btrfs_lookup_dir_item
(
trans
,
root
,
&
path
,
dir
->
i_ino
,
name
,
name_len
,
-
1
);
if
(
ret
<
0
)
...
...
@@ -114,13 +111,98 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
dentry
->
d_inode
->
i_ctime
=
dir
->
i_ctime
;
err:
btrfs_release_path
(
root
,
&
path
);
btrfs_end_transaction
(
trans
,
root
);
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
if
(
ret
==
0
)
inode_dec_link_count
(
dentry
->
d_inode
);
return
ret
;
}
static
int
btrfs_unlink
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
{
struct
btrfs_root
*
root
;
struct
btrfs_trans_handle
*
trans
;
int
ret
;
root
=
btrfs_sb
(
dir
->
i_sb
);
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
ret
=
btrfs_unlink_trans
(
trans
,
root
,
dir
,
dentry
);
btrfs_end_transaction
(
trans
,
root
);
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
return
ret
;
}
static
int
btrfs_rmdir
(
struct
inode
*
dir
,
struct
dentry
*
dentry
)
{
struct
inode
*
inode
=
dentry
->
d_inode
;
int
err
;
int
ret
;
struct
btrfs_root
*
root
=
btrfs_sb
(
dir
->
i_sb
);
struct
btrfs_path
path
;
struct
btrfs_key
key
;
struct
btrfs_trans_handle
*
trans
;
struct
btrfs_disk_key
*
found_key
;
struct
btrfs_leaf
*
leaf
;
btrfs_init_path
(
&
path
);
mutex_lock
(
&
root
->
fs_info
->
fs_mutex
);
trans
=
btrfs_start_transaction
(
root
,
1
);
key
.
objectid
=
inode
->
i_ino
;
key
.
offset
=
(
u64
)
-
1
;
key
.
flags
=
0
;
btrfs_set_key_type
(
&
key
,
BTRFS_DIR_ITEM_KEY
);
ret
=
btrfs_search_slot
(
trans
,
root
,
&
key
,
&
path
,
-
1
,
1
);
if
(
ret
<
0
)
{
err
=
ret
;
goto
out
;
}
BUG_ON
(
ret
==
0
);
BUG_ON
(
path
.
slots
[
0
]
==
0
);
path
.
slots
[
0
]
--
;
leaf
=
btrfs_buffer_leaf
(
path
.
nodes
[
0
]);
found_key
=
&
leaf
->
items
[
path
.
slots
[
0
]].
key
;
if
(
btrfs_disk_key_objectid
(
found_key
)
!=
inode
->
i_ino
)
{
err
=
-
ENOENT
;
goto
out
;
}
if
(
btrfs_disk_key_type
(
found_key
)
!=
BTRFS_DIR_ITEM_KEY
||
btrfs_disk_key_offset
(
found_key
)
!=
2
)
{
err
=
-
ENOTEMPTY
;
goto
out
;
}
ret
=
btrfs_del_item
(
trans
,
root
,
&
path
);
BUG_ON
(
ret
);
btrfs_release_path
(
root
,
&
path
);
key
.
offset
=
1
;
ret
=
btrfs_search_slot
(
trans
,
root
,
&
key
,
&
path
,
-
1
,
1
);
if
(
ret
<
0
)
{
err
=
ret
;
goto
out
;
}
if
(
ret
>
0
)
{
err
=
-
ENOTEMPTY
;
goto
out
;
}
ret
=
btrfs_del_item
(
trans
,
root
,
&
path
);
if
(
ret
)
{
err
=
ret
;
goto
out
;
}
btrfs_release_path
(
root
,
&
path
);
/* now the directory is empty */
err
=
btrfs_unlink_trans
(
trans
,
root
,
dir
,
dentry
);
if
(
!
err
)
{
inode
->
i_size
=
0
;
}
out:
mutex_unlock
(
&
root
->
fs_info
->
fs_mutex
);
ret
=
btrfs_end_transaction
(
trans
,
root
);
if
(
ret
&&
!
err
)
err
=
ret
;
return
err
;
}
static
int
btrfs_free_inode
(
struct
btrfs_trans_handle
*
trans
,
struct
btrfs_root
*
root
,
struct
inode
*
inode
)
...
...
@@ -191,9 +273,6 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
break
;
if
(
btrfs_disk_key_type
(
found_key
)
!=
BTRFS_EXTENT_DATA_KEY
)
break
;
if
(
btrfs_disk_key_offset
(
found_key
)
<
inode
->
i_size
)
break
;
/* FIXME: add extent truncation */
if
(
btrfs_disk_key_offset
(
found_key
)
<
inode
->
i_size
)
break
;
fi
=
btrfs_item_ptr
(
btrfs_buffer_leaf
(
path
.
nodes
[
0
]),
...
...
@@ -209,7 +288,7 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
ret
=
btrfs_free_extent
(
trans
,
root
,
extent_start
,
extent_num_blocks
,
0
);
BUG_ON
(
ret
);
if
(
btrfs_disk_key_offset
(
found_key
)
==
0
)
if
(
key
.
offset
+
1
==
0
)
break
;
}
btrfs_release_path
(
root
,
&
path
);
...
...
@@ -852,6 +931,7 @@ static struct inode_operations btrfs_dir_inode_operations = {
.
create
=
btrfs_create
,
.
unlink
=
btrfs_unlink
,
.
mkdir
=
btrfs_mkdir
,
.
rmdir
=
btrfs_rmdir
,
};
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录