From: Ben Gras Date: Tue, 16 Oct 2007 14:31:35 +0000 (+0000) Subject: Internally, floppy driver still used vircopies ('unsafe' copies), but X-Git-Tag: v3.1.4~319 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch09.html?a=commitdiff_plain;h=af591d2151372aec552e50f635cdf9609824fafd;p=minix.git Internally, floppy driver still used vircopies ('unsafe' copies), but this isn't allowed in its drivers.conf entry. Changed these to memcpy() calls. Bug reported by Maurizio Lombardi in comp.os.minix. --- diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index 9891c330e..f21c4de7b 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -24,6 +24,7 @@ #include "floppy.h" #include +#include #include #include #include @@ -458,6 +459,12 @@ int safe; return OK; /* Way beyond EOF */ position= cv64ul(pos64); + /* internally, floppy uses f_transfer without grant id, with safe set to + * 0. This is OK, as long as proc_nr is SELF. + */ + if(!safe && proc_nr != SELF) + panic("FLOPPY", "f_transfer: not safe and proc_nr not SELF", proc_nr); + /* Check disk address. */ if ((position & SECTOR_MASK) != 0) return(EINVAL); @@ -490,16 +497,15 @@ int safe; s=sys_safecopyfrom(proc_nr, iov->iov_addr, SECTOR_SIZE + iov_offset, (vir_bytes) &fmt_param, (phys_bytes) sizeof(fmt_param), D); + if(s != OK) + panic("FLOPPY", "sys_safecopyfrom failed", s); } else { - s=sys_datacopy(proc_nr, iov->iov_addr + - SECTOR_SIZE + iov_offset, - SELF, (vir_bytes) &fmt_param, - (phys_bytes) sizeof(fmt_param)); + assert(proc_nr == SELF); + memcpy(&fmt_param, (void *) (iov->iov_addr + + SECTOR_SIZE + iov_offset), + (phys_bytes) sizeof(fmt_param)); } - if(s != OK) - panic("FLOPPY", "Sys_*copy failed", s); - /* Check that the number of sectors in the data is reasonable, * to avoid division by 0. Leave checking of other data to * the FDC. @@ -598,13 +604,12 @@ int safe; s=sys_safecopyfrom(proc_nr, *ug, *up, (vir_bytes) tmp_buf, (phys_bytes) SECTOR_SIZE, D); + if(s != OK) + panic("FLOPPY", "sys_safecopyfrom failed", s); } else { - s=sys_datacopy(proc_nr, *ug + *up, SELF, - (vir_bytes) tmp_buf, - (phys_bytes) SECTOR_SIZE); + assert(proc_nr == SELF); + memcpy(tmp_buf, (void *) (*ug + *up), SECTOR_SIZE); } - if(s != OK) - panic("FLOPPY", "Sys_vircopy failed", s); } /* Set up the DMA chip and perform the transfer. */ @@ -625,13 +630,12 @@ int safe; s=sys_safecopyto(proc_nr, *ug, *up, (vir_bytes) tmp_buf, (phys_bytes) SECTOR_SIZE, D); + if(s != OK) + panic("FLOPPY", "sys_safecopyto failed", s); } else { - s=sys_datacopy(SELF, (vir_bytes) tmp_buf, - proc_nr, *ug + *up, - (phys_bytes) SECTOR_SIZE); + assert(proc_nr == SELF); + memcpy((void *) (*ug + *up), tmp_buf, SECTOR_SIZE); } - if(s != OK) - panic("FLOPPY", "Sys_vircopy failed", s); } if (r != OK) {