From: Jeremy Allison Date: Fri, 18 Oct 2019 17:48:55 +0000 (-0700) Subject: s3: libsmb: Move setting all struct stat fields into setup_stat(). X-Git-Tag: samba-4.10.13~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=745f563d4c79d228c3780f187dd847c0c4d67b6e;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andreas Schneider (cherry picked from commit 1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc) --- 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 1bb9e909b15..16839ae20ad 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;