]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Move setting all struct stat fields into setup_stat().
authorJeremy Allison <jra@samba.org>
Fri, 18 Oct 2019 17:48:55 +0000 (10:48 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 14 Jan 2020 08:30:23 +0000 (08:30 +0000)
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>
(cherry picked from commit 1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc)

source3/include/libsmb_internal.h
source3/libsmb/libsmb_stat.c

index 6a58b3306c7239077969013f48f9b8a012ce13ee..c1bcab18138289e6fad356f9cefb87c3f172675f 100644 (file)
@@ -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,
index 1bb9e909b15b2cef97a40a22783a82d453c39952..16839ae20add2dc5a6ceae49e8c27190b0c22a2c 100644 (file)
@@ -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;