summaryrefslogtreecommitdiffstats
path: root/lib/libstand
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2013-12-19 05:23:10 +0000
committermarcel <marcel@FreeBSD.org>2013-12-19 05:23:10 +0000
commitc05f51eb857d31a2d609b4d61a15caafb02fbbba (patch)
tree5ca9f5f75d1bd9cda1d527ae8e67ab1baebf2e32 /lib/libstand
parent8cbbd0b8f501ac1d41d017edc9ea3bac004643bb (diff)
downloadFreeBSD-src-c05f51eb857d31a2d609b4d61a15caafb02fbbba.zip
FreeBSD-src-c05f51eb857d31a2d609b4d61a15caafb02fbbba.tar.gz
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.
Diffstat (limited to 'lib/libstand')
-rw-r--r--lib/libstand/dosfs.c18
-rw-r--r--lib/libstand/dosfs.h3
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/libstand/dosfs.c b/lib/libstand/dosfs.c
index f43b721..72205a2 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 e44b6b5..9e5744d 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 {
OpenPOWER on IntegriCloud