CDROM fix
Eric Pouech
eric.pouech at wanadoo.fr
Mon Apr 22 15:36:48 CDT 2002
always close fd on cdrom after trying to read the super block
seems to prevent wild drive spinning and some unwished cdrom
locking
A+
-------------- next part --------------
Name: drive_sb
ChangeLog: always close fd when reading super block
License: X11
GenDate: 2002/04/22 19:27:23 UTC
ModifiedFiles: files/drive.c
AddedFiles:
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/files/drive.c,v
retrieving revision 1.67
diff -u -u -r1.67 drive.c
--- files/drive.c 9 Mar 2002 23:50:37 -0000 1.67
+++ files/drive.c 22 Apr 2002 17:54:52 -0000
@@ -521,6 +521,7 @@
#define DRIVE_SUPER 96
int fd;
off_t offs;
+ int ret = 0;
if (memset(buff,0,DRIVE_SUPER)!=buff) return -1;
if ((fd=open(DOSDrives[drive].device,O_RDONLY)) == -1)
@@ -551,8 +552,16 @@
break;
}
- if ((offs) && (lseek(fd,offs,SEEK_SET)!=offs)) return -4;
- if (read(fd,buff,DRIVE_SUPER)!=DRIVE_SUPER) return -2;
+ if ((offs) && (lseek(fd,offs,SEEK_SET)!=offs))
+ {
+ ret = -4;
+ goto the_end;
+ }
+ if (read(fd,buff,DRIVE_SUPER)!=DRIVE_SUPER)
+ {
+ ret = -2;
+ goto the_end;
+ }
switch(DOSDrives[drive].type)
{
@@ -565,20 +574,27 @@
{
ERR("The filesystem is not FAT !! (device=%s)\n",
DOSDrives[drive].device);
- return -3;
+ ret = -3;
+ goto the_end;
}
break;
case DRIVE_CDROM:
if (strncmp(&buff[1],"CD001",5)) /* Check for iso9660 present */
- return -3;
+ {
+ ret = -3;
+ goto the_end;
+ }
/* FIXME: do we need to check for "CDROM", too ? (high sierra) */
- break;
+ break;
default:
- return -3;
- break;
+ ret = -3;
+ goto the_end;
}
return close(fd);
+ the_end:
+ close(fd);
+ return ret;
}
More information about the wine-patches
mailing list