From owner-svn-src-head@FreeBSD.ORG Mon Aug 5 03:56:15 2013 Return-Path: Delivered-To: svn-src-head@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 ESMTP id E77BCD49; Mon, 5 Aug 2013 03:56:15 +0000 (UTC) (envelope-from marcel@xcllnt.net) Received: from mail.xcllnt.net (mail.xcllnt.net [50.0.150.214]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BDC9D267E; Mon, 5 Aug 2013 03:56:15 +0000 (UTC) Received: from dhcp-192-168-2-38.wifi.xcllnt.net (50-0-150-213.dsl.static.sonic.net [50.0.150.213]) (authenticated bits=0) by mail.xcllnt.net (8.14.7/8.14.7) with ESMTP id r753uDmj077660 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Sun, 4 Aug 2013 20:56:14 -0700 (PDT) (envelope-from marcel@xcllnt.net) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Subject: Re: svn commit: r253862 - head/sys/boot/ficl From: Marcel Moolenaar In-Reply-To: <1V65V2-0001RI-Fu@internal.tormail.org> Date: Sun, 4 Aug 2013 20:56:13 -0700 Content-Transfer-Encoding: 7bit Message-Id: <953FDB6A-11EF-46D3-85D8-634952AF9309@xcllnt.net> References: <201308011806.r71I6xpd088690@svn.freebsd.org> <1V65V2-0001RI-Fu@internal.tormail.org> To: Jan Beich X-Mailer: Apple Mail (2.1508) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Marcel Moolenaar , src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Aug 2013 03:56:16 -0000 On Aug 4, 2013, at 2:06 PM, Jan Beich wrote: > Marcel Moolenaar writes: > >> + static union { >> + struct dirent dirent; >> + char buf[512]; >> + } u; >> + off_t off; >> + int len; > [...] >> + /* >> + * The readdirfd() function is specific to the loader environment. >> + * We do the best we can to make freaddir work, but it's not at >> + * all guaranteed. >> + */ >> + off = lseek(fd, 0LL, SEEK_CUR); >> + len = getdents(fd, u.buf, sizeof(u.buf)); >> + d = (len != -1) ? &u.dirent : NULL; >> + if (d != NULL) >> + lseek(fd, off + d->d_reclen, SEEK_SET); > > How did you test? On amd64 with UFS. The problem is that using d_reclen to get to the next dirent is highly non-portable and depends on the FS used: fbsdvm64% uname -m amd64 fbsdvm64% pwd /usr/src/sys/boot/ficl fbsdvm64% ./testmain ficl Version 3.03 Aug 4 2013 ok> s" /bin" 0 fopen . cr 3 ok> 3 freaddir . type cr -1 . ok> 3 freaddir . type cr -1 .. ok> 3 freaddir . type cr -1 chflags ok> 3 freaddir . type cr -1 [ ok> 3 freaddir . type cr -1 cat ok> 3 freaddir . type cr -1 domainname ok> 3 freaddir . type cr -1 chio ok> 3 freaddir . type cr -1 chmod ok> 3 freaddir . type cr -1 cp ok> 3 freaddir . type cr -1 csh It's probably not going to work on any other FS. The alternative is to just not support freaddir due to lack of runtime support. FYI, -- Marcel Moolenaar marcel@xcllnt.net