Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
af3ba2cd
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,发现更多精彩内容 >>
提交
af3ba2cd
编写于
11月 01, 2010
作者:
O
Osier Yang
提交者:
Eric Blake
11月 01, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
util: Add helper function to build timestamp string
* src/util/util.h * src/util/util.c * src/libvirt_private.syms
上级
d02d548e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
0 deletion
+32
-0
src/libvirt_private.syms
src/libvirt_private.syms
+1
-0
src/util/util.c
src/util/util.c
+28
-0
src/util/util.h
src/util/util.h
+3
-0
未找到文件。
src/libvirt_private.syms
浏览文件 @
af3ba2cd
...
...
@@ -779,6 +779,7 @@ virStrToLong_ui;
virStrToLong_ull;
virStrcpy;
virStrncpy;
virTimestamp;
# uuid.h
...
...
src/util/util.c
浏览文件 @
af3ba2cd
...
...
@@ -38,6 +38,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <sys/time.h>
#if HAVE_MMAP
# include <sys/mman.h>
#endif
...
...
@@ -2912,3 +2913,30 @@ int virBuildPathInternal(char **path, ...)
return
ret
;
}
/**
* virTimestamp:
*
* Return an allocated string containing the current date and time,
* followed by ": ". Return NULL on allocation failure.
*/
char
*
virTimestamp
(
void
)
{
struct
timeval
cur_time
;
struct
tm
time_info
;
char
timestr
[
100
];
char
*
timestamp
;
gettimeofday
(
&
cur_time
,
NULL
);
localtime_r
(
&
cur_time
.
tv_sec
,
&
time_info
);
strftime
(
timestr
,
sizeof
(
timestr
),
"%Y-%m-%d %H:%M:%S"
,
&
time_info
);
if
(
virAsprintf
(
&
timestamp
,
"%s.%03d: "
,
timestr
,
(
int
)
cur_time
.
tv_usec
/
1000
)
<
0
)
{
return
NULL
;
}
return
timestamp
;
}
src/util/util.h
浏览文件 @
af3ba2cd
...
...
@@ -160,6 +160,7 @@ int virFileOpenTtyAt(const char *ptmx,
char
*
virFilePid
(
const
char
*
dir
,
const
char
*
name
);
int
virFileWritePidPath
(
const
char
*
path
,
pid_t
pid
)
ATTRIBUTE_RETURN_CHECK
;
int
virFileWritePid
(
const
char
*
dir
,
...
...
@@ -277,4 +278,6 @@ void virFileWaitForDevices(void);
# define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
int
virBuildPathInternal
(
char
**
path
,
...)
ATTRIBUTE_SENTINEL
;
char
*
virTimestamp
(
void
);
#endif
/* __VIR_UTIL_H__ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录