]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: lib: Add sys_fstatat() wrapper.
authorJeremy Allison <jra@samba.org>
Mon, 12 Jul 2021 22:37:20 +0000 (15:37 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 14 Jul 2021 08:09:31 +0000 (08:09 +0000)
Does the usual things we need with fake_dir_create_times.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/proto.h
source3/lib/system.c

index 4485cb434194a22ac87356aab26bb6e37b48d7c2..938a71e808359804db8859887e8232e2c5e7197f 100644 (file)
@@ -214,6 +214,11 @@ int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
              bool fake_dir_create_times);
 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
              bool fake_dir_create_times);
+int sys_fstatat(int fd,
+               const char *pathname,
+               SMB_STRUCT_STAT *sbuf,
+               int flags,
+               bool fake_dir_create_times);
 int sys_posix_fallocate(int fd, off_t offset, off_t len);
 int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len);
 void kernel_flock(int fd, uint32_t share_access, uint32_t access_mask);
index ad525737c5b5f27ed23ceeac00fbaef853c2321a..5d57ffadda10f86796054757b7b11460a88213eb 100644 (file)
@@ -369,6 +369,32 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
        return ret;
 }
 
+/*******************************************************************
+ An fstatat() wrapper.
+********************************************************************/
+
+int sys_fstatat(int fd,
+               const char *pathname,
+               SMB_STRUCT_STAT *sbuf,
+               int flags,
+               bool fake_dir_create_times)
+{
+       int ret;
+       struct stat statbuf;
+
+       ret = fstatat(fd, pathname, &statbuf, flags);
+       if (ret != 0) {
+               return -1;
+       }
+
+       /* we always want directories to appear zero size */
+       if (S_ISDIR(statbuf.st_mode)) {
+               statbuf.st_size = 0;
+       }
+       init_stat_ex_from_stat(sbuf, &statbuf, fake_dir_create_times);
+       return 0;
+}
+
 /*******************************************************************
  An posix_fallocate() wrapper.
 ********************************************************************/