diff --git a/kernel/fatdir.c b/kernel/fatdir.c index c9abe9f..8f0f110 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -68,8 +68,7 @@ f_node_ptr dir_open(register const char *dirname, BOOL split, f_node_ptr fnp) /* Perform all directory common handling after all special */ /* handling has been performed. */ - if (media_check(fnp->f_dpb) < 0) - return (f_node_ptr) 0; + /* truename() already did a media check() */ /* Walk the directory tree to find the starting cluster */ /* */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 8fa565d..b131a85 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1482,10 +1482,7 @@ CLUSTER dos_free(struct dpb FAR * dpbp) int dos_cd(char * PathName) { f_node_ptr fnp; - struct cds FAR *cdsp = get_cds(PathName[0] - 'A'); - - if ((media_check(cdsp->cdsDpb) < 0)) - return DE_INVLDDRV; + struct cds FAR *cdsp; /* now test for its existance. If it doesn't, return an error. */ if ((fnp = dir_open(PathName, FALSE, &fnode[0])) == NULL) @@ -1493,6 +1490,7 @@ int dos_cd(char * PathName) /* problem: RBIL table 01643 does not give a FAT32 field for the CDS start cluster. But we are not using this field ourselves */ + cdsp = get_cds(PathName[0] - 'A'); cdsp->cdsStrtClst = (UWORD)fnp->f_dmp->dm_dircluster; return SUCCESS; } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 731b96d..c92ab14 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -466,14 +466,16 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) cp[MAX_CDSPATH - 1] = '\0'; if ((TempCDS.cdsFlags & CDSNETWDRV) == 0) { + if ((media_check(TempCDS.cdsDpb) < 0)) + return DE_PATHNOTFND; + /* dos_cd ensures that the path exists; if not, we need to change to the root directory */ - int result = dos_cd(cp); - if (result == DE_PATHNOTFND) + if (dos_cd(cp) != SUCCESS) { cp[TempCDS.cdsBackslashOffset + 1] = cdsEntry->cdsCurrentPath[TempCDS.cdsBackslashOffset + 1] = '\0'; - else if (result < SUCCESS) - return DE_PATHNOTFND; + dos_cd(cp); + } } cp += TempCDS.cdsBackslashOffset;