Fix file handle operations for tmpfs by removing a now bogus test and

fixing the return value of tmpfs_fhtovp() in the not-found case.

When vmlocking2 was merged to head (Jan 2008 !!) the inode numbering was
changed.  Before inodes were numbered 2..tm_nodes_max-1 and after the
merge the numbers are derived from the nodes memory address.

Fixes PR #43605 (tmpfs file handles are broken)
This commit is contained in:
hannken 2011-04-02 14:24:53 +00:00
parent b50095d784
commit 032b3dee5f
2 changed files with 4 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_vfsops.c,v 1.46 2010/06/26 03:38:14 rmind Exp $ */
/* $NetBSD: tmpfs_vfsops.c,v 1.47 2011/04/02 14:24:53 hannken Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.46 2010/06/26 03:38:14 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.47 2011/04/02 14:24:53 hannken Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -278,9 +278,6 @@ tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
memcpy(&tfh, fhp, sizeof(struct tmpfs_fid));
if (tfh.tf_id >= tmp->tm_nodes_max)
return EINVAL;
found = false;
mutex_enter(&tmp->tm_lock);
LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) {
@ -293,7 +290,7 @@ tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
mutex_exit(&tmp->tm_lock);
/* XXXAD nothing to prevent 'node' from being removed. */
return found ? tmpfs_alloc_vp(mp, node, vpp) : EINVAL;
return found ? tmpfs_alloc_vp(mp, node, vpp) : ESTALE;
}
/* --------------------------------------------------------------------- */

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_vfsops.c,v 1.9 2011/01/07 12:01:11 pooka Exp $ */
/* $NetBSD: t_vfsops.c,v 1.10 2011/04/02 14:24:53 hannken Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -108,11 +108,6 @@ tfilehandle(const atf_tc_t *tc, const char *path)
/* open file based on file handle */
fd = rump_sys_fhopen(fhp, fhsize, O_RDONLY);
if (FSTYPE_TMPFS(tc)) {
atf_tc_expect_fail("PR kern/43605");
if (fd != -1 || errno != EINVAL)
atf_tc_expect_pass();
}
if (fd == -1) {
atf_tc_fail_errno("fhopen");
}
@ -154,8 +149,6 @@ tfhremove(const atf_tc_t *tc, const char *path)
if (FSTYPE_MSDOS(tc) || FSTYPE_LFS(tc))
atf_tc_expect_fail("fhopen() for removed file succeeds "
"(PR kern/43745)");
if (FSTYPE_TMPFS(tc))
atf_tc_expect_fail("PR kern/43605");
ATF_REQUIRE_ERRNO(ESTALE, rump_sys_fhopen(fhp, fhsize, O_RDONLY) == -1);
atf_tc_expect_pass();
@ -175,8 +168,6 @@ tfhinval(const atf_tc_t *tc, const char *path)
unsigned long seed;
int fd;
/* XXX: this test succeeds "accidentally" on tmpfs, PR kern/43605 */
srandom(seed = time(NULL));
printf("RNG seed %lu\n", seed);