struct smb_filename *adp_smb_fname = NULL;
struct files_struct *ad_fsp = NULL;
NTSTATUS status;
- int flags = in_flags;
+ struct vfs_open_how how = { .flags = in_flags, .mode = mode, };
rc = adouble_path(talloc_tos(),
smb_base_fname,
}
#ifdef O_PATH
- flags &= ~(O_PATH);
+ how.flags &= ~(O_PATH);
#endif
- if (flags & (O_CREAT | O_TRUNC | O_WRONLY)) {
+ if (how.flags & (O_CREAT | O_TRUNC | O_WRONLY)) {
/* We always need read/write access for the metadata header too */
- flags &= ~(O_WRONLY);
- flags |= O_RDWR;
+ how.flags &= ~(O_WRONLY);
+ how.flags |= O_RDWR;
}
status = fd_openat(dirfsp,
adp_smb_fname,
ad_fsp,
- flags,
- mode);
+ &how);
if (!NT_STATUS_IS_OK(status)) {
file_free(NULL, ad_fsp);
return status;
}
- if (flags & (O_CREAT | O_TRUNC)) {
+ if (how.flags & (O_CREAT | O_TRUNC)) {
ad = ad_init(talloc_tos(), ADOUBLE_RSRC);
if (ad == NULL) {
file_free(NULL, ad_fsp);
NTSTATUS status;
bool ok;
int ret;
- int flags = 0;
+ struct vfs_open_how how = { .flags = 0, };
struct file_id file_id;
struct smb_filename *smb_fname = NULL;
enum ndr_err_code ndr_err;
* TODO: properly calculate open flags
*/
if (fsp->fsp_flags.can_write && fsp->fsp_flags.can_read) {
- flags = O_RDWR;
+ how.flags = O_RDWR;
} else if (fsp->fsp_flags.can_write) {
- flags = O_WRONLY;
+ how.flags = O_WRONLY;
} else if (fsp->fsp_flags.can_read) {
- flags = O_RDONLY;
+ how.flags = O_RDONLY;
}
- status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, flags, 0);
+ status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, &how);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(lck);
DEBUG(1, ("vfs_default_durable_reconnect: failed to open "
*/
NTSTATUS open_internal_dirfsp(connection_struct *conn,
const struct smb_filename *smb_dname,
- int open_flags,
+ int _open_flags,
struct files_struct **_fsp)
{
+ struct vfs_open_how how = { .flags = _open_flags, };
struct files_struct *fsp = NULL;
NTSTATUS status;
}
#ifdef O_DIRECTORY
- open_flags |= O_DIRECTORY;
+ how.flags |= O_DIRECTORY;
#endif
- status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, open_flags, 0);
+ status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, &how);
if (!NT_STATUS_IS_OK(status)) {
DBG_INFO("Could not open fd for %s (%s)\n",
smb_fname_str_dbg(smb_dname),
*/
NTSTATUS openat_internal_dir_from_pathref(
struct files_struct *dirfsp,
- int open_flags,
+ int _open_flags,
struct files_struct **_fsp)
{
struct connection_struct *conn = dirfsp->conn;
.flags = smb_dname->flags,
.twrp = smb_dname->twrp,
};
+ struct vfs_open_how how = { .flags = _open_flags, };
NTSTATUS status;
status = create_internal_dirfsp(conn, smb_dname, &fsp);
/*
* Pointless for opening ".", but you never know...
*/
- open_flags |= O_NOFOLLOW;
+ how.flags |= O_NOFOLLOW;
- status = fd_openat(dirfsp, &smb_dot, fsp, open_flags, 0);
+ status = fd_openat(dirfsp, &smb_dot, fsp, &how);
if (!NT_STATUS_IS_OK(status)) {
DBG_INFO("fd_openat(\"%s\", \".\") failed: %s\n",
fsp_str_dbg(dirfsp),
struct files_struct *fsp = NULL;
bool have_dirfsp = (dirfsp != NULL);
bool have_basefsp = (basefsp != NULL);
+ struct vfs_open_how how = { .flags = O_RDONLY|O_NONBLOCK, };
NTSTATUS status;
DBG_DEBUG("smb_fname [%s]\n", smb_fname_str_dbg(smb_fname));
}
fsp_set_base_fsp(fsp, basefsp);
- status = fd_openat(
- dirfsp, smb_fname, fsp, O_RDONLY|O_NONBLOCK, 0);
+ status = fd_openat(dirfsp, smb_fname, fsp, &how);
if (!NT_STATUS_IS_OK(status)) {
smb_fname->st = fsp->fsp_name->st;
NTSTATUS fd_openat(const struct files_struct *dirfsp,
struct smb_filename *smb_fname,
files_struct *fsp,
- int _flags,
- mode_t _mode)
+ const struct vfs_open_how *_how)
{
- struct vfs_open_how how = { .flags = _flags, .mode = _mode, };
+ struct vfs_open_how how = *_how;
struct connection_struct *conn = fsp->conn;
NTSTATUS status = NT_STATUS_OK;
bool fsp_is_stream = fsp_is_alternate_stream(fsp);
mode_t mode,
bool *file_created)
{
+ struct vfs_open_how how = { .flags = flags, .mode = mode, };
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
NTSTATUS retry_status;
bool file_existed = VALID_STAT(smb_fname->st);
- int curr_flags;
- if (!(flags & O_CREAT)) {
+ if (!(how.flags & O_CREAT)) {
/*
* We're not creating the file, just pass through.
*/
- status = fd_openat(dirfsp, smb_fname, fsp, flags, mode);
+ status = fd_openat(dirfsp, smb_fname, fsp, &how);
*file_created = false;
return status;
}
- if (flags & O_EXCL) {
+ if (how.flags & O_EXCL) {
/*
* Fail if already exists, just pass through.
*/
- status = fd_openat(dirfsp, smb_fname, fsp, flags, mode);
+ status = fd_openat(dirfsp, smb_fname, fsp, &how);
/*
* Here we've opened with O_CREAT|O_EXCL. If that went
*/
if (file_existed) {
- curr_flags = flags & ~(O_CREAT);
+ how.flags = flags & ~(O_CREAT);
retry_status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
} else {
- curr_flags = flags | O_EXCL;
+ how.flags = flags | O_EXCL;
retry_status = NT_STATUS_OBJECT_NAME_COLLISION;
}
- status = fd_openat(dirfsp, smb_fname, fsp, curr_flags, mode);
+ status = fd_openat(dirfsp, smb_fname, fsp, &how);
if (NT_STATUS_IS_OK(status)) {
*file_created = !file_existed;
return NT_STATUS_OK;
file_existed ? "existed" : "did not exist");
if (file_existed) {
- curr_flags = flags & ~(O_CREAT);
+ how.flags = flags & ~(O_CREAT);
} else {
- curr_flags = flags | O_EXCL;
+ how.flags = flags | O_EXCL;
}
- status = fd_openat(dirfsp, smb_fname, fsp, curr_flags, mode);
+ status = fd_openat(dirfsp, smb_fname, fsp, &how);
}
*file_created = (NT_STATUS_IS_OK(status) && !file_existed);
bool posix_open = false;
bool need_re_stat = false;
uint32_t access_mask = SEC_DIR_ADD_SUBDIR;
+ struct vfs_open_how how = { .flags = O_RDONLY|O_DIRECTORY, };
int ret;
if (!CAN_WRITE(conn) || (access_mask & ~(conn->share_access))) {
*/
fsp->fsp_flags.is_pathref = true;
- status = fd_openat(conn->cwd_fsp, smb_dname, fsp, O_RDONLY | O_DIRECTORY, 0);
+ status = fd_openat(conn->cwd_fsp, smb_dname, fsp, &how);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
NTSTATUS fd_openat(const struct files_struct *dirfsp,
struct smb_filename *smb_fname,
files_struct *fsp,
- int flags, mode_t mode);
+ const struct vfs_open_how *how);
NTSTATUS fd_close(files_struct *fsp);
bool is_oplock_stat_open(uint32_t access_mask);
bool is_lease_stat_open(uint32_t access_mask);
}
if (in_flags & SMB2_CONTINUE_FLAG_REOPEN) {
- int flags;
+ struct vfs_open_how how = { .flags = O_RDONLY, };
status = fd_close(fsp);
if (tevent_req_nterror(req, status)) {
* descriptor. So we have to reopen it.
*/
- flags = O_RDONLY;
#ifdef O_DIRECTORY
- flags |= O_DIRECTORY;
+ how.flags |= O_DIRECTORY;
#endif
- status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, flags, 0);
+ status = fd_openat(conn->cwd_fsp, fsp->fsp_name, fsp, &how);
if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}