mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Remove the char * argument from the SMB_VFS_GETWD() call. Now always
returns malloc'ed memory. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Wed Jun 1 04:06:12 CEST 2011 on sn-devel-104
This commit is contained in:
parent
1cee71713f
commit
c7d2f6d35a
@ -293,7 +293,7 @@ static int skel_chdir(vfs_handle_struct *handle, const char *path)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *skel_getwd(vfs_handle_struct *handle, char *buf)
|
||||
static char *skel_getwd(vfs_handle_struct *handle)
|
||||
{
|
||||
errno = ENOSYS;
|
||||
return NULL;
|
||||
|
@ -280,9 +280,9 @@ static int skel_chdir(vfs_handle_struct *handle, const char *path)
|
||||
return SMB_VFS_NEXT_CHDIR(handle, path);
|
||||
}
|
||||
|
||||
static char *skel_getwd(vfs_handle_struct *handle, char *buf)
|
||||
static char *skel_getwd(vfs_handle_struct *handle)
|
||||
{
|
||||
return SMB_VFS_NEXT_GETWD(handle, buf);
|
||||
return SMB_VFS_NEXT_GETWD(handle);
|
||||
}
|
||||
|
||||
static int skel_ntimes(vfs_handle_struct *handle,
|
||||
|
@ -134,6 +134,7 @@
|
||||
to split out the two possible uses. JRA. */
|
||||
/* Leave at 28 - not yet released. Add fdopendir. JRA. */
|
||||
/* Leave at 28 - not yet released. Rename open function to open_fn. - gd */
|
||||
/* Leave at 28 - not yet released. Make getwd function always return malloced memory. JRA. */
|
||||
#define SMB_VFS_INTERFACE_VERSION 28
|
||||
|
||||
/*
|
||||
@ -250,7 +251,7 @@ struct vfs_fn_pointers {
|
||||
int (*fchown)(struct vfs_handle_struct *handle, struct files_struct *fsp, uid_t uid, gid_t gid);
|
||||
int (*lchown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
|
||||
int (*chdir)(struct vfs_handle_struct *handle, const char *path);
|
||||
char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
|
||||
char *(*getwd)(struct vfs_handle_struct *handle);
|
||||
int (*ntimes)(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
struct smb_file_time *ft);
|
||||
@ -613,7 +614,7 @@ int smb_vfs_call_fchown(struct vfs_handle_struct *handle,
|
||||
int smb_vfs_call_lchown(struct vfs_handle_struct *handle, const char *path,
|
||||
uid_t uid, gid_t gid);
|
||||
int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path);
|
||||
char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf);
|
||||
char *smb_vfs_call_getwd(struct vfs_handle_struct *handle);
|
||||
int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
|
||||
const struct smb_filename *smb_fname,
|
||||
struct smb_file_time *ft);
|
||||
|
@ -239,10 +239,10 @@
|
||||
#define SMB_VFS_NEXT_CHDIR(handle, path) \
|
||||
smb_vfs_call_chdir((handle)->next, (path))
|
||||
|
||||
#define SMB_VFS_GETWD(conn, buf) \
|
||||
smb_vfs_call_getwd((conn)->vfs_handles, (buf))
|
||||
#define SMB_VFS_NEXT_GETWD(handle, buf) \
|
||||
smb_vfs_call_getwd((handle)->next, (buf))
|
||||
#define SMB_VFS_GETWD(conn) \
|
||||
smb_vfs_call_getwd((conn)->vfs_handles)
|
||||
#define SMB_VFS_NEXT_GETWD(handle) \
|
||||
smb_vfs_call_getwd((handle)->next)
|
||||
|
||||
#define SMB_VFS_NTIMES(conn, path, ts) \
|
||||
smb_vfs_call_ntimes((conn)->vfs_handles, (path), (ts))
|
||||
|
@ -748,16 +748,14 @@ static int vfswrap_chdir(vfs_handle_struct *handle, const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *vfswrap_getwd(vfs_handle_struct *handle, char *path)
|
||||
static char *vfswrap_getwd(vfs_handle_struct *handle)
|
||||
{
|
||||
char *result;
|
||||
|
||||
START_PROFILE(syscall_getwd);
|
||||
result = sys_getwd();
|
||||
END_PROFILE(syscall_getwd);
|
||||
/* FIXME - with a VFS change. JRA !! */
|
||||
strlcpy(path, result, PATH_MAX);
|
||||
return path;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -1208,14 +1208,14 @@ static int smb_full_audit_chdir(vfs_handle_struct *handle,
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *smb_full_audit_getwd(vfs_handle_struct *handle,
|
||||
char *path)
|
||||
static char *smb_full_audit_getwd(vfs_handle_struct *handle)
|
||||
{
|
||||
char *result;
|
||||
|
||||
result = SMB_VFS_NEXT_GETWD(handle, path);
|
||||
result = SMB_VFS_NEXT_GETWD(handle);
|
||||
|
||||
do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s", path);
|
||||
do_log(SMB_VFS_OP_GETWD, (result != NULL), handle, "%s",
|
||||
result == NULL? "" : result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -869,14 +869,14 @@ static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *smb_time_audit_getwd(vfs_handle_struct *handle, char *path)
|
||||
static char *smb_time_audit_getwd(vfs_handle_struct *handle)
|
||||
{
|
||||
char *result;
|
||||
struct timespec ts1,ts2;
|
||||
double timediff;
|
||||
|
||||
clock_gettime_mono(&ts1);
|
||||
result = SMB_VFS_NEXT_GETWD(handle, path);
|
||||
result = SMB_VFS_NEXT_GETWD(handle);
|
||||
clock_gettime_mono(&ts2);
|
||||
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
|
||||
|
||||
|
@ -795,7 +795,7 @@ int vfs_ChDir(connection_struct *conn, const char *path)
|
||||
|
||||
char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
|
||||
{
|
||||
char s[PATH_MAX+1];
|
||||
char *current_dir = NULL;
|
||||
char *result = NULL;
|
||||
DATA_BLOB cache_value;
|
||||
struct file_id key;
|
||||
@ -803,8 +803,6 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
|
||||
struct smb_filename *smb_fname_full = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
*s = 0;
|
||||
|
||||
if (!lp_getwd_cache()) {
|
||||
goto nocache;
|
||||
}
|
||||
@ -866,7 +864,8 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
|
||||
* systems, or the not quite so bad getwd.
|
||||
*/
|
||||
|
||||
if (!SMB_VFS_GETWD(conn,s)) {
|
||||
current_dir = SMB_VFS_GETWD(conn);
|
||||
if (current_dir == NULL) {
|
||||
DEBUG(0, ("vfs_GetWd: SMB_VFS_GETWD call failed: %s\n",
|
||||
strerror(errno)));
|
||||
goto out;
|
||||
@ -877,10 +876,11 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
|
||||
|
||||
memcache_add(smbd_memcache(), GETWD_CACHE,
|
||||
data_blob_const(&key, sizeof(key)),
|
||||
data_blob_const(s, strlen(s)+1));
|
||||
data_blob_const(current_dir,
|
||||
strlen(current_dir)+1));
|
||||
}
|
||||
|
||||
result = talloc_strdup(ctx, s);
|
||||
result = talloc_strdup(ctx, current_dir);
|
||||
if (result == NULL) {
|
||||
errno = ENOMEM;
|
||||
}
|
||||
@ -888,6 +888,7 @@ char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn)
|
||||
out:
|
||||
TALLOC_FREE(smb_fname_dot);
|
||||
TALLOC_FREE(smb_fname_full);
|
||||
SAFE_FREE(current_dir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1553,10 +1554,10 @@ int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const char *path)
|
||||
return handle->fns->chdir(handle, path);
|
||||
}
|
||||
|
||||
char *smb_vfs_call_getwd(struct vfs_handle_struct *handle, char *buf)
|
||||
char *smb_vfs_call_getwd(struct vfs_handle_struct *handle)
|
||||
{
|
||||
VFS_FIND(getwd);
|
||||
return handle->fns->getwd(handle, buf);
|
||||
return handle->fns->getwd(handle);
|
||||
}
|
||||
|
||||
int smb_vfs_call_ntimes(struct vfs_handle_struct *handle,
|
||||
|
@ -889,13 +889,14 @@ static NTSTATUS cmd_fchown(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
|
||||
|
||||
static NTSTATUS cmd_getwd(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
if (SMB_VFS_GETWD(vfs->conn, buf) == NULL) {
|
||||
char *buf = SMB_VFS_GETWD(vfs->conn);
|
||||
if (buf == NULL) {
|
||||
printf("getwd: error=%d (%s)\n", errno, strerror(errno));
|
||||
return NT_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
printf("getwd: %s\n", buf);
|
||||
SAFE_FREE(buf);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user