[ 1/3] kernel32/tests: Add tests for GetVolumeInformationA and volume enumeration

Alexandre Julliard julliard at winehq.org
Wed Apr 8 06:17:12 CDT 2009


Guy Albertelli <galberte at neo.rr.com> writes:

>      BOOL found = FALSE;
>  
> +    buffer = VirtualAlloc( NULL, buflen, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE );

HeapAlloc is preferable.

> +        /* test the result of opening a volume id (no trailing \)   */
> +        /* this should work.  It provides access to the disk volume */
> +        /* starting with the first sector                           */
> +        Volume[eos] = 0;
> +        hFile = CreateFileA( Volume, GENERIC_READ | GENERIC_WRITE,
> +                        FILE_SHARE_READ | FILE_SHARE_WRITE,
> +                        NULL, OPEN_EXISTING,
> +                        FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL );
> +        /* wine currently returns 5 (ERROR_ACCESS_DENIED) for normal      */
> +        /*  volume ids (normal drive letters, ex C: -> ..\drive_c         */
> +        /* **cause: side effect of opening directory                      */
> +        /* **         gets STATUS_INVALID_PARAMETER from NtCreateFile     */
> +        /* **          which comes from server(create_file)               */
> +        /* **           which comes from server(open_fd) because the open */
> +        /* **            either open writable or readonly gives EISDIR.   */
> +        /* **            Then NtCreateFile returns status 0xC00000BA      */
> +        /* **            (STATUS_FILE_IS_A_DIRECTORY which is then        */
> +        /* **            changed to ERROR_ACCESS_DENIED                   */
> +        /* The only time wine works is when the unix translation is a     */
> +        /* special file (ex: /dev/sdx).  If that special device is        */
> +        /* readable (or r/w) for the user then the open succeeds.  This   */
> +        /* allows the picture keychain to work if I set its permissions   */
> +        /* correctly.                                                     */
> +        todo_wine ok(hFile != INVALID_HANDLE_VALUE && GetLastError() == ERROR_SUCCESS,
> +            "CreateFileA did not work, last error %u for device <%s> on volume <%s>\n",
> +             GetLastError(), Dev_Name, Volume );

This will fail on many Windows platforms too, you can't always open the
raw device. And the tests are not the appropriate place for documenting
Wine implementation details that are subject to change.

> +            if (ret)
> +            {
> +                trace( "First 64 bytes of volume <%s>, for device <%s>\n",
> +                        Volume, Dev_Name );
> +                dumpmem( buffer, 64 );
> +                if (pGetVolumeInformationA)
> +                {
> +                    /* need the traling \ for the API */
> +                    Volume[eos] = '\\';
> +                    ret = pGetVolumeInformationA(Volume, vol_name_buf,
> +                            vol_name_size, NULL, NULL, NULL, fs_name_buf,
> +                            fs_name_len);
> +                    ok(ret, "GetVolumeInformationA failed, root=%s, last error %u\n",
> +                            Volume, GetLastError());
> +                    if (ret && strcmp(fs_name_buf, "NTFS")==0)
> +                    {
> +                        /* If the filesystem is NTFS, then NTFS is in the */
> +                        /* first few bytes of the first block of the fs   */
> +                        p = (char *)(buffer + 3);
> +                        ok(strncmp(p, "NTFS", 4)==0,
> +                            "NTFS file system does not match block read\n");
> +                    }

This will probably never work on Wine, what's the point of that test?

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list