]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/stat.h
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / include / stat.h
CommitLineData
7c673cae
FG
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
18static inline uint32_t stat_get_mtime_nsec(struct stat *st)
19{
20 return st->st_mtim.tv_nsec;
21}
22
23static inline void stat_set_mtime_nsec(struct stat *st, uint32_t nsec)
24{
25 st->st_mtim.tv_nsec = nsec;
26}
27
28static inline uint32_t stat_get_atime_nsec(struct stat *st)
29{
30 return st->st_atim.tv_nsec;
31}
32
33static inline void stat_set_atime_nsec(struct stat *st, uint32_t nsec)
34{
35 st->st_atim.tv_nsec = nsec;
36}
37
38static inline uint32_t stat_get_ctime_nsec(struct stat *st)
39{
40 return st->st_ctim.tv_nsec;
41}
42
43static 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
50static inline uint32_t stat_get_mtime_nsec(struct stat *st)
51{
52 return st->st_mtimespec.tv_nsec;
53}
54
55static inline void stat_set_mtime_nsec(struct stat *st, uint32_t nsec)
56{
57 st->st_mtimespec.tv_nsec = nsec;
58}
59
60static inline uint32_t stat_get_atime_nsec(struct stat *st)
61{
62 return st->st_atimespec.tv_nsec;
63}
64
65static inline void stat_set_atime_nsec(struct stat *st, uint32_t nsec)
66{
67 st->st_atimespec.tv_nsec = nsec;
68}
69
70static inline uint32_t stat_get_ctime_nsec(struct stat *st)
71{
72 return st->st_ctimespec.tv_nsec;
73}
74
75static 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
82static inline uint32_t stat_get_mtime_nsec(struct stat *st)
83{
84 return 0;
85}
86
87static inline void stat_set_mtime_nsec(struct stat *st, uint32_t nsec)
88{
89}
90
91static inline uint32_t stat_get_atime_nsec(struct stat *st)
92{
93 return 0;
94}
95
96static inline void stat_set_atime_nsec(struct stat *st, uint32_t nsec)
97{
98}
99
100static inline uint32_t stat_get_ctime_nsec(struct stat *st)
101{
102 return 0;
103}
104
105static 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
115static inline uint32_t stat_get_mtime_sec(struct stat *st)
116{
117 return st->st_mtime;
118}
119
120static inline void stat_set_mtime_sec(struct stat *st, uint32_t sec)
121{
122 st->st_mtime = sec;
123}
124
125static inline uint32_t stat_get_atime_sec(struct stat *st)
126{
127 return st->st_atime;
128}
129
130static inline void stat_set_atime_sec(struct stat *st, uint32_t sec)
131{
132 st->st_atime = sec;
133}
134
135static inline uint32_t stat_get_ctime_sec(struct stat *st)
136{
137 return st->st_ctime;
138}
139
140static inline void stat_set_ctime_sec(struct stat *st, uint32_t sec)
141{
142 st->st_ctime = sec;
143}
144
145#endif