Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
b81d685e
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b81d685e
编写于
5月 08, 2011
作者:
A
Aneesh Kumar K.V
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hw/9pfs: Update v9fs_wstat to use coroutines
Signed-off-by:
N
Aneesh Kumar K.V
<
aneesh.kumar@linux.vnet.ibm.com
>
上级
d7a90491
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
211 deletion
+63
-211
hw/9pfs/virtio-9p.c
hw/9pfs/virtio-9p.c
+63
-201
hw/9pfs/virtio-9p.h
hw/9pfs/virtio-9p.h
+0
-10
未找到文件。
hw/9pfs/virtio-9p.c
浏览文件 @
b81d685e
...
...
@@ -103,40 +103,6 @@ static int v9fs_do_preadv(V9fsState *s, int fd, const struct iovec *iov,
return
s
->
ops
->
preadv
(
&
s
->
ctx
,
fd
,
iov
,
iovcnt
,
offset
);
}
static
int
v9fs_do_chmod
(
V9fsState
*
s
,
V9fsString
*
path
,
mode_t
mode
)
{
FsCred
cred
;
cred_init
(
&
cred
);
cred
.
fc_mode
=
mode
;
return
s
->
ops
->
chmod
(
&
s
->
ctx
,
path
->
data
,
&
cred
);
}
static
int
v9fs_do_truncate
(
V9fsState
*
s
,
V9fsString
*
path
,
off_t
size
)
{
return
s
->
ops
->
truncate
(
&
s
->
ctx
,
path
->
data
,
size
);
}
static
int
v9fs_do_chown
(
V9fsState
*
s
,
V9fsString
*
path
,
uid_t
uid
,
gid_t
gid
)
{
FsCred
cred
;
cred_init
(
&
cred
);
cred
.
fc_uid
=
uid
;
cred
.
fc_gid
=
gid
;
return
s
->
ops
->
chown
(
&
s
->
ctx
,
path
->
data
,
&
cred
);
}
static
int
v9fs_do_utimensat
(
V9fsState
*
s
,
V9fsString
*
path
,
const
struct
timespec
times
[
2
])
{
return
s
->
ops
->
utimensat
(
&
s
->
ctx
,
path
->
data
,
times
);
}
static
int
v9fs_do_fsync
(
V9fsState
*
s
,
int
fd
,
int
datasync
)
{
return
s
->
ops
->
fsync
(
&
s
->
ctx
,
fd
,
datasync
);
}
static
void
v9fs_string_init
(
V9fsString
*
str
)
{
str
->
data
=
NULL
;
...
...
@@ -2181,39 +2147,6 @@ out:
complete_pdu
(
pdu
->
s
,
pdu
,
err
);
}
static
void
v9fs_wstat_post_truncate
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
{
if
(
err
<
0
)
{
goto
out
;
}
err
=
vs
->
offset
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
void
v9fs_wstat_post_rename
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
{
if
(
err
<
0
)
{
goto
out
;
}
if
(
vs
->
v9stat
.
length
!=
-
1
)
{
if
(
v9fs_do_truncate
(
s
,
&
vs
->
fidp
->
path
,
vs
->
v9stat
.
length
)
<
0
)
{
err
=
-
errno
;
}
}
v9fs_wstat_post_truncate
(
s
,
vs
,
err
);
return
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
int
v9fs_complete_rename
(
V9fsState
*
s
,
V9fsFidState
*
fidp
,
int32_t
newdirfid
,
V9fsString
*
name
)
{
...
...
@@ -2282,24 +2215,6 @@ out:
return
err
;
}
static
void
v9fs_wstat_post_chown
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
{
if
(
err
<
0
)
{
goto
out
;
}
if
(
vs
->
v9stat
.
name
.
size
!=
0
)
{
err
=
v9fs_complete_rename
(
s
,
vs
->
fidp
,
-
1
,
&
vs
->
v9stat
.
name
);
}
v9fs_wstat_post_rename
(
s
,
vs
,
err
);
return
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
void
v9fs_rename
(
void
*
opaque
)
{
int32_t
fid
;
...
...
@@ -2329,143 +2244,90 @@ out:
v9fs_string_free
(
&
name
);
}
static
void
v9fs_wstat
_post_utime
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
static
void
v9fs_wstat
(
void
*
opaque
)
{
if
(
err
<
0
)
{
goto
out
;
}
int32_t
fid
;
int
err
=
0
;
int16_t
unused
;
V9fsStat
v9stat
;
size_t
offset
=
7
;
struct
stat
stbuf
;
V9fsFidState
*
fidp
;
V9fsPDU
*
pdu
=
opaque
;
V9fsState
*
s
=
pdu
->
s
;
if
(
vs
->
v9stat
.
n_gid
!=
-
1
||
vs
->
v9stat
.
n_uid
!=
-
1
)
{
if
(
v9fs_do_chown
(
s
,
&
vs
->
fidp
->
path
,
vs
->
v9stat
.
n_uid
,
vs
->
v9stat
.
n_gid
)
)
{
err
=
-
errno
;
}
pdu_unmarshal
(
pdu
,
offset
,
"dwS"
,
&
fid
,
&
unused
,
&
v9stat
);
fidp
=
lookup_fid
(
s
,
fid
);
if
(
fidp
==
NULL
)
{
err
=
-
EINVAL
;
goto
out
;
}
v9fs_wstat_post_chown
(
s
,
vs
,
err
);
return
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
void
v9fs_wstat_post_chmod
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
{
if
(
err
<
0
)
{
/* do we need to sync the file? */
if
(
donttouch_stat
(
&
v9stat
))
{
err
=
v9fs_co_fsync
(
s
,
fidp
,
0
);
goto
out
;
}
if
(
vs
->
v9stat
.
mtime
!=
-
1
||
vs
->
v9stat
.
atime
!=
-
1
)
{
if
(
v9stat
.
mode
!=
-
1
)
{
uint32_t
v9_mode
;
err
=
v9fs_co_lstat
(
s
,
&
fidp
->
path
,
&
stbuf
);
if
(
err
<
0
)
{
goto
out
;
}
v9_mode
=
stat_to_v9mode
(
&
stbuf
);
if
((
v9stat
.
mode
&
P9_STAT_MODE_TYPE_BITS
)
!=
(
v9_mode
&
P9_STAT_MODE_TYPE_BITS
))
{
/* Attempting to change the type */
err
=
-
EIO
;
goto
out
;
}
err
=
v9fs_co_chmod
(
s
,
&
fidp
->
path
,
v9mode_to_mode
(
v9stat
.
mode
,
&
v9stat
.
extension
));
if
(
err
<
0
)
{
goto
out
;
}
}
if
(
v9stat
.
mtime
!=
-
1
||
v9stat
.
atime
!=
-
1
)
{
struct
timespec
times
[
2
];
if
(
v
s
->
v
9stat
.
atime
!=
-
1
)
{
times
[
0
].
tv_sec
=
v
s
->
v
9stat
.
atime
;
if
(
v9stat
.
atime
!=
-
1
)
{
times
[
0
].
tv_sec
=
v9stat
.
atime
;
times
[
0
].
tv_nsec
=
0
;
}
else
{
times
[
0
].
tv_nsec
=
UTIME_OMIT
;
}
if
(
v
s
->
v
9stat
.
mtime
!=
-
1
)
{
times
[
1
].
tv_sec
=
v
s
->
v
9stat
.
mtime
;
if
(
v9stat
.
mtime
!=
-
1
)
{
times
[
1
].
tv_sec
=
v9stat
.
mtime
;
times
[
1
].
tv_nsec
=
0
;
}
else
{
times
[
1
].
tv_nsec
=
UTIME_OMIT
;
}
if
(
v9fs_do_utimensat
(
s
,
&
vs
->
fidp
->
path
,
times
)
)
{
err
=
-
errno
;
err
=
v9fs_co_utimensat
(
s
,
&
fidp
->
path
,
times
);
if
(
err
<
0
)
{
goto
out
;
}
}
v9fs_wstat_post_utime
(
s
,
vs
,
err
);
return
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
void
v9fs_wstat_post_fsync
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
{
if
(
err
==
-
1
)
{
err
=
-
errno
;
}
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
void
v9fs_wstat_post_lstat
(
V9fsState
*
s
,
V9fsWstatState
*
vs
,
int
err
)
{
uint32_t
v9_mode
;
if
(
err
==
-
1
)
{
err
=
-
errno
;
goto
out
;
}
v9_mode
=
stat_to_v9mode
(
&
vs
->
stbuf
);
if
((
vs
->
v9stat
.
mode
&
P9_STAT_MODE_TYPE_BITS
)
!=
(
v9_mode
&
P9_STAT_MODE_TYPE_BITS
))
{
/* Attempting to change the type */
err
=
-
EIO
;
if
(
v9stat
.
n_gid
!=
-
1
||
v9stat
.
n_uid
!=
-
1
)
{
err
=
v9fs_co_chown
(
s
,
&
fidp
->
path
,
v9stat
.
n_uid
,
v9stat
.
n_gid
);
if
(
err
<
0
)
{
goto
out
;
}
}
if
(
v9fs_do_chmod
(
s
,
&
vs
->
fidp
->
path
,
v9mode_to_mode
(
vs
->
v9stat
.
mode
,
&
vs
->
v9stat
.
extension
)))
{
err
=
-
errno
;
}
v9fs_wstat_post_chmod
(
s
,
vs
,
err
);
return
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
}
static
void
v9fs_wstat
(
void
*
opaque
)
{
V9fsPDU
*
pdu
=
opaque
;
V9fsState
*
s
=
pdu
->
s
;
int32_t
fid
;
V9fsWstatState
*
vs
;
int
err
=
0
;
vs
=
g_malloc
(
sizeof
(
*
vs
));
vs
->
pdu
=
pdu
;
vs
->
offset
=
7
;
pdu_unmarshal
(
pdu
,
vs
->
offset
,
"dwS"
,
&
fid
,
&
vs
->
unused
,
&
vs
->
v9stat
);
vs
->
fidp
=
lookup_fid
(
s
,
fid
);
if
(
vs
->
fidp
==
NULL
)
{
err
=
-
EINVAL
;
goto
out
;
}
/* do we need to sync the file? */
if
(
donttouch_stat
(
&
vs
->
v9stat
))
{
err
=
v9fs_do_fsync
(
s
,
vs
->
fidp
->
fs
.
fd
,
0
);
v9fs_wstat_post_fsync
(
s
,
vs
,
err
);
return
;
if
(
v9stat
.
name
.
size
!=
0
)
{
err
=
v9fs_complete_rename
(
s
,
fidp
,
-
1
,
&
v9stat
.
name
);
if
(
err
<
0
)
{
goto
out
;
}
}
if
(
vs
->
v9stat
.
mode
!=
-
1
)
{
err
=
v9fs_do_lstat
(
s
,
&
vs
->
fidp
->
path
,
&
vs
->
stbuf
);
v9fs_wstat_post_lstat
(
s
,
vs
,
err
)
;
return
;
if
(
v9stat
.
length
!=
-
1
)
{
err
=
v9fs_co_truncate
(
s
,
&
fidp
->
path
,
v9stat
.
length
);
if
(
err
<
0
)
{
goto
out
;
}
}
v9fs_wstat_post_chmod
(
s
,
vs
,
err
);
return
;
err
=
offset
;
out:
v9fs_stat_free
(
&
vs
->
v9stat
);
complete_pdu
(
s
,
vs
->
pdu
,
err
);
g_free
(
vs
);
v9fs_stat_free
(
&
v9stat
);
complete_pdu
(
s
,
pdu
,
err
);
}
static
int
v9fs_fill_statfs
(
V9fsState
*
s
,
V9fsPDU
*
pdu
,
struct
statfs
*
stbuf
)
...
...
hw/9pfs/virtio-9p.h
浏览文件 @
b81d685e
...
...
@@ -295,16 +295,6 @@ typedef struct V9fsWriteState {
int
cnt
;
}
V9fsWriteState
;
typedef
struct
V9fsWstatState
{
V9fsPDU
*
pdu
;
size_t
offset
;
int16_t
unused
;
V9fsStat
v9stat
;
V9fsFidState
*
fidp
;
struct
stat
stbuf
;
}
V9fsWstatState
;
typedef
struct
V9fsIattr
{
int32_t
valid
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录