summaryrefslogtreecommitdiff
path: root/source3/smbd/durable.c
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-12-02 16:30:50 +0100
committerJeremy Allison <jra@samba.org>2019-12-06 00:17:36 +0000
commit69691dd0cd5fac292bfb1c1dc28136ae253bbc76 (patch)
tree89c86e4ee8bd9d7a9e390bdb7c3e87460ba92212 /source3/smbd/durable.c
parent6e58cfab98d958c8008c77b0d909a3384de28d7b (diff)
downloadsamba-69691dd0cd5fac292bfb1c1dc28136ae253bbc76.tar.gz
smbd: fix handling of sentinel timestamp values
This implements two core changes: * use NTTIME instead of struct timespec at the database layer * use struct timespec { .tv_nsec = SAMBA_UTIME_OMIT } as special sentinel value in smbd when processing timestamps Using NTTIME at the database layer is only done to avoid storing the special struct timespec sentinel values on disk. Instead, with NTTIME the sentinel value for an "unset" timestamp is just 0 on-disk. The NTTIME value of 0 gets translated by nt_time_to_full_timespec() to the struct timespec sentinel value { .tv_nsec = SAMBA_UTIME_OMIT }. The function is_omit_timespec() can be used to check this. Beside nt_time_to_full_timespec(), there are various other new time conversion functions with *full* in their name that can be used to safely convert between different types with the changed sentinel value. 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>
Diffstat (limited to 'source3/smbd/durable.c')
-rw-r--r--source3/smbd/durable.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c
index 9a2e639bdcd..9a4ebfb12d2 100644
--- a/source3/smbd/durable.c
+++ b/source3/smbd/durable.c
@@ -104,7 +104,8 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp,
cookie.update_write_time_triggered = fsp->update_write_time_triggered;
cookie.update_write_time_on_close = fsp->update_write_time_on_close;
cookie.write_time_forced = fsp->write_time_forced;
- cookie.close_write_time = fsp->close_write_time;
+ cookie.close_write_time = full_timespec_to_nt_time(
+ &fsp->close_write_time);
cookie.stat_info.st_ex_dev = fsp->fsp_name->st.st_ex_dev;
cookie.stat_info.st_ex_ino = fsp->fsp_name->st.st_ex_ino;
@@ -205,19 +206,20 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp,
if (lck != NULL) {
struct smb_file_time ft;
- ZERO_STRUCT(ft);
+ init_smb_file_time(&ft);
if (fsp->write_time_forced) {
- ft.mtime = lck->data->changed_write_time;
+ ft.mtime = nt_time_to_full_timespec(
+ lck->data->changed_write_time);
} else if (fsp->update_write_time_on_close) {
- if (null_timespec(fsp->close_write_time)) {
+ if (is_omit_timespec(&fsp->close_write_time)) {
ft.mtime = timespec_current();
} else {
ft.mtime = fsp->close_write_time;
}
}
- if (!null_timespec(ft.mtime)) {
+ if (!is_omit_timespec(&ft.mtime)) {
round_timespec(conn->ts_res, &ft.mtime);
file_ntimes(conn, fsp->fsp_name, &ft);
}
@@ -253,7 +255,8 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp,
cookie.update_write_time_triggered = fsp->update_write_time_triggered;
cookie.update_write_time_on_close = fsp->update_write_time_on_close;
cookie.write_time_forced = fsp->write_time_forced;
- cookie.close_write_time = fsp->close_write_time;
+ cookie.close_write_time = full_timespec_to_nt_time(
+ &fsp->close_write_time);
cookie.stat_info.st_ex_dev = fsp->fsp_name->st.st_ex_dev;
cookie.stat_info.st_ex_ino = fsp->fsp_name->st.st_ex_ino;
@@ -748,7 +751,8 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
fsp->update_write_time_triggered = cookie.update_write_time_triggered;
fsp->update_write_time_on_close = cookie.update_write_time_on_close;
fsp->write_time_forced = cookie.write_time_forced;
- fsp->close_write_time = cookie.close_write_time;
+ fsp->close_write_time = nt_time_to_full_timespec(
+ cookie.close_write_time);
status = fsp_set_smb_fname(fsp, smb_fname);
if (!NT_STATUS_IS_OK(status)) {