in some fs (ie. procfs), readdir won't return a cookie, so calculate it based on the offset and reclen. with this, a emulated ls binary (ie. linux) correctly list the files in such filesystems.  also plug some memory leak and remove a unneeded panic. adapted from FreeBSD. henning@ tedu@ ok. some other people ok'ed this in the past as well.
in some fs (ie. procfs), readdir won't return a cookie, so calculate
it based on the offset and reclen. with this, a emulated ls binary
(ie. linux) correctly list the files in such filesystems.  also plug some
memory leak and remove a unneeded panic.
adapted from FreeBSD.
henning@ tedu@ ok. some other people ok'ed this in the past as well.

orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars,orumin/openbsd-efivars