return result;
}
-static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, int fd, void *data,
+static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void *data,
size_t n, SMB_OFF_T offset)
{
ssize_t result;
#if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
START_PROFILE_BYTES(syscall_pread, n);
- result = sys_pread(fd, data, n, offset);
+ result = sys_pread(fsp->fh->fd, data, n, offset);
END_PROFILE(syscall_pread);
if (result == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be seeked (sought?) on. */
- result = SMB_VFS_READ(fsp, fd, data, n);
+ result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n);
fsp->fh->pos = 0;
}
SMB_OFF_T curr;
int lerrno;
- curr = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
+ curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (curr == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be seeked (sought?) on. */
- result = SMB_VFS_READ(fsp, fd, data, n);
+ result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n);
fsp->fh->pos = 0;
return result;
}
- if (SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET) == -1) {
+ if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {
return -1;
}
errno = 0;
- result = SMB_VFS_READ(fsp, fd, data, n);
+ result = SMB_VFS_READ(fsp, fsp->fh->fd, data, n);
lerrno = errno;
- SMB_VFS_LSEEK(fsp, fd, curr, SEEK_SET);
+ SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
errno = lerrno;
#endif /* HAVE_PREAD */
return result;
}
-static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, int fd, const void *data,
+static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data,
size_t n, SMB_OFF_T offset)
{
ssize_t result;
#if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
START_PROFILE_BYTES(syscall_pwrite, n);
- result = sys_pwrite(fd, data, n, offset);
+ result = sys_pwrite(fsp->fh->fd, data, n, offset);
END_PROFILE(syscall_pwrite);
if (result == -1 && errno == ESPIPE) {
/* Maintain the fiction that pipes can be sought on. */
- result = SMB_VFS_WRITE(fsp, fd, data, n);
+ result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n);
}
#else /* HAVE_PWRITE */
SMB_OFF_T curr;
int lerrno;
- curr = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
+ curr = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (curr == -1) {
return -1;
}
- if (SMB_VFS_LSEEK(fsp, fd, offset, SEEK_SET) == -1) {
+ if (SMB_VFS_LSEEK(fsp, offset, SEEK_SET) == -1) {
return -1;
}
- result = SMB_VFS_WRITE(fsp, fd, data, n);
+ result = SMB_VFS_WRITE(fsp, fsp->fh->fd, data, n);
lerrno = errno;
- SMB_VFS_LSEEK(fsp, fd, curr, SEEK_SET);
+ SMB_VFS_LSEEK(fsp, curr, SEEK_SET);
errno = lerrno;
#endif /* HAVE_PWRITE */
return result;
}
-static SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, int filedes, SMB_OFF_T offset, int whence)
+static SMB_OFF_T vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset, int whence)
{
SMB_OFF_T result = 0;
START_PROFILE(syscall_lseek);
/* Cope with 'stat' file opens. */
- if (filedes != -1)
- result = sys_lseek(filedes, offset, whence);
+ if (fsp->fh->fd != -1)
+ result = sys_lseek(fsp->fh->fd, offset, whence);
/*
* We want to maintain the fiction that we can seek
return result;
}
+static ssize_t vfswrap_recvfile(vfs_handle_struct *handle,
+ int fromfd,
+ files_struct *fsp,
+ int tofd,
+ SMB_OFF_T offset,
+ size_t n)
+{
+ ssize_t result;
+
+ START_PROFILE_BYTES(syscall_recvfile, n);
+ result = sys_recvfile(fromfd, tofd, offset, n);
+ END_PROFILE(syscall_recvfile);
+ return result;
+}
+
/*********************************************************
For rename across filesystems Patch from Warren Birnbaum
<warrenb@hpcvscdp.cv.hp.com>
return result;
}
-static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp, int fd)
+static int vfswrap_fsync(vfs_handle_struct *handle, files_struct *fsp)
{
#ifdef HAVE_FSYNC
int result;
START_PROFILE(syscall_fsync);
- result = fsync(fd);
+ result = fsync(fsp->fh->fd);
END_PROFILE(syscall_fsync);
return result;
#else
return result;
}
-static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf)
+static int vfswrap_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
{
int result;
START_PROFILE(syscall_fstat);
- result = sys_fstat(fd, sbuf);
+ result = sys_fstat(fsp->fh->fd, sbuf);
END_PROFILE(syscall_fstat);
return result;
}
static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
{
SMB_STRUCT_STAT st;
- SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
+ SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
unsigned char zero_space[4096];
SMB_OFF_T space_to_write;
if (currpos == -1)
return -1;
- if (SMB_VFS_FSTAT(fsp, fd, &st) == -1)
+ if (SMB_VFS_FSTAT(fsp, &st) == -1)
return -1;
space_to_write = len - st.st_size;
return sys_ftruncate(fd, len);
/* Write out the real space on disk. */
- if (SMB_VFS_LSEEK(fsp, fd, st.st_size, SEEK_SET) != st.st_size)
+ if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size)
return -1;
space_to_write = len - st.st_size;
}
/* Seek to where we were */
- if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
+ if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
return -1;
return 0;
/* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
extend a file with ftruncate. Provide alternate implementation
for this */
- currpos = SMB_VFS_LSEEK(fsp, fd, 0, SEEK_CUR);
+ currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (currpos == -1) {
goto done;
}
size in which case the ftruncate above should have
succeeded or shorter, in which case seek to len - 1 and
write 1 byte of zero */
- if (SMB_VFS_FSTAT(fsp, fd, &st) == -1) {
+ if (SMB_VFS_FSTAT(fsp, &st) == -1) {
goto done;
}
goto done;
}
- if (SMB_VFS_LSEEK(fsp, fd, len-1, SEEK_SET) != len -1)
+ if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
goto done;
if (SMB_VFS_WRITE(fsp, fd, &c, 1)!=1)
goto done;
/* Seek to where we were */
- if (SMB_VFS_LSEEK(fsp, fd, currpos, SEEK_SET) != currpos)
+ if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
goto done;
result = 0;
return file_id_create_dev(dev, inode);
}
-static size_t vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info, SEC_DESC **ppdesc)
+static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
+ files_struct *fsp,
+ uint32 security_info, SEC_DESC **ppdesc)
{
- size_t result;
+ NTSTATUS result;
START_PROFILE(fget_nt_acl);
- result = get_nt_acl(fsp, security_info, ppdesc);
+ result = posix_fget_nt_acl(fsp, security_info, ppdesc);
END_PROFILE(fget_nt_acl);
return result;
}
-static size_t vfswrap_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, SEC_DESC **ppdesc)
+static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,
+ const char *name,
+ uint32 security_info, SEC_DESC **ppdesc)
{
- size_t result;
+ NTSTATUS result;
START_PROFILE(get_nt_acl);
- result = get_nt_acl(fsp, security_info, ppdesc);
+ result = posix_get_nt_acl(handle->conn, name, security_info, ppdesc);
END_PROFILE(get_nt_acl);
return result;
}
-static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd)
+static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
{
NTSTATUS result;
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_sendfile), SMB_VFS_OP_SENDFILE,
SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(vfswrap_recvfile), SMB_VFS_OP_RECVFILE,
+ SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_rename), SMB_VFS_OP_RENAME,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_fsync), SMB_VFS_OP_FSYNC,