summaryrefslogtreecommitdiff
path: root/source3/smbd/vfs.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-01-06 01:22:14 +0000
committerJeremy Allison <jra@samba.org>2004-01-06 01:22:14 +0000
commit0d44747df99f2168a063feedad5039f222746f61 (patch)
tree0ddeca47e4408a6fb7b86357a128caac373f028e /source3/smbd/vfs.c
parent1fa073b55bca9bbc66b86e652e491cc44656071e (diff)
downloadsamba-0d44747df99f2168a063feedad5039f222746f61.tar.gz
samba-0d44747df99f2168a063feedad5039f222746f61.tar.bz2
samba-0d44747df99f2168a063feedad5039f222746f61.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 019aaaf0df091c3f67048f591e70d4353a02bb9b)
Diffstat (limited to 'source3/smbd/vfs.c')
-rw-r--r--source3/smbd/vfs.c43
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.