No change in behaviour.
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
{
if ((fsp->fh != NULL) && (fsp->fh->fd != -1)) {
close(fsp->fh->fd);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
}
return NULL;
}
* but also practiced elsewhere -
* needed for calling the VFS.
*/
- fsp->fh->fd = fd;
+ fsp_set_fd(fsp, fd);
if (SMB_VFS_FSTAT(fsp, &st) == -1) {
int saved_errno = errno;
SMB_VFS_CLOSE(fsp);
SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
TALLOC_FREE(data);
/* fd is now closed. */
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
return NULL;
}
goto exit;
}
- fsp->fh->fd = hostfd;
+ fsp_set_fd(fsp, hostfd);
rc = ad_fset(handle, ad, fsp);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
if (rc != 0) {
rc = -1;
goto exit;
* fd_close_posix here, but we don't have a
* full fsp yet
*/
- fsp->fh->fd = hostfd;
+ fsp_set_fd(fsp, hostfd);
SMB_VFS_CLOSE(fsp);
}
hostfd = -1;
case FRUIT_META_NETATALK:
ret = close(fsp->fh->fd);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
break;
default:
case FRUIT_RSRC_XATTR:
ret = close(fsp->fh->fd);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
break;
default:
int fd;
ret = SMB_VFS_NEXT_CLOSE(handle, fsp);
+ fsp_set_fd(fsp, -1);
if (ret != 0) {
DBG_ERR("Close [%s] failed: %s\n",
fsp_str_dbg(fsp), strerror(errno));
- fsp->fh->fd = -1;
return -1;
}
fsp_str_dbg(fsp), strerror(errno));
return -1;
}
- fsp->fh->fd = fd;
+ fsp_set_fd(fsp, fd);
fio->fake_fd = false;
}
DEBUG(0,("shadow_copy_fdopendir: Out of memory\n"));
SMB_VFS_NEXT_CLOSEDIR(handle,p);
/* We have now closed the fd in fsp. */
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
return NULL;
}
SMB_VFS_NEXT_CLOSEDIR(handle,p);
/* We have now closed the fd in fsp. */
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
return((DIR *)dirp);
}
bool get_snaplist = false;
bool access_granted = false;
int open_flags = O_RDONLY;
+ int fd;
int ret = -1;
NTSTATUS status;
open_flags |= O_DIRECTORY;
#endif
- dirfsp->fh->fd = SMB_VFS_NEXT_OPENAT(handle,
- fspcwd,
- snapdir_smb_fname,
- dirfsp,
- open_flags,
- 0);
- if (dirfsp->fh->fd == -1) {
+ fd = SMB_VFS_NEXT_OPENAT(handle,
+ fspcwd,
+ snapdir_smb_fname,
+ dirfsp,
+ open_flags,
+ 0);
+ if (fd == -1) {
DBG_WARNING("SMB_VFS_NEXT_OPEN failed for '%s'"
" - %s\n", snapdir, strerror(errno));
errno = ENOSYS;
goto done;
}
+ fsp_set_fd(dirfsp, fd);
p = SMB_VFS_NEXT_FDOPENDIR(handle, dirfsp, NULL, 0);
if (!p) {
* VFS_CLOSEDIR implicitly
* closed the associated fd.
*/
- dirfsp->fh->fd = -1;
+ fsp_set_fd(dirfsp, -1);
}
}
if (dirfsp != NULL) {
}
ret = close(fd);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
return ret;
}
struct db_context *db = NULL;
TALLOC_CTX *frame = NULL;
SMB_STRUCT_STAT sbuf;
+ int fd;
int ret;
- fsp->fh->fd = SMB_VFS_NEXT_OPENAT(handle,
- dirfsp,
- smb_fname,
- fsp,
- flags,
- mode);
+ fd = SMB_VFS_NEXT_OPENAT(handle,
+ dirfsp,
+ smb_fname,
+ fsp,
+ flags,
+ mode);
- if (fsp->fh->fd < 0) {
- return fsp->fh->fd;
+ if (fd == -1) {
+ return -1;
}
+ fsp_set_fd(fsp, fd);
if ((flags & (O_CREAT|O_EXCL)) != (O_CREAT|O_EXCL)) {
- return fsp->fh->fd;
+ return fd;
}
/*
xattr_tdb_remove_all_attrs(db, &fsp->file_id);
TALLOC_FREE(frame);
- return fsp->fh->fd;
+ return fd;
}
static int xattr_tdb_mkdirat(vfs_handle_struct *handle,
#include "rpc_server/rpc_ncacn_np.h"
#include "smbd/globals.h"
#include "../libcli/security/security.h"
+#include "smbd/fd_handle.h"
struct print_file_data {
char *svcname;
}
fsp->file_id = vfs_file_id_from_sbuf(fsp->conn, &fsp->fsp_name->st);
- fsp->fh->fd = fd;
+ fsp_set_fd(fsp, fd);
fsp->vuid = current_vuid;
fsp->fsp_flags.can_lock = false;
}
conn->sconn = sconn;
conn->force_group_gid = (gid_t)-1;
- conn->cwd_fsp->fh->fd = -1;
+ fsp_set_fd(conn->cwd_fsp, -1);
conn->cwd_fsp->fnum = FNUM_FIELD_INVALID;
conn->cwd_fsp->conn = conn;
files_struct *fsp = dir_hnd->fsp;
SMB_VFS_CLOSEDIR(dir_hnd->conn, dir_hnd->dir);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
if (fsp->dptr != NULL) {
SMB_ASSERT(fsp->dptr->dir_hnd == dir_hnd);
fsp->dptr->dir_hnd = NULL;
goto fail;
}
- if (fsp->fh->fd == -1) {
+ if (fsp_get_io_fd(fsp) == -1) {
errno = EBADF;
goto fail;
}
(unsigned int)access_mask));
fsp->conn = conn;
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
fsp->vuid = current_vuid;
fsp->fh->pos = -1;
fsp->fsp_flags.can_lock = false; /* Should this be true ? - No, JRA */
#endif
fsp->fh->ref_count = 1;
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
fsp->fnum = FNUM_FIELD_INVALID;
fsp->conn = conn;
return status;
}
- fsp->fh->fd = fd;
+ fsp_set_fd(fsp, fd);
DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d\n",
smb_fname_str_dbg(smb_fname), flags, (int)mode, fd);
}
ret = SMB_VFS_CLOSE(fsp);
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
}
fsp->conn = conn;
- fsp->fh->fd = -1;
+ fsp_set_fd(fsp, -1);
fsp->vuid = smb_req->vuid;
fsp->fsp_flags.can_lock = false;
fsp->access_mask = FILE_READ_DATA | FILE_WRITE_DATA;
struct files_struct **_fsp)
{
struct smb_filename *smb_fname = NULL;
+ int fd;
int ret;
mode_t saved_umask;
struct files_struct *fsp;
*/
saved_umask = umask(0);
- fsp->fh->fd = SMB_VFS_OPENAT(conn,
- fspcwd,
- smb_fname,
- fsp,
- flags,
- 00644);
+ fd = SMB_VFS_OPENAT(conn,
+ fspcwd,
+ smb_fname,
+ fsp,
+ flags,
+ 00644);
umask(saved_umask);
- if (fsp->fh->fd == -1) {
+ if (fd == -1) {
int err = errno;
if (err == ENOENT) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
return NT_STATUS_INVALID_PARAMETER;
}
+ fsp_set_fd(fsp, fd);
ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
if (ret == -1) {
* tree connect to a share with the same underlying
* path (may or may not the same share).
*/
- conn->cwd_fsp->fh->fd = AT_FDCWD;
+ fsp_set_fd(conn->cwd_fsp, AT_FDCWD);
return 0;
}
talloc_move(talloc_tos(), &conn->cwd_fsp->fsp_name);
conn->cwd_fsp->fsp_name = talloc_move(conn->cwd_fsp, &cwd);
- conn->cwd_fsp->fh->fd = AT_FDCWD;
+ fsp_set_fd(conn->cwd_fsp, AT_FDCWD);
DBG_INFO("vfs_ChDir got %s\n", fsp_str_dbg(conn->cwd_fsp));
return NT_STATUS_NO_MEMORY;
}
- fsp->fh->fd = AT_FDCWD;
+ fsp_set_fd(fsp, AT_FDCWD);
fsp->fnum = FNUM_FIELD_INVALID;
fsp->conn = conn;
struct smb_filename *smb_fname = NULL;
NTSTATUS status;
int ret;
+ int fd;
mode = 00400;
return status;
}
- fsp->fh->fd = SMB_VFS_OPENAT(vfs->conn,
- fspcwd,
- smb_fname,
- fsp,
- flags,
- mode);
- if (fsp->fh->fd == -1) {
+ fd = SMB_VFS_OPENAT(vfs->conn,
+ fspcwd,
+ smb_fname,
+ fsp,
+ flags,
+ mode);
+ if (fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
TALLOC_FREE(fsp);
TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
+ fsp_set_fd(fsp, fd);
status = NT_STATUS_OK;
ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
struct smb_filename *smb_fname = NULL;
NTSTATUS status;
struct security_descriptor *sd = NULL;
+ int fd;
if (argc != 3) {
printf("Usage: set_nt_acl <file> <sddl>\n");
return status;
}
- fsp->fh->fd = SMB_VFS_OPENAT(vfs->conn,
- fspcwd,
- smb_fname,
- fsp,
- O_RDWR,
- mode);
- if (fsp->fh->fd == -1 && errno == EISDIR) {
- fsp->fh->fd = SMB_VFS_OPENAT(vfs->conn,
- fspcwd,
- smb_fname,
- fsp,
- flags,
- mode);
- }
- if (fsp->fh->fd == -1) {
+ fd = SMB_VFS_OPENAT(vfs->conn,
+ fspcwd,
+ smb_fname,
+ fsp,
+ O_RDWR,
+ mode);
+ if (fd == -1 && errno == EISDIR) {
+ fd = SMB_VFS_OPENAT(vfs->conn,
+ fspcwd,
+ smb_fname,
+ fsp,
+ flags,
+ mode);
+ }
+ if (fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
TALLOC_FREE(fsp);
TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
+ fsp_set_fd(fsp, fd);
status = NT_STATUS_OK;
ret = SMB_VFS_FSTAT(fsp, &smb_fname->st);
vfs_acl_common
NDR_QUOTA
GNUTLS_HELPERS
+ fd_handle
''' +
bld.env['dmapi_lib'] +
bld.env['legacy_quota_libs'] +