Making Linux stat() less evil
Roman Divacky
rdivacky at FreeBSD.org
Thu Feb 19 13:00:01 PST 2009
On Thu, Feb 19, 2009 at 09:56:45PM +0100, Ed Schouten wrote:
> Hi folks,
>
> I may have mentioned this earlier, but our Linuxolator's stat()
> implementation calls kern_openat(), followed by an
> translate_fd_major_minor() to perform a device major/minor number
> lookup. This is very evil, because it causes random chardevs to be
> opened when you run ls -l /dev.
>
> I propose the following patch:
>
> http://80386.nl/pub/linux-stat.diff
>
> I've copied kern_stat() into the Linuxolator. Not the ideal solution,
> but it's better than what we have right now. Comments?
why cant you use kern_statat() and perform this after it returns?
+ if (S_ISCHR(sb.st_mode) && nd.ni_vp->v_un.vu_cdev != NULL &&
+ linux_driver_get_major_minor(
+ nd.ni_vp->v_un.vu_cdev->si_name, &major, &minor) == 0) {
+ sb.st_rdev = (major << 8 | minor);
+ }
More information about the freebsd-emulation
mailing list