s3:lib: add update_stat_ex_from_saved_stat()
authorRalph Boehme <slow@samba.org>
Fri, 30 Aug 2019 12:49:47 +0000 (14:49 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 10 Sep 2019 19:05:29 +0000 (19:05 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/include/proto.h
source3/lib/system.c

index 17ea54fc4fe812626fba931de4ca618cb86fb184..7bf921f347625a8721e9ed6ab6e4302ae657c936 100644 (file)
@@ -223,6 +223,8 @@ void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
 void update_stat_ex_itime(struct stat_ex *dst, struct timespec itime);
 void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
 void update_stat_ex_file_id(struct stat_ex *dst, uint64_t file_id);
+void update_stat_ex_from_saved_stat(struct stat_ex *dst,
+                                   const struct stat_ex *src);
 int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
             bool fake_dir_create_times);
 int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
index 251c02bb1ee9fcee2811cf1ff812445fce2d7d8a..def8281fc437172c2573c24b29557e7a62665ac6 100644 (file)
@@ -355,6 +355,26 @@ void update_stat_ex_file_id(struct stat_ex *dst, uint64_t file_id)
        dst->st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_FILE_ID;
 }
 
+void update_stat_ex_from_saved_stat(struct stat_ex *dst,
+                                   const struct stat_ex *src)
+{
+       if (!VALID_STAT(*src)) {
+               return;
+       }
+
+       if (!(src->st_ex_iflags & ST_EX_IFLAG_CALCULATED_BTIME)) {
+               update_stat_ex_create_time(dst, src->st_ex_btime);
+       }
+
+       if (!(src->st_ex_iflags & ST_EX_IFLAG_CALCULATED_ITIME)) {
+               update_stat_ex_itime(dst, src->st_ex_itime);
+       }
+
+       if (!(src->st_ex_iflags & ST_EX_IFLAG_CALCULATED_FILE_ID)) {
+               update_stat_ex_file_id(dst, src->st_ex_file_id);
+       }
+}
+
 void init_stat_ex_from_stat (struct stat_ex *dst,
                            const struct stat *src,
                            bool fake_dir_create_times)