diff options
author | dwhite <dwhite@FreeBSD.org> | 2005-11-09 22:03:50 +0000 |
---|---|---|
committer | dwhite <dwhite@FreeBSD.org> | 2005-11-09 22:03:50 +0000 |
commit | 0bcdf7c0332746573fc0de7a81621778fcca937b (patch) | |
tree | df01b7b1216dc56834f356e58c27cfda7c5ae598 /sys/fs | |
parent | fc360a564f423f6153219166750b4335eee05f51 (diff) | |
download | FreeBSD-src-0bcdf7c0332746573fc0de7a81621778fcca937b.zip FreeBSD-src-0bcdf7c0332746573fc0de7a81621778fcca937b.tar.gz |
This is a workaround for a complicated issue involving VFS cookies and devfs.
The PR and patch have the details. The ultimate fix requires architectural
changes and clarifications to the VFS API, but this will prevent the system
from panicking when someone does "ls /dev" while running in a shell under the
linuxulator.
This issue affects HEAD and RELENG_6 only.
PR: 88249
Submitted by: "Devon H. O'Dell" <dodell@ixsystems.com>
MFC after: 3 days
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 7fbcad0..d567ea5 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -797,6 +797,7 @@ devfs_readdir(struct vop_readdir_args *ap) struct devfs_dirent *de; struct devfs_mount *dmp; off_t off, oldoff; + int *tmp_ncookies = NULL; if (ap->a_vp->v_type != VDIR) return (ENOTDIR); @@ -805,6 +806,21 @@ devfs_readdir(struct vop_readdir_args *ap) if (uio->uio_offset < 0) return (EINVAL); + /* + * XXX: This is a temporary hack to get around this filesystem not + * supporting cookies. We store the location of the ncookies pointer + * in a temporary variable before calling vfs_subr.c:vfs_read_dirent() + * and set the number of cookies to 0. We then set the pointer to + * NULL so that vfs_read_dirent doesn't try to call realloc() on + * ap->a_cookies. Later in this function, we restore the ap->a_ncookies + * pointer to its original location before returning to the caller. + */ + if (ap->a_ncookies != NULL) { + tmp_ncookies = ap->a_ncookies; + *ap->a_ncookies = 0; + ap->a_ncookies = NULL; + } + dmp = VFSTODEVFS(ap->a_vp->v_mount); sx_xlock(&dmp->dm_lock); devfs_populate(dmp); @@ -833,6 +849,14 @@ devfs_readdir(struct vop_readdir_args *ap) } sx_xunlock(&dmp->dm_lock); uio->uio_offset = off; + + /* + * Restore ap->a_ncookies if it wasn't originally NULL in the first + * place. + */ + if (tmp_ncookies != NULL) + ap->a_ncookies = tmp_ncookies; + return (error); } |