summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/vfs.h7
-rw-r--r--source3/lib/sendfile.c4
-rw-r--r--source3/smbd/reply.c2
-rw-r--r--source3/smbd/vfs-wrap.c7
-rw-r--r--source3/smbd/vfs.c3
5 files changed, 14 insertions, 9 deletions
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 1b1a13d7c1..9a06764371 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -44,17 +44,18 @@
/* Changed to version 2 for CIFS UNIX extensions (mknod and link added). JRA. */
/* Changed to version 3 for POSIX acl extensions. JRA. */
/* Changed to version 4 for cascaded VFS interface. Alexander Bokovoy. */
+/* Changed to version 5 for sendfile addition. JRA. */
#define SMB_VFS_INTERFACE_VERSION 5
/* Version of supported cascaded interface backward copmatibility.
- (version 4 corresponds to SMB_VFS_INTERFACE_VERSION 4)
+ (version 5 corresponds to SMB_VFS_INTERFACE_VERSION 5)
It is used in vfs_init_custom() to detect VFS modules which conform to cascaded
VFS interface but implement elder version than current version of Samba uses.
This allows to use old modules with new VFS interface as far as combined VFS operation
set is coherent (will be in most cases).
*/
-#define SMB_VFS_INTERFACE_CASCADED 4
+#define SMB_VFS_INTERFACE_CASCADED 5
/*
Each VFS module must provide following global functions:
@@ -116,6 +117,7 @@ struct vfs_ops {
ssize_t (*read)(struct files_struct *fsp, int fd, void *data, size_t n);
ssize_t (*write)(struct files_struct *fsp, int fd, const void *data, size_t n);
SMB_OFF_T (*lseek)(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence);
+ ssize_t (*sendfile)(int tofd, files_struct *fsp, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
int (*rename)(struct connection_struct *conn, const char *old, const char *new);
int (*fsync)(struct files_struct *fsp, int fd);
int (*stat)(struct connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf);
@@ -210,6 +212,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_READ,
SMB_VFS_OP_WRITE,
SMB_VFS_OP_LSEEK,
+ SMB_VFS_OP_SENDFILE,
SMB_VFS_OP_RENAME,
SMB_VFS_OP_FSYNC,
SMB_VFS_OP_STAT,
diff --git a/source3/lib/sendfile.c b/source3/lib/sendfile.c
index 8bcb9dbd02..bcace5fee2 100644
--- a/source3/lib/sendfile.c
+++ b/source3/lib/sendfile.c
@@ -47,7 +47,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
if (header) {
hdr_len = header->length;
- while (total < hd_len) {
+ while (total < hdr_len) {
ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE);
if (ret == -1)
return -1;
@@ -115,7 +115,7 @@ ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T of
if (header) {
hdr_len = header->length;
- while (total < hd_len) {
+ while (total < hdr_len) {
ret = sys_send(tofd, header->data + total,hdr_len - total, MSG_MORE);
if (ret == -1)
return -1;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 45704b9264..b8a89b1d9d 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1723,7 +1723,7 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length
SSVAL(outbuf,smb_vwv5,smb_maxcnt);
SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
SSVAL(smb_buf(outbuf),-2,smb_maxcnt);
- CVAL(outbuf,smb_vwv0) = 0xFF;
+ SCVAL(outbuf,smb_vwv0,0xFF);
set_message(outbuf,12,smb_maxcnt,False);
header.data = outbuf;
header.length = data - outbuf;
diff --git a/source3/smbd/vfs-wrap.c b/source3/smbd/vfs-wrap.c
index 27bb1f42f3..bae304096c 100644
--- a/source3/smbd/vfs-wrap.c
+++ b/source3/smbd/vfs-wrap.c
@@ -192,17 +192,16 @@ SMB_OFF_T vfswrap_lseek(files_struct *fsp, int filedes, SMB_OFF_T offset, int wh
return result;
}
-#if 0 /* JRATEST */
-ssize_t vfswrap_sendfile(int tofd, struct files_struct *fsp, int fromfd, DATA_BLOB *hdr, SMB_OFF_T offset, size_t n)
+ssize_t vfswrap_sendfile(int tofd, struct files_struct *fsp, int fromfd, const DATA_BLOB *hdr,
+ SMB_OFF_T offset, size_t n)
{
ssize_t result;
START_PROFILE_BYTES(syscall_sendfile, n);
- result = sys_sendfile(outfd, fsp, infd, hdr, offset, n);
+ result = sys_sendfile(tofd, fromfd, hdr, offset, n);
END_PROFILE(syscall_sendfile);
return result;
}
-#endif
int vfswrap_rename(connection_struct *conn, const char *old, const char *new)
{
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 6869c61861..a0a7b920b8 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -68,6 +68,7 @@ static struct vfs_ops default_vfs_ops = {
vfswrap_read,
vfswrap_write,
vfswrap_lseek,
+ vfswrap_sendfile,
vfswrap_rename,
vfswrap_fsync,
vfswrap_stat,
@@ -263,6 +264,7 @@ BOOL smbd_vfs_init(connection_struct *conn)
/*******************************************************************
Create vfs_ops reflecting current vfs_opaque_ops
*******************************************************************/
+
struct vfs_ops *smb_vfs_get_opaque_ops(void)
{
int i;
@@ -301,6 +303,7 @@ BOOL vfs_directory_exist(connection_struct *conn, const char *dname, SMB_STRUCT_
/*******************************************************************
vfs getwd wrapper
********************************************************************/
+
static char *vfs_getwd(connection_struct *conn, char *path)
{
return conn->vfs_ops.getwd(conn,path);