wine/dlls/kernel volume.c
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Nov 22 09:03:27 CST 2005
ChangeSet ID: 21404
CVSROOT: /opt/cvs-commit
Module name: wine
Changes by: julliard at winehq.org 2005/11/22 09:03:27
Modified files:
dlls/kernel : volume.c
Log message:
Don't try to set the label in the superblock of FAT filesystems, that
doesn't do the right thing anyway.
Patch: http://cvs.winehq.org/patch.py?id=21404
Old revision New revision Changes Path
1.34 1.35 +9 -48 wine/dlls/kernel/volume.c
Index: wine/dlls/kernel/volume.c
diff -u -p wine/dlls/kernel/volume.c:1.34 wine/dlls/kernel/volume.c:1.35
--- wine/dlls/kernel/volume.c:1.34 22 Nov 2005 15: 3:27 -0000
+++ wine/dlls/kernel/volume.c 22 Nov 2005 15: 3:27 -0000
@@ -382,36 +382,6 @@ static void VOLUME_GetSuperblockLabel( e
/**************************************************************************
- * VOLUME_SetSuperblockLabel
- */
-static BOOL VOLUME_SetSuperblockLabel( enum fs_type type, HANDLE handle, const WCHAR *label )
-{
- CHAR label_data[11];
- DWORD offset, len;
-
- switch(type)
- {
- case FS_FAT1216:
- offset = 0x2b;
- break;
- case FS_FAT32:
- offset = 0x47;
- break;
- default:
- SetLastError( ERROR_ACCESS_DENIED );
- return FALSE;
- }
- RtlUnicodeToMultiByteN( label_data, sizeof(label_data), &len,
- label, strlenW(label) * sizeof(WCHAR) );
- if (len < sizeof(label_data))
- memset( label_data + len, ' ', sizeof(label_data) - len );
-
- return (SetFilePointer( handle, offset, NULL, FILE_BEGIN ) == offset &&
- WriteFile( handle, label_data, sizeof(label_data), &len, NULL ));
-}
-
-
-/**************************************************************************
* VOLUME_GetSuperblockSerial
*/
static DWORD VOLUME_GetSuperblockSerial( enum fs_type type, const BYTE *superblock )
@@ -699,31 +669,22 @@ BOOL WINAPI SetVolumeLabelW( LPCWSTR roo
/* try to open the device */
- handle = CreateFileW( device, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
+ handle = CreateFileW( device, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, 0 );
- if (handle == INVALID_HANDLE_VALUE)
- {
- /* try read-only */
- handle = CreateFileW( device, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING, 0, 0 );
- if (handle != INVALID_HANDLE_VALUE)
- {
- /* device can be read but not written, return error */
- CloseHandle( handle );
- SetLastError( ERROR_ACCESS_DENIED );
- return FALSE;
- }
- }
-
if (handle != INVALID_HANDLE_VALUE)
{
BYTE superblock[SUPERBLOCK_SIZE];
- BOOL ret;
type = VOLUME_ReadFATSuperblock( handle, superblock );
- ret = VOLUME_SetSuperblockLabel( type, handle, label );
+ if (type == FS_UNKNOWN) type = VOLUME_ReadCDSuperblock( handle, superblock );
CloseHandle( handle );
- return ret;
+ if (type != FS_UNKNOWN)
+ {
+ /* we can't set the label on FAT or CDROM file systems */
+ TRACE( "cannot set label on device %s type %d\n", debugstr_w(device), type );
+ SetLastError( ERROR_ACCESS_DENIED );
+ return FALSE;
+ }
}
else
{
More information about the wine-cvs
mailing list