mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
smbd: Remove "local_flags" from open_file()
This needs close review. I could not see where we were actually referencing the original flags in a way that would not be available in local_flags. The reason for this patch is that I want to pass in vfs_open_how into open_file(), and the distinction between flags and local_flags made this significantly harder to understand for me. The only place where we really used both versions is the DBG_NOTICE in the last hunk, and this will come back in the next patch. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
6ec031b2d1
commit
7c35676987
@ -1315,7 +1315,6 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
connection_struct *conn = fsp->conn;
|
connection_struct *conn = fsp->conn;
|
||||||
struct smb_filename *smb_fname = fsp->fsp_name;
|
struct smb_filename *smb_fname = fsp->fsp_name;
|
||||||
NTSTATUS status = NT_STATUS_OK;
|
NTSTATUS status = NT_STATUS_OK;
|
||||||
int local_flags = flags;
|
|
||||||
bool file_existed = VALID_STAT(fsp->fsp_name->st);
|
bool file_existed = VALID_STAT(fsp->fsp_name->st);
|
||||||
const uint32_t need_fd_mask =
|
const uint32_t need_fd_mask =
|
||||||
FILE_READ_DATA |
|
FILE_READ_DATA |
|
||||||
@ -1350,7 +1349,7 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
if (((flags & O_ACCMODE) == O_RDONLY) && (flags & O_TRUNC)) {
|
if (((flags & O_ACCMODE) == O_RDONLY) && (flags & O_TRUNC)) {
|
||||||
DBG_DEBUG("truncate requested on read-only open for file %s\n",
|
DBG_DEBUG("truncate requested on read-only open for file %s\n",
|
||||||
smb_fname_str_dbg(smb_fname));
|
smb_fname_str_dbg(smb_fname));
|
||||||
local_flags = (flags & ~O_ACCMODE) | O_RDWR;
|
flags = (flags & ~O_ACCMODE) | O_RDWR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check permissions */
|
/* Check permissions */
|
||||||
@ -1378,7 +1377,7 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
* O_CREAT doesn't create the file if we have write
|
* O_CREAT doesn't create the file if we have write
|
||||||
* access into the directory.
|
* access into the directory.
|
||||||
*/
|
*/
|
||||||
local_flags &= ~(O_CREAT | O_EXCL);
|
flags &= ~(O_CREAT | O_EXCL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((open_access_mask & need_fd_mask) || creating ||
|
if ((open_access_mask & need_fd_mask) || creating ||
|
||||||
@ -1397,7 +1396,7 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (file_existed && S_ISFIFO(smb_fname->st.st_ex_mode)) {
|
if (file_existed && S_ISFIFO(smb_fname->st.st_ex_mode)) {
|
||||||
local_flags |= O_NONBLOCK;
|
flags |= O_NONBLOCK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1456,7 +1455,7 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!file_existed) {
|
if (!file_existed) {
|
||||||
if (!(local_flags & O_CREAT)) {
|
if (!(flags & O_CREAT)) {
|
||||||
/* File didn't exist and no O_CREAT. */
|
/* File didn't exist and no O_CREAT. */
|
||||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -1483,7 +1482,7 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
struct vfs_open_how how = {
|
struct vfs_open_how how = {
|
||||||
.flags = local_flags & ~O_TRUNC,
|
.flags = flags & ~O_TRUNC,
|
||||||
.mode = unx_mode,
|
.mode = unx_mode,
|
||||||
};
|
};
|
||||||
status = reopen_from_fsp(dirfsp,
|
status = reopen_from_fsp(dirfsp,
|
||||||
@ -1503,13 +1502,14 @@ static NTSTATUS open_file(struct smb_request *req,
|
|||||||
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(3,("Error opening file %s (%s) (local_flags=%d) "
|
DBG_NOTICE("Error opening file %s (%s) (flags=%d)\n",
|
||||||
"(flags=%d)\n", smb_fname_str_dbg(smb_fname),
|
smb_fname_str_dbg(smb_fname),
|
||||||
nt_errstr(status),local_flags,flags));
|
nt_errstr(status),
|
||||||
|
flags);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local_flags & O_NONBLOCK) {
|
if (flags & O_NONBLOCK) {
|
||||||
/*
|
/*
|
||||||
* GPFS can return ETIMEDOUT for pread on
|
* GPFS can return ETIMEDOUT for pread on
|
||||||
* nonblocking file descriptors when files
|
* nonblocking file descriptors when files
|
||||||
|
Loading…
Reference in New Issue
Block a user