1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
Commit Graph

41 Commits

Author SHA1 Message Date
Amir Goldstein
cb9df8181e lib: add NTTIME_[U|m]SEC macros
Signed-off-by: Amir Goldstein <amir@ctera.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2023-03-01 19:55:32 +00:00
Volker Lendecke
0d1890011e lib: Fix the FreeBSD build
"time_t" only comes in via a proper include of <time.h>

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-07-23 23:29:38 +00:00
Jeremy Allison
29d69c22a0 lib: util: Add a function nt_time_to_unix_timespec_raw().
Not yet used. Does no checks on the converted values.

A later cleanup will allow us to move nt_time_to_unix_timespec()
and nt_time_to_full_timespec() to use common code.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14928

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2022-01-08 05:43:32 +00:00
Ralph Boehme
f73aff502c lib: add NTTIME_THAW
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14127

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-10-28 18:11:28 +00:00
Philipp Gesang
8ff6ad7454 lib/util: fix timespec normalization
When fixing up timespec structs, negative values for the ns part
should be taken into account. Also, the range for a valid ns part
is [0, 1000000000), not [0, 1000000000].

Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-16 09:38:35 +00:00
Matthew DeVore
53a1d034f3 lib/util: Standardize use of st_[acm]time ns
Commit 810397f89a, and possibly others, broke the build for macOS and
other environments which don't have st_[acm]tim fields on 'struct stat'.

Multiple places in the codebase used the config.h values to determine
how to access the nanosecond or microsecond values of the stat
timestamps, so rather than add more, centralize them all into
lib/util/time.c.

Also allow pvfs_fileinfo.c to read nanosecond-granularity timestamps on
platforms where it didn't before, since its #if branches were not
complete.

Signed-off-by: Matthew DeVore <matvore@google.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Aug 15 08:51:09 UTC 2020 on sn-devel-184
2020-08-15 08:51:09 +00:00
Ralph Boehme
a5e3db5b51 lib: spelling fix
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Mon Dec  9 19:23:10 UTC 2019 on sn-devel-184
2019-12-09 19:23:10 +00:00
Ralph Boehme
99d153fad1 lib: add NTTIME_MAX, NTTIME_MIN, NTTIME_OMIT and NTTIME_FREEZE definitions
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-12-09 16:10:38 +00:00
Ralph Boehme
7a69f642d7 lib: add time_t_to_full_timespec()
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>
2019-12-06 00:17:36 +00:00
Ralph Boehme
928694af7e lib: add timespec_string_buf()
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>
2019-12-06 00:17:36 +00:00
Ralph Boehme
2e687d0e4d lib: add nt_time_to_full_time_t()
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>
2019-12-06 00:17:35 +00:00
Ralph Boehme
6f9a824fda lib: add full_timespec_to_time_t()
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>
2019-12-06 00:17:35 +00:00
Ralph Boehme
af142df467 lib: add nt_time_to_full_timespec()
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>
2019-12-06 00:17:35 +00:00
Ralph Boehme
b5dc6aa720 lib: add full_timespec_to_nt_time()
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>
2019-12-06 00:17:35 +00:00
Ralph Boehme
eb42beeb1b lib: add functions dealing with struct timespec UTIME_OMIT
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>
2019-12-06 00:17:35 +00:00
Ralph Boehme
96418cb156 lib: provide UTIME_NOW|OMIT defines under our own namespace
We may want to add additional defines in the future in order to deal with
NTTIME(-1) and NTTIME(-2) coming in over the wire. They have special semantics
attached to them, -1 requests "no automatic write time updates" on a filehandle
and -2 reenables them.

We could use something like

  #define SAMBA_UTIME_FREEZE (SAMBA_UTIME_OMIT - 1)
  #define SAMBA_UTIME_THAW (SAMBA_UTIME_FREEZE - 1)

in the future.

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>
2019-12-06 00:17:35 +00:00
Ralph Boehme
5403bb22e6 lib: add round_timespec_to_nttime()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-09-10 19:05:29 +00:00
Swen Schillig
a2f718fb75 lib: remove unused function nttime_from_string()
Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12 03:13:31 +01:00
Dr. Thomas Orgis
ca66efc241 Add substitutions %t, %j, and %J as path-safe variants of %T, %i, and %I.
Rationale: Using the existing substitutions in construction of paths
(dynamic shares, created on client connect) results in directory names with
colons and dots in them. Those can be hard to use when accessed from a
different share, as Windows does not allow : in paths and has some ideas about
dots.

Signed-off-by: Dr. Thomas Orgis <thomas.orgis@uni-hamburg.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-01-08 03:34:17 +01:00
Martin Schwenke
fd9f0c27e7 lib/util: Clean up includes for time.[ch]
Allows standalone compile without external includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:20 +02:00
Volker Lendecke
0753c1bec1 lib: Create time_basic.[ch]
Make the two functions that debug.c needs a subsystem of their own. The
goal is to put debug.c on a diet. Anybody who wants to use it should
not be forced to pull in half of Samba :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:47 +02:00
Volker Lendecke
2aa1492c7b lib: Add timeval_str_buf
Similarly to server_id_str_buf it does not do any allocation

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:46 +02:00
Volker Lendecke
379cbb6397 lib: Align nt_time_to_unix_timespec with unix_timespec_to_nt_time
Both take and return values now

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-30 22:28:14 +02:00
Volker Lendecke
dcd6373613 lib: Align unix_timespec_to_nt_time with nt_time_to_unix_timespec
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-06-30 22:28:14 +02:00
Volker Lendecke
32b45bfa98 lib: Apply const to nt_time_to_unix_timespec
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Jun 18 16:35:26 CEST 2014 on sn-devel-104
2014-06-18 16:35:26 +02:00
Volker Lendecke
b2dfd57669 lib-util: add functions to get elapsed from given timespec structs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-12-12 12:50:21 -08:00
Jelmer Vernooij
56852bf1fc util/time: Remove unnecessary _PUBLIC_ - that's implicit for things in header files. 2011-11-03 14:34:08 +01:00
Stefan Metzmacher
66f8070dd3 lib/util: move some timespec helpers from source3 to the toplevel
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Fri Sep 23 00:15:31 CEST 2011 on sn-devel-104
2011-09-23 00:15:31 +02:00
Andrew Bartlett
530e4cac2e s3-param Remove 'time offset' from smb.conf
This strange parameter is apparently very rarely used, and it seems to
me that on modern networks, if clients don't have correct clocks and
DST offsets, that many other things (Kerberos) start to fail pretty
quickly, and time and DST tables tend to be internet delivered anyway.

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Sat Jun 11 03:54:45 CEST 2011 on sn-devel-104
2011-06-11 03:54:44 +02:00
Günther Deschner
74610109ac lib/util/time.h: fix licence/copyright
Guenther
2011-06-10 15:11:25 +02:00
Rusty Russell
0204ae6229 lib/util/time.c: timeval_current_ofs_usec
Several places want "microseconds from current time", and several were
simply handing "usecs" values which could be over a million.

Using a helper to do this is safer and more readable.

I didn't replace any obviously correct callers (ie. constants).

I also renamed wait_nsec in source3/lib/util_sock.c; it's actually
microseconds not nanoseconds (introduced with this code in Volker's
19b783cc Async wrapper for open_socket_out_send/recv).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-01 10:38:47 +02:00
Rusty Russell
56e72337b0 lib/util/time.c: timeval_current_ofs_msec
Several places want "milliseconds from current time", and several were
simply doing "msec * 1000" which can (and does in one place) result in
a usec value over 1 a million.

Using a helper to do this is safer and more readable.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2011-06-01 10:38:47 +02:00
Andrew Bartlett
608c8e7872 lib/util/time: Merge time functions from source3/lib/time.c 2011-03-01 02:13:22 +01:00
Björn Jacke
b428952eef lib/util: add time_mono() for monotonic time a la time() 2010-09-07 20:29:13 +02:00
Björn Jacke
73ad77f20a lib/util: add nsec_time_diff to calulate diffs from timespecs 2010-08-31 10:26:23 +02:00
Björn Jacke
c091b3344b lib/util: add function to query the monotonic clock with the required fallback to the realtime clock 2010-08-31 10:25:03 +02:00
Björn Jacke
571ee54b79 lib/util: move TIME_T_MIN/MAX defines into header file 2010-01-07 00:50:29 +01:00
Jelmer Vernooij
ef80d1b794 Fix use of "time offset" parameter, and add test to make sure I don't break it again :-) 2008-12-23 22:10:34 +01:00
Jelmer Vernooij
87ec1d2532 Make sure prototypes are always included, make some functions static and
remove some unused functions.
2008-10-20 18:59:51 +02:00
Jelmer Vernooij
cb78d4593b Cope with changed signature of http_timestring(). 2008-10-11 23:57:44 +02:00
Jelmer Vernooij
caa4e42860 Move lib/util from source4 to top-level libutil.
Conflicts:

	source4/Makefile
2008-10-11 21:05:38 +02:00