diff options
author | Jeremy Allison <jra@samba.org> | 2019-10-18 10:48:55 -0700 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2019-10-30 20:44:31 +0000 |
commit | 1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc (patch) | |
tree | 7fdc3373d0ba4117c75340a85daf466fceec00b8 /source3 | |
parent | 7d3b4f47be0359b496087fc40f89b815c7958dd6 (diff) | |
download | samba-1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc.tar.gz |
s3: libsmb: Move setting all struct stat fields into setup_stat().
That way we only have one place where a struct stat is synthesised
for libsmbclient callers.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/libsmb_internal.h | 6 | ||||
-rw-r--r-- | source3/libsmb/libsmb_stat.c | 41 |
2 files changed, 33 insertions, 14 deletions
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index 6a58b3306c7..c1bcab18138 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -526,7 +526,11 @@ void setup_stat(struct stat *st, const char *fname, off_t size, int mode, - ino_t ino); + ino_t ino, + dev_t dev, + struct timespec access_time_ts, + struct timespec change_time_ts, + struct timespec write_time_ts); int SMBC_stat_ctx(SMBCCTX *context, diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index c009e7f34cd..0db9be3677b 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -49,7 +49,11 @@ void setup_stat(struct stat *st, const char *fname, off_t size, int mode, - ino_t ino) + ino_t ino, + dev_t dev, + struct timespec access_time_ts, + struct timespec change_time_ts, + struct timespec write_time_ts) { st->st_mode = 0; @@ -96,6 +100,11 @@ void setup_stat(struct stat *st, } else { st->st_ino = generate_inode(fname); } + + st->st_dev = dev; + st->st_atime = convert_timespec_to_time_t(access_time_ts); + st->st_ctime = convert_timespec_to_time_t(change_time_ts); + st->st_mtime = convert_timespec_to_time_t(write_time_ts); } /* @@ -180,12 +189,15 @@ SMBC_stat_ctx(SMBCCTX *context, return -1; } - setup_stat(st, fname, size, mode, ino); - - st->st_atime = convert_timespec_to_time_t(access_time_ts); - st->st_ctime = convert_timespec_to_time_t(change_time_ts); - st->st_mtime = convert_timespec_to_time_t(write_time_ts); - st->st_dev = srv->dev; + setup_stat(st, + fname, + size, + mode, + ino, + srv->dev, + access_time_ts, + change_time_ts, + write_time_ts); TALLOC_FREE(frame); return 0; @@ -283,12 +295,15 @@ SMBC_fstat_ctx(SMBCCTX *context, write_time_ts = convert_time_t_to_timespec(write_time); } - setup_stat(st, file->fname, size, mode, ino); - - st->st_atime = convert_timespec_to_time_t(access_time_ts); - st->st_ctime = convert_timespec_to_time_t(change_time_ts); - st->st_mtime = convert_timespec_to_time_t(write_time_ts); - st->st_dev = file->srv->dev; + setup_stat(st, + file->fname, + size, + mode, + ino, + file->srv->dev, + access_time_ts, + change_time_ts, + write_time_ts); TALLOC_FREE(frame); return 0; |