Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / include / stat.h
1 #ifndef CEPH_STAT_H
2 #define CEPH_STAT_H
3
4 #include <acconfig.h>
5
6 #include <sys/stat.h>
7
8 /*
9  * Access time-related `struct stat` members.
10  *
11  * Note that for each of the stat member get/set functions below, setting a
12  * high-res value (stat_set_*_nsec) on a platform without high-res support is
13  * a no-op.
14  */
15
16 #ifdef HAVE_STAT_ST_MTIM_TV_NSEC
17
18 static inline uint32_t stat_get_mtime_nsec(struct stat *st)
19 {
20   return st->st_mtim.tv_nsec;
21 }
22
23 static inline void stat_set_mtime_nsec(struct stat *st, uint32_t nsec)
24 {
25   st->st_mtim.tv_nsec = nsec;
26 }
27
28 static inline uint32_t stat_get_atime_nsec(struct stat *st)
29 {
30   return st->st_atim.tv_nsec;
31 }
32
33 static inline void stat_set_atime_nsec(struct stat *st, uint32_t nsec)
34 {
35   st->st_atim.tv_nsec = nsec;
36 }
37
38 static inline uint32_t stat_get_ctime_nsec(struct stat *st)
39 {
40   return st->st_ctim.tv_nsec;
41 }
42
43 static inline void stat_set_ctime_nsec(struct stat *st, uint32_t nsec)
44 {
45   st->st_ctim.tv_nsec = nsec;
46 }
47
48 #elif defined(HAVE_STAT_ST_MTIMESPEC_TV_NSEC)
49
50 static inline uint32_t stat_get_mtime_nsec(struct stat *st)
51 {
52   return st->st_mtimespec.tv_nsec;
53 }
54
55 static inline void stat_set_mtime_nsec(struct stat *st, uint32_t nsec)
56 {
57   st->st_mtimespec.tv_nsec = nsec;
58 }
59
60 static inline uint32_t stat_get_atime_nsec(struct stat *st)
61 {
62   return st->st_atimespec.tv_nsec;
63 }
64
65 static inline void stat_set_atime_nsec(struct stat *st, uint32_t nsec)
66 {
67   st->st_atimespec.tv_nsec = nsec;
68 }
69
70 static inline uint32_t stat_get_ctime_nsec(struct stat *st)
71 {
72   return st->st_ctimespec.tv_nsec;
73 }
74
75 static inline void stat_set_ctime_nsec(struct stat *st, uint32_t nsec)
76 {
77   st->st_ctimespec.tv_nsec = nsec;
78 }
79
80 #else
81
82 static inline uint32_t stat_get_mtime_nsec(struct stat *st)
83 {
84   return 0;
85 }
86
87 static inline void stat_set_mtime_nsec(struct stat *st, uint32_t nsec)
88 {
89 }
90
91 static inline uint32_t stat_get_atime_nsec(struct stat *st)
92 {
93   return 0;
94 }
95
96 static inline void stat_set_atime_nsec(struct stat *st, uint32_t nsec)
97 {
98 }
99
100 static inline uint32_t stat_get_ctime_nsec(struct stat *st)
101 {
102   return 0;
103 }
104
105 static inline void stat_set_ctime_nsec(struct stat *st, uint32_t nsec)
106 {
107 }
108
109 #endif
110
111 /*
112  * Access second-resolution `struct stat` members.
113  */
114
115 static inline uint32_t stat_get_mtime_sec(struct stat *st)
116 {
117   return st->st_mtime;
118 }
119
120 static inline void stat_set_mtime_sec(struct stat *st, uint32_t sec)
121 {
122   st->st_mtime = sec;
123 }
124
125 static inline uint32_t stat_get_atime_sec(struct stat *st)
126 {
127   return st->st_atime;
128 }
129
130 static inline void stat_set_atime_sec(struct stat *st, uint32_t sec)
131 {
132   st->st_atime = sec;
133 }
134
135 static inline uint32_t stat_get_ctime_sec(struct stat *st)
136 {
137   return st->st_ctime;
138 }
139
140 static inline void stat_set_ctime_sec(struct stat *st, uint32_t sec)
141 {
142   st->st_ctime = sec;
143 }
144
145 #endif