mirror of
https://github.com/samba-team/samba.git
synced 2025-03-05 20:58:40 +03:00
vfs: Add dirfsp to connectpath_fn()
So far we only call CONNECTPATH on full paths. In the future, we'll have a call that will not have converted a relative path to absolute just for efficiency reasons. To give shadow_copy2 the chance to still find the snapshot directory, pass the dirfsp down to it. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
9ef2f7345f
commit
e1ca4e28d8
@ -665,8 +665,10 @@ static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
|
|||||||
return NT_STATUS_NOT_IMPLEMENTED;
|
return NT_STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *skel_connectpath(struct vfs_handle_struct *handle,
|
static const char *skel_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -886,10 +886,12 @@ static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
|
|||||||
handle, dirfsp, name, mem_ctx, found_name);
|
handle, dirfsp, name, mem_ctx, found_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *skel_connectpath(struct vfs_handle_struct *handle,
|
static const char *skel_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
|
return SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
|
static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
|
||||||
|
@ -377,6 +377,7 @@
|
|||||||
* Version 47 - Add VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS for SMB_VFS_OPENAT()
|
* Version 47 - Add VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS for SMB_VFS_OPENAT()
|
||||||
* Change to Version 48 - will ship with 4.18
|
* Change to Version 48 - will ship with 4.18
|
||||||
* Version 48 - Add cached_dos_attributes to struct stat_ex
|
* Version 48 - Add cached_dos_attributes to struct stat_ex
|
||||||
|
* Version 48 - Add dirfsp to connectpath_fn()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SMB_VFS_INTERFACE_VERSION 48
|
#define SMB_VFS_INTERFACE_VERSION 48
|
||||||
@ -1172,6 +1173,7 @@ struct vfs_fn_pointers {
|
|||||||
char **found_name);
|
char **found_name);
|
||||||
|
|
||||||
const char *(*connectpath_fn)(struct vfs_handle_struct *handle,
|
const char *(*connectpath_fn)(struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
const struct smb_filename *smb_fname);
|
const struct smb_filename *smb_fname);
|
||||||
|
|
||||||
NTSTATUS (*brl_lock_windows_fn)(struct vfs_handle_struct *handle,
|
NTSTATUS (*brl_lock_windows_fn)(struct vfs_handle_struct *handle,
|
||||||
@ -1640,7 +1642,8 @@ NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
|
|||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
char **found_name);
|
char **found_name);
|
||||||
const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
|
const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
|
||||||
const struct smb_filename *smb_fname);
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname);
|
||||||
NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
|
NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
|
||||||
struct byte_range_lock *br_lck,
|
struct byte_range_lock *br_lck,
|
||||||
struct lock_struct *plock);
|
struct lock_struct *plock);
|
||||||
@ -2112,8 +2115,10 @@ NTSTATUS vfs_not_implemented_get_real_filename_at(
|
|||||||
const char *name,
|
const char *name,
|
||||||
TALLOC_CTX *mem_ctx,
|
TALLOC_CTX *mem_ctx,
|
||||||
char **found_name);
|
char **found_name);
|
||||||
const char *vfs_not_implemented_connectpath(struct vfs_handle_struct *handle,
|
const char *vfs_not_implemented_connectpath(
|
||||||
const struct smb_filename *smb_fname);
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname);
|
||||||
NTSTATUS vfs_not_implemented_brl_lock_windows(struct vfs_handle_struct *handle,
|
NTSTATUS vfs_not_implemented_brl_lock_windows(struct vfs_handle_struct *handle,
|
||||||
struct byte_range_lock *br_lck,
|
struct byte_range_lock *br_lck,
|
||||||
struct lock_struct *plock);
|
struct lock_struct *plock);
|
||||||
|
@ -385,10 +385,10 @@
|
|||||||
(mem_ctx), \
|
(mem_ctx), \
|
||||||
(found_name))
|
(found_name))
|
||||||
|
|
||||||
#define SMB_VFS_CONNECTPATH(conn, smb_fname) \
|
#define SMB_VFS_CONNECTPATH(conn, dirfsp, smb_fname) \
|
||||||
smb_vfs_call_connectpath((conn)->vfs_handles, (smb_fname))
|
smb_vfs_call_connectpath((conn)->vfs_handles, (dirfsp), (smb_fname))
|
||||||
#define SMB_VFS_NEXT_CONNECTPATH(conn, smb_fname) \
|
#define SMB_VFS_NEXT_CONNECTPATH(conn, dirfsp, smb_fname) \
|
||||||
smb_vfs_call_connectpath((conn)->next, (smb_fname))
|
smb_vfs_call_connectpath((conn)->next, (dirfsp), (smb_fname))
|
||||||
|
|
||||||
#define SMB_VFS_BRL_LOCK_WINDOWS(conn, br_lck, plock) \
|
#define SMB_VFS_BRL_LOCK_WINDOWS(conn, br_lck, plock) \
|
||||||
smb_vfs_call_brl_lock_windows((conn)->vfs_handles, (br_lck), (plock))
|
smb_vfs_call_brl_lock_windows((conn)->vfs_handles, (br_lck), (plock))
|
||||||
|
@ -1292,8 +1292,10 @@ static NTSTATUS cephwrap_get_real_filename_at(
|
|||||||
return NT_STATUS_NOT_SUPPORTED;
|
return NT_STATUS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
|
static const char *cephwrap_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
return handle->conn->connectpath;
|
return handle->conn->connectpath;
|
||||||
}
|
}
|
||||||
|
@ -3453,6 +3453,7 @@ static NTSTATUS vfswrap_get_real_filename_at(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *vfswrap_connectpath(struct vfs_handle_struct *handle,
|
static const char *vfswrap_connectpath(struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
const struct smb_filename *smb_fname)
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
return handle->conn->connectpath;
|
return handle->conn->connectpath;
|
||||||
|
@ -2115,12 +2115,14 @@ static NTSTATUS smb_full_audit_get_real_filename_at(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
|
static const char *smb_full_audit_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
const char *result;
|
const char *result;
|
||||||
|
|
||||||
result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
|
result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
|
||||||
|
|
||||||
do_log(SMB_VFS_OP_CONNECTPATH,
|
do_log(SMB_VFS_OP_CONNECTPATH,
|
||||||
result != NULL,
|
result != NULL,
|
||||||
|
@ -2348,8 +2348,10 @@ static NTSTATUS vfs_gluster_get_real_filename_at(
|
|||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
|
static const char *vfs_gluster_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
return handle->conn->connectpath;
|
return handle->conn->connectpath;
|
||||||
}
|
}
|
||||||
|
@ -735,8 +735,10 @@ NTSTATUS vfs_not_implemented_get_real_filename_at(
|
|||||||
}
|
}
|
||||||
|
|
||||||
_PUBLIC_
|
_PUBLIC_
|
||||||
const char *vfs_not_implemented_connectpath(struct vfs_handle_struct *handle,
|
const char *vfs_not_implemented_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2625,8 +2625,10 @@ static NTSTATUS shadow_copy2_get_real_filename_at(
|
|||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
|
static const char *shadow_copy2_connectpath(
|
||||||
const struct smb_filename *smb_fname_in)
|
struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname_in)
|
||||||
{
|
{
|
||||||
time_t timestamp = 0;
|
time_t timestamp = 0;
|
||||||
char *stripped = NULL;
|
char *stripped = NULL;
|
||||||
@ -2656,7 +2658,7 @@ static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (timestamp == 0) {
|
if (timestamp == 0) {
|
||||||
return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname_in);
|
return SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = shadow_copy2_do_convert(talloc_tos(), handle, stripped, timestamp,
|
tmp = shadow_copy2_do_convert(talloc_tos(), handle, stripped, timestamp,
|
||||||
|
@ -1743,15 +1743,17 @@ static NTSTATUS smb_time_audit_get_real_filename_at(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
|
static const char *smb_time_audit_connectpath(
|
||||||
const struct smb_filename *smb_fname)
|
vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
const char *result;
|
const char *result;
|
||||||
struct timespec ts1,ts2;
|
struct timespec ts1,ts2;
|
||||||
double timediff;
|
double timediff;
|
||||||
|
|
||||||
clock_gettime_mono(&ts1);
|
clock_gettime_mono(&ts1);
|
||||||
result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
|
result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
|
||||||
clock_gettime_mono(&ts2);
|
clock_gettime_mono(&ts2);
|
||||||
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
|
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ static NTSTATUS process_symlink_open(const struct files_struct *dirfsp,
|
|||||||
struct smb_filename *full_fname = NULL;
|
struct smb_filename *full_fname = NULL;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
||||||
conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname);
|
conn_rootdir = SMB_VFS_CONNECTPATH(conn, NULL, smb_fname);
|
||||||
if (conn_rootdir == NULL) {
|
if (conn_rootdir == NULL) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
@ -705,7 +705,8 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
|||||||
SMB_ASSERT(!fsp_is_alternate_stream(fsp));
|
SMB_ASSERT(!fsp_is_alternate_stream(fsp));
|
||||||
|
|
||||||
if (smb_fname->base_name[0] == '/') {
|
if (smb_fname->base_name[0] == '/') {
|
||||||
const char *connpath = SMB_VFS_CONNECTPATH(conn, smb_fname);
|
const char *connpath = SMB_VFS_CONNECTPATH(
|
||||||
|
conn, NULL, smb_fname);
|
||||||
int cmp = strcmp(connpath, smb_fname->base_name);
|
int cmp = strcmp(connpath, smb_fname->base_name);
|
||||||
|
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
|
@ -1224,7 +1224,7 @@ NTSTATUS check_reduced_name(connection_struct *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Common widelinks and symlinks checks. */
|
/* Common widelinks and symlinks checks. */
|
||||||
conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname);
|
conn_rootdir = SMB_VFS_CONNECTPATH(conn, NULL, smb_fname);
|
||||||
if (conn_rootdir == NULL) {
|
if (conn_rootdir == NULL) {
|
||||||
DBG_NOTICE("Could not get conn_rootdir\n");
|
DBG_NOTICE("Could not get conn_rootdir\n");
|
||||||
TALLOC_FREE(resolved_fname);
|
TALLOC_FREE(resolved_fname);
|
||||||
@ -2312,10 +2312,11 @@ NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
|
const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
|
||||||
|
const struct files_struct *dirfsp,
|
||||||
const struct smb_filename *smb_fname)
|
const struct smb_filename *smb_fname)
|
||||||
{
|
{
|
||||||
VFS_FIND(connectpath);
|
VFS_FIND(connectpath);
|
||||||
return handle->fns->connectpath_fn(handle, smb_fname);
|
return handle->fns->connectpath_fn(handle, dirfsp, smb_fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
|
bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user