From fef39d26fa3636f7b8bd36a93707f8ee3e704a30 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 26 Oct 1997 09:32:53 +0000 Subject: [PATCH] Partially undo last change. Time-stamp problem is more complicated than I originally thought. --- v7/src/microcode/ntfs.c | 57 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/v7/src/microcode/ntfs.c b/v7/src/microcode/ntfs.c index d779f5c81..16ae20d2f 100644 --- a/v7/src/microcode/ntfs.c +++ b/v7/src/microcode/ntfs.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ntfs.c,v 1.17 1997/10/26 09:15:04 cph Exp $ +$Id: ntfs.c,v 1.18 1997/10/26 09:32:53 cph Exp $ Copyright (c) 1992-97 Massachusetts Institute of Technology @@ -37,14 +37,44 @@ MIT in each case. */ #include #include "outf.h" -/* Incredible kludge. Some files (e.g. \pagefile.sys) cannot be - accessed by the usual technique, but much of the same information - is available by reading the directory. Additionally, - GetFileInformationByHandle returns incorrect time-stamp information - for some files (specifically, Samba files), but FindFirstFile - returns correct information. Go figure. More M$ bullshit. */ +static HANDLE create_file_for_info (const char *); + +static enum get_file_info_result get_file_info_from_dir + (const char *, BY_HANDLE_FILE_INFORMATION *); + enum get_file_info_result NT_get_file_info (const char * namestring, BY_HANDLE_FILE_INFORMATION * info) +{ + HANDLE hfile = (create_file_for_info (namestring)); + if (hfile == INVALID_HANDLE_VALUE) + { + DWORD code = (GetLastError ()); + if (STAT_NOT_FOUND_P (code)) + return (gfi_not_found); + if (STAT_NOT_ACCESSIBLE_P (code)) + return (get_file_info_from_dir (namestring, info)); + NT_error_api_call (code, apicall_CreateFile); + } + if (!GetFileInformationByHandle (hfile, info)) + { + DWORD code = (GetLastError ()); + (void) CloseHandle (hfile); + if (STAT_NOT_FOUND_P (code)) + return (gfi_not_found); + if (STAT_NOT_ACCESSIBLE_P (code)) + return (gfi_not_accessible); + NT_error_api_call (code, apicall_GetFileInformationByHandle); + } + STD_BOOL_API_CALL (CloseHandle, (hfile)); + return (gfi_ok); +} + +/* Incredible kludge. Some files (e.g. \pagefile.sys) cannot be + accessed by the usual technique, but much of the same information + is available by reading the directory. More M$ bullshit. */ +static enum get_file_info_result +get_file_info_from_dir (const char * namestring, + BY_HANDLE_FILE_INFORMATION * info) { char nscopy [MAX_PATH]; WIN32_FIND_DATA fi; @@ -80,6 +110,19 @@ NT_get_file_info (const char * namestring, BY_HANDLE_FILE_INFORMATION * info) return (gfi_ok); } +static HANDLE +create_file_for_info (const char * namestring) +{ + return + (CreateFile (namestring, + 0, + (FILE_SHARE_READ | FILE_SHARE_WRITE), + 0, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL)); +} + enum file_existence DEFUN (OS_file_existence_test, (name), CONST char * name) { -- 2.25.1