A vfs_readdir wrapper which just returns the file name.
********************************************************************/
-char *vfs_readdirname(connection_struct *conn, void *p, SMB_STRUCT_STAT *sbuf)
+const char *vfs_readdirname(connection_struct *conn, void *p,
+ SMB_STRUCT_STAT *sbuf, char **talloced)
{
SMB_STRUCT_DIRENT *ptr= NULL;
- char *dname = NULL;
- NTSTATUS result;
+ const char *dname;
+ char *translated;
+ NTSTATUS status;
if (!p)
return(NULL);
if (!ptr)
return(NULL);
- dname = talloc_strdup(talloc_tos(), ptr->d_name);
- if (dname == NULL) {
- errno = ENOMEM;
- return NULL;
- }
- result = SMB_VFS_TRANSLATE_NAME(conn, &dname,
- vfs_translate_to_windows);
- if (!NT_STATUS_IS_OK(result)) {
- TALLOC_FREE(dname);
- return NULL;
- }
+ dname = ptr->d_name;
+
#ifdef NEXT2
if (telldir(p) < 0)
dname = dname - 2;
#endif
- return(dname);
+ status = SMB_VFS_TRANSLATE_NAME(conn, dname, vfs_translate_to_windows,
+ talloc_tos(), &translated);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) {
+ *talloced = NULL;
+ return dname;
+ }
+ *talloced = translated;
+ if (!NT_STATUS_IS_OK(status)) {
+ return NULL;
+ }
+ return translated;
}
/*******************************************************************
int vfs_ChDir(connection_struct *conn, const char *path)
{
- int res;
-
- if (!LastDir) {
- LastDir = SMB_STRDUP("");
- }
-
- if (strcsequal(path,"."))
- return(0);
-
- if (*path == '/' && strcsequal(LastDir,path))
- return(0);
-
- DEBUG(4,("vfs_ChDir to %s\n",path));
-
- res = SMB_VFS_CHDIR(conn,path);
- if (!res) {
- SAFE_FREE(LastDir);
- LastDir = SMB_STRDUP(path);
- }
- return(res);
+ return SMB_VFS_CHDIR(conn,path);
}
/*******************************************************************
DEBUG(3,("check_reduced_name: Component not a "
"directory in getting realpath for "
"%s\n", fname));
- return map_nt_error_from_unix(errno);
+ return NT_STATUS_OBJECT_PATH_NOT_FOUND;
case ENOENT:
{
TALLOC_CTX *ctx = talloc_tos();
resolved_name = SMB_VFS_REALPATH(conn,tmp_fname,resolved_name_buf);
#endif
if (!resolved_name) {
+ NTSTATUS status = map_nt_error_from_unix(errno);
+
+ if (errno == ENOENT || errno == ENOTDIR) {
+ status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+ }
+
DEBUG(3,("check_reduce_named: "
"couldn't get realpath for "
- "%s\n", fname));
- return map_nt_error_from_unix(errno);
+ "%s (%s)\n",
+ fname,
+ nt_errstr(status)));
+ return status;
}
tmp_fname = talloc_asprintf(ctx,
"%s/%s",
strlen(conn_rootdir)) != 0) {
DEBUG(2, ("check_reduced_name: Bad access "
"attempt: %s is a symlink outside the "
- "share path", fname));
+ "share path\n", fname));
if (free_resolved_name) {
SAFE_FREE(resolved_name);
}
}
NTSTATUS smb_vfs_call_translate_name(struct vfs_handle_struct *handle,
- char **mapped_name,
- enum vfs_translate_direction direction)
+ const char *name,
+ enum vfs_translate_direction direction,
+ TALLOC_CTX *mem_ctx,
+ char **mapped_name)
{
VFS_FIND(translate_name);
- return handle->fns->translate_name(handle, mapped_name, direction);
+ return handle->fns->translate_name(handle, name, direction, mem_ctx,
+ mapped_name);
}
NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,