A wrapper for vfs_chdir().
********************************************************************/
-int vfs_ChDir(connection_struct *conn, const char *path)
+int vfs_ChDir(connection_struct *conn, const struct smb_filename *smb_fname)
{
int ret;
LastDir = SMB_STRDUP("");
}
- if (ISDOT(path)) {
+ if (ISDOT(smb_fname->base_name)) {
return 0;
}
- if (*path == '/' && strcsequal(LastDir,path)) {
+ if (*smb_fname->base_name == '/' &&
+ strcsequal(LastDir,smb_fname->base_name)) {
return 0;
}
- DEBUG(4,("vfs_ChDir to %s\n",path));
+ DEBUG(4,("vfs_ChDir to %s\n", smb_fname->base_name));
- ret = SMB_VFS_CHDIR(conn,path);
+ ret = SMB_VFS_CHDIR(conn, smb_fname);
if (ret == 0) {
/* Global cache. */
SAFE_FREE(LastDir);
- LastDir = SMB_STRDUP(path);
+ LastDir = SMB_STRDUP(smb_fname->base_name);
/* conn cache. */
TALLOC_FREE(conn->cwd);
const char *last_component = NULL;
char *resolved_name = NULL;
char *saved_dir = NULL;
+ struct smb_filename *saved_dir_fname = NULL;
struct smb_filename *smb_fname_cwd = NULL;
struct privilege_paths *priv_paths = NULL;
int ret;
goto err;
}
+ saved_dir_fname = synthetic_smb_fname(ctx,
+ saved_dir,
+ NULL,
+ NULL,
+ 0);
+ if (saved_dir_fname == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto err;
+ }
+
/* Go to the parent directory to lock in memory. */
- if (vfs_ChDir(conn, priv_paths->parent_name.base_name) == -1) {
+ if (vfs_ChDir(conn, &priv_paths->parent_name) == -1) {
status = map_nt_error_from_unix(errno);
goto err;
}
err:
- if (saved_dir) {
- vfs_ChDir(conn, saved_dir);
+ if (saved_dir_fname) {
+ vfs_ChDir(conn, saved_dir_fname);
+ TALLOC_FREE(saved_dir);
+ TALLOC_FREE(saved_dir_fname);
}
SAFE_FREE(resolved_name);
if (!NT_STATUS_IS_OK(status)) {
}
uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
- const char *path, uint64_t *bsize,
- uint64_t *dfree, uint64_t *dsize)
+ const struct smb_filename *smb_fname,
+ uint64_t *bsize,
+ uint64_t *dfree,
+ uint64_t *dsize)
{
VFS_FIND(disk_free);
- return handle->fns->disk_free_fn(handle, path, bsize, dfree, dsize);
+ return handle->fns->disk_free_fn(handle, smb_fname,
+ bsize, dfree, dsize);
}
-int smb_vfs_call_get_quota(struct vfs_handle_struct *handle, const char *path,
- enum SMB_QUOTA_TYPE qtype, unid_t id,
- SMB_DISK_QUOTA *qt)
+int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ enum SMB_QUOTA_TYPE qtype,
+ unid_t id,
+ SMB_DISK_QUOTA *qt)
{
VFS_FIND(get_quota);
- return handle->fns->get_quota_fn(handle, path, qtype, id, qt);
+ return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt);
}
int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
shadow_copy_data,
labels);
}
-int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path,
- struct vfs_statvfs_struct *statbuf)
+int smb_vfs_call_statvfs(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ struct vfs_statvfs_struct *statbuf)
{
VFS_FIND(statvfs);
- return handle->fns->statvfs_fn(handle, path, statbuf);
+ return handle->fns->statvfs_fn(handle, smb_fname, statbuf);
}
uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
char *parent_dir = NULL;
const char *final_component = NULL;
struct smb_filename *local_smb_fname = NULL;
+ struct smb_filename parent_dir_fname = {0};
+ struct smb_filename saved_dir_fname = {0};
saved_dir = vfs_GetWd(talloc_tos(),fsp->conn);
if (!saved_dir) {
return status;
}
+ saved_dir_fname = (struct smb_filename) {
+ .base_name = saved_dir
+ };
+
if (!parent_dirname(talloc_tos(),
fsp->fsp_name->base_name,
&parent_dir,
return NT_STATUS_NO_MEMORY;
}
+ parent_dir_fname = (struct smb_filename) {
+ .base_name = parent_dir,
+ .flags = fsp->fsp_name->flags
+ };
+
/* cd into the parent dir to pin it. */
- ret = vfs_ChDir(fsp->conn, parent_dir);
+ ret = vfs_ChDir(fsp->conn, &parent_dir_fname);
if (ret == -1) {
return map_nt_error_from_unix(errno);
}
out:
- vfs_ChDir(fsp->conn,saved_dir);
+ vfs_ChDir(fsp->conn, &saved_dir_fname);
TALLOC_FREE(local_smb_fname);
TALLOC_FREE(saved_dir);
TALLOC_FREE(parent_dir);
return status;
}
-int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path)
+int smb_vfs_call_chdir(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname)
{
VFS_FIND(chdir);
- return handle->fns->chdir_fn(handle, path);
+ return handle->fns->chdir_fn(handle, smb_fname);
}
char *smb_vfs_call_getwd(struct vfs_handle_struct *handle)
return handle->fns->linux_setlease_fn(handle, fsp, leasetype);
}
-int smb_vfs_call_symlink(struct vfs_handle_struct *handle, const char *oldpath,
- const char *newpath)
+int smb_vfs_call_symlink(struct vfs_handle_struct *handle,
+ const char *link_target,
+ const struct smb_filename *new_smb_fname)
{
VFS_FIND(symlink);
- return handle->fns->symlink_fn(handle, oldpath, newpath);
+ return handle->fns->symlink_fn(handle, link_target, new_smb_fname);
}
int smb_vfs_call_readlink(struct vfs_handle_struct *handle,
- const char *path, char *buf, size_t bufsiz)
+ const struct smb_filename *smb_fname,
+ char *buf,
+ size_t bufsiz)
{
VFS_FIND(readlink);
- return handle->fns->readlink_fn(handle, path, buf, bufsiz);
+ return handle->fns->readlink_fn(handle, smb_fname, buf, bufsiz);
}
-int smb_vfs_call_link(struct vfs_handle_struct *handle, const char *oldpath,
- const char *newpath)
+int smb_vfs_call_link(struct vfs_handle_struct *handle,
+ const struct smb_filename *old_smb_fname,
+ const struct smb_filename *new_smb_fname)
{
VFS_FIND(link);
- return handle->fns->link_fn(handle, oldpath, newpath);
+ return handle->fns->link_fn(handle, old_smb_fname, new_smb_fname);
}
-int smb_vfs_call_mknod(struct vfs_handle_struct *handle, const char *path,
- mode_t mode, SMB_DEV_T dev)
+int smb_vfs_call_mknod(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ mode_t mode,
+ SMB_DEV_T dev)
{
VFS_FIND(mknod);
- return handle->fns->mknod_fn(handle, path, mode, dev);
+ return handle->fns->mknod_fn(handle, smb_fname, mode, dev);
}
char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path)
return handle->fns->realpath_fn(handle, path);
}
-int smb_vfs_call_chflags(struct vfs_handle_struct *handle, const char *path,
- unsigned int flags)
+int smb_vfs_call_chflags(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ unsigned int flags)
{
VFS_FIND(chflags);
- return handle->fns->chflags_fn(handle, path, flags);
+ return handle->fns->chflags_fn(handle, smb_fname, flags);
}
struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
}
int smb_vfs_call_sys_acl_blob_get_file(struct vfs_handle_struct *handle,
- const char *path_p,
- TALLOC_CTX *mem_ctx,
- char **blob_description,
- DATA_BLOB *blob)
+ const struct smb_filename *smb_fname,
+ TALLOC_CTX *mem_ctx,
+ char **blob_description,
+ DATA_BLOB *blob)
{
VFS_FIND(sys_acl_blob_get_file);
- return handle->fns->sys_acl_blob_get_file_fn(handle, path_p, mem_ctx, blob_description, blob);
+ return handle->fns->sys_acl_blob_get_file_fn(handle, smb_fname,
+ mem_ctx, blob_description, blob);
}
int smb_vfs_call_sys_acl_blob_get_fd(struct vfs_handle_struct *handle,
}
int smb_vfs_call_sys_acl_set_file(struct vfs_handle_struct *handle,
- const char *name, SMB_ACL_TYPE_T acltype,
- SMB_ACL_T theacl)
+ const struct smb_filename *smb_fname,
+ SMB_ACL_TYPE_T acltype,
+ SMB_ACL_T theacl)
{
VFS_FIND(sys_acl_set_file);
- return handle->fns->sys_acl_set_file_fn(handle, name, acltype, theacl);
+ return handle->fns->sys_acl_set_file_fn(handle, smb_fname,
+ acltype, theacl);
}
int smb_vfs_call_sys_acl_set_fd(struct vfs_handle_struct *handle,
}
ssize_t smb_vfs_call_getxattr(struct vfs_handle_struct *handle,
- const char *path, const char *name, void *value,
- size_t size)
+ const struct smb_filename *smb_fname,
+ const char *name,
+ void *value,
+ size_t size)
{
VFS_FIND(getxattr);
- return handle->fns->getxattr_fn(handle, path, name, value, size);
+ return handle->fns->getxattr_fn(handle, smb_fname, name, value, size);
}
ssize_t smb_vfs_call_fgetxattr(struct vfs_handle_struct *handle,
}
ssize_t smb_vfs_call_listxattr(struct vfs_handle_struct *handle,
- const char *path, char *list, size_t size)
+ const struct smb_filename *smb_fname,
+ char *list,
+ size_t size)
{
VFS_FIND(listxattr);
- return handle->fns->listxattr_fn(handle, path, list, size);
+ return handle->fns->listxattr_fn(handle, smb_fname, list, size);
}
ssize_t smb_vfs_call_flistxattr(struct vfs_handle_struct *handle,
}
int smb_vfs_call_removexattr(struct vfs_handle_struct *handle,
- const char *path, const char *name)
+ const struct smb_filename *smb_fname,
+ const char *name)
{
VFS_FIND(removexattr);
- return handle->fns->removexattr_fn(handle, path, name);
+ return handle->fns->removexattr_fn(handle, smb_fname, name);
}
int smb_vfs_call_fremovexattr(struct vfs_handle_struct *handle,
return handle->fns->fremovexattr_fn(handle, fsp, name);
}
-int smb_vfs_call_setxattr(struct vfs_handle_struct *handle, const char *path,
- const char *name, const void *value, size_t size,
- int flags)
+int smb_vfs_call_setxattr(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *name,
+ const void *value,
+ size_t size,
+ int flags)
{
VFS_FIND(setxattr);
- return handle->fns->setxattr_fn(handle, path, name, value, size, flags);
+ return handle->fns->setxattr_fn(handle, smb_fname,
+ name, value, size, flags);
}
int smb_vfs_call_fsetxattr(struct vfs_handle_struct *handle,