diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 2013-12-19 05:23:10 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2013-12-19 05:23:10 +0000 |
commit | 72cad431b894792d06367622aaefd45e2c3f3cbf (patch) | |
tree | 5ca9f5f75d1bd9cda1d527ae8e67ab1baebf2e32 /lib | |
parent | 18f3ddcdee3af2f6ff14d8f9c55891b1ac669486 (diff) | |
download | src-72cad431b894792d06367622aaefd45e2c3f3cbf.tar.gz src-72cad431b894792d06367622aaefd45e2c3f3cbf.zip |
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.
Notes
Notes:
svn path=/head/; revision=259590
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libstand/dosfs.c | 18 | ||||
-rw-r--r-- | lib/libstand/dosfs.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/libstand/dosfs.c b/lib/libstand/dosfs.c index f43b7213ee7e..72205a2c648a 100644 --- a/lib/libstand/dosfs.c +++ b/lib/libstand/dosfs.c @@ -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; diff --git a/lib/libstand/dosfs.h b/lib/libstand/dosfs.h index e44b6b51f288..9e5744de2e5c 100644 --- a/lib/libstand/dosfs.h +++ b/lib/libstand/dosfs.h @@ -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 { |