mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
smbd: Remove a few vfs_stat() calls
openat_pathref_fsp() does not need them anymore Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Fri Mar 11 19:19:21 UTC 2022 on sn-devel-184
This commit is contained in:
parent
de439cd030
commit
d8e966da1c
@ -1208,12 +1208,6 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
|
||||
|
||||
DBG_DEBUG("stream_name: %s\n", smb_fname_str_dbg(stream_name));
|
||||
|
||||
rc = vfs_stat(handle->conn, stream_name);
|
||||
if (rc == -1 && errno != ENOENT) {
|
||||
ok = false;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(handle->conn->cwd_fsp, stream_name);
|
||||
if (!NT_STATUS_IS_OK(status) &&
|
||||
!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND))
|
||||
@ -1307,7 +1301,6 @@ static bool ad_convert_finderinfo(vfs_handle_struct *handle,
|
||||
NTSTATUS status;
|
||||
int saved_errno = 0;
|
||||
int cmp;
|
||||
int rc;
|
||||
|
||||
cmp = memcmp(ad->ad_filler, AD_FILLER_TAG_OSX, ADEDLEN_FILLER);
|
||||
if (cmp != 0) {
|
||||
@ -1352,11 +1345,6 @@ static bool ad_convert_finderinfo(vfs_handle_struct *handle,
|
||||
|
||||
DBG_DEBUG("stream_name: %s\n", smb_fname_str_dbg(stream_name));
|
||||
|
||||
rc = vfs_stat(handle->conn, stream_name);
|
||||
if (rc == -1 && errno != ENOENT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(handle->conn->cwd_fsp, stream_name);
|
||||
if (!NT_STATUS_IS_OK(status) &&
|
||||
!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND))
|
||||
@ -1607,18 +1595,12 @@ static bool ad_unconvert_open_ad(TALLOC_CTX *mem_ctx,
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
ret = vfs_stat(handle->conn, adpath);
|
||||
if (ret == -1 && errno != ENOENT) {
|
||||
status = openat_pathref_fsp(handle->conn->cwd_fsp, adpath);
|
||||
if (!NT_STATUS_IS_OK(status) &&
|
||||
!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (VALID_STAT(adpath->st)) {
|
||||
status = openat_pathref_fsp(handle->conn->cwd_fsp, adpath);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
status = SMB_VFS_CREATE_FILE(
|
||||
handle->conn,
|
||||
NULL, /* req */
|
||||
@ -1670,10 +1652,6 @@ static bool ad_unconvert_get_streams(struct vfs_handle_struct *handle,
|
||||
files_struct *fsp = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
if (!VALID_STAT(smb_fname->st)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(handle->conn->cwd_fsp, smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return false;
|
||||
@ -1749,7 +1727,6 @@ static bool ad_collect_one_stream(struct vfs_handle_struct *handle,
|
||||
size_t needed_size;
|
||||
ssize_t nread;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
bool ok;
|
||||
|
||||
sname = synthetic_smb_fname(ad,
|
||||
@ -1769,13 +1746,6 @@ static bool ad_collect_one_stream(struct vfs_handle_struct *handle,
|
||||
|
||||
DBG_DEBUG("Collecting stream [%s]\n", smb_fname_str_dbg(sname));
|
||||
|
||||
ret = SMB_VFS_STAT(handle->conn, sname);
|
||||
if (ret != 0) {
|
||||
DBG_ERR("SMB_VFS_STAT [%s] failed\n", smb_fname_str_dbg(sname));
|
||||
ok = false;
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(handle->conn->cwd_fsp, sname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
ok = false;
|
||||
|
@ -397,7 +397,6 @@ static NTSTATUS open_pathref_base_fsp(const struct files_struct *dirfsp,
|
||||
{
|
||||
struct smb_filename *smb_fname_base = NULL;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
smb_fname_base = synthetic_smb_fname(talloc_tos(),
|
||||
smb_fname->base_name,
|
||||
@ -409,11 +408,6 @@ static NTSTATUS open_pathref_base_fsp(const struct files_struct *dirfsp,
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
ret = vfs_stat(fsp->conn, smb_fname_base);
|
||||
if (ret != 0) {
|
||||
return map_nt_error_from_unix(errno);
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(dirfsp, smb_fname_base);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(smb_fname_base);
|
||||
@ -626,7 +620,6 @@ NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx,
|
||||
{
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
smb_fname = synthetic_smb_fname(mem_ctx,
|
||||
base_name,
|
||||
@ -638,19 +631,6 @@ NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx,
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (!VALID_STAT(smb_fname->st)) {
|
||||
ret = vfs_stat(dirfsp->conn, smb_fname);
|
||||
if (ret != 0) {
|
||||
int err = errno;
|
||||
int lvl = err == ENOENT ? DBGLVL_INFO : DBGLVL_ERR;
|
||||
DBG_PREFIX(lvl, ("stat [%s] failed: %s\n",
|
||||
smb_fname_str_dbg(smb_fname),
|
||||
strerror(err)));
|
||||
TALLOC_FREE(smb_fname);
|
||||
return map_nt_error_from_unix(err);
|
||||
}
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(dirfsp, smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_ERR("opening [%s] failed\n",
|
||||
@ -686,7 +666,6 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
|
||||
struct smb_filename *parent = NULL;
|
||||
struct smb_filename *atname = NULL;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
status = SMB_VFS_PARENT_PATHNAME(dirfsp->conn,
|
||||
mem_ctx,
|
||||
@ -707,12 +686,6 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
|
||||
*/
|
||||
parent->flags &= ~SMB_FILENAME_POSIX_PATH;
|
||||
|
||||
ret = vfs_stat(dirfsp->conn, parent);
|
||||
if (ret != 0) {
|
||||
TALLOC_FREE(parent);
|
||||
return map_nt_error_from_unix(errno);
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(dirfsp, parent);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(parent);
|
||||
|
@ -5009,11 +5009,6 @@ static NTSTATUS open_streams_for_delete(connection_struct *conn,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (SMB_VFS_STAT(conn, smb_fname_cp) == -1) {
|
||||
DEBUG(10, ("Unable to stat stream: %s\n",
|
||||
smb_fname_str_dbg(smb_fname_cp)));
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_cp);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_DEBUG("Unable to open stream [%s]: %s\n",
|
||||
|
@ -141,12 +141,6 @@ static int set_sys_acl_conn(const char *fname,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = vfs_stat(conn, smb_fname);
|
||||
if (ret == -1) {
|
||||
TALLOC_FREE(frame);
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(conn->cwd_fsp, smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(frame);
|
||||
@ -307,7 +301,6 @@ static NTSTATUS get_nt_acl_conn(TALLOC_CTX *mem_ctx,
|
||||
{
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
|
||||
smb_fname = synthetic_smb_fname_split(frame,
|
||||
@ -319,12 +312,6 @@ static NTSTATUS get_nt_acl_conn(TALLOC_CTX *mem_ctx,
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
ret = vfs_stat(conn, smb_fname);
|
||||
if (ret == -1) {
|
||||
TALLOC_FREE(frame);
|
||||
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(conn->cwd_fsp, smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(frame);
|
||||
@ -995,7 +982,6 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
|
||||
char *service = NULL;
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
NTSTATUS status;
|
||||
int ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO|z",
|
||||
discard_const_p(char *, kwnames),
|
||||
@ -1036,11 +1022,6 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
|
||||
TALLOC_FREE(frame);
|
||||
return NULL;
|
||||
}
|
||||
ret = vfs_stat(conn, smb_fname);
|
||||
if (ret == -1) {
|
||||
TALLOC_FREE(frame);
|
||||
return PyErr_SetFromErrno(PyExc_OSError);
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(conn->cwd_fsp, smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
|
@ -7585,7 +7585,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
int create_options = 0;
|
||||
struct smb2_create_blobs *posx = NULL;
|
||||
int rc;
|
||||
struct files_struct *fsp = NULL;
|
||||
bool posix_pathname = (smb_fname_src->flags & SMB_FILENAME_POSIX_PATH);
|
||||
bool case_sensitive = posix_pathname ? true : conn->case_sensitive;
|
||||
@ -7614,12 +7613,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
|
||||
|
||||
ZERO_STRUCT(smb_fname_src->st);
|
||||
|
||||
rc = vfs_stat(conn, smb_fname_src);
|
||||
if (rc == -1) {
|
||||
status = map_nt_error_from_unix_common(errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = openat_pathref_fsp(conn->cwd_fsp, smb_fname_src);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (!NT_STATUS_EQUAL(status,
|
||||
|
Loading…
Reference in New Issue
Block a user