Alexandre Julliard : ntdll: Move nt_to_unix_file_name_attr() to avoid forward declarations.
Alexandre Julliard
julliard at winehq.org
Wed Apr 14 16:01:19 CDT 2021
Module: wine
Branch: master
Commit: 90024e492dcefd204c6c953a804c0d51544db5b2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=90024e492dcefd204c6c953a804c0d51544db5b2
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Apr 13 16:19:50 2021 +0200
ntdll: Move nt_to_unix_file_name_attr() to avoid forward declarations.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/file.c | 126 ++++++++++++++++++++++++-------------------------
1 file changed, 63 insertions(+), 63 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index b87da541f1d..45c220a1d63 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -3216,69 +3216,6 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
}
-/******************************************************************************
- * nt_to_unix_file_name_attr
- */
-static NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, char **name_ret,
- UNICODE_STRING *nt_name, UINT disposition )
-{
- enum server_fd_type type;
- int old_cwd, root_fd, needs_close;
- const WCHAR *name;
- char *unix_name;
- int name_len, unix_len;
- NTSTATUS status;
-
- if (!attr->RootDirectory) /* without root dir fall back to normal lookup */
- return nt_to_unix_file_name( attr->ObjectName, name_ret, nt_name, disposition );
-
- name = attr->ObjectName->Buffer;
- name_len = attr->ObjectName->Length / sizeof(WCHAR);
-
- if (name_len && name[0] == '\\') return STATUS_INVALID_PARAMETER;
-
- unix_len = name_len * 3 + MAX_DIR_ENTRY_LEN + 3;
- if (!(unix_name = malloc( unix_len ))) return STATUS_NO_MEMORY;
- unix_name[0] = '.';
-
- if (!(status = server_get_unix_fd( attr->RootDirectory, 0, &root_fd, &needs_close, &type, NULL )))
- {
- if (type != FD_TYPE_DIR)
- {
- if (needs_close) close( root_fd );
- status = STATUS_BAD_DEVICE_TYPE;
- }
- else
- {
- mutex_lock( &dir_mutex );
- if ((old_cwd = open( ".", O_RDONLY )) != -1 && fchdir( root_fd ) != -1)
- {
- status = lookup_unix_name( name, name_len, &unix_name, unix_len, 1, disposition, FALSE );
- if (fchdir( old_cwd ) == -1) chdir( "/" );
- }
- else status = errno_to_status( errno );
- mutex_unlock( &dir_mutex );
- if (old_cwd != -1) close( old_cwd );
- if (needs_close) close( root_fd );
- }
- }
- else if (status == STATUS_OBJECT_TYPE_MISMATCH) status = STATUS_BAD_DEVICE_TYPE;
-
- if (status == STATUS_SUCCESS || status == STATUS_NO_SUCH_FILE)
- {
- TRACE( "%s -> %s\n", debugstr_us(attr->ObjectName), debugstr_a(unix_name) );
- *name_ret = unix_name;
- if (nt_name) rebuild_nt_name( attr->ObjectName, 0, unix_name, nt_name );
- }
- else
- {
- TRACE( "%s not found in %s\n", debugstr_w(name), unix_name );
- free( unix_name );
- }
- return status;
-}
-
-
/******************************************************************************
* nt_to_unix_file_name
*
@@ -3393,6 +3330,69 @@ NTSTATUS nt_to_unix_file_name( const UNICODE_STRING *nameW, char **unix_name_ret
}
+/******************************************************************************
+ * nt_to_unix_file_name_attr
+ */
+static NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, char **name_ret,
+ UNICODE_STRING *nt_name, UINT disposition )
+{
+ enum server_fd_type type;
+ int old_cwd, root_fd, needs_close;
+ const WCHAR *name;
+ char *unix_name;
+ int name_len, unix_len;
+ NTSTATUS status;
+
+ if (!attr->RootDirectory) /* without root dir fall back to normal lookup */
+ return nt_to_unix_file_name( attr->ObjectName, name_ret, nt_name, disposition );
+
+ name = attr->ObjectName->Buffer;
+ name_len = attr->ObjectName->Length / sizeof(WCHAR);
+
+ if (name_len && name[0] == '\\') return STATUS_INVALID_PARAMETER;
+
+ unix_len = name_len * 3 + MAX_DIR_ENTRY_LEN + 3;
+ if (!(unix_name = malloc( unix_len ))) return STATUS_NO_MEMORY;
+ unix_name[0] = '.';
+
+ if (!(status = server_get_unix_fd( attr->RootDirectory, 0, &root_fd, &needs_close, &type, NULL )))
+ {
+ if (type != FD_TYPE_DIR)
+ {
+ if (needs_close) close( root_fd );
+ status = STATUS_BAD_DEVICE_TYPE;
+ }
+ else
+ {
+ mutex_lock( &dir_mutex );
+ if ((old_cwd = open( ".", O_RDONLY )) != -1 && fchdir( root_fd ) != -1)
+ {
+ status = lookup_unix_name( name, name_len, &unix_name, unix_len, 1, disposition, FALSE );
+ if (fchdir( old_cwd ) == -1) chdir( "/" );
+ }
+ else status = errno_to_status( errno );
+ mutex_unlock( &dir_mutex );
+ if (old_cwd != -1) close( old_cwd );
+ if (needs_close) close( root_fd );
+ }
+ }
+ else if (status == STATUS_OBJECT_TYPE_MISMATCH) status = STATUS_BAD_DEVICE_TYPE;
+
+ if (status == STATUS_SUCCESS || status == STATUS_NO_SUCH_FILE)
+ {
+ TRACE( "%s -> %s\n", debugstr_us(attr->ObjectName), debugstr_a(unix_name) );
+ *name_ret = unix_name;
+ if (nt_name) rebuild_nt_name( attr->ObjectName, 0, unix_name, nt_name );
+ }
+ else
+ {
+ TRACE( "%s not found in %s\n", debugstr_w(name), unix_name );
+ free( unix_name );
+ }
+ return status;
+}
+
+
/******************************************************************************
* wine_nt_to_unix_file_name
*
More information about the wine-cvs
mailing list