diff options
author | Volker Lendecke <vl@samba.org> | 2020-03-26 12:29:13 +0100 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2020-04-08 14:46:40 +0000 |
commit | e4aa9a970a483ea16aa5b5bc9f7bbf542a4eeecd (patch) | |
tree | 141fbae7a2e15491eb6f89e715cdd324f0ee562f /source3 | |
parent | b89ab75cd6a77d2c069051f7bb174882cb5d1e68 (diff) | |
download | samba-e4aa9a970a483ea16aa5b5bc9f7bbf542a4eeecd.tar.gz |
libsmb: Pass "struct timespec" to SMBC_setatr()
Prepare to set higher-precision timestamps. No change in behaviour so
far: The {.tv_nsec=SAMBA_UTIME_OMIT} implicitly sets .tv_sec=0, and
SMBC_setatr() only looks at .tv_sec
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/libsmb_internal.h | 8 | ||||
-rw-r--r-- | source3/libsmb/libsmb_dir.c | 13 | ||||
-rw-r--r-- | source3/libsmb/libsmb_file.c | 22 | ||||
-rw-r--r-- | source3/libsmb/libsmb_xattr.c | 42 |
4 files changed, 55 insertions, 30 deletions
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index d23b33c43b9..be88e8e300d 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -411,10 +411,10 @@ SMBC_getatr(SMBCCTX * context, bool SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, - time_t create_time, - time_t access_time, - time_t write_time, - time_t change_time, + struct timespec create_time, + struct timespec access_time, + struct timespec write_time, + struct timespec change_time, uint16_t mode); off_t diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 00d2a878e84..fe236f41f0c 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -2051,6 +2051,7 @@ SMBC_utimes_ctx(SMBCCTX *context, time_t write_time; uint16_t port = 0; TALLOC_CTX *frame = talloc_stackframe(); + bool ok; if (!context || !context->internal->initialized) { @@ -2126,8 +2127,16 @@ SMBC_utimes_ctx(SMBCCTX *context, return -1; /* errno set by SMBC_server */ } - if (!SMBC_setatr(context, srv, path, - 0, access_time, write_time, 0, 0)) { + ok = SMBC_setatr( + context, + srv, + path, + (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, + (struct timespec) { .tv_sec = access_time }, + (struct timespec) { .tv_sec = write_time }, + (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, + 0); + if (!ok) { TALLOC_FREE(frame); return -1; /* errno set by SMBC_setatr */ } diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index f0a16c61a83..7e8916e61b5 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -588,10 +588,10 @@ all_failed: */ bool SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, - time_t create_time, - time_t access_time, - time_t write_time, - time_t change_time, + struct timespec create_time, + struct timespec access_time, + struct timespec write_time, + struct timespec change_time, uint16_t mode) { uint16_t fd; @@ -606,10 +606,10 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, */ if (srv->no_pathinfo || !NT_STATUS_IS_OK(cli_setpathinfo_basic(srv->cli, path, - create_time, - access_time, - write_time, - change_time, + create_time.tv_sec, + access_time.tv_sec, + write_time.tv_sec, + change_time.tv_sec, mode))) { /* @@ -634,9 +634,9 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path, /* Set the new attributes */ ret = NT_STATUS_IS_OK(cli_setattrE(srv->cli, fd, - change_time, - access_time, - write_time)); + change_time.tv_sec, + access_time.tv_sec, + write_time.tv_sec)); /* Close the file */ cli_close(srv->cli, fd); diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index 9e3f542b924..059233b4f09 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -1796,17 +1796,26 @@ SMBC_setxattr_ctx(SMBCCTX *context, /* get a DOS Attribute Descriptor with current attributes */ dad = dos_attr_query(context, talloc_tos(), path, srv); if (dad) { + bool ok; + /* Overwrite old with new, using what was provided */ dos_attr_parse(context, dad, srv, namevalue); /* Set the new DOS attributes */ - if (! SMBC_setatr(context, srv, path, - dad->create_time, - dad->access_time, - dad->write_time, - dad->change_time, - dad->mode)) { - + ok = SMBC_setatr( + context, + srv, + path, + (struct timespec) { + .tv_sec = dad->create_time }, + (struct timespec) { + .tv_sec = dad->access_time }, + (struct timespec) { + .tv_sec = dad->write_time }, + (struct timespec) { + .tv_sec = dad->change_time }, + dad->mode); + if (!ok) { /* cause failure if NT failed too */ dad = NULL; } @@ -1951,12 +1960,19 @@ SMBC_setxattr_ctx(SMBCCTX *context, dos_attr_parse(context, dad, srv, namevalue); /* Set the new DOS attributes */ - ret2 = SMBC_setatr(context, srv, path, - dad->create_time, - dad->access_time, - dad->write_time, - dad->change_time, - dad->mode); + ret2 = SMBC_setatr( + context, + srv, + path, + (struct timespec) { + .tv_sec = dad->create_time }, + (struct timespec) { + .tv_sec = dad->access_time }, + (struct timespec) { + .tv_sec = dad->write_time }, + (struct timespec) { + .tv_sec = dad->change_time }, + dad->mode); /* ret2 has True (success) / False (failure) */ if (ret2) { |