mirror of
https://github.com/samba-team/samba.git
synced 2025-03-24 10:50:22 +03:00
smbd: use fsp_get_io_fd() when accessing a file or it's associated metadata
In all places where we access or modify a file or it's associated metadata, we use fsp_get_io_fd() to fetch the low-level fd from the fsp. This ensures we don't accidentally use a pathref fsp where the fd would be opened as root on systems lacking O_PATH. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
50ce980902
commit
9db3ff2573
@ -45,7 +45,8 @@
|
||||
#define IS_PRINT(conn) ((conn) && (conn)->printer)
|
||||
|
||||
#define CHECK_READ(fsp,req) \
|
||||
(((fsp)->fh->fd != -1) && \
|
||||
((!(fsp)->fsp_flags.is_pathref) && \
|
||||
(fsp_get_io_fd(fsp) != -1) && \
|
||||
(((fsp)->fsp_flags.can_read) || \
|
||||
((req->flags2 & FLAGS2_READ_PERMIT_EXECUTE) && \
|
||||
(fsp->access_mask & FILE_EXECUTE))))
|
||||
@ -63,7 +64,8 @@
|
||||
* test).
|
||||
*/
|
||||
#define CHECK_READ_SMB2(fsp) \
|
||||
(((fsp)->fh->fd != -1) && \
|
||||
((!(fsp)->fsp_flags.is_pathref) && \
|
||||
(fsp_get_io_fd(fsp) != -1) && \
|
||||
(((fsp)->fsp_flags.can_read) || \
|
||||
(fsp->access_mask & FILE_EXECUTE)))
|
||||
|
||||
@ -74,12 +76,14 @@
|
||||
* the "if execute is granted then also grant read" arrangement.
|
||||
*/
|
||||
#define CHECK_READ_IOCTL(fsp) \
|
||||
(((fsp)->fh->fd != -1) && \
|
||||
((!(fsp)->fsp_flags.is_pathref) && \
|
||||
(fsp_get_io_fd(fsp) != -1) && \
|
||||
(((fsp)->fsp_flags.can_read)))
|
||||
|
||||
#define CHECK_WRITE(fsp) \
|
||||
((fsp)->fsp_flags.can_write && \
|
||||
((fsp)->fh->fd != -1))
|
||||
(!(fsp)->fsp_flags.is_pathref) && \
|
||||
(fsp_get_io_fd(fsp) != -1))
|
||||
|
||||
#define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \
|
||||
NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) )
|
||||
|
@ -2521,7 +2521,7 @@ int ad_fset(struct vfs_handle_struct *handle,
|
||||
|
||||
if ((fsp == NULL)
|
||||
|| (fsp->fh == NULL)
|
||||
|| (fsp->fh->fd == -1))
|
||||
|| (fsp_get_io_fd(fsp) == -1))
|
||||
{
|
||||
smb_panic("bad fsp");
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "dbwrap/dbwrap.h"
|
||||
#include "dbwrap/dbwrap_rbt.h"
|
||||
#include "util_tdb.h"
|
||||
#include "smbd/fd_handle.h"
|
||||
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_LOCKING
|
||||
@ -196,7 +197,7 @@ static bool posix_fcntl_lock(files_struct *fsp, int op, off_t offset, off_t coun
|
||||
bool ret;
|
||||
|
||||
DEBUG(8,("posix_fcntl_lock %d %d %jd %jd %d\n",
|
||||
fsp->fh->fd,op,(intmax_t)offset,(intmax_t)count,type));
|
||||
fsp_get_io_fd(fsp),op,(intmax_t)offset,(intmax_t)count,type));
|
||||
|
||||
ret = SMB_VFS_LOCK(fsp, op, offset, count, type);
|
||||
|
||||
@ -262,7 +263,7 @@ static bool posix_fcntl_getlock(files_struct *fsp, off_t *poffset, off_t *pcount
|
||||
bool ret;
|
||||
|
||||
DEBUG(8, ("posix_fcntl_getlock %d %ju %ju %d\n",
|
||||
fsp->fh->fd, (uintmax_t)*poffset, (uintmax_t)*pcount,
|
||||
fsp_get_io_fd(fsp), (uintmax_t)*poffset, (uintmax_t)*pcount,
|
||||
*ptype));
|
||||
|
||||
ret = SMB_VFS_GETLOCK(fsp, poffset, pcount, ptype, &pid);
|
||||
@ -600,7 +601,7 @@ int fd_close_posix(const struct files_struct *fsp)
|
||||
/*
|
||||
* There are outstanding locks on this dev/inode pair on
|
||||
* other fds. Add our fd to the pending close db. We also
|
||||
* set fsp->fh->fd to -1 inside fd_close() after returning
|
||||
* set fsp_get_io_fd(fsp) to -1 inside fd_close() after returning
|
||||
* from VFS layer.
|
||||
*/
|
||||
|
||||
|
@ -585,7 +585,7 @@ static struct tevent_req *aio_fork_pread_send(struct vfs_handle_struct *handle,
|
||||
cmd.cmd = READ_CMD;
|
||||
cmd.erratic_testing_mode = config->erratic_testing_mode;
|
||||
|
||||
DEBUG(10, ("sending fd %d to child %d\n", fsp->fh->fd,
|
||||
DEBUG(10, ("sending fd %d to child %d\n", fsp_get_io_fd(fsp),
|
||||
(int)state->child->pid));
|
||||
|
||||
/*
|
||||
@ -593,7 +593,7 @@ static struct tevent_req *aio_fork_pread_send(struct vfs_handle_struct *handle,
|
||||
* domain socket. This should never block.
|
||||
*/
|
||||
written = write_fd(state->child->sockfd, &cmd, sizeof(cmd),
|
||||
fsp->fh->fd);
|
||||
fsp_get_io_fd(fsp));
|
||||
if (written == -1) {
|
||||
err = errno;
|
||||
|
||||
@ -711,7 +711,7 @@ static struct tevent_req *aio_fork_pwrite_send(
|
||||
cmd.cmd = WRITE_CMD;
|
||||
cmd.erratic_testing_mode = config->erratic_testing_mode;
|
||||
|
||||
DEBUG(10, ("sending fd %d to child %d\n", fsp->fh->fd,
|
||||
DEBUG(10, ("sending fd %d to child %d\n", fsp_get_io_fd(fsp),
|
||||
(int)state->child->pid));
|
||||
|
||||
/*
|
||||
@ -719,7 +719,7 @@ static struct tevent_req *aio_fork_pwrite_send(
|
||||
* domain socket. This should never block.
|
||||
*/
|
||||
written = write_fd(state->child->sockfd, &cmd, sizeof(cmd),
|
||||
fsp->fh->fd);
|
||||
fsp_get_io_fd(fsp));
|
||||
if (written == -1) {
|
||||
err = errno;
|
||||
|
||||
@ -819,7 +819,7 @@ static struct tevent_req *aio_fork_fsync_send(
|
||||
cmd.cmd = FSYNC_CMD;
|
||||
cmd.erratic_testing_mode = config->erratic_testing_mode;
|
||||
|
||||
DEBUG(10, ("sending fd %d to child %d\n", fsp->fh->fd,
|
||||
DEBUG(10, ("sending fd %d to child %d\n", fsp_get_io_fd(fsp),
|
||||
(int)state->child->pid));
|
||||
|
||||
/*
|
||||
@ -827,7 +827,7 @@ static struct tevent_req *aio_fork_fsync_send(
|
||||
* domain socket. This should never block.
|
||||
*/
|
||||
written = write_fd(state->child->sockfd, &cmd, sizeof(cmd),
|
||||
fsp->fh->fd);
|
||||
fsp_get_io_fd(fsp));
|
||||
if (written == -1) {
|
||||
err = errno;
|
||||
|
||||
|
@ -302,8 +302,8 @@ static struct aio_open_private_data *create_private_open_data(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dirfsp->fh->fd != AT_FDCWD) {
|
||||
opd->dir_fd = dirfsp->fh->fd;
|
||||
if (fsp_get_io_fd(dirfsp) != AT_FDCWD) {
|
||||
opd->dir_fd = fsp_get_io_fd(dirfsp);
|
||||
} else {
|
||||
#if defined(O_DIRECTORY)
|
||||
opd->dir_fd = open(".", O_RDONLY|O_DIRECTORY);
|
||||
@ -466,7 +466,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
|
||||
|
||||
if (!aio_allow_open) {
|
||||
/* aio opens turned off. */
|
||||
return openat(dirfsp->fh->fd,
|
||||
return openat(fsp_get_io_fd(dirfsp),
|
||||
smb_fname->base_name,
|
||||
flags,
|
||||
mode);
|
||||
@ -474,7 +474,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
|
||||
|
||||
if (!(flags & O_CREAT)) {
|
||||
/* Only creates matter. */
|
||||
return openat(dirfsp->fh->fd,
|
||||
return openat(fsp_get_io_fd(dirfsp),
|
||||
smb_fname->base_name,
|
||||
flags,
|
||||
mode);
|
||||
@ -482,7 +482,7 @@ static int aio_pthread_openat_fn(vfs_handle_struct *handle,
|
||||
|
||||
if (!(flags & O_EXCL)) {
|
||||
/* Only creates with O_EXCL matter. */
|
||||
return openat(dirfsp->fh->fd,
|
||||
return openat(fsp_get_io_fd(dirfsp),
|
||||
smb_fname->base_name,
|
||||
flags,
|
||||
mode);
|
||||
|
@ -95,7 +95,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
|
||||
/* Get the acl using fstatacl */
|
||||
|
||||
DEBUG(10,("Entering AIX sys_acl_get_fd\n"));
|
||||
DEBUG(10,("fd is %d\n",fsp->fh->fd));
|
||||
DEBUG(10,("fd is %d\n",fsp_get_io_fd(fsp)));
|
||||
file_acl = (struct acl *)SMB_MALLOC(BUFSIZ);
|
||||
|
||||
if(file_acl == NULL) {
|
||||
@ -106,7 +106,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
|
||||
|
||||
memset(file_acl,0,BUFSIZ);
|
||||
|
||||
rc = fstatacl(fsp->fh->fd,0,file_acl,BUFSIZ);
|
||||
rc = fstatacl(fsp_get_io_fd(fsp),0,file_acl,BUFSIZ);
|
||||
if( (rc == -1) && (errno == ENOSPC)) {
|
||||
struct acl *new_acl = SMB_MALLOC(file_acl->acl_len + sizeof(struct acl));
|
||||
if( new_acl == NULL) {
|
||||
@ -115,7 +115,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
|
||||
return NULL;
|
||||
}
|
||||
file_acl = new_acl;
|
||||
rc = fstatacl(fsp->fh->fd,0,file_acl,file_acl->acl_len + sizeof(struct acl));
|
||||
rc = fstatacl(fsp_get_io_fd(fsp),0,file_acl,file_acl->acl_len + sizeof(struct acl));
|
||||
if( rc == -1) {
|
||||
DEBUG(0,("fstatacl returned %d with errno %d\n",rc,errno));
|
||||
SAFE_FREE(file_acl);
|
||||
@ -165,7 +165,7 @@ int aixacl_sys_acl_set_fd(vfs_handle_struct *handle,
|
||||
if (!file_acl)
|
||||
return -1;
|
||||
|
||||
rc = fchacl(fsp->fh->fd,file_acl,file_acl->acl_len);
|
||||
rc = fchacl(fsp_get_io_fd(fsp),file_acl,file_acl->acl_len);
|
||||
DEBUG(10,("errno is %d\n",errno));
|
||||
DEBUG(10,("return code is %d\n",rc));
|
||||
SAFE_FREE(file_acl);
|
||||
|
@ -533,7 +533,7 @@ int aixjfs2_sys_acl_set_fd(vfs_handle_struct *handle,
|
||||
return -1;
|
||||
|
||||
rc = aclx_fput(
|
||||
fsp->fh->fd,
|
||||
fsp_get_io_fd(fsp),
|
||||
SET_ACL, /* set only the ACL, not mode bits */
|
||||
acl_type_info,
|
||||
acl_aixc,
|
||||
|
@ -361,12 +361,12 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
|
||||
}
|
||||
|
||||
ZERO_STRUCT(cr_args);
|
||||
cr_args.src_fd = src_fsp->fh->fd;
|
||||
cr_args.src_fd = fsp_get_io_fd(src_fsp);
|
||||
cr_args.src_offset = (uint64_t)src_off;
|
||||
cr_args.dest_offset = (uint64_t)dest_off;
|
||||
cr_args.src_length = (uint64_t)num;
|
||||
|
||||
ret = ioctl(dest_fsp->fh->fd, BTRFS_IOC_CLONE_RANGE, &cr_args);
|
||||
ret = ioctl(fsp_get_io_fd(dest_fsp), BTRFS_IOC_CLONE_RANGE, &cr_args);
|
||||
if (ret < 0) {
|
||||
/*
|
||||
* BTRFS_IOC_CLONE_RANGE only supports 'sectorsize' aligned
|
||||
@ -379,7 +379,7 @@ static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct *han
|
||||
(unsigned long long)cr_args.src_length,
|
||||
(long long)cr_args.src_fd,
|
||||
(unsigned long long)cr_args.src_offset,
|
||||
dest_fsp->fh->fd,
|
||||
fsp_get_io_fd(dest_fsp),
|
||||
(unsigned long long)cr_args.dest_offset));
|
||||
subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle,
|
||||
state,
|
||||
@ -468,8 +468,8 @@ static NTSTATUS btrfs_get_compression(struct vfs_handle_struct *handle,
|
||||
NTSTATUS status;
|
||||
DIR *dir = NULL;
|
||||
|
||||
if ((fsp != NULL) && (fsp->fh->fd != -1)) {
|
||||
fd = fsp->fh->fd;
|
||||
if ((fsp != NULL) && (fsp_get_io_fd(fsp) != -1)) {
|
||||
fd = fsp_get_io_fd(fsp);
|
||||
} else if (smb_fname != NULL) {
|
||||
if (S_ISDIR(smb_fname->st.st_ex_mode)) {
|
||||
dir = opendir(smb_fname->base_name);
|
||||
@ -528,11 +528,11 @@ static NTSTATUS btrfs_set_compression(struct vfs_handle_struct *handle,
|
||||
int fd;
|
||||
NTSTATUS status;
|
||||
|
||||
if ((fsp == NULL) || (fsp->fh->fd == -1)) {
|
||||
if ((fsp == NULL) || (fsp_get_io_fd(fsp) == -1)) {
|
||||
status = NT_STATUS_INVALID_PARAMETER;
|
||||
goto err_out;
|
||||
}
|
||||
fd = fsp->fh->fd;
|
||||
fd = fsp_get_io_fd(fsp);
|
||||
|
||||
ret = ioctl(fd, FS_IOC_GETFLAGS, &flags);
|
||||
if (ret < 0) {
|
||||
|
@ -76,7 +76,7 @@ static bool prime_cache(
|
||||
MODULE, (long long)g_readsz, (long long)*last,
|
||||
fsp_str_dbg(fsp)));
|
||||
|
||||
nread = sys_pread(fsp->fh->fd, g_readbuf, g_readsz, *last);
|
||||
nread = sys_pread(fsp_get_io_fd(fsp), g_readbuf, g_readsz, *last);
|
||||
if (nread < 0) {
|
||||
*last = -1;
|
||||
return False;
|
||||
|
@ -432,7 +432,7 @@ static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp)
|
||||
int result;
|
||||
|
||||
DBG_DEBUG("[CEPH] close(%p, %p)\n", handle, fsp);
|
||||
result = ceph_close(handle->data, fsp->fh->fd);
|
||||
result = ceph_close(handle->data, fsp_get_io_fd(fsp));
|
||||
DBG_DEBUG("[CEPH] close(...) = %d\n", result);
|
||||
|
||||
WRAP_RETURN(result);
|
||||
@ -445,7 +445,7 @@ static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fs
|
||||
|
||||
DBG_DEBUG("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset));
|
||||
|
||||
result = ceph_read(handle->data, fsp->fh->fd, data, n, offset);
|
||||
result = ceph_read(handle->data, fsp_get_io_fd(fsp), data, n, offset);
|
||||
DBG_DEBUG("[CEPH] pread(...) = %llu\n", llu(result));
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
@ -475,7 +475,7 @@ static struct tevent_req *cephwrap_pread_send(struct vfs_handle_struct *handle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ceph_read(handle->data, fsp->fh->fd, data, n, offset);
|
||||
ret = ceph_read(handle->data, fsp_get_io_fd(fsp), data, n, offset);
|
||||
if (ret < 0) {
|
||||
/* ceph returns -errno on error. */
|
||||
tevent_req_error(req, -ret);
|
||||
@ -508,7 +508,7 @@ static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *f
|
||||
ssize_t result;
|
||||
|
||||
DBG_DEBUG("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset));
|
||||
result = ceph_write(handle->data, fsp->fh->fd, data, n, offset);
|
||||
result = ceph_write(handle->data, fsp_get_io_fd(fsp), data, n, offset);
|
||||
DBG_DEBUG("[CEPH] pwrite(...) = %llu\n", llu(result));
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
@ -538,7 +538,7 @@ static struct tevent_req *cephwrap_pwrite_send(struct vfs_handle_struct *handle,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ceph_write(handle->data, fsp->fh->fd, data, n, offset);
|
||||
ret = ceph_write(handle->data, fsp_get_io_fd(fsp), data, n, offset);
|
||||
if (ret < 0) {
|
||||
/* ceph returns -errno on error. */
|
||||
tevent_req_error(req, -ret);
|
||||
@ -570,7 +570,7 @@ static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp,
|
||||
off_t result = 0;
|
||||
|
||||
DBG_DEBUG("[CEPH] cephwrap_lseek\n");
|
||||
result = ceph_lseek(handle->data, fsp->fh->fd, offset, whence);
|
||||
result = ceph_lseek(handle->data, fsp_get_io_fd(fsp), offset, whence);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
|
||||
@ -640,7 +640,7 @@ static struct tevent_req *cephwrap_fsync_send(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
/* Make sync call. */
|
||||
ret = ceph_fsync(handle->data, fsp->fh->fd, false);
|
||||
ret = ceph_fsync(handle->data, fsp_get_io_fd(fsp), false);
|
||||
|
||||
if (ret != 0) {
|
||||
/* ceph_fsync returns -errno on error. */
|
||||
@ -739,8 +739,8 @@ static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, S
|
||||
int result = -1;
|
||||
struct ceph_statx stx;
|
||||
|
||||
DBG_DEBUG("[CEPH] fstat(%p, %d)\n", handle, fsp->fh->fd);
|
||||
result = ceph_fstatx(handle->data, fsp->fh->fd, &stx,
|
||||
DBG_DEBUG("[CEPH] fstat(%p, %d)\n", handle, fsp_get_io_fd(fsp));
|
||||
result = ceph_fstatx(handle->data, fsp_get_io_fd(fsp), &stx,
|
||||
SAMBA_STATX_ATTR_MASK, 0);
|
||||
DBG_DEBUG("[CEPH] fstat(...) = %d\n", result);
|
||||
if (result < 0) {
|
||||
@ -849,7 +849,7 @@ static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp,
|
||||
int result;
|
||||
|
||||
DBG_DEBUG("[CEPH] fchmod(%p, %p, %d)\n", handle, fsp, mode);
|
||||
result = ceph_fchmod(handle->data, fsp->fh->fd, mode);
|
||||
result = ceph_fchmod(handle->data, fsp_get_io_fd(fsp), mode);
|
||||
DBG_DEBUG("[CEPH] fchmod(...) = %d\n", result);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
@ -859,7 +859,7 @@ static int cephwrap_fchown(struct vfs_handle_struct *handle, files_struct *fsp,
|
||||
int result;
|
||||
|
||||
DBG_DEBUG("[CEPH] fchown(%p, %p, %d, %d)\n", handle, fsp, uid, gid);
|
||||
result = ceph_fchown(handle->data, fsp->fh->fd, uid, gid);
|
||||
result = ceph_fchown(handle->data, fsp_get_io_fd(fsp), uid, gid);
|
||||
DBG_DEBUG("[CEPH] fchown(...) = %d\n", result);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
@ -922,12 +922,12 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str
|
||||
|
||||
/* Shrink - just ftruncate. */
|
||||
if (pst->st_ex_size > len) {
|
||||
result = ceph_ftruncate(handle->data, fsp->fh->fd, len);
|
||||
result = ceph_ftruncate(handle->data, fsp_get_io_fd(fsp), len);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
|
||||
space_to_write = len - pst->st_ex_size;
|
||||
result = ceph_fallocate(handle->data, fsp->fh->fd, 0, pst->st_ex_size,
|
||||
result = ceph_fallocate(handle->data, fsp_get_io_fd(fsp), 0, pst->st_ex_size,
|
||||
space_to_write);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
@ -942,7 +942,7 @@ static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fs
|
||||
return strict_allocate_ftruncate(handle, fsp, len);
|
||||
}
|
||||
|
||||
result = ceph_ftruncate(handle->data, fsp->fh->fd, len);
|
||||
result = ceph_ftruncate(handle->data, fsp_get_io_fd(fsp), len);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
|
||||
@ -957,7 +957,7 @@ static int cephwrap_fallocate(struct vfs_handle_struct *handle,
|
||||
DBG_DEBUG("[CEPH] fallocate(%p, %p, %u, %llu, %llu\n",
|
||||
handle, fsp, mode, llu(offset), llu(len));
|
||||
/* unsupported mode flags are rejected by libcephfs */
|
||||
result = ceph_fallocate(handle->data, fsp->fh->fd, mode, offset, len);
|
||||
result = ceph_fallocate(handle->data, fsp_get_io_fd(fsp), mode, offset, len);
|
||||
DBG_DEBUG("[CEPH] fallocate(...) = %d\n", result);
|
||||
WRAP_RETURN(result);
|
||||
}
|
||||
@ -1201,7 +1201,7 @@ static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, struct files
|
||||
{
|
||||
int ret;
|
||||
DBG_DEBUG("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n", handle, fsp, name, value, llu(size));
|
||||
ret = ceph_fgetxattr(handle->data, fsp->fh->fd, name, value, size);
|
||||
ret = ceph_fgetxattr(handle->data, fsp_get_io_fd(fsp), name, value, size);
|
||||
DBG_DEBUG("[CEPH] fgetxattr(...) = %d\n", ret);
|
||||
if (ret < 0) {
|
||||
WRAP_RETURN(ret);
|
||||
@ -1230,7 +1230,7 @@ static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct file
|
||||
int ret;
|
||||
DBG_DEBUG("[CEPH] flistxattr(%p, %p, %p, %llu)\n",
|
||||
handle, fsp, list, llu(size));
|
||||
ret = ceph_flistxattr(handle->data, fsp->fh->fd, list, size);
|
||||
ret = ceph_flistxattr(handle->data, fsp_get_io_fd(fsp), list, size);
|
||||
DBG_DEBUG("[CEPH] flistxattr(...) = %d\n", ret);
|
||||
if (ret < 0) {
|
||||
WRAP_RETURN(ret);
|
||||
@ -1254,7 +1254,7 @@ static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_
|
||||
{
|
||||
int ret;
|
||||
DBG_DEBUG("[CEPH] fremovexattr(%p, %p, %s)\n", handle, fsp, name);
|
||||
ret = ceph_fremovexattr(handle->data, fsp->fh->fd, name);
|
||||
ret = ceph_fremovexattr(handle->data, fsp_get_io_fd(fsp), name);
|
||||
DBG_DEBUG("[CEPH] fremovexattr(...) = %d\n", ret);
|
||||
WRAP_RETURN(ret);
|
||||
}
|
||||
@ -1279,7 +1279,7 @@ static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, struct files_str
|
||||
{
|
||||
int ret;
|
||||
DBG_DEBUG("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", handle, fsp, name, value, llu(size), flags);
|
||||
ret = ceph_fsetxattr(handle->data, fsp->fh->fd,
|
||||
ret = ceph_fsetxattr(handle->data, fsp_get_io_fd(fsp),
|
||||
name, value, size, flags);
|
||||
DBG_DEBUG("[CEPH] fsetxattr(...) = %d\n", ret);
|
||||
WRAP_RETURN(ret);
|
||||
|
@ -113,7 +113,7 @@ static int commit_all(
|
||||
("%s: flushing %lu dirty bytes\n",
|
||||
MODULE, (unsigned long)c->dbytes));
|
||||
|
||||
return commit_do(c, fsp->fh->fd);
|
||||
return commit_do(c, fsp_get_io_fd(fsp));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -135,7 +135,7 @@ static int commit(
|
||||
c->dbytes += last_write; /* dirty bytes always counted */
|
||||
|
||||
if (c->dthresh && (c->dbytes > c->dthresh)) {
|
||||
return commit_do(c, fsp->fh->fd);
|
||||
return commit_do(c, fsp_get_io_fd(fsp));
|
||||
}
|
||||
|
||||
/* Return if we are not in EOF mode or if we have temporarily opted
|
||||
@ -147,7 +147,7 @@ static int commit(
|
||||
|
||||
/* This write hit or went past our cache the file size. */
|
||||
if ((offset + last_write) >= c->eof) {
|
||||
if (commit_do(c, fsp->fh->fd) == -1) {
|
||||
if (commit_do(c, fsp_get_io_fd(fsp)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ static NTSTATUS vfswrap_create_dfs_pathat(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
ret = symlinkat(msdfs_link,
|
||||
dirfsp->fh->fd,
|
||||
fsp_get_io_fd(dirfsp),
|
||||
smb_fname->base_name);
|
||||
if (ret == 0) {
|
||||
status = NT_STATUS_OK;
|
||||
@ -460,7 +460,7 @@ static NTSTATUS vfswrap_read_dfs_pathat(struct vfs_handle_struct *handle,
|
||||
}
|
||||
}
|
||||
|
||||
referral_len = readlinkat(dirfsp->fh->fd,
|
||||
referral_len = readlinkat(fsp_get_io_fd(dirfsp),
|
||||
smb_fname->base_name,
|
||||
link_target,
|
||||
bufsize - 1);
|
||||
@ -563,7 +563,7 @@ static DIR *vfswrap_fdopendir(vfs_handle_struct *handle,
|
||||
DIR *result;
|
||||
|
||||
START_PROFILE(syscall_fdopendir);
|
||||
result = sys_fdopendir(fsp->fh->fd);
|
||||
result = sys_fdopendir(fsp_get_io_fd(fsp));
|
||||
END_PROFILE(syscall_fdopendir);
|
||||
return result;
|
||||
}
|
||||
@ -753,12 +753,12 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void
|
||||
|
||||
#if defined(HAVE_PREAD) || defined(HAVE_PREAD64)
|
||||
START_PROFILE_BYTES(syscall_pread, n);
|
||||
result = sys_pread_full(fsp->fh->fd, data, n, offset);
|
||||
result = sys_pread_full(fsp_get_io_fd(fsp), data, n, offset);
|
||||
END_PROFILE_BYTES(syscall_pread);
|
||||
|
||||
if (result == -1 && errno == ESPIPE) {
|
||||
/* Maintain the fiction that pipes can be seeked (sought?) on. */
|
||||
result = sys_read(fsp->fh->fd, data, n);
|
||||
result = sys_read(fsp_get_io_fd(fsp), data, n);
|
||||
fsp->fh->pos = 0;
|
||||
}
|
||||
|
||||
@ -777,12 +777,12 @@ static ssize_t vfswrap_pwrite(vfs_handle_struct *handle, files_struct *fsp, cons
|
||||
|
||||
#if defined(HAVE_PWRITE) || defined(HAVE_PRWITE64)
|
||||
START_PROFILE_BYTES(syscall_pwrite, n);
|
||||
result = sys_pwrite_full(fsp->fh->fd, data, n, offset);
|
||||
result = sys_pwrite_full(fsp_get_io_fd(fsp), data, n, offset);
|
||||
END_PROFILE_BYTES(syscall_pwrite);
|
||||
|
||||
if (result == -1 && errno == ESPIPE) {
|
||||
/* Maintain the fiction that pipes can be sought on. */
|
||||
result = sys_write(fsp->fh->fd, data, n);
|
||||
result = sys_write(fsp_get_io_fd(fsp), data, n);
|
||||
}
|
||||
|
||||
#else /* HAVE_PWRITE */
|
||||
@ -824,7 +824,7 @@ static struct tevent_req *vfswrap_pread_send(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
state->ret = -1;
|
||||
state->fd = fsp->fh->fd;
|
||||
state->fd = fsp_get_io_fd(fsp);
|
||||
state->buf = data;
|
||||
state->count = n;
|
||||
state->offset = offset;
|
||||
@ -952,7 +952,7 @@ static struct tevent_req *vfswrap_pwrite_send(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
state->ret = -1;
|
||||
state->fd = fsp->fh->fd;
|
||||
state->fd = fsp_get_io_fd(fsp);
|
||||
state->buf = data;
|
||||
state->count = n;
|
||||
state->offset = offset;
|
||||
@ -1075,7 +1075,7 @@ static struct tevent_req *vfswrap_fsync_send(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
state->ret = -1;
|
||||
state->fd = fsp->fh->fd;
|
||||
state->fd = fsp_get_io_fd(fsp);
|
||||
|
||||
SMBPROFILE_BYTES_ASYNC_START(syscall_asys_fsync, profile_p,
|
||||
state->profile_bytes, 0);
|
||||
@ -1173,7 +1173,7 @@ static off_t vfswrap_lseek(vfs_handle_struct *handle, files_struct *fsp, off_t o
|
||||
|
||||
START_PROFILE(syscall_lseek);
|
||||
|
||||
result = lseek(fsp->fh->fd, offset, whence);
|
||||
result = lseek(fsp_get_io_fd(fsp), offset, whence);
|
||||
/*
|
||||
* We want to maintain the fiction that we can seek
|
||||
* on a fifo for file system purposes. This allows
|
||||
@ -1196,7 +1196,7 @@ static ssize_t vfswrap_sendfile(vfs_handle_struct *handle, int tofd, files_struc
|
||||
ssize_t result;
|
||||
|
||||
START_PROFILE_BYTES(syscall_sendfile, n);
|
||||
result = sys_sendfile(tofd, fromfsp->fh->fd, hdr, offset, n);
|
||||
result = sys_sendfile(tofd, fsp_get_io_fd(fromfsp), hdr, offset, n);
|
||||
END_PROFILE_BYTES(syscall_sendfile);
|
||||
return result;
|
||||
}
|
||||
@ -1210,7 +1210,7 @@ static ssize_t vfswrap_recvfile(vfs_handle_struct *handle,
|
||||
ssize_t result;
|
||||
|
||||
START_PROFILE_BYTES(syscall_recvfile, n);
|
||||
result = sys_recvfile(fromfd, tofsp->fh->fd, offset, n);
|
||||
result = sys_recvfile(fromfd, fsp_get_io_fd(tofsp), offset, n);
|
||||
END_PROFILE_BYTES(syscall_recvfile);
|
||||
return result;
|
||||
}
|
||||
@ -2423,7 +2423,7 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m
|
||||
|
||||
START_PROFILE(syscall_fchmod);
|
||||
#if defined(HAVE_FCHMOD)
|
||||
result = fchmod(fsp->fh->fd, mode);
|
||||
result = fchmod(fsp_get_io_fd(fsp), mode);
|
||||
#else
|
||||
result = -1;
|
||||
errno = ENOSYS;
|
||||
@ -2439,7 +2439,7 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t ui
|
||||
int result;
|
||||
|
||||
START_PROFILE(syscall_fchown);
|
||||
result = fchown(fsp->fh->fd, uid, gid);
|
||||
result = fchown(fsp_get_io_fd(fsp), uid, gid);
|
||||
END_PROFILE(syscall_fchown);
|
||||
return result;
|
||||
#else
|
||||
@ -2625,7 +2625,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
|
||||
|
||||
/* Shrink - just ftruncate. */
|
||||
if (pst->st_ex_size > len)
|
||||
return ftruncate(fsp->fh->fd, len);
|
||||
return ftruncate(fsp_get_io_fd(fsp), len);
|
||||
|
||||
space_to_write = len - pst->st_ex_size;
|
||||
|
||||
@ -2684,7 +2684,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
|
||||
expansion and some that don't! On Linux fat can't do
|
||||
ftruncate extend but ext2 can. */
|
||||
|
||||
result = ftruncate(fsp->fh->fd, len);
|
||||
result = ftruncate(fsp_get_io_fd(fsp), len);
|
||||
|
||||
/* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
|
||||
extend a file with ftruncate. Provide alternate implementation
|
||||
@ -2745,7 +2745,7 @@ static int vfswrap_fallocate(vfs_handle_struct *handle,
|
||||
|
||||
START_PROFILE(syscall_fallocate);
|
||||
if (mode == 0) {
|
||||
result = sys_posix_fallocate(fsp->fh->fd, offset, len);
|
||||
result = sys_posix_fallocate(fsp_get_io_fd(fsp), offset, len);
|
||||
/*
|
||||
* posix_fallocate returns 0 on success, errno on error
|
||||
* and doesn't set errno. Make it behave like fallocate()
|
||||
@ -2757,7 +2757,7 @@ static int vfswrap_fallocate(vfs_handle_struct *handle,
|
||||
}
|
||||
} else {
|
||||
/* sys_fallocate handles filtering of unsupported mode flags */
|
||||
result = sys_fallocate(fsp->fh->fd, mode, offset, len);
|
||||
result = sys_fallocate(fsp_get_io_fd(fsp), mode, offset, len);
|
||||
}
|
||||
END_PROFILE(syscall_fallocate);
|
||||
return result;
|
||||
@ -2773,7 +2773,7 @@ static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, o
|
||||
op = map_process_lock_to_ofd_lock(op);
|
||||
}
|
||||
|
||||
result = fcntl_lock(fsp->fh->fd, op, offset, count, type);
|
||||
result = fcntl_lock(fsp_get_io_fd(fsp), op, offset, count, type);
|
||||
END_PROFILE(syscall_fcntl_lock);
|
||||
return result;
|
||||
}
|
||||
@ -2782,7 +2782,7 @@ static int vfswrap_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
|
||||
uint32_t share_access, uint32_t access_mask)
|
||||
{
|
||||
START_PROFILE(syscall_kernel_flock);
|
||||
kernel_flock(fsp->fh->fd, share_access, access_mask);
|
||||
kernel_flock(fsp_get_io_fd(fsp), share_access, access_mask);
|
||||
END_PROFILE(syscall_kernel_flock);
|
||||
return 0;
|
||||
}
|
||||
@ -2819,11 +2819,11 @@ static int vfswrap_fcntl(vfs_handle_struct *handle, files_struct *fsp, int cmd,
|
||||
case F_SET_FILE_RW_HINT:
|
||||
#endif
|
||||
argp = va_arg(dup_cmd_arg, void *);
|
||||
result = sys_fcntl_ptr(fsp->fh->fd, cmd, argp);
|
||||
result = sys_fcntl_ptr(fsp_get_io_fd(fsp), cmd, argp);
|
||||
break;
|
||||
default:
|
||||
val = va_arg(dup_cmd_arg, int);
|
||||
result = sys_fcntl_int(fsp->fh->fd, cmd, val);
|
||||
result = sys_fcntl_int(fsp_get_io_fd(fsp), cmd, val);
|
||||
}
|
||||
|
||||
va_end(dup_cmd_arg);
|
||||
@ -2843,7 +2843,7 @@ static bool vfswrap_getlock(vfs_handle_struct *handle, files_struct *fsp, off_t
|
||||
op = map_process_lock_to_ofd_lock(op);
|
||||
}
|
||||
|
||||
result = fcntl_getlock(fsp->fh->fd, op, poffset, pcount, ptype, ppid);
|
||||
result = fcntl_getlock(fsp_get_io_fd(fsp), op, poffset, pcount, ptype, ppid);
|
||||
END_PROFILE(syscall_fcntl_getlock);
|
||||
return result;
|
||||
}
|
||||
@ -2856,7 +2856,7 @@ static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
|
||||
START_PROFILE(syscall_linux_setlease);
|
||||
|
||||
#ifdef HAVE_KERNEL_OPLOCKS_LINUX
|
||||
result = linux_setlease(fsp->fh->fd, leasetype);
|
||||
result = linux_setlease(fsp_get_io_fd(fsp), leasetype);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
#endif
|
||||
@ -3552,7 +3552,7 @@ static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle,
|
||||
void *value,
|
||||
size_t size)
|
||||
{
|
||||
return fgetxattr(fsp->fh->fd, name, value, size);
|
||||
return fgetxattr(fsp_get_io_fd(fsp), name, value, size);
|
||||
}
|
||||
|
||||
static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle,
|
||||
@ -3565,7 +3565,7 @@ static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle,
|
||||
|
||||
static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
|
||||
{
|
||||
return flistxattr(fsp->fh->fd, list, size);
|
||||
return flistxattr(fsp_get_io_fd(fsp), list, size);
|
||||
}
|
||||
|
||||
static int vfswrap_removexattr(struct vfs_handle_struct *handle,
|
||||
@ -3577,7 +3577,7 @@ static int vfswrap_removexattr(struct vfs_handle_struct *handle,
|
||||
|
||||
static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
|
||||
{
|
||||
return fremovexattr(fsp->fh->fd, name);
|
||||
return fremovexattr(fsp_get_io_fd(fsp), name);
|
||||
}
|
||||
|
||||
static int vfswrap_setxattr(struct vfs_handle_struct *handle,
|
||||
@ -3592,7 +3592,7 @@ static int vfswrap_setxattr(struct vfs_handle_struct *handle,
|
||||
|
||||
static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
|
||||
{
|
||||
return fsetxattr(fsp->fh->fd, name, value, size, flags);
|
||||
return fsetxattr(fsp_get_io_fd(fsp), name, value, size, flags);
|
||||
}
|
||||
|
||||
static bool vfswrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
|
||||
|
@ -588,7 +588,7 @@ static NTSTATUS fruit_check_access(vfs_handle_struct *handle,
|
||||
access_mask & FILE_WRITE_DATA ? "WRITE" : "-",
|
||||
share_mode);
|
||||
|
||||
if (fsp->fh->fd == -1) {
|
||||
if (fsp_get_io_fd(fsp) == -1) {
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
@ -1347,7 +1347,7 @@ static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
|
||||
}
|
||||
if (ret < 0) {
|
||||
DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
|
||||
fsp->fh->fd, strerror(errno)));
|
||||
fsp_get_io_fd(fsp), strerror(errno)));
|
||||
}
|
||||
END_PROFILE(syscall_fstat);
|
||||
|
||||
|
@ -130,7 +130,7 @@ static int set_gpfs_sharemode(files_struct *fsp, uint32_t access_mask,
|
||||
DBG_DEBUG("access_mask=0x%x, allow=0x%x, share_access=0x%x, "
|
||||
"deny=0x%x\n", access_mask, allow, share_access, deny);
|
||||
|
||||
result = gpfswrap_set_share(fsp->fh->fd, allow, deny);
|
||||
result = gpfswrap_set_share(fsp_get_io_fd(fsp), allow, deny);
|
||||
if (result == 0) {
|
||||
return 0;
|
||||
}
|
||||
@ -182,7 +182,7 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
kernel_flock(fsp->fh->fd, share_access, access_mask);
|
||||
kernel_flock(fsp_get_io_fd(fsp), share_access, access_mask);
|
||||
|
||||
ret = set_gpfs_sharemode(fsp, access_mask, share_access);
|
||||
|
||||
@ -208,7 +208,7 @@ static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp)
|
||||
* close gets deferred due to outstanding POSIX locks
|
||||
* (see fd_close_posix)
|
||||
*/
|
||||
int ret = gpfswrap_set_share(fsp->fh->fd, 0, 0);
|
||||
int ret = gpfswrap_set_share(fsp_get_io_fd(fsp), 0, 0);
|
||||
if (ret != 0) {
|
||||
DBG_ERR("Clearing GPFS sharemode on close failed for "
|
||||
" %s/%s: %s\n",
|
||||
@ -247,7 +247,7 @@ static int vfs_gpfs_setlease(vfs_handle_struct *handle,
|
||||
struct gpfs_config_data,
|
||||
return -1);
|
||||
|
||||
ret = linux_set_lease_sighandler(fsp->fh->fd);
|
||||
ret = linux_set_lease_sighandler(fsp_get_io_fd(fsp));
|
||||
if (ret == -1) {
|
||||
goto failure;
|
||||
}
|
||||
@ -261,7 +261,7 @@ static int vfs_gpfs_setlease(vfs_handle_struct *handle,
|
||||
* correct delivery of lease-break signals.
|
||||
*/
|
||||
become_root();
|
||||
ret = gpfswrap_set_lease(fsp->fh->fd, gpfs_lease_type);
|
||||
ret = gpfswrap_set_lease(fsp_get_io_fd(fsp), gpfs_lease_type);
|
||||
if (ret < 0) {
|
||||
saved_errno = errno;
|
||||
}
|
||||
@ -1885,7 +1885,7 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle,
|
||||
}
|
||||
|
||||
attrs.winAttrs = vfs_gpfs_dosmode_to_winattrs(dosmode);
|
||||
ret = gpfswrap_set_winattrs(fsp->fh->fd,
|
||||
ret = gpfswrap_set_winattrs(fsp_get_io_fd(fsp),
|
||||
GPFS_WINATTR_SET_ATTRS, &attrs);
|
||||
|
||||
if (ret == -1 && errno == ENOSYS) {
|
||||
@ -2118,7 +2118,7 @@ static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
|
||||
return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
|
||||
}
|
||||
|
||||
result = gpfswrap_ftruncate(fsp->fh->fd, len);
|
||||
result = gpfswrap_ftruncate(fsp_get_io_fd(fsp), len);
|
||||
if ((result == -1) && (errno == ENOSYS)) {
|
||||
return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ static struct tevent_req *vfs_io_uring_pread_send(struct vfs_handle_struct *hand
|
||||
static void vfs_io_uring_pread_submit(struct vfs_io_uring_pread_state *state)
|
||||
{
|
||||
io_uring_prep_readv(&state->ur.sqe,
|
||||
state->fsp->fh->fd,
|
||||
fsp_get_io_fd(state->fsp),
|
||||
&state->iov, 1,
|
||||
state->offset);
|
||||
vfs_io_uring_request_submit(&state->ur);
|
||||
@ -610,7 +610,7 @@ static struct tevent_req *vfs_io_uring_pwrite_send(struct vfs_handle_struct *han
|
||||
static void vfs_io_uring_pwrite_submit(struct vfs_io_uring_pwrite_state *state)
|
||||
{
|
||||
io_uring_prep_writev(&state->ur.sqe,
|
||||
state->fsp->fh->fd,
|
||||
fsp_get_io_fd(state->fsp),
|
||||
&state->iov, 1,
|
||||
state->offset);
|
||||
vfs_io_uring_request_submit(&state->ur);
|
||||
@ -728,7 +728,7 @@ static struct tevent_req *vfs_io_uring_fsync_send(struct vfs_handle_struct *hand
|
||||
SMBPROFILE_BYTES_ASYNC_SET_IDLE(state->ur.profile_bytes);
|
||||
|
||||
io_uring_prep_fsync(&state->ur.sqe,
|
||||
fsp->fh->fd,
|
||||
fsp_get_io_fd(fsp),
|
||||
0); /* fsync_flags */
|
||||
vfs_io_uring_request_submit(&state->ur);
|
||||
|
||||
|
@ -396,7 +396,7 @@ static NTSTATUS nfs4acl_xattr_fset_nt_acl(vfs_handle_struct *handle,
|
||||
|
||||
restored_mode = existing_mode | expected_mode;
|
||||
|
||||
if (fsp->fh->fd != -1) {
|
||||
if (fsp_get_io_fd(fsp) != -1) {
|
||||
ret = SMB_VFS_NEXT_FCHMOD(handle,
|
||||
fsp,
|
||||
restored_mode);
|
||||
|
@ -98,7 +98,7 @@ static ssize_t posix_eadb_fgetxattr(struct vfs_handle_struct *handle,
|
||||
|
||||
SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
|
||||
|
||||
return posix_eadb_getattr(db, fsp->fsp_name->base_name, fsp->fh->fd, name, value, size);
|
||||
return posix_eadb_getattr(db, fsp->fsp_name->base_name, fsp_get_io_fd(fsp), name, value, size);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -150,7 +150,7 @@ static int posix_eadb_fsetxattr(struct vfs_handle_struct *handle,
|
||||
|
||||
SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
|
||||
|
||||
return posix_eadb_setattr(db, fsp->fsp_name->base_name, fsp->fh->fd, name, value, size, flags);
|
||||
return posix_eadb_setattr(db, fsp->fsp_name->base_name, fsp_get_io_fd(fsp), name, value, size, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -205,7 +205,7 @@ static ssize_t posix_eadb_flistxattr(struct vfs_handle_struct *handle,
|
||||
|
||||
SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
|
||||
|
||||
return posix_eadb_listattr(db, fsp->fsp_name->base_name, fsp->fh->fd, list, size);
|
||||
return posix_eadb_listattr(db, fsp->fsp_name->base_name, fsp_get_io_fd(fsp), list, size);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -245,7 +245,7 @@ static int posix_eadb_fremovexattr(struct vfs_handle_struct *handle,
|
||||
|
||||
SMB_VFS_HANDLE_GET_DATA(handle, db, struct tdb_wrap, return -1);
|
||||
|
||||
return posix_eadb_removeattr(db, fsp->fsp_name->base_name, fsp->fh->fd, name);
|
||||
return posix_eadb_removeattr(db, fsp->fsp_name->base_name, fsp_get_io_fd(fsp), name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -69,7 +69,7 @@ SMB_ACL_T posixacl_sys_acl_get_fd(vfs_handle_struct *handle,
|
||||
files_struct *fsp, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct smb_acl_t *result;
|
||||
acl_t acl = acl_get_fd(fsp->fh->fd);
|
||||
acl_t acl = acl_get_fd(fsp_get_io_fd(fsp));
|
||||
|
||||
if (acl == NULL) {
|
||||
return NULL;
|
||||
@ -125,7 +125,7 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle,
|
||||
if (acl == NULL) {
|
||||
return -1;
|
||||
}
|
||||
res = acl_set_fd(fsp->fh->fd, acl);
|
||||
res = acl_set_fd(fsp_get_io_fd(fsp), acl);
|
||||
acl_free(acl);
|
||||
return res;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ static int prealloc_ftruncate(vfs_handle_struct * handle,
|
||||
|
||||
/* Maintain the allocated space even in the face of truncates. */
|
||||
if ((psize = VFS_FETCH_FSP_EXTENSION(handle, fsp))) {
|
||||
preallocate_space(fsp->fh->fd, *psize);
|
||||
preallocate_space(fsp_get_io_fd(fsp), *psize);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -50,16 +50,16 @@ static ssize_t readahead_sendfile(struct vfs_handle_struct *handle,
|
||||
|
||||
if ( offset % rhd->off_bound == 0) {
|
||||
#if defined(HAVE_LINUX_READAHEAD)
|
||||
int err = readahead(fromfsp->fh->fd, offset, (size_t)rhd->len);
|
||||
int err = readahead(fsp_get_io_fd(fromfsp), offset, (size_t)rhd->len);
|
||||
DEBUG(10,("readahead_sendfile: readahead on fd %u, offset %llu, len %u returned %d\n",
|
||||
(unsigned int)fromfsp->fh->fd,
|
||||
(unsigned int)fsp_get_io_fd(fromfsp),
|
||||
(unsigned long long)offset,
|
||||
(unsigned int)rhd->len,
|
||||
err ));
|
||||
#elif defined(HAVE_POSIX_FADVISE)
|
||||
int err = posix_fadvise(fromfsp->fh->fd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED);
|
||||
int err = posix_fadvise(fsp_get_io_fd(fromfsp), offset, (off_t)rhd->len, POSIX_FADV_WILLNEED);
|
||||
DEBUG(10,("readahead_sendfile: posix_fadvise on fd %u, offset %llu, len %u returned %d\n",
|
||||
(unsigned int)fromfsp->fh->fd,
|
||||
(unsigned int)fsp_get_io_fd(fromfsp),
|
||||
(unsigned long long)offset,
|
||||
(unsigned int)rhd->len,
|
||||
err ));
|
||||
@ -92,16 +92,16 @@ static ssize_t readahead_pread(vfs_handle_struct *handle,
|
||||
|
||||
if ( offset % rhd->off_bound == 0) {
|
||||
#if defined(HAVE_LINUX_READAHEAD)
|
||||
int err = readahead(fsp->fh->fd, offset, (size_t)rhd->len);
|
||||
int err = readahead(fsp_get_io_fd(fsp), offset, (size_t)rhd->len);
|
||||
DEBUG(10,("readahead_pread: readahead on fd %u, offset %llu, len %u returned %d\n",
|
||||
(unsigned int)fsp->fh->fd,
|
||||
(unsigned int)fsp_get_io_fd(fsp),
|
||||
(unsigned long long)offset,
|
||||
(unsigned int)rhd->len,
|
||||
err ));
|
||||
#elif defined(HAVE_POSIX_FADVISE)
|
||||
int err = posix_fadvise(fsp->fh->fd, offset, (off_t)rhd->len, POSIX_FADV_WILLNEED);
|
||||
int err = posix_fadvise(fsp_get_io_fd(fsp), offset, (off_t)rhd->len, POSIX_FADV_WILLNEED);
|
||||
DEBUG(10,("readahead_pread: posix_fadvise on fd %u, offset %llu, len %u returned %d\n",
|
||||
(unsigned int)fsp->fh->fd,
|
||||
(unsigned int)fsp_get_io_fd(fsp),
|
||||
(unsigned long long)offset,
|
||||
(unsigned int)rhd->len,
|
||||
err ));
|
||||
|
@ -113,7 +113,7 @@ SMB_ACL_T solarisacl_sys_acl_get_fd(vfs_handle_struct *handle,
|
||||
|
||||
DEBUG(10, ("entering solarisacl_sys_acl_get_fd.\n"));
|
||||
|
||||
if (!solaris_acl_get_fd(fsp->fh->fd, &solaris_acl, &count)) {
|
||||
if (!solaris_acl_get_fd(fsp_get_io_fd(fsp), &solaris_acl, &count)) {
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
@ -260,7 +260,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle,
|
||||
strerror(errno)));
|
||||
goto done;
|
||||
}
|
||||
if (!solaris_acl_get_fd(fsp->fh->fd, &default_acl, &default_count)) {
|
||||
if (!solaris_acl_get_fd(fsp_get_io_fd(fsp), &default_acl, &default_count)) {
|
||||
DEBUG(10, ("error getting (default) acl from fd\n"));
|
||||
goto done;
|
||||
}
|
||||
@ -276,7 +276,7 @@ int solarisacl_sys_acl_set_fd(vfs_handle_struct *handle,
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = facl(fsp->fh->fd, SETACL, count, solaris_acl);
|
||||
ret = facl(fsp_get_io_fd(fsp), SETACL, count, solaris_acl);
|
||||
if (ret != 0) {
|
||||
DEBUG(10, ("call of facl failed (%s).\n", strerror(errno)));
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ static int syncops_close(vfs_handle_struct *handle, files_struct *fsp)
|
||||
if (fsp->fsp_flags.can_write && config->onclose) {
|
||||
/* ideally we'd only do this if we have written some
|
||||
data, but there is no flag for that in fsp yet. */
|
||||
fsync(fsp->fh->fd);
|
||||
fsync(fsp_get_io_fd(fsp));
|
||||
}
|
||||
return SMB_VFS_NEXT_CLOSE(handle, fsp);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ SMB_ACL_T tru64acl_sys_acl_get_fd(vfs_handle_struct *handle,
|
||||
TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct smb_acl_t *result;
|
||||
acl_t tru64_acl = acl_get_fd(fsp->fh->fd, ACL_TYPE_ACCESS);
|
||||
acl_t tru64_acl = acl_get_fd(fsp_get_io_fd(fsp), ACL_TYPE_ACCESS);
|
||||
|
||||
if (tru64_acl == NULL) {
|
||||
return NULL;
|
||||
@ -142,7 +142,7 @@ int tru64acl_sys_acl_set_fd(vfs_handle_struct *handle,
|
||||
if (tru64_acl == NULL) {
|
||||
return -1;
|
||||
}
|
||||
res = acl_set_fd(fsp->fh->fd, ACL_TYPE_ACCESS, tru64_acl);
|
||||
res = acl_set_fd(fsp_get_io_fd(fsp), ACL_TYPE_ACCESS, tru64_acl);
|
||||
acl_free(tru64_acl);
|
||||
return res;
|
||||
|
||||
|
@ -596,7 +596,7 @@ static int vxfs_fset_xattr(struct vfs_handle_struct *handle,
|
||||
|
||||
DEBUG(10, ("In vxfs_fset_xattr\n"));
|
||||
|
||||
ret = vxfs_setxattr_fd(fsp->fh->fd, name, value, size, flags);
|
||||
ret = vxfs_setxattr_fd(fsp_get_io_fd(fsp), name, value, size, flags);
|
||||
if ((ret == 0) ||
|
||||
((ret == -1) && (errno != ENOTSUP) && (errno != ENOSYS))) {
|
||||
SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
|
||||
@ -654,7 +654,7 @@ static ssize_t vxfs_fget_xattr(struct vfs_handle_struct *handle,
|
||||
|
||||
DEBUG(10, ("In vxfs_fget_xattr\n"));
|
||||
|
||||
ret = vxfs_getxattr_fd(fsp->fh->fd, name, value, size);
|
||||
ret = vxfs_getxattr_fd(fsp_get_io_fd(fsp), name, value, size);
|
||||
if ((ret != -1) || ((errno != ENOTSUP) &&
|
||||
(errno != ENOSYS) && (errno != ENODATA))) {
|
||||
return ret;
|
||||
@ -746,7 +746,7 @@ static int vxfs_fremove_xattr(struct vfs_handle_struct *handle,
|
||||
old_errno = errno;
|
||||
|
||||
/* Remove with new way */
|
||||
ret_new = vxfs_removexattr_fd(fsp->fh->fd, name);
|
||||
ret_new = vxfs_removexattr_fd(fsp_get_io_fd(fsp), name);
|
||||
/*
|
||||
* If both fail, return failuer else return whichever succeeded
|
||||
*/
|
||||
@ -809,7 +809,7 @@ static ssize_t vxfs_flistxattr(struct vfs_handle_struct *handle,
|
||||
{
|
||||
ssize_t result;
|
||||
|
||||
result = vxfs_listxattr_fd(fsp->fh->fd, list, size);
|
||||
result = vxfs_listxattr_fd(fsp_get_io_fd(fsp), list, size);
|
||||
if (result >= 0 || ((errno != ENOTSUP) && (errno != ENOSYS))) {
|
||||
return result;
|
||||
}
|
||||
@ -883,7 +883,7 @@ static NTSTATUS vxfs_fset_ea_dos_attributes(struct vfs_handle_struct *handle,
|
||||
DBG_DEBUG("Entered function\n");
|
||||
|
||||
if (!(dosmode & FILE_ATTRIBUTE_READONLY)) {
|
||||
ret = vxfs_checkwxattr_fd(fsp->fh->fd);
|
||||
ret = vxfs_checkwxattr_fd(fsp_get_io_fd(fsp));
|
||||
if (ret == -1) {
|
||||
DBG_DEBUG("ret:%d\n", ret);
|
||||
if ((errno != EOPNOTSUPP) && (errno != ENOENT)) {
|
||||
@ -892,7 +892,7 @@ static NTSTATUS vxfs_fset_ea_dos_attributes(struct vfs_handle_struct *handle,
|
||||
}
|
||||
}
|
||||
if (dosmode & FILE_ATTRIBUTE_READONLY) {
|
||||
ret = vxfs_setwxattr_fd(fsp->fh->fd);
|
||||
ret = vxfs_setwxattr_fd(fsp_get_io_fd(fsp));
|
||||
DBG_DEBUG("ret:%d\n", ret);
|
||||
if (ret == -1) {
|
||||
if ((errno != EOPNOTSUPP) && (errno != EINVAL)) {
|
||||
@ -905,7 +905,7 @@ static NTSTATUS vxfs_fset_ea_dos_attributes(struct vfs_handle_struct *handle,
|
||||
err = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle, fsp, dosmode);
|
||||
if (!NT_STATUS_IS_OK(err)) {
|
||||
if (attrset) {
|
||||
ret = vxfs_clearwxattr_fd(fsp->fh->fd);
|
||||
ret = vxfs_clearwxattr_fd(fsp_get_io_fd(fsp));
|
||||
DBG_DEBUG("ret:%d\n", ret);
|
||||
if ((ret == -1) && (errno != ENOENT)) {
|
||||
return map_nt_error_from_unix(errno);
|
||||
|
@ -277,7 +277,7 @@ int print_spool_write(files_struct *fsp,
|
||||
* spoolss may have deleted it to signal someone has killed
|
||||
* the job through it's interface */
|
||||
|
||||
if (sys_fstat(fsp->fh->fd, &st, false) != 0) {
|
||||
if (sys_fstat(fsp_get_io_fd(fsp), &st, false) != 0) {
|
||||
ret = errno;
|
||||
DEBUG(3, ("printfile_offset: sys_fstat failed on %s (%s)\n",
|
||||
fsp_str_dbg(fsp), strerror(ret)));
|
||||
@ -287,7 +287,7 @@ int print_spool_write(files_struct *fsp,
|
||||
/* check if the file is unlinked, this will signal spoolss has
|
||||
* killed it, just return an error and close the file */
|
||||
if (st.st_ex_nlink == 0) {
|
||||
close(fsp->fh->fd);
|
||||
close(fsp_get_io_fd(fsp));
|
||||
return EBADF;
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ int print_spool_write(files_struct *fsp,
|
||||
offset = (st.st_ex_size & 0xffffffff00000000LL) + offset;
|
||||
}
|
||||
|
||||
n = write_data_at_offset(fsp->fh->fd, data, size, offset);
|
||||
n = write_data_at_offset(fsp_get_io_fd(fsp), data, size, offset);
|
||||
if (n == -1) {
|
||||
ret = errno;
|
||||
print_spool_terminate(fsp->conn, fsp->print_file);
|
||||
@ -329,7 +329,7 @@ void print_spool_end(files_struct *fsp, enum file_close_type close_type)
|
||||
* _spoolss_EndDocPrinter() will take
|
||||
* care of deleting it for us.
|
||||
*/
|
||||
ret = ftruncate(fsp->fh->fd, 0);
|
||||
ret = ftruncate(fsp_get_io_fd(fsp), 0);
|
||||
if (ret == -1) {
|
||||
DBG_ERR("ftruncate failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
@ -1380,7 +1380,7 @@ static NTSTATUS get_file_handle_for_metadata(connection_struct *conn,
|
||||
for(fsp = file_find_di_first(conn->sconn, file_id);
|
||||
fsp;
|
||||
fsp = file_find_di_next(fsp)) {
|
||||
if (fsp->fh->fd != -1) {
|
||||
if (fsp_get_io_fd(fsp) != -1) {
|
||||
*ret_fsp = fsp;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp,
|
||||
return NT_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (fsp->fh->fd == -1) {
|
||||
if (fsp_get_io_fd(fsp) == -1) {
|
||||
return NT_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ sync a file
|
||||
|
||||
NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, bool write_through)
|
||||
{
|
||||
if (fsp->fh->fd == -1)
|
||||
if (fsp_get_io_fd(fsp) == -1)
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
|
||||
if (lp_strict_sync(SNUM(conn)) &&
|
||||
|
@ -3895,7 +3895,10 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
|
||||
}
|
||||
}
|
||||
|
||||
if (fsp->fh->fd != -1 && lp_kernel_share_modes(SNUM(conn))) {
|
||||
if (!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1 &&
|
||||
lp_kernel_share_modes(SNUM(conn)))
|
||||
{
|
||||
int ret_flock;
|
||||
/*
|
||||
* Beware: streams implementing VFS modules may
|
||||
|
@ -122,7 +122,7 @@ static bool linux_set_kernel_oplock(struct kernel_oplocks *ctx,
|
||||
DBG_NOTICE("Refused oplock on file %s, "
|
||||
"fd = %d, file_id = %s. (%s)\n",
|
||||
fsp_str_dbg(fsp),
|
||||
fsp->fh->fd,
|
||||
fsp_get_io_fd(fsp),
|
||||
file_id_str_buf(fsp->file_id, &idbuf),
|
||||
strerror(errno));
|
||||
return False;
|
||||
@ -151,7 +151,7 @@ static void linux_release_kernel_oplock(struct kernel_oplocks *ctx,
|
||||
* Check and print out the current kernel
|
||||
* oplock state of this file.
|
||||
*/
|
||||
int state = fcntl(fsp->fh->fd, F_GETLEASE, 0);
|
||||
int state = fcntl(fsp_get_io_fd(fsp), F_GETLEASE, 0);
|
||||
dbgtext("linux_release_kernel_oplock: file %s, file_id = %s "
|
||||
"gen_id = %"PRIu64" has kernel oplock state "
|
||||
"of %x.\n",
|
||||
|
@ -3021,7 +3021,7 @@ static bool set_canon_ace_list(files_struct *fsp,
|
||||
* Finally apply it to the file or directory.
|
||||
*/
|
||||
|
||||
if (default_ace || fsp->fsp_flags.is_directory || fsp->fh->fd == -1) {
|
||||
if (default_ace || fsp->fsp_flags.is_directory || fsp_get_io_fd(fsp) == -1) {
|
||||
if (SMB_VFS_SYS_ACL_SET_FILE(conn, fsp->fsp_name,
|
||||
the_acl_type, the_acl) == -1) {
|
||||
/*
|
||||
@ -4697,7 +4697,7 @@ int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle,
|
||||
int ret;
|
||||
|
||||
/* This ensures that we also consider the default ACL */
|
||||
if (fsp->fsp_flags.is_directory || fsp->fh->fd == -1) {
|
||||
if (fsp->fsp_flags.is_directory || fsp_get_io_fd(fsp) == -1) {
|
||||
return posix_sys_acl_blob_get_file(handle,
|
||||
fsp->fsp_name,
|
||||
mem_ctx,
|
||||
|
@ -2892,7 +2892,7 @@ void reply_mknew(struct smb_request *req)
|
||||
|
||||
DEBUG(2, ("reply_mknew: file %s\n", smb_fname_str_dbg(smb_fname)));
|
||||
DEBUG(3, ("reply_mknew %s fd=%d dmode=0x%x\n",
|
||||
smb_fname_str_dbg(smb_fname), fsp->fh->fd,
|
||||
smb_fname_str_dbg(smb_fname), fsp_get_io_fd(fsp),
|
||||
(unsigned int)fattr));
|
||||
|
||||
out:
|
||||
@ -3055,7 +3055,7 @@ void reply_ctemp(struct smb_request *req)
|
||||
|
||||
DEBUG(2, ("reply_ctemp: created temp file %s\n", fsp_str_dbg(fsp)));
|
||||
DEBUG(3, ("reply_ctemp %s fd=%d umode=0%o\n", fsp_str_dbg(fsp),
|
||||
fsp->fh->fd, (unsigned int)smb_fname->st.st_ex_mode));
|
||||
fsp_get_io_fd(fsp), (unsigned int)smb_fname->st.st_ex_mode));
|
||||
out:
|
||||
TALLOC_FREE(smb_fname);
|
||||
TALLOC_FREE(wire_name);
|
||||
@ -3961,7 +3961,7 @@ void reply_readbraw(struct smb_request *req)
|
||||
conn != fsp->conn ||
|
||||
req->vuid != fsp->vuid ||
|
||||
fsp->fsp_flags.is_directory ||
|
||||
fsp->fh->fd == -1)
|
||||
fsp_get_io_fd(fsp) == -1)
|
||||
{
|
||||
/*
|
||||
* fsp could be NULL here so use the value from the packet. JRA.
|
||||
@ -5669,7 +5669,7 @@ static struct files_struct *file_sync_one_fn(struct files_struct *fsp,
|
||||
if (conn != fsp->conn) {
|
||||
return NULL;
|
||||
}
|
||||
if (fsp->fh->fd == -1) {
|
||||
if (fsp_get_io_fd(fsp) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
sync_file(conn, fsp, True /* write through */);
|
||||
@ -6317,7 +6317,7 @@ void reply_lock(struct smb_request *req)
|
||||
};
|
||||
|
||||
DBG_NOTICE("lock fd=%d %s offset=%"PRIu64" count=%"PRIu64"\n",
|
||||
fsp->fh->fd,
|
||||
fsp_get_io_fd(fsp),
|
||||
fsp_fnum_dbg(fsp),
|
||||
lck->offset,
|
||||
lck->count);
|
||||
@ -6417,7 +6417,7 @@ void reply_unlock(struct smb_request *req)
|
||||
}
|
||||
|
||||
DBG_NOTICE("unlock fd=%d %s offset=%"PRIu64" count=%"PRIu64"\n",
|
||||
fsp->fh->fd,
|
||||
fsp_get_io_fd(fsp),
|
||||
fsp_fnum_dbg(fsp),
|
||||
lck.offset,
|
||||
lck.count);
|
||||
@ -6754,7 +6754,7 @@ void reply_printopen(struct smb_request *req)
|
||||
SSVAL(req->outbuf,smb_vwv0,fsp->fnum);
|
||||
|
||||
DEBUG(3,("openprint fd=%d %s\n",
|
||||
fsp->fh->fd, fsp_fnum_dbg(fsp)));
|
||||
fsp_get_io_fd(fsp), fsp_fnum_dbg(fsp)));
|
||||
|
||||
END_PROFILE(SMBsplopen);
|
||||
return;
|
||||
@ -6792,7 +6792,7 @@ void reply_printclose(struct smb_request *req)
|
||||
}
|
||||
|
||||
DEBUG(3,("printclose fd=%d %s\n",
|
||||
fsp->fh->fd, fsp_fnum_dbg(fsp)));
|
||||
fsp_get_io_fd(fsp), fsp_fnum_dbg(fsp)));
|
||||
|
||||
status = close_file(req, fsp, NORMAL_CLOSE);
|
||||
|
||||
|
@ -174,7 +174,7 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (fsp->fh->fd == -1) {
|
||||
if (fsp_get_io_fd(fsp) == -1) {
|
||||
tevent_req_nterror(req, NT_STATUS_INVALID_HANDLE);
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx,
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp && !fsp->fsp_flags.is_pathref && fsp_get_io_fd(fsp) != -1) {
|
||||
sizeret = SMB_VFS_FGETXATTR(fsp, ea_name, val, attr_size);
|
||||
} else {
|
||||
sizeret = SMB_VFS_GETXATTR(conn, smb_fname,
|
||||
@ -328,7 +328,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp && !fsp->fsp_flags.is_pathref && fsp_get_io_fd(fsp) != -1) {
|
||||
sizeret = SMB_VFS_FLISTXATTR(fsp, ea_namelist,
|
||||
ea_namelist_size);
|
||||
} else {
|
||||
@ -346,7 +346,10 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
to_free = ea_namelist;
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
sizeret = SMB_VFS_FLISTXATTR(fsp, ea_namelist,
|
||||
ea_namelist_size);
|
||||
} else {
|
||||
@ -847,7 +850,10 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
|
||||
|
||||
if (ea_list->ea.value.length == 0) {
|
||||
/* Remove the attribute. */
|
||||
if (fsp && (fsp->fh->fd != -1)) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
DEBUG(10,("set_ea: deleting ea name %s on "
|
||||
"file %s by file descriptor.\n",
|
||||
unix_ea_name, fsp_str_dbg(fsp)));
|
||||
@ -868,7 +874,10 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (fsp && (fsp->fh->fd != -1)) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
DEBUG(10,("set_ea: setting ea name %s on file "
|
||||
"%s by file descriptor.\n",
|
||||
unix_ea_name, fsp_str_dbg(fsp)));
|
||||
@ -5914,7 +5923,10 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
|
||||
enum brl_type lock_type;
|
||||
|
||||
/* We need an open file with a real fd for this. */
|
||||
if (!fsp || fsp->fh->fd == -1) {
|
||||
if (fsp == NULL ||
|
||||
fsp->fsp_flags.is_pathref ||
|
||||
fsp_get_io_fd(fsp) == -1)
|
||||
{
|
||||
return NT_STATUS_INVALID_LEVEL;
|
||||
}
|
||||
|
||||
@ -6320,7 +6332,10 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
|
||||
|
||||
case SMB_QUERY_POSIX_LOCK:
|
||||
{
|
||||
if (fsp == NULL || fsp->fh->fd == -1) {
|
||||
if (fsp == NULL ||
|
||||
fsp->fsp_flags.is_pathref ||
|
||||
fsp_get_io_fd(fsp) == -1)
|
||||
{
|
||||
reply_nterror(req, NT_STATUS_INVALID_HANDLE);
|
||||
return;
|
||||
}
|
||||
@ -6687,7 +6702,10 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
|
||||
DEBUG(10,("smb_set_file_size: file %s : setting new size to %.0f\n",
|
||||
smb_fname_str_dbg(smb_fname), (double)size));
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
/* Handle based call. */
|
||||
if (!(fsp->access_mask & FILE_WRITE_DATA)) {
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
@ -7654,7 +7672,10 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn,
|
||||
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
|
||||
if (fsp == NULL || fsp->fh->fd == -1) {
|
||||
if (fsp == NULL ||
|
||||
fsp->fsp_flags.is_pathref ||
|
||||
fsp_get_io_fd(fsp) == -1)
|
||||
{
|
||||
return NT_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@ -7952,7 +7973,10 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
|
||||
"allocation size to %.0f\n", smb_fname_str_dbg(smb_fname),
|
||||
(double)allocation_size));
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
/* Open file handle. */
|
||||
if (!(fsp->access_mask & FILE_WRITE_DATA)) {
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
@ -8261,7 +8285,10 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
|
||||
"setting mode 0%o for file %s\n",
|
||||
(unsigned int)unixmode,
|
||||
smb_fname_str_dbg(smb_fname)));
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
ret = SMB_VFS_FCHMOD(fsp, unixmode);
|
||||
} else {
|
||||
ret = SMB_VFS_CHMOD(conn, smb_fname, unixmode);
|
||||
@ -8284,7 +8311,10 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
|
||||
(unsigned int)set_owner,
|
||||
smb_fname_str_dbg(smb_fname)));
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
ret = SMB_VFS_FCHOWN(fsp, set_owner, (gid_t)-1);
|
||||
} else {
|
||||
/*
|
||||
@ -8313,7 +8343,10 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
|
||||
"changing group %u for file %s\n",
|
||||
(unsigned int)set_grp,
|
||||
smb_fname_str_dbg(smb_fname)));
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
ret = SMB_VFS_FCHOWN(fsp, (uid_t)-1, set_grp);
|
||||
} else {
|
||||
/*
|
||||
@ -8425,7 +8458,10 @@ static NTSTATUS smb_set_file_unix_info2(connection_struct *conn,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (fsp && fsp->fh->fd != -1) {
|
||||
if (fsp &&
|
||||
!fsp->fsp_flags.is_pathref &&
|
||||
fsp_get_io_fd(fsp) != -1)
|
||||
{
|
||||
/* XXX: we should be using SMB_VFS_FCHFLAGS here. */
|
||||
return NT_STATUS_NOT_SUPPORTED;
|
||||
} else {
|
||||
|
@ -754,6 +754,7 @@ bld.SAMBA3_SUBSYSTEM('LOCKING',
|
||||
LEASES_UTIL
|
||||
NDR_OPEN_FILES
|
||||
FNAME_UTIL
|
||||
fd_handle
|
||||
''')
|
||||
|
||||
bld.SAMBA3_SUBSYSTEM('LEASES_DB',
|
||||
|
Loading…
x
Reference in New Issue
Block a user