]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: add functions dealing with struct timespec UTIME_OMIT
authorRalph Boehme <slow@samba.org>
Tue, 26 Nov 2019 17:22:17 +0000 (17:22 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 6 Dec 2019 00:17:35 +0000 (00:17 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7771

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/time.c
lib/util/time.h

index 3a6043025f410033d9e1a2a81cd4e90df0ea84e6..a1a1f666506b89b80461251ab45e92b904049ef7 100644 (file)
@@ -991,3 +991,26 @@ _PUBLIC_ NTTIME unix_timespec_to_nt_time(struct timespec ts)
 
        return d;
 }
+
+/*
+ * Functions supporting the full range of time_t and struct timespec values,
+ * including 0, -1 and all other negative values. These functions don't use 0 or
+ * -1 values as sentinel to denote "unset" variables, but use the POSIX 2008
+ * define UTIME_OMIT from utimensat(2).
+ */
+
+/**
+ * Check if it's a to be omitted timespec.
+ **/
+bool is_omit_timespec(const struct timespec *ts)
+{
+       return ts->tv_nsec == SAMBA_UTIME_OMIT;
+}
+
+/**
+ * Return a to be omitted timespec.
+ **/
+struct timespec make_omit_timespec(void)
+{
+       return (struct timespec){.tv_nsec = SAMBA_UTIME_OMIT};
+}
index d03dc4908f3f34f55fbee8dd4dd77f43d48ec12c..494b6f653ffff38cdfdd3b7777da84497360859e 100644 (file)
@@ -333,4 +333,13 @@ void round_timespec_to_usec(struct timespec *ts);
 void round_timespec_to_nttime(struct timespec *ts);
 NTTIME unix_timespec_to_nt_time(struct timespec ts);
 
+/*
+ * Functions supporting the full range of time_t and struct timespec values,
+ * including 0, -1 and all other negative values. These functions don't use 0 or
+ * -1 values as sentinel to denote "unset" variables, but use the POSIX 2008
+ * define UTIME_OMIT from utimensat(2).
+ */
+bool is_omit_timespec(const struct timespec *ts);
+struct timespec make_omit_timespec(void);
+
 #endif /* _SAMBA_TIME_H_ */