summaryrefslogtreecommitdiff
path: root/source3/smbd/vfs.c
diff options
context:
space:
mode:
authorAnoop C S <anoopcs@redhat.com>2019-09-27 12:07:40 +0530
committerRalph Boehme <slow@samba.org>2019-10-08 09:57:19 +0000
commit0abd1189a60eea4501b5279ebc4bff2b5689f888 (patch)
treef9ac4133ce035a87209552c92701a094b8ab40dc /source3/smbd/vfs.c
parent5084a69de14f24e9d804998580eefcba773fdd5a (diff)
downloadsamba-0abd1189a60eea4501b5279ebc4bff2b5689f888.tar.gz
s3: VFS: Use SMB_VFS_FCNTL to set fd flags in open_file()
Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Tue Oct 8 09:57:19 UTC 2019 on sn-devel-184
Diffstat (limited to 'source3/smbd/vfs.c')
-rw-r--r--source3/smbd/vfs.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index bef79e4c64e..5332f00e876 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -711,6 +711,37 @@ int vfs_fill_sparse(files_struct *fsp, off_t len)
return ret;
}
+/*******************************************************************************
+ Set a fd into blocking/nonblocking mode through VFS
+*******************************************************************************/
+
+int vfs_set_blocking(files_struct *fsp, bool set)
+{
+ int val;
+#ifdef O_NONBLOCK
+#define FLAG_TO_SET O_NONBLOCK
+#else
+#ifdef SYSV
+#define FLAG_TO_SET O_NDELAY
+#else /* BSD */
+#define FLAG_TO_SET FNDELAY
+#endif
+#endif
+ val = SMB_VFS_FCNTL(fsp, F_GETFL, 0);
+ if (val == -1) {
+ return -1;
+ }
+
+ if (set) {
+ val &= ~FLAG_TO_SET;
+ } else {
+ val |= FLAG_TO_SET;
+ }
+
+ return SMB_VFS_FCNTL(fsp, F_SETFL, val);
+#undef FLAG_TO_SET
+}
+
/****************************************************************************
Transfer some data (n bytes) between two file_struct's.
****************************************************************************/