ssize_t ret;
if (req && req->unread_bytes) {
+ int sockfd = req->sconn->sock;
SMB_ASSERT(req->unread_bytes == N);
/* VFS_RECVFILE must drain the socket
* before returning. */
req->unread_bytes = 0;
- return SMB_VFS_RECVFILE(req->sconn->sock,
- fsp,
- offset,
- N);
+ /*
+ * Leave the socket non-blocking and
+ * use SMB_VFS_RECVFILE. If it returns
+ * EAGAIN || EWOULDBLOCK temporarily set
+ * the socket blocking and retry
+ * the RECVFILE.
+ */
+ while (total < N) {
+ ret = SMB_VFS_RECVFILE(sockfd,
+ fsp,
+ offset + total,
+ N - total);
+#if defined(EWOULDBLOCK)
+ if (ret == 0 || (ret == -1 &&
+ (errno == EAGAIN || errno == EWOULDBLOCK))) {
+#else /* EWOULDBLOCK */
+ if (ret == 0 || (ret == -1 && errno == EAGAIN)) {
+#endif /* EWOULDBLOCK */
+ int old_flags;
+ /* Ensure the socket is blocking. */
+ old_flags = fcntl(sockfd, F_GETFL, 0);
+ if (set_blocking(sockfd, true) == -1) {
+ return (ssize_t)-1;
+ }
+ ret = SMB_VFS_RECVFILE(sockfd,
+ fsp,
+ offset + total,
+ N - total);
+ if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
+ return (ssize_t)-1;
+ }
+ if (ret == -1) {
+ return (ssize_t)-1;
+ }
+ total += ret;
+ return (ssize_t)total;
+ }
+ /* Any other error case. */
+ if (ret == -1) {
+ return ret;
+ }
+ total += ret;
+ }
+ return (ssize_t)total;
}
while (total < N) {
contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
- flush_write_cache(fsp, SIZECHANGE_FLUSH);
+ flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
if ((ret = SMB_VFS_FTRUNCATE(fsp, (off_t)len)) != -1) {
set_filelen_write_cache(fsp, len);
}
return ret;
}
- if (!lp_strict_allocate(SNUM(fsp->conn)))
- return 0;
-
/* Grow - we need to test if we have enough space. */
contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW);
- /* See if we have a syscall that will allocate beyond end-of-file
- without changing EOF. */
- ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len);
+ if (lp_strict_allocate(SNUM(fsp->conn))) {
+ /* See if we have a syscall that will allocate beyond
+ end-of-file without changing EOF. */
+ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len);
+ } else {
+ ret = 0;
+ }
contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW);
DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n",
fsp_str_dbg(fsp), (double)len));
- flush_write_cache(fsp, SIZECHANGE_FLUSH);
+ flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
set_filelen_write_cache(fsp, len);
notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
- flush_write_cache(fsp, SIZECHANGE_FLUSH);
+ flush_write_cache(fsp, SAMBA_SIZECHANGE_FLUSH);
offset = fsp->fsp_name->st.st_ex_size;
num_to_write = len - fsp->fsp_name->st.st_ex_size;
LastDir = SMB_STRDUP("");
}
- if (strcsequal(path,".")) {
+ if (ISDOT(path)) {
return 0;
}
}
allow_widelinks = lp_widelinks(SNUM(conn));
- allow_symlinks = lp_symlinks(SNUM(conn));
+ allow_symlinks = lp_follow_symlinks(SNUM(conn));
/* Common widelinks and symlinks checks. */
if (!allow_widelinks || !allow_symlinks) {
return handle->fns->copy_chunk_recv_fn(handle, req, copied);
}
+NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *fsp,
+ struct smb_filename *smb_fname,
+ uint16_t *_compression_fmt)
+{
+ VFS_FIND(get_compression);
+ return handle->fns->get_compression_fn(handle, mem_ctx, fsp, smb_fname,
+ _compression_fmt);
+}
+
+NTSTATUS smb_vfs_call_set_compression(vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *fsp,
+ uint16_t compression_fmt)
+{
+ VFS_FIND(set_compression);
+ return handle->fns->set_compression_fn(handle, mem_ctx, fsp,
+ compression_fmt);
+}
+
NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32 security_info,