summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2019-10-18 10:48:55 -0700
committerKarolin Seeger <kseeger@samba.org>2020-01-14 08:30:23 +0000
commit745f563d4c79d228c3780f187dd847c0c4d67b6e (patch)
treefae91c16a842a34b9f668253d3e714fcb5022ce0 /source3
parentee236c2f3078348bcc2bcfd5e4100be9711f6071 (diff)
downloadsamba-745f563d4c79d228c3780f187dd847c0c4d67b6e.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> (cherry picked from commit 1f0715c0e5e6ff371e3b393a0b35222c8b6f49bc)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/libsmb_internal.h6
-rw-r--r--source3/libsmb/libsmb_stat.c41
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 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;