mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
Actually use sendfile if selected.
Jeremy. (This used to be commit 5881f0a22633ed9fb73e6cd788d0751c4db6cd32)
This commit is contained in:
parent
b33681fc0b
commit
9bab1d0c1a
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user