Date: Sun, 04 Aug 2013 21:06:05 +0000 From: Jan Beich <jbeich@tormail.org> To: Marcel Moolenaar <marcel@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r253862 - head/sys/boot/ficl Message-ID: <1V65V2-0001RI-Fu@internal.tormail.org> In-Reply-To: <201308011806.r71I6xpd088690@svn.freebsd.org> (Marcel Moolenaar's message of "Thu, 1 Aug 2013 18:06:59 %2B0000 (UTC)") References: <201308011806.r71I6xpd088690@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Marcel Moolenaar <marcel@FreeBSD.org> 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? I can't make the code work on amd64 using
either ficl32 or ficl64.
# r253862
ok> s" /bin" 0 fopen
ok> dup freaddir . type cr
-1 .
ok> dup freaddir . type cr
-1 sleep
ok> dup freaddir . type cr
-1 sleep
ok> dup freaddir . type cr
-1 sleep
ok> dup freaddir . type cr
-1 sleep
# bin/172542
ok> s" /bin" 0 fopen
ok> dup freaddir . type cr
-1 .
ok> dup freaddir . type cr
-1 ..
ok> dup freaddir . type cr
-1 sleep
ok> dup freaddir . type cr
-1 domainname
ok> dup freaddir . type cr
-1 ps
ok> dup freaddir . type cr
-1 sync
ok> dup freaddir . type cr
-1 red
# zfsloader (no '.' and '..' - zfs_readdir bug?)
OK s" /bin" 0 fopen
OK dup freaddir . type cr
-1 cat
OK dup freaddir . type cr
-1 sh
OK dup freaddir . type cr
-1 chflags
OK dup freaddir . type cr
-1 chio
OK dup freaddir . type cr
-1 sleep
OK dup freaddir . type cr
-1 chmod
Here's an example with a loop almost endless.
# r253862
ok> s" /bin" lsdir
.
sleep
sleep
sleep
...
\ list directory contents
: lsdir ( dir -- )
0 fopen
begin
dup
freaddir
while
type cr
repeat
fclose
;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1V65V2-0001RI-Fu>
