diff options
author | Jeremy Allison <jra@samba.org> | 2004-01-06 01:21:59 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-01-06 01:21:59 +0000 |
commit | 827c68deb89b5bd14324c57db14274b36a0790d7 (patch) | |
tree | 018ea2e604f64a73899744fced6a41086c90e512 /source3/smbd/vfs.c | |
parent | 35f843a1be9a703328eee3241bc24416cca945e0 (diff) | |
download | samba-827c68deb89b5bd14324c57db14274b36a0790d7.tar.gz samba-827c68deb89b5bd14324c57db14274b36a0790d7.tar.bz2 samba-827c68deb89b5bd14324c57db14274b36a0790d7.zip |
Patch based on work from James Peach <jpeach@sgi.com> to convert over to
using pread/pwrite. Modified a little to ensure fsp->pos is correct.
Fix for #889.
Jeremy.
(This used to be commit 3a24dc868d95c9bcc2ac3a0dbd50e6e226ac0841)
Diffstat (limited to 'source3/smbd/vfs.c')
-rw-r--r-- | source3/smbd/vfs.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 753db4cece..2f981c743f 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -71,7 +71,9 @@ static struct vfs_ops default_vfs = { vfswrap_open, vfswrap_close, vfswrap_read, + vfswrap_pread, vfswrap_write, + vfswrap_pwrite, vfswrap_lseek, vfswrap_sendfile, vfswrap_rename, @@ -429,6 +431,28 @@ ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count) return (ssize_t)total; } +ssize_t vfs_pread_data(files_struct *fsp, char *buf, + size_t byte_count, SMB_OFF_T offset) +{ + size_t total=0; + + while (total < byte_count) + { + ssize_t ret = SMB_VFS_PREAD(fsp, fsp->fd, buf + total, + byte_count - total, offset + total); + + if (ret == 0) return total; + if (ret == -1) { + if (errno == EINTR) + continue; + else + return -1; + } + total += ret; + } + return (ssize_t)total; +} + /**************************************************************************** Write data to a fd on the vfs. ****************************************************************************/ @@ -451,6 +475,25 @@ ssize_t vfs_write_data(files_struct *fsp,const char *buffer,size_t N) return (ssize_t)total; } +ssize_t vfs_pwrite_data(files_struct *fsp,const char *buffer, + size_t N, SMB_OFF_T offset) +{ + size_t total=0; + ssize_t ret; + + while (total < N) { + ret = SMB_VFS_PWRITE(fsp, fsp->fd, buffer + total, + N - total, offset + total); + + if (ret == -1) + return -1; + if (ret == 0) + return total; + + total += ret; + } + return (ssize_t)total; +} /**************************************************************************** An allocate file space call using the vfs interface. Allocates space for a file from a filedescriptor. |