提交 a8b9d024 编写于 作者: Y yuqing

define nsec of file stat in Linux and FreeBSD

上级 08d39328
......@@ -116,6 +116,18 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind);
#define IS_UPPER_HEX(ch) ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F'))
#define STRERROR(no) (strerror(no) != NULL ? strerror(no) : "Unkown error")
#if defined(OS_LINUX)
#if defined __USE_MISC || defined __USE_XOPEN2K8
#define st_atimensec st_atim.tv_nsec
#define st_mtimensec st_mtim.tv_nsec
#define st_ctimensec st_ctim.tv_nsec
#endif
#elif defined(OS_FREEBSD)
#define st_atimensec st_atimespec.tv_nsec
#define st_mtimensec st_mtimespec.tv_nsec
#define st_ctimensec st_ctimespec.tv_nsec
#endif
#ifdef __cplusplus
extern "C" {
#endif
......
......@@ -4,7 +4,9 @@
#include <math.h>
#include <time.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include "logger.h"
#include "shared_func.h"
#include "sched_thread.h"
......@@ -87,6 +89,7 @@ int main(int argc, char *argv[])
{
FastProcessInfo *processes;
struct fast_sysinfo info;
struct stat st;
get_processes(&processes, &count);
printf("process count: %d\n", count);
......@@ -117,7 +120,13 @@ int main(int argc, char *argv[])
printf("freeswap: %ld\n", info.freeswap);
printf("procs: %d\n", info.procs);
}
stat("/dev/null", &st);
printf("file access time: %d.%ld\n", (int)st.st_atime, st.st_atimensec);
printf("file modify time: %d.%ld\n", (int)st.st_mtime, st.st_mtimensec);
printf("file change time: %d.%ld\n", (int)st.st_ctime, st.st_ctimensec);
}
#endif
if ((result=iniLoadFromFile(filename, &iniContext)) != 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册