From owner-svn-src-head@FreeBSD.ORG Mon Aug 5 04:53:05 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BCF24484; Mon, 5 Aug 2013 04:53:05 +0000 (UTC) (envelope-from jbeich@tormail.org) Received: from outgoing.tormail.org (outgoing.tormail.org [82.221.96.22]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6DFE527E4; Mon, 5 Aug 2013 04:53:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=internal.tormail.org) by outgoing.tormail.org with esmtp (Exim 4.72) (envelope-from ) id 1V6Cmy-0006Mn-Sb; Mon, 05 Aug 2013 08:53:01 +0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tormail.org; s=tm; h=Message-Id:Date:X-TorMail-User:Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From; bh=wONkO72ZP0aej/tlYJjsOOZeRQlOPF+KOSUD80ZygVw=; b=reoyxTLUiXd+kpgJxQ0t0jthG5Q48JitwryafC9ObvCjUdzvEPSz8w3gLYk/SMlgBRyBIWwkLjJz1Hw9iM/cw8zPcmHWbjIIdcU/S5tycw7XV/uly34QmBtwuevGVcQyhFRxoyMBj8Xygv9jgE6RG2egef1EcgOPm3jWiLYHqNM=; Received: from jbeich by internal.tormail.org with local (Exim 4.63) (envelope-from ) id 1V6Cmb-000M0k-0l; Mon, 05 Aug 2013 04:52:38 +0000 From: Jan Beich To: Marcel Moolenaar Subject: Re: svn commit: r253862 - head/sys/boot/ficl In-Reply-To: <953FDB6A-11EF-46D3-85D8-634952AF9309@xcllnt.net> (Marcel Moolenaar's message of "Sun, 4 Aug 2013 20:56:13 -0700") References: <201308011806.r71I6xpd088690@svn.freebsd.org> <1V65V2-0001RI-Fu@internal.tormail.org> <953FDB6A-11EF-46D3-85D8-634952AF9309@xcllnt.net> MIME-Version: 1.0 Content-Type: text/plain X-TorMail-User: jbeich Date: Mon, 05 Aug 2013 04:52:38 +0000 Message-Id: <1V6Cmb-000M0k-0l@internal.tormail.org> 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 04:53:05 -0000 Marcel Moolenaar writes: > 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 Except there'd be no FICL_FALSE after the last entry. Try running my lsdir function. > > 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. What's the issue with my version in bin/172542 ? It doesn't use d_reclen but relies on a side-effect of readdir() call. >> + static DIR *dir; >> + if (lseek(fd, 0, SEEK_CUR) == 0) >> + dir = fdopendir(fd); >> + if (dir != NULL) >> + d = readdir(dir);