}
-/* Use 'FileAllInformationStruct' identifier instead of the logical 'FileAllInformation'
- * to prevent override of enum member 'FileAllInformation'
+/* Use 'FileNameInformationStruct' identifier instead of the logical 'FileNameInformation'
+ * to prevent override of enum member 'FileNameInformation'
*/
-static GnomeVFSResult FileAllInformationStruct_to_GnomeVFSFileInfo(GnomeVFSFileInfo *file_info,
- FILE_ALL_INFORMATION *FileAllInformationStruct,IO_STATUS_BLOCK *IoStatusBlock)
+static GnomeVFSResult FileNameInformationStruct_to_GnomeVFSFileInfo(GnomeVFSFileInfo *file_info,
+ FILE_NAME_INFORMATION *FileNameInformationStruct)
{
UNICODE_STRING FileName_UnicodeString;
-BOOLEAN errBOOLEAN;
-ULONG tmp_ULONG;
g_return_val_if_fail(file_info!=NULL,GNOME_VFS_ERROR_GENERIC);
- g_return_val_if_fail(FileAllInformationStruct!=NULL,GNOME_VFS_ERROR_GENERIC);
+ g_return_val_if_fail(FileNameInformationStruct!=NULL,GNOME_VFS_ERROR_GENERIC);
- g_return_val_if_fail(NT_SUCCESS(IoStatusBlock->Status),GNOME_VFS_ERROR_GENERIC);
-
- file_info->valid_fields=0;
+ FileName_UnicodeString.Length=FileNameInformationStruct->FileNameLength;
+ FileName_UnicodeString.MaximumLength=FileNameInformationStruct->FileNameLength
+ +sizeof(*FileNameInformationStruct->FileName); /* 0-terminator */
- FileName_UnicodeString.Length=FileAllInformationStruct->NameInformation.FileNameLength;
- FileName_UnicodeString.MaximumLength=FileAllInformationStruct->NameInformation.FileNameLength
- +sizeof(*FileAllInformationStruct->NameInformation.FileName); /* 0-terminator */
- g_assert((gpointer)(((char *)FileAllInformationStruct->NameInformation.FileName)+FileName_UnicodeString.Length)
+#if 0 /* 'IoStatusBlock->Information' is sometimes weird, do not check it */
+ g_assert((gpointer)(((char *)FileNameInformationStruct->FileName)+FileName_UnicodeString.Length)
<=(gpointer)(((char *)FileAllInformationStruct)+IoStatusBlock->Information));
/* ensure we fit below '->IoStatusBlock->Information' at least without the 0-terminator */
- FileAllInformationStruct->NameInformation.FileName[FileAllInformationStruct->NameInformation.FileNameLength
- /sizeof(*FileAllInformationStruct->NameInformation.FileName)]=0; /* 0-terminate it */
- FileName_UnicodeString.Buffer=FileAllInformationStruct->NameInformation.FileName;
+#endif
+
+ FileNameInformationStruct->FileName[FileNameInformationStruct->FileNameLength
+ /sizeof(*FileNameInformationStruct->FileName)]=0; /* 0-terminate it */
+ FileName_UnicodeString.Buffer=FileNameInformationStruct->FileName;
file_info->name=captive_UnicodeString_to_utf8_malloc(&FileName_UnicodeString);
/* '->name' assumed for 'file_info->valid_fields' */
+ return GNOME_VFS_OK;
+}
+
+
+/* Use 'FileBasicInformationStruct' identifier instead of the logical 'FileBasicInformation'
+ * to prevent override of enum member 'FileBasicInformation'
+ */
+static GnomeVFSResult FileBasicInformationStruct_to_GnomeVFSFileInfo(GnomeVFSFileInfo *file_info,
+ FILE_BASIC_INFORMATION *FileBasicInformationStruct)
+{
+BOOLEAN errBOOLEAN;
+ULONG tmp_ULONG;
+
/* FIXME: What is 'FILE_ATTRIBUTE_NORMAL'? */
- switch (FileAllInformationStruct->BasicInformation.FileAttributes & (0
+ switch (FileBasicInformationStruct->FileAttributes & (0
| FILE_ATTRIBUTE_DIRECTORY
| FILE_ATTRIBUTE_DEVICE)) {
case 0: file_info->type=GNOME_VFS_FILE_TYPE_REGULAR; break;
file_info->permissions=GNOME_VFS_PERM_USER_READ;
if (file_info->type==GNOME_VFS_FILE_TYPE_DIRECTORY)
file_info->permissions|=GNOME_VFS_PERM_USER_EXEC;
- if (!(FileAllInformationStruct->BasicInformation.FileAttributes & FILE_ATTRIBUTE_READONLY))
+ if (!(FileBasicInformationStruct->FileAttributes & FILE_ATTRIBUTE_READONLY))
file_info->permissions|=GNOME_VFS_PERM_USER_WRITE;
file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS;
- file_info->size=FileAllInformationStruct->StandardInformation.EndOfFile.QuadPart;
- file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_SIZE;
-
- file_info->block_count=FileAllInformationStruct->StandardInformation.AllocationSize.QuadPart/512;
- file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
-
- file_info->flags=GNOME_VFS_FILE_FLAGS_LOCAL;
- file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_FLAGS;
-
- if (FileAllInformationStruct->BasicInformation.LastAccessTime.QuadPart) { /* it may be 0 if not set */
- errBOOLEAN=RtlTimeToSecondsSince1970(&FileAllInformationStruct->BasicInformation.LastAccessTime,&tmp_ULONG);
+ if (FileBasicInformationStruct->LastAccessTime.QuadPart) { /* it may be 0 if not set */
+ errBOOLEAN=RtlTimeToSecondsSince1970(&FileBasicInformationStruct->LastAccessTime,&tmp_ULONG);
g_assert(errBOOLEAN==TRUE);
file_info->atime=tmp_ULONG;
file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_ATIME;
}
/* it may be 0 if not set */
- if (FileAllInformationStruct->BasicInformation.LastWriteTime.QuadPart || FileAllInformationStruct->BasicInformation.ChangeTime.QuadPart) {
+ if (FileBasicInformationStruct->LastWriteTime.QuadPart || FileBasicInformationStruct->ChangeTime.QuadPart) {
errBOOLEAN=RtlTimeToSecondsSince1970(
/* take the more recent (==bigger) time: */
- (FileAllInformationStruct->BasicInformation.LastWriteTime.QuadPart > FileAllInformationStruct->BasicInformation.ChangeTime.QuadPart
- ? &FileAllInformationStruct->BasicInformation.LastWriteTime : &FileAllInformationStruct->BasicInformation.ChangeTime),
+ (FileBasicInformationStruct->LastWriteTime.QuadPart > FileBasicInformationStruct->ChangeTime.QuadPart
+ ? &FileBasicInformationStruct->LastWriteTime : &FileBasicInformationStruct->ChangeTime),
&tmp_ULONG);
g_assert(errBOOLEAN==TRUE);
file_info->mtime=tmp_ULONG;
file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_MTIME;
}
- if (FileAllInformationStruct->BasicInformation.CreationTime.QuadPart) { /* it may be 0 if not set */
- errBOOLEAN=RtlTimeToSecondsSince1970(&FileAllInformationStruct->BasicInformation.CreationTime,&tmp_ULONG);
+ if (FileBasicInformationStruct->CreationTime.QuadPart) { /* it may be 0 if not set */
+ errBOOLEAN=RtlTimeToSecondsSince1970(&FileBasicInformationStruct->CreationTime,&tmp_ULONG);
g_assert(errBOOLEAN==TRUE);
file_info->ctime=tmp_ULONG;
file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_CTIME;
}
+/* Use 'FileStandardInformationStruct' identifier instead of the logical 'FileStandardInformation'
+ * to prevent override of enum member 'FileStandardInformation'
+ */
+static GnomeVFSResult FileStandardInformationStruct_to_GnomeVFSFileInfo(GnomeVFSFileInfo *file_info,
+ FILE_STANDARD_INFORMATION *FileStandardInformationStruct)
+{
+ file_info->size=FileStandardInformationStruct->EndOfFile.QuadPart;
+ file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_SIZE;
+
+ file_info->block_count=FileStandardInformationStruct->AllocationSize.QuadPart/512;
+ file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_BLOCK_COUNT;
+
+ return GNOME_VFS_OK;
+}
+
+
GnomeVFSResult captive_file_file_info_get(CaptiveFileObject *captive_file_object,
GnomeVFSFileInfo *file_info)
{
NTSTATUS err;
IO_STATUS_BLOCK file_IoStatusBlock;
-FILE_ALL_INFORMATION *FileAllInformationStruct;
+FILE_NAME_INFORMATION *FileNameInformationStruct;
+FILE_BASIC_INFORMATION *FileBasicInformationStruct;
+FILE_STANDARD_INFORMATION *FileStandardInformationStruct;
GnomeVFSResult errvfsresult;
-char QueryFile_buf[sizeof(FILE_ALL_INFORMATION)
+char QueryFile_buf[sizeof(FILE_NAME_INFORMATION)
+0x1000 /* max 'FileName' length, 255 should be enough */ * sizeof(WCHAR /* *FILE_ALL_INFORMATION.NameInformation.FileName */ )];
g_return_val_if_fail(captive_file_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
g_return_val_if_fail(captive_file_object->file_Handle!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
g_return_val_if_fail(file_info!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
- /* query */
- FileAllInformationStruct=(void *)QueryFile_buf;
+ /* ntfs.sys of NT-5.1sp1 has *(FILE_BASIC_INFORMATION *)FILE_ALL_INFORMATION.BasicInformation
+ * size 0x28 although reactos includes and all the information says 0x24.
+ * fastfat.sys of NT-5.1sp1 also has the 'official' sizeof 0x24.
+ * It would be a bit of heuristic to correctly detect its expected sizeof.
+ */
+
+ file_info->valid_fields=0;
+
+ file_info->flags=GNOME_VFS_FILE_FLAGS_LOCAL;
+ file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_FLAGS;
+
+ /* query NameInformation */
+ FileNameInformationStruct=(void *)QueryFile_buf;
err=NtQueryInformationFile(
captive_file_object->file_Handle, /* FileHandle */
&file_IoStatusBlock, /* IoStatusBlock */
(gpointer)QueryFile_buf, /* FileInformation */
sizeof(QueryFile_buf) /* Length */
- -sizeof(*FileAllInformationStruct->NameInformation.FileName), /* reserve space for 0-terminator */
- FileAllInformation); /* FileInformationClass; =>FILE_ALL_INFORMATION */
+ -sizeof(*FileNameInformationStruct->FileName), /* reserve space for a possible 0-terminator */
+ FileNameInformation); /* FileInformationClass; =>FILE_NAME_INFORMATION */
if (GNOME_VFS_OK!=(errvfsresult=captive_NTSTATUS_to_GnomeVFSResult(err)))
return errvfsresult;
+ g_return_val_if_fail(NT_SUCCESS(err)==NT_SUCCESS(file_IoStatusBlock.Status),GNOME_VFS_ERROR_GENERIC);
g_return_val_if_fail(NT_SUCCESS(err),GNOME_VFS_ERROR_GENERIC);
+ errvfsresult=FileNameInformationStruct_to_GnomeVFSFileInfo(file_info,FileNameInformationStruct);
+ g_return_val_if_fail(errvfsresult==GNOME_VFS_OK,errvfsresult);
- /* process gathered info */
- errvfsresult=FileAllInformationStruct_to_GnomeVFSFileInfo(file_info,FileAllInformationStruct,
- &file_IoStatusBlock);
+ /* query BasicInformation */
+ FileBasicInformationStruct=(void *)QueryFile_buf;
+ err=NtQueryInformationFile(
+ captive_file_object->file_Handle, /* FileHandle */
+ &file_IoStatusBlock, /* IoStatusBlock */
+ (gpointer)QueryFile_buf, /* FileInformation */
+ sizeof(QueryFile_buf), /* Length */
+ FileBasicInformation); /* FileInformationClass; =>FILE_BASIC_INFORMATION */
+ if (GNOME_VFS_OK!=(errvfsresult=captive_NTSTATUS_to_GnomeVFSResult(err)))
+ return errvfsresult;
+ g_return_val_if_fail(NT_SUCCESS(err)==NT_SUCCESS(file_IoStatusBlock.Status),GNOME_VFS_ERROR_GENERIC);
+ g_return_val_if_fail(NT_SUCCESS(err),GNOME_VFS_ERROR_GENERIC);
+ errvfsresult=FileBasicInformationStruct_to_GnomeVFSFileInfo(file_info,FileBasicInformationStruct);
+ g_return_val_if_fail(errvfsresult==GNOME_VFS_OK,errvfsresult);
+
+ /* query StandardInformation */
+ FileStandardInformationStruct=(void *)QueryFile_buf;
+ err=NtQueryInformationFile(
+ captive_file_object->file_Handle, /* FileHandle */
+ &file_IoStatusBlock, /* IoStatusBlock */
+ (gpointer)QueryFile_buf, /* FileInformation */
+ sizeof(QueryFile_buf), /* Length */
+ FileStandardInformation); /* FileInformationClass; =>FILE_STANDARD_INFORMATION */
+ if (GNOME_VFS_OK!=(errvfsresult=captive_NTSTATUS_to_GnomeVFSResult(err)))
+ return errvfsresult;
+ g_return_val_if_fail(NT_SUCCESS(err)==NT_SUCCESS(file_IoStatusBlock.Status),GNOME_VFS_ERROR_GENERIC);
+ g_return_val_if_fail(NT_SUCCESS(err),GNOME_VFS_ERROR_GENERIC);
+ errvfsresult=FileStandardInformationStruct_to_GnomeVFSFileInfo(file_info,FileStandardInformationStruct);
g_return_val_if_fail(errvfsresult==GNOME_VFS_OK,errvfsresult);
return GNOME_VFS_OK;
/* FIXME: Everywhere is is the declaration with 4xLARGE_INTEGER+1xULONG==36 bytes
* but the precompiled ext2fsd.sys wants 40 bytes - why?
+ * The same case applies to ntfs.sys of NT-5.1sp1.
*/
g_assert(sizeof(FILE_BASIC_INFORMATION)==36);
g_assert(sizeof(FileBasicInformation_buf)==40);