Add more strictly size check into Fdopen to eliminate
possible end-user errors. Now: 1) on physical 1.2 can open logical 1.2, 720, 360H 2) on physical 1.44 can open logical 1.44, 720 3) on physical 360 can open logical 360 All other variants refused. C-style improved in this check, multiply if's changed to switch.
This commit is contained in:
parent
dffff499a9
commit
fa4700b4f1
@ -529,10 +529,20 @@ Fdopen(dev, flags)
|
||||
if (fdu >= NFD || fd_data[fdu].fdc == NULL
|
||||
|| fd_data[fdu].type == NO_TYPE) return(ENXIO);
|
||||
if (type >= NUMTYPES) return(ENXIO);
|
||||
if (fd_data[fdu].type == FD360 && type != FD360)
|
||||
return(ENXIO);
|
||||
if (fd_data[fdu].type == FD12 && type == FD144)
|
||||
return(ENXIO);
|
||||
switch (fd_data[fdu].type) {
|
||||
case FD360:
|
||||
if (type != FD360)
|
||||
return(ENXIO);
|
||||
break;
|
||||
case FD12:
|
||||
if (type == FD144 || type == FD360)
|
||||
return(ENXIO);
|
||||
break;
|
||||
case FD144:
|
||||
if (type == FD12 || type == FD360 || type == FD360H)
|
||||
return(ENXIO);
|
||||
break;
|
||||
}
|
||||
fd_data[fdu].ft = fd_types + type;
|
||||
fd_data[fdu].flags |= FD_OPEN;
|
||||
|
||||
|
@ -529,10 +529,20 @@ Fdopen(dev, flags)
|
||||
if (fdu >= NFD || fd_data[fdu].fdc == NULL
|
||||
|| fd_data[fdu].type == NO_TYPE) return(ENXIO);
|
||||
if (type >= NUMTYPES) return(ENXIO);
|
||||
if (fd_data[fdu].type == FD360 && type != FD360)
|
||||
return(ENXIO);
|
||||
if (fd_data[fdu].type == FD12 && type == FD144)
|
||||
return(ENXIO);
|
||||
switch (fd_data[fdu].type) {
|
||||
case FD360:
|
||||
if (type != FD360)
|
||||
return(ENXIO);
|
||||
break;
|
||||
case FD12:
|
||||
if (type == FD144 || type == FD360)
|
||||
return(ENXIO);
|
||||
break;
|
||||
case FD144:
|
||||
if (type == FD12 || type == FD360 || type == FD360H)
|
||||
return(ENXIO);
|
||||
break;
|
||||
}
|
||||
fd_data[fdu].ft = fd_types + type;
|
||||
fd_data[fdu].flags |= FD_OPEN;
|
||||
|
||||
|
18
sys/isa/fd.c
18
sys/isa/fd.c
@ -529,10 +529,20 @@ Fdopen(dev, flags)
|
||||
if (fdu >= NFD || fd_data[fdu].fdc == NULL
|
||||
|| fd_data[fdu].type == NO_TYPE) return(ENXIO);
|
||||
if (type >= NUMTYPES) return(ENXIO);
|
||||
if (fd_data[fdu].type == FD360 && type != FD360)
|
||||
return(ENXIO);
|
||||
if (fd_data[fdu].type == FD12 && type == FD144)
|
||||
return(ENXIO);
|
||||
switch (fd_data[fdu].type) {
|
||||
case FD360:
|
||||
if (type != FD360)
|
||||
return(ENXIO);
|
||||
break;
|
||||
case FD12:
|
||||
if (type == FD144 || type == FD360)
|
||||
return(ENXIO);
|
||||
break;
|
||||
case FD144:
|
||||
if (type == FD12 || type == FD360 || type == FD360H)
|
||||
return(ENXIO);
|
||||
break;
|
||||
}
|
||||
fd_data[fdu].ft = fd_types + type;
|
||||
fd_data[fdu].flags |= FD_OPEN;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user