+workaround for ext2fsd.sys with incorrect(?) FILE_BASIC_INFORMATION size
authorshort <>
Mon, 10 Feb 2003 10:11:34 +0000 (10:11 +0000)
committershort <>
Mon, 10 Feb 2003 10:11:34 +0000 (10:11 +0000)
 - all my W32 include sources have size 36; ext2fsd.sys has size 40

src/libcaptive/client/file.c

index ae41da7..4aeb93c 100644 (file)
@@ -553,23 +553,29 @@ err:
                }
 
        if (mask & (GNOME_VFS_SET_FILE_INFO_PERMISSIONS | GNOME_VFS_SET_FILE_INFO_TIME)) {
-FILE_BASIC_INFORMATION FileBasicInformation_struct;
+char FileBasicInformation_buf[sizeof(FILE_BASIC_INFORMATION)+4];
+FILE_BASIC_INFORMATION *FileBasicInformationp=(FILE_BASIC_INFORMATION *)FileBasicInformation_buf;
 IO_STATUS_BLOCK file_IoStatusBlock;
 NTSTATUS err;
 
+               /* FIXME: Everywhere is is the declaration with 4xLARGE_INTEGER+1xULONG==36 bytes
+                * but the precompiled ext2fsd.sys wants 40 bytes - why?
+                */
+               g_assert(sizeof(FILE_BASIC_INFORMATION)==36);
+               g_assert(sizeof(FileBasicInformation_buf)==40);
                err=NtQueryInformationFile(
                                captive_file_object->file_Handle,       /* FileHandle */
                                &file_IoStatusBlock,    /* IoStatusBlock */
-                               &FileBasicInformation_struct,   /* FileInformation */
-                               sizeof(FileBasicInformation_struct),    /* Length */
+                               FileBasicInformation_buf,       /* FileInformation */
+                               sizeof(FileBasicInformation_buf),       /* Length */
                                FileBasicInformation);  /* FileInformationClass */
                g_return_val_if_fail(NT_SUCCESS(err),GNOME_VFS_ERROR_GENERIC);
 
                if (mask & GNOME_VFS_SET_FILE_INFO_PERMISSIONS) {
-                       FileBasicInformation_struct.FileAttributes&=~FILE_ATTRIBUTE_READONLY;
+                       FileBasicInformationp->FileAttributes&=~FILE_ATTRIBUTE_READONLY;
                        g_assert(info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS);
                        if (!(info->permissions&0200))
-                               FileBasicInformation_struct.FileAttributes|=FILE_ATTRIBUTE_READONLY;
+                               FileBasicInformationp->FileAttributes|=FILE_ATTRIBUTE_READONLY;
                        }
 
                if (mask & GNOME_VFS_SET_FILE_INFO_TIME) {
@@ -580,26 +586,26 @@ NTSTATUS err;
                        if (info->valid_fields&GNOME_VFS_FILE_INFO_FIELDS_ATIME) {
                                RtlSecondsSince1970ToTime(
                                                info->atime,    /* SecondsSince1970 */
-                                               &FileBasicInformation_struct.LastAccessTime);   /* Time */
+                                               &FileBasicInformationp->LastAccessTime);        /* Time */
                                }
                        if (info->valid_fields&GNOME_VFS_FILE_INFO_FIELDS_MTIME) {
                                RtlSecondsSince1970ToTime(
                                                info->mtime,    /* SecondsSince1970 */
-                                               &FileBasicInformation_struct.LastWriteTime);    /* Time */
-                               FileBasicInformation_struct.ChangeTime=FileBasicInformation_struct.LastWriteTime;
+                                               &FileBasicInformationp->LastWriteTime); /* Time */
+                               FileBasicInformationp->ChangeTime=FileBasicInformationp->LastWriteTime;
                                }
                        if (info->valid_fields&GNOME_VFS_FILE_INFO_FIELDS_CTIME) {
                                RtlSecondsSince1970ToTime(
                                                info->ctime,    /* SecondsSince1970 */
-                                               &FileBasicInformation_struct.CreationTime);     /* Time */
+                                               &FileBasicInformationp->CreationTime);  /* Time */
                                }
                        }
 
                err=NtSetInformationFile(
                                captive_file_object->file_Handle,       /* FileHandle */
                                &file_IoStatusBlock,    /* IoStatusBlock */
-                               &FileBasicInformation_struct,   /* FileInformation */
-                               sizeof(FileBasicInformation_struct),    /* Length */
+                               FileBasicInformation_buf,       /* FileInformation */
+                               sizeof(FileBasicInformation_buf),       /* Length */
                                FileBasicInformation);  /* FileInformationClass */
                g_return_val_if_fail(NT_SUCCESS(err),GNOME_VFS_ERROR_GENERIC);
                }