Fix readdir for the root directory on a FAT32 file system. The root
directory is like any subdirectory and as such needs to use a real cluster number. To this end, keep a DE structure for the root in the DOS_FS structure and populate it accordingly. While here: o allow consecutive path separators by skipping them all. o add missing $FreeBSD$ keyword to dosfs.h.
This commit is contained in:
parent
18f3ddcdee
commit
72cad431b8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=259590
@ -162,6 +162,14 @@ dos_mount(DOS_FS *fs, struct open_file *fd)
|
||||
(void)dosunmount(fs);
|
||||
return(err);
|
||||
}
|
||||
fs->root = dot[0];
|
||||
fs->root.name[0] = ' ';
|
||||
if (fs->fatsz == 32) {
|
||||
fs->root.clus[0] = fs->rdcl & 0xff;
|
||||
fs->root.clus[1] = (fs->rdcl >> 8) & 0xff;
|
||||
fs->root.dex.h_clus[0] = (fs->rdcl >> 16) & 0xff;
|
||||
fs->root.dex.h_clus[1] = (fs->rdcl >> 24) & 0xff;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -494,10 +502,12 @@ namede(DOS_FS *fs, const char *path, DOS_DE **dep)
|
||||
int err;
|
||||
|
||||
err = 0;
|
||||
de = dot;
|
||||
if (*path == '/')
|
||||
path++;
|
||||
de = &fs->root;
|
||||
while (*path) {
|
||||
while (*path == '/')
|
||||
path++;
|
||||
if (*path == '\0')
|
||||
break;
|
||||
if (!(s = strchr(path, '/')))
|
||||
s = strchr(path, 0);
|
||||
if ((n = s - path) > 255)
|
||||
@ -509,8 +519,6 @@ namede(DOS_FS *fs, const char *path, DOS_DE **dep)
|
||||
return ENOTDIR;
|
||||
if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de)))
|
||||
return err;
|
||||
if (*path == '/')
|
||||
path++;
|
||||
}
|
||||
*dep = de;
|
||||
return 0;
|
||||
|
@ -23,6 +23,8 @@
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef DOSIO_H
|
||||
@ -108,6 +110,7 @@ typedef struct {
|
||||
u_int lsndta; /* start of data area */
|
||||
u_int fatsz; /* FAT entry size */
|
||||
u_int xclus; /* maximum cluster number */
|
||||
DOS_DE root;
|
||||
} DOS_FS;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user