summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2019-11-25 11:10:49 +0100
committerKarolin Seeger <kseeger@samba.org>2020-01-15 09:14:17 +0000
commite82e78b8747110b73231fdc83e18a43a06f71404 (patch)
treea1b928ff0c4d57f9dbdec62f5283ea1304b96141
parent8936e2d0274f5601f97e69aaaf2f92965dd00ddd (diff)
downloadsamba-e82e78b8747110b73231fdc83e18a43a06f71404.tar.gz
s3:libsmb: Add a setup_stat_from_stat_ex() function
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit b3e3cb3bbd86a53b48ee009adf811d48dd50dc8b)
-rw-r--r--source3/include/libsmb_internal.h3
-rw-r--r--source3/libsmb/libsmb_stat.c37
2 files changed, 40 insertions, 0 deletions
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index 2c139404c37..af56df58792 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -526,6 +526,9 @@ void setup_stat(struct stat *st,
struct timespec access_time_ts,
struct timespec change_time_ts,
struct timespec write_time_ts);
+void setup_stat_from_stat_ex(const struct stat_ex *stex,
+ const char *fname,
+ struct stat *st);
int
SMBC_stat_ctx(SMBCCTX *context,
diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c
index 46141ce1af2..f20f79579e2 100644
--- a/source3/libsmb/libsmb_stat.c
+++ b/source3/libsmb/libsmb_stat.c
@@ -107,6 +107,43 @@ void setup_stat(struct stat *st,
st->st_mtime = convert_timespec_to_time_t(write_time_ts);
}
+void setup_stat_from_stat_ex(const struct stat_ex *stex,
+ const char *fname,
+ struct stat *st)
+{
+ st->st_atime = convert_timespec_to_time_t(stex->st_ex_atime);
+ st->st_ctime = convert_timespec_to_time_t(stex->st_ex_ctime);
+ st->st_mtime = convert_timespec_to_time_t(stex->st_ex_mtime);
+
+ st->st_mode = stex->st_ex_mode;
+ st->st_size = stex->st_ex_size;
+#ifdef HAVE_STAT_ST_BLKSIZE
+ st->st_blksize = 512;
+#endif
+#ifdef HAVE_STAT_ST_BLOCKS
+ st->st_blocks = (st->st_size + 511) / 512;
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+ st->st_rdev = 0;
+#endif
+ st->st_uid = stex->st_ex_uid;
+ st->st_gid = stex->st_ex_gid;
+
+ st->st_nlink = stex->st_ex_nlink;
+
+ if (stex->st_ex_ino == 0) {
+ st->st_ino = 0;
+ if (fname != NULL) {
+ st->st_ino = generate_inode(fname);
+ }
+ } else {
+ st->st_ino = stex->st_ex_ino;
+ }
+
+ st->st_dev = stex->st_ex_dev;
+
+}
+
/*
* Routine to stat a file given a name
*/