From owner-svn-src-all@FreeBSD.ORG Thu Dec 19 05:23:11 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 70E226CB; Thu, 19 Dec 2013 05:23:11 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4317C1A4F; Thu, 19 Dec 2013 05:23:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBJ5NBT4055858; Thu, 19 Dec 2013 05:23:11 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBJ5NA5f055856; Thu, 19 Dec 2013 05:23:10 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201312190523.rBJ5NA5f055856@svn.freebsd.org> From: Marcel Moolenaar Date: Thu, 19 Dec 2013 05:23:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259590 - head/lib/libstand X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Dec 2013 05:23:11 -0000 Author: marcel Date: Thu Dec 19 05:23:10 2013 New Revision: 259590 URL: http://svnweb.freebsd.org/changeset/base/259590 Log: 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. Modified: head/lib/libstand/dosfs.c head/lib/libstand/dosfs.h Modified: head/lib/libstand/dosfs.c ============================================================================== --- head/lib/libstand/dosfs.c Thu Dec 19 05:22:48 2013 (r259589) +++ head/lib/libstand/dosfs.c Thu Dec 19 05:23:10 2013 (r259590) @@ -162,6 +162,14 @@ dos_mount(DOS_FS *fs, struct open_file * (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 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 return ENOTDIR; if ((err = lookup(fs, stclus(fs->fatsz, de), name, &de))) return err; - if (*path == '/') - path++; } *dep = de; return 0; Modified: head/lib/libstand/dosfs.h ============================================================================== --- head/lib/libstand/dosfs.h Thu Dec 19 05:22:48 2013 (r259589) +++ head/lib/libstand/dosfs.h Thu Dec 19 05:23:10 2013 (r259590) @@ -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 {