1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-30 19:42:05 +03:00

VFS: Modify rmdir to take a const struct smb_filename * instead of const char *

Preparing to reduce use of lp_posix_pathnames().

Uses the same techniques as commit 616d068f0c
(synthetic_smb_fname()) to cope with modules that
modify the incoming pathname.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Thu Feb 25 20:46:49 CET 2016 on sn-devel-144
This commit is contained in:
Jeremy Allison
2016-02-24 14:02:45 -08:00
committed by Michael Adam
parent de2bc1bc38
commit cd1335e67d
28 changed files with 215 additions and 112 deletions

View File

@ -165,7 +165,8 @@ static int skel_mkdir(vfs_handle_struct *handle,
return -1;
}
static int skel_rmdir(vfs_handle_struct *handle, const char *path)
static int skel_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
errno = ENOSYS;
return -1;

View File

@ -164,9 +164,10 @@ static int skel_mkdir(vfs_handle_struct *handle,
return SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
}
static int skel_rmdir(vfs_handle_struct *handle, const char *path)
static int skel_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
return SMB_VFS_NEXT_RMDIR(handle, path);
return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
static int skel_closedir(vfs_handle_struct *handle, DIR *dir)

View File

@ -175,6 +175,8 @@
const struct smb_filename * */
/* Version 35 - Change mkdir from const char *, to
const struct smb_filename * */
/* Version 35 - Change rmdir from const char *, to
const struct smb_filename * */
#define SMB_VFS_INTERFACE_VERSION 35
@ -559,7 +561,8 @@ struct vfs_fn_pointers {
int (*mkdir_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
int (*rmdir_fn)(struct vfs_handle_struct *handle, const char *path);
int (*rmdir_fn)(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
int (*closedir_fn)(struct vfs_handle_struct *handle, DIR *dir);
void (*init_search_op_fn)(struct vfs_handle_struct *handle, DIR *dirp);
@ -978,7 +981,8 @@ void smb_vfs_call_rewind_dir(struct vfs_handle_struct *handle,
int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode);
int smb_vfs_call_rmdir(struct vfs_handle_struct *handle, const char *path);
int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname);
int smb_vfs_call_closedir(struct vfs_handle_struct *handle,
DIR *dir);
void smb_vfs_call_init_search_op(struct vfs_handle_struct *handle,

View File

@ -114,10 +114,10 @@
#define SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode) \
smb_vfs_call_mkdir((handle)->next,(smb_fname), (mode))
#define SMB_VFS_RMDIR(conn, path) \
smb_vfs_call_rmdir((conn)->vfs_handles, (path))
#define SMB_VFS_NEXT_RMDIR(handle, path) \
smb_vfs_call_rmdir((handle)->next, (path))
#define SMB_VFS_RMDIR(conn, smb_fname) \
smb_vfs_call_rmdir((conn)->vfs_handles, (smb_fname))
#define SMB_VFS_NEXT_RMDIR(handle, smb_fname) \
smb_vfs_call_rmdir((handle)->next, (smb_fname))
#define SMB_VFS_CLOSEDIR(conn, dir) \
smb_vfs_call_closedir((conn)->vfs_handles, dir)

View File

@ -1007,7 +1007,7 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
become_root();
if (is_directory) {
ret = SMB_VFS_NEXT_RMDIR(handle, final_component);
ret = SMB_VFS_NEXT_RMDIR(handle, &local_fname);
} else {
ret = SMB_VFS_NEXT_UNLINK(handle, &local_fname);
}
@ -1031,12 +1031,12 @@ static int acl_common_remove_object(vfs_handle_struct *handle,
}
static int rmdir_acl_common(struct vfs_handle_struct *handle,
const char *path)
const struct smb_filename *smb_fname)
{
int ret;
/* Try the normal rmdir first. */
ret = SMB_VFS_NEXT_RMDIR(handle, path);
ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
if (ret == 0) {
return 0;
}
@ -1044,12 +1044,12 @@ static int rmdir_acl_common(struct vfs_handle_struct *handle,
/* Failed due to access denied,
see if we need to root override. */
return acl_common_remove_object(handle,
path,
smb_fname->base_name,
true);
}
DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
path,
smb_fname->base_name,
strerror(errno) ));
return -1;
}

View File

@ -275,19 +275,20 @@ static int unlink_acl_tdb(vfs_handle_struct *handle,
On rmdir we need to delete the tdb record (if using tdb).
*********************************************************************/
static int rmdir_acl_tdb(vfs_handle_struct *handle, const char *path)
static int rmdir_acl_tdb(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
SMB_STRUCT_STAT sbuf;
struct db_context *db = acl_db;
int ret = -1;
ret = vfs_stat_smb_basename(handle->conn, path, &sbuf);
ret = vfs_stat_smb_basename(handle->conn, smb_fname->base_name, &sbuf);
if (ret == -1) {
return -1;
}
ret = rmdir_acl_common(handle, path);
ret = rmdir_acl_common(handle, smb_fname);
if (ret == -1) {
return -1;
}

View File

@ -136,14 +136,15 @@ static int audit_mkdir(vfs_handle_struct *handle,
return result;
}
static int audit_rmdir(vfs_handle_struct *handle, const char *path)
static int audit_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
int result;
result = SMB_VFS_NEXT_RMDIR(handle, path);
result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n",
path,
smb_fname->base_name,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");

View File

@ -122,15 +122,28 @@ static int cap_mkdir(vfs_handle_struct *handle,
return SMB_VFS_NEXT_MKDIR(handle, cap_smb_fname, mode);
}
static int cap_rmdir(vfs_handle_struct *handle, const char *path)
static int cap_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
char *cappath = capencode(talloc_tos(), path);
char *cappath = capencode(talloc_tos(), smb_fname->base_name);
struct smb_filename *cap_smb_fname = NULL;
if (!cappath) {
errno = ENOMEM;
return -1;
}
return SMB_VFS_NEXT_RMDIR(handle, cappath);
cap_smb_fname = synthetic_smb_fname(talloc_tos(),
cappath,
NULL,
NULL);
if (cap_smb_fname == NULL) {
TALLOC_FREE(cappath);
errno = ENOMEM;
return -1;
}
return SMB_VFS_NEXT_RMDIR(handle, cap_smb_fname);
}
static int cap_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,

View File

@ -570,21 +570,34 @@ static int catia_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
}
static int catia_rmdir(vfs_handle_struct *handle,
const char *path)
const struct smb_filename *smb_fname)
{
char *name = NULL;
NTSTATUS status;
int ret;
struct smb_filename *catia_smb_fname = NULL;
status = catia_string_replace_allocate(handle->conn, path,
&name, vfs_translate_to_unix);
status = catia_string_replace_allocate(handle->conn,
smb_fname->base_name,
&name,
vfs_translate_to_unix);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
return -1;
}
catia_smb_fname = synthetic_smb_fname(talloc_tos(),
name,
NULL,
NULL);
if (catia_smb_fname == NULL) {
TALLOC_FREE(name);
errno = ENOMEM;
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, name);
ret = SMB_VFS_NEXT_RMDIR(handle, catia_smb_fname);
TALLOC_FREE(name);
TALLOC_FREE(catia_smb_fname);
return ret;
}

View File

@ -367,12 +367,13 @@ static int cephwrap_mkdir(struct vfs_handle_struct *handle,
return result;
}
static int cephwrap_rmdir(struct vfs_handle_struct *handle, const char *path)
static int cephwrap_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
int result;
DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, path));
result = ceph_rmdir(handle->data, path);
DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, smb_fname->base_name));
result = ceph_rmdir(handle->data, smb_fname->base_name);
DEBUG(10, ("[CEPH] rmdir(...) = %d\n", result));
WRAP_RETURN(result);
}

View File

@ -503,12 +503,13 @@ static int vfswrap_mkdir(vfs_handle_struct *handle,
return result;
}
static int vfswrap_rmdir(vfs_handle_struct *handle, const char *path)
static int vfswrap_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
int result;
START_PROFILE(syscall_rmdir);
result = rmdir(path);
result = rmdir(smb_fname->base_name);
END_PROFILE(syscall_rmdir);
return result;
}

View File

@ -158,20 +158,21 @@ static int audit_mkdir(vfs_handle_struct *handle,
return result;
}
static int audit_rmdir(vfs_handle_struct *handle, const char *path)
static int audit_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
int result;
result = SMB_VFS_NEXT_RMDIR(handle, path);
result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
if (lp_syslog() > 0) {
syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n",
path,
smb_fname->base_name,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : "");
}
DEBUG(0, ("vfs_extd_audit: rmdir %s %s %s\n",
path,
smb_fname->base_name,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));

View File

@ -2576,11 +2576,13 @@ static int fruit_chown(vfs_handle_struct *handle,
return rc;
}
static int fruit_rmdir(struct vfs_handle_struct *handle, const char *path)
static int fruit_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
DIR *dh = NULL;
struct dirent *de;
struct fruit_config_data *config;
const char *path = smb_fname->base_name;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct fruit_config_data, return -1);
@ -2618,7 +2620,7 @@ exit_rmdir:
if (dh) {
closedir(dh);
}
return SMB_VFS_NEXT_RMDIR(handle, path);
return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
static ssize_t fruit_pread(vfs_handle_struct *handle,

View File

@ -857,13 +857,14 @@ static int smb_full_audit_mkdir(vfs_handle_struct *handle,
}
static int smb_full_audit_rmdir(vfs_handle_struct *handle,
const char *path)
const struct smb_filename *smb_fname)
{
int result;
result = SMB_VFS_NEXT_RMDIR(handle, path);
result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s", path);
do_log(SMB_VFS_OP_RMDIR, (result >= 0), handle, "%s",
smb_fname->base_name);
return result;
}

View File

@ -436,9 +436,10 @@ static int vfs_gluster_mkdir(struct vfs_handle_struct *handle,
return glfs_mkdir(handle->data, smb_fname->base_name, mode);
}
static int vfs_gluster_rmdir(struct vfs_handle_struct *handle, const char *path)
static int vfs_gluster_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
return glfs_rmdir(handle->data, path);
return glfs_rmdir(handle->data, smb_fname->base_name);
}
static int vfs_gluster_open(struct vfs_handle_struct *handle,

View File

@ -1069,34 +1069,31 @@ out:
* Failure: set errno, return -1
*/
static int mh_rmdir(vfs_handle_struct *handle,
const char *path)
const struct smb_filename *smb_fname)
{
int status;
char *clientPath;
TALLOC_CTX *ctx;
struct smb_filename *clientFname = NULL;
const char *path = smb_fname->base_name;
DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", path));
if (!is_in_media_files(path))
{
status = SMB_VFS_NEXT_RMDIR(handle, path);
status = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
goto out;
}
clientPath = NULL;
ctx = talloc_tos();
if ((status = alloc_get_client_path(handle, ctx,
path,
&clientPath)))
{
status = alloc_get_client_smb_fname(handle,
talloc_tos(),
smb_fname,
&clientFname);
if (status != 0) {
goto err;
}
status = SMB_VFS_NEXT_RMDIR(handle, clientPath);
status = SMB_VFS_NEXT_RMDIR(handle, clientFname);
err:
TALLOC_FREE(clientPath);
TALLOC_FREE(clientFname);
out:
DEBUG(MH_INFO_DEBUG, ("Leaving with path '%s'\n", path));
return status;

View File

@ -223,10 +223,12 @@ static DIR *atalk_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp,
return ret;
}
static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
static int atalk_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
bool add = False;
TALLOC_CTX *ctx = 0;
const char *path = smb_fname->base_name;
char *dpath;
if (!handle->conn->cwd || !path) goto exit_rmdir;
@ -248,7 +250,7 @@ static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
exit_rmdir:
talloc_destroy(ctx);
return SMB_VFS_NEXT_RMDIR(handle, path);
return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
/* File operations */

View File

@ -343,11 +343,13 @@ out:
/*
* On rmdir we need to delete the tdb record
*/
static int posix_eadb_rmdir(vfs_handle_struct *handle, const char *path)
static int posix_eadb_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
NTSTATUS status;
struct tdb_wrap *ea_tdb;
int ret;
const char *path = smb_fname->base_name;
SMB_VFS_HANDLE_GET_DATA(handle, ea_tdb, struct tdb_wrap, return -1);
@ -360,7 +362,7 @@ static int posix_eadb_rmdir(vfs_handle_struct *handle, const char *path)
tdb_transaction_cancel(ea_tdb->tdb);
}
ret = SMB_VFS_NEXT_RMDIR(handle, path);
ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
if (ret == -1) {
tdb_transaction_cancel(ea_tdb->tdb);

View File

@ -1583,27 +1583,41 @@ static int shadow_copy2_mkdir(vfs_handle_struct *handle,
return ret;
}
static int shadow_copy2_rmdir(vfs_handle_struct *handle, const char *fname)
static int shadow_copy2_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
time_t timestamp;
char *stripped;
int ret, saved_errno;
char *conv;
struct smb_filename *conv_smb_fname = NULL;
if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
&timestamp, &stripped)) {
if (!shadow_copy2_strip_snapshot(talloc_tos(),
handle,
smb_fname->base_name,
&timestamp,
&stripped)) {
return -1;
}
if (timestamp == 0) {
return SMB_VFS_NEXT_RMDIR(handle, fname);
return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, conv);
conv_smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
NULL);
if (conv_smb_fname == NULL) {
TALLOC_FREE(conv);
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, conv_smb_fname);
saved_errno = errno;
TALLOC_FREE(conv_smb_fname);
TALLOC_FREE(conv);
errno = saved_errno;
return ret;

View File

@ -2527,14 +2527,16 @@ static int snapper_gmt_mkdir(vfs_handle_struct *handle,
return ret;
}
static int snapper_gmt_rmdir(vfs_handle_struct *handle, const char *fname)
static int snapper_gmt_rmdir(vfs_handle_struct *handle,
const struct smb_filename *fname)
{
time_t timestamp;
char *stripped;
int ret, saved_errno;
char *conv;
struct smb_filename *smb_fname = NULL;
if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname->base_name,
&timestamp, &stripped)) {
return -1;
}
@ -2546,9 +2548,18 @@ static int snapper_gmt_rmdir(vfs_handle_struct *handle, const char *fname)
if (conv == NULL) {
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, conv);
saved_errno = errno;
smb_fname = synthetic_smb_fname(talloc_tos(),
conv,
NULL,
NULL);
TALLOC_FREE(conv);
if (smb_fname == NULL) {
errno = ENOMEM;
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
saved_errno = errno;
TALLOC_FREE(smb_fname);
errno = saved_errno;
return ret;
}

View File

@ -233,7 +233,7 @@ static char *stream_dir(vfs_handle_struct *handle,
smb_fname_hash->base_name));
recursive_rmdir(talloc_tos(), handle->conn,
smb_fname_hash);
SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash->base_name);
SMB_VFS_NEXT_RMDIR(handle, smb_fname_hash);
} else {
newname = talloc_asprintf(talloc_tos(), "lost-%lu",
random());
@ -682,7 +682,19 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
&smb_fname_base->st, false);
if (dirname != NULL) {
SMB_VFS_NEXT_RMDIR(handle, dirname);
struct smb_filename *smb_fname_dir =
synthetic_smb_fname(talloc_tos(),
dirname,
NULL,
NULL);
if (smb_fname_dir == NULL) {
TALLOC_FREE(smb_fname_base);
TALLOC_FREE(dirname);
errno = ENOMEM;
return -1;
}
SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
TALLOC_FREE(smb_fname_dir);
}
TALLOC_FREE(dirname);
}
@ -691,18 +703,23 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
return ret;
}
static int streams_depot_rmdir(vfs_handle_struct *handle, const char *path)
static int streams_depot_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
struct smb_filename *smb_fname_base = NULL;
int ret = -1;
DEBUG(10, ("streams_depot_rmdir called for %s\n", path));
DEBUG(10, ("streams_depot_rmdir called for %s\n",
smb_fname->base_name));
/*
* We potentially need to delete the per-inode streams directory
*/
smb_fname_base = synthetic_smb_fname(talloc_tos(), path, NULL, NULL);
smb_fname_base = synthetic_smb_fname(talloc_tos(),
smb_fname->base_name,
NULL,
NULL);
if (smb_fname_base == NULL) {
errno = ENOMEM;
return -1;
@ -719,13 +736,25 @@ static int streams_depot_rmdir(vfs_handle_struct *handle, const char *path)
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, path);
ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base);
if (ret == 0) {
char *dirname = stream_dir(handle, smb_fname_base,
&smb_fname_base->st, false);
if (dirname != NULL) {
SMB_VFS_NEXT_RMDIR(handle, dirname);
struct smb_filename *smb_fname_dir =
synthetic_smb_fname(talloc_tos(),
dirname,
NULL,
NULL);
if (smb_fname_dir == NULL) {
TALLOC_FREE(smb_fname_base);
TALLOC_FREE(dirname);
errno = ENOMEM;
return -1;
}
SMB_VFS_NEXT_RMDIR(handle, smb_fname_dir);
TALLOC_FREE(smb_fname_dir);
}
TALLOC_FREE(dirname);
}

View File

@ -224,9 +224,10 @@ static int syncops_mkdir(vfs_handle_struct *handle,
SYNCOPS_NEXT_SMB_FNAME(MKDIR, smb_fname, (handle, smb_fname, mode));
}
static int syncops_rmdir(vfs_handle_struct *handle, const char *fname)
static int syncops_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
SYNCOPS_NEXT(RMDIR, fname, (handle, fname));
SYNCOPS_NEXT_SMB_FNAME(RMDIR, smb_fname, (handle, smb_fname));
}
/* close needs to be handled specially */

View File

@ -482,19 +482,21 @@ static int smb_time_audit_mkdir(vfs_handle_struct *handle,
}
static int smb_time_audit_rmdir(vfs_handle_struct *handle,
const char *path)
const struct smb_filename *smb_fname)
{
int result;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
result = SMB_VFS_NEXT_RMDIR(handle, path);
result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
smb_time_audit_log_fname("rmdir", timediff, path);
smb_time_audit_log_smb_fname("rmdir",
timediff,
smb_fname);
}
return result;

View File

@ -795,31 +795,29 @@ err:
}
static int um_rmdir(vfs_handle_struct *handle,
const char *path)
const struct smb_filename *smb_fname)
{
int status;
char *clientPath;
TALLOC_CTX *ctx;
const char *path = smb_fname->base_name;
struct smb_filename *client_fname = NULL;
DEBUG(10, ("Entering with path '%s'\n", path));
if (!is_in_media_files(path)) {
return SMB_VFS_NEXT_RMDIR(handle, path);
return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
clientPath = NULL;
ctx = talloc_tos();
if ((status = alloc_get_client_path(handle, ctx,
path,
&clientPath))) {
status = alloc_get_client_smb_fname(handle,
talloc_tos(),
smb_fname,
&client_fname);
if (status != 0) {
goto err;
}
status = SMB_VFS_NEXT_RMDIR(handle, clientPath);
status = SMB_VFS_NEXT_RMDIR(handle, client_fname);
err:
TALLOC_FREE(clientPath);
TALLOC_FREE(client_fname);
DEBUG(10, ("Leaving with path '%s'\n", path));
return status;
}

View File

@ -400,12 +400,14 @@ static int xattr_tdb_unlink(vfs_handle_struct *handle,
/*
* On rmdir we need to delete the tdb record
*/
static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
static int xattr_tdb_rmdir(vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
SMB_STRUCT_STAT sbuf;
struct file_id id;
struct db_context *db;
int ret;
const char *path = smb_fname->base_name;
TALLOC_CTX *frame = talloc_stackframe();
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
@ -419,7 +421,7 @@ static int xattr_tdb_rmdir(vfs_handle_struct *handle, const char *path)
return -1;
}
ret = SMB_VFS_NEXT_RMDIR(handle, path);
ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
if (ret == -1) {
TALLOC_FREE(frame);

View File

@ -845,8 +845,7 @@ bool recursive_rmdir(TALLOC_CTX *ctx,
if(!recursive_rmdir(ctx, conn, smb_dname_full)) {
goto err_break;
}
if(SMB_VFS_RMDIR(conn,
smb_dname_full->base_name) != 0) {
if(SMB_VFS_RMDIR(conn, smb_dname_full) != 0) {
goto err_break;
}
} else if(SMB_VFS_UNLINK(conn, smb_dname_full) != 0) {
@ -896,7 +895,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
}
ret = SMB_VFS_UNLINK(conn, smb_dname);
} else {
ret = SMB_VFS_RMDIR(conn, smb_dname->base_name);
ret = SMB_VFS_RMDIR(conn, smb_dname);
}
if (ret == 0) {
notify_fname(conn, NOTIFY_ACTION_REMOVED,
@ -998,7 +997,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
goto err_break;
}
if(SMB_VFS_RMDIR(conn,
smb_dname_full->base_name) != 0) {
smb_dname_full) != 0) {
goto err_break;
}
} else if(SMB_VFS_UNLINK(conn, smb_dname_full) != 0) {
@ -1017,7 +1016,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp)
}
TALLOC_FREE(dir_hnd);
/* Retry the rmdir */
ret = SMB_VFS_RMDIR(conn, smb_dname->base_name);
ret = SMB_VFS_RMDIR(conn, smb_dname);
}
err:

View File

@ -1505,10 +1505,11 @@ int smb_vfs_call_mkdir(struct vfs_handle_struct *handle,
return handle->fns->mkdir_fn(handle, smb_fname, mode);
}
int smb_vfs_call_rmdir(struct vfs_handle_struct *handle, const char *path)
int smb_vfs_call_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
VFS_FIND(rmdir);
return handle->fns->rmdir_fn(handle, path);
return handle->fns->rmdir_fn(handle, smb_fname);
}
int smb_vfs_call_closedir(struct vfs_handle_struct *handle,

View File

@ -399,6 +399,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
struct smb_filename *smb_fname = NULL;
int ret = -1;
if (argc != 2) {
@ -406,16 +407,19 @@ static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
return NT_STATUS_OK;
}
smb_fname = synthetic_smb_fname(talloc_tos(),
argv[1],
NULL,
NULL);
if (smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
}
if (strcmp("rmdir", argv[0]) == 0 ) {
ret = SMB_VFS_RMDIR(vfs->conn, argv[1]);
ret = SMB_VFS_RMDIR(vfs->conn, smb_fname);
TALLOC_FREE(smb_fname);
} else if (strcmp("unlink", argv[0]) == 0 ) {
struct smb_filename *smb_fname;
smb_fname = synthetic_smb_fname_split(mem_ctx, argv[1], NULL);
if (smb_fname == NULL) {
return NT_STATUS_NO_MEMORY;
}
ret = SMB_VFS_UNLINK(vfs->conn, smb_fname);
TALLOC_FREE(smb_fname);
} else if (strcmp("chdir", argv[0]) == 0 ) {