svn commit: r253862 - head/sys/boot/ficl

Marcel Moolenaar marcel at xcllnt.net
Mon Aug 5 03:56:16 UTC 2013


On Aug 4, 2013, at 2:06 PM, Jan Beich <jbeich at tormail.org> wrote:

> Marcel Moolenaar <marcel at 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?

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 at xcllnt.net




More information about the svn-src-head mailing list