]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: syncops: Remove direct system calls and use OpenDir()/smb_vfs_fsync_sync...
authorJeremy Allison <jra@samba.org>
Thu, 17 Jun 2021 19:10:16 +0000 (12:10 -0700)
committerNoel Power <npower@samba.org>
Tue, 22 Jun 2021 13:44:34 +0000 (13:44 +0000)
syncops is now *really* stackable.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
source3/modules/vfs_syncops.c

index c3f11cf67e9952413399dec036e41e7751da8ecb..c0ef4c3b81e42a9e0e5c5ca4889360ffc53b77d2 100644 (file)
@@ -74,19 +74,24 @@ static char *parent_dir(TALLOC_CTX *mem_ctx, const char *name)
 static void syncops_sync_directory(connection_struct *conn,
                                   char *dname)
 {
-#ifdef O_DIRECTORY
-       int fd = open(dname, O_DIRECTORY|O_RDONLY);
-       if (fd != -1) {
-               fsync(fd);
-               close(fd);
-       }
-#else
-       DIR *d = opendir(dname);
-       if (d != NULL) {
-               fsync(dirfd(d));
-               closedir(d);
+       struct smb_Dir *dir_hnd = NULL;
+       struct files_struct *dirfsp = NULL;
+       struct smb_filename smb_dname = { .base_name = dname };
+
+       dir_hnd = OpenDir(talloc_tos(),
+                         conn,
+                         &smb_dname,
+                         "*",
+                         0);
+       if (dir_hnd == NULL) {
+               return;
        }
-#endif
+
+       dirfsp = dir_hnd_fetch_fsp(dir_hnd);
+
+       smb_vfs_fsync_sync(dirfsp);
+
+       TALLOC_FREE(dir_hnd);
 }
 
 /*