diff options
author | David Mulder <dmulder@suse.com> | 2022-03-17 11:15:23 -0600 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2022-04-07 17:37:29 +0000 |
commit | 01ee69a958bf671c324d0ccb59205cfc83cb0b4d (patch) | |
tree | b355438f60ed19ddc9c11cc048cba44b94436707 /source3/smbd/reply.c | |
parent | 56ac1efc700a4cd5a5326f845bd5dd9e0f560710 (diff) | |
download | samba-01ee69a958bf671c324d0ccb59205cfc83cb0b4d.tar.gz |
smbd: Move fake_sendfile to smb2_reply.c
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r-- | source3/smbd/reply.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 757133320d0..1785e95d4dc 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2447,66 +2447,6 @@ static void fail_readraw(void) } /**************************************************************************** - Fake (read/write) sendfile. Returns -1 on read or write fail. -****************************************************************************/ - -ssize_t fake_sendfile(struct smbXsrv_connection *xconn, files_struct *fsp, - off_t startpos, size_t nread) -{ - size_t bufsize; - size_t tosend = nread; - char *buf; - - if (nread == 0) { - return 0; - } - - bufsize = MIN(nread, 65536); - - if (!(buf = SMB_MALLOC_ARRAY(char, bufsize))) { - return -1; - } - - while (tosend > 0) { - ssize_t ret; - size_t cur_read; - - cur_read = MIN(tosend, bufsize); - ret = read_file(fsp,buf,startpos,cur_read); - if (ret == -1) { - SAFE_FREE(buf); - return -1; - } - - /* If we had a short read, fill with zeros. */ - if (ret < cur_read) { - memset(buf + ret, '\0', cur_read - ret); - } - - ret = write_data(xconn->transport.sock, buf, cur_read); - if (ret != cur_read) { - int saved_errno = errno; - /* - * Try and give an error message saying what - * client failed. - */ - DEBUG(0, ("write_data failed for client %s. " - "Error %s\n", - smbXsrv_connection_dbg(xconn), - strerror(saved_errno))); - SAFE_FREE(buf); - errno = saved_errno; - return -1; - } - tosend -= cur_read; - startpos += cur_read; - } - - SAFE_FREE(buf); - return (ssize_t)nread; -} - -/**************************************************************************** Deal with the case of sendfile reading less bytes from the file than requested. Fill with zeros (all we can do). Returns 0 on success ****************************************************************************/ |