Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
3506ad7f
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3506ad7f
编写于
5月 03, 2016
作者:
N
Nikolay Shirokovskiy
提交者:
Cole Robinson
5月 03, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
util: factor out reading file into preallocated buffer
Signed-off-by:
N
Nikolay Shirokovskiy
<
nshirokovskiy@virtuozzo.com
>
上级
600977e2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
9 deletion
+29
-9
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/util/virfile.c
src/util/virfile.c
+24
-0
src/util/virfile.h
src/util/virfile.h
+2
-0
src/util/viruuid.c
src/util/viruuid.c
+2
-9
未找到文件。
src/libvirt_private.syms
浏览文件 @
3506ad7f
...
...
@@ -1512,6 +1512,7 @@ virFileOpenTty;
virFilePrintf;
virFileReadAll;
virFileReadAllQuiet;
virFileReadBufQuiet;
virFileReadHeaderFD;
virFileReadLimFD;
virFileRelLinkPointsTo;
...
...
src/util/virfile.c
浏览文件 @
3506ad7f
...
...
@@ -1401,6 +1401,30 @@ virFileReadAllQuiet(const char *path, int maxlen, char **buf)
return
len
;
}
/* Read @file into preallocated buffer @buf of size @len.
* Return value is -errno in case of errors and size
* of data read (no trailing zero) in case of success.
* If there is more data then @len - 1 then data will be
* truncated. */
int
virFileReadBufQuiet
(
const
char
*
file
,
char
*
buf
,
int
len
)
{
int
fd
;
ssize_t
sz
;
fd
=
open
(
file
,
O_RDONLY
);
if
(
fd
<
0
)
return
-
errno
;
sz
=
saferead
(
fd
,
buf
,
len
-
1
);
VIR_FORCE_CLOSE
(
fd
);
if
(
sz
<
0
)
return
-
errno
;
buf
[
sz
]
=
'\0'
;
return
sz
;
}
/* Truncate @path and write @str to it. If @mode is 0, ensure that
@path exists; otherwise, use @mode if @path must be created.
Return 0 for success, nonzero for failure.
...
...
src/util/virfile.h
浏览文件 @
3506ad7f
...
...
@@ -131,6 +131,8 @@ int virFileReadAll(const char *path, int maxlen, char **buf)
ATTRIBUTE_RETURN_CHECK
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
3
);
int
virFileReadAllQuiet
(
const
char
*
path
,
int
maxlen
,
char
**
buf
)
ATTRIBUTE_RETURN_CHECK
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
3
);
int
virFileReadBufQuiet
(
const
char
*
file
,
char
*
buf
,
int
len
)
ATTRIBUTE_RETURN_CHECK
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
2
);
int
virFileWriteStr
(
const
char
*
path
,
const
char
*
str
,
mode_t
mode
)
ATTRIBUTE_NONNULL
(
1
)
ATTRIBUTE_NONNULL
(
2
)
ATTRIBUTE_RETURN_CHECK
;
...
...
src/util/viruuid.c
浏览文件 @
3506ad7f
...
...
@@ -231,15 +231,8 @@ getDMISystemUUID(char *uuid, int len)
};
while
(
paths
[
i
])
{
int
fd
=
open
(
paths
[
i
],
O_RDONLY
);
if
(
fd
>=
0
)
{
if
(
saferead
(
fd
,
uuid
,
len
-
1
)
==
len
-
1
)
{
uuid
[
len
-
1
]
=
'\0'
;
VIR_FORCE_CLOSE
(
fd
);
return
0
;
}
VIR_FORCE_CLOSE
(
fd
);
}
if
(
virFileReadBufQuiet
(
paths
[
i
],
uuid
,
len
)
==
len
-
1
)
return
0
;
i
++
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录