Module Name: src Committed By: hannken Date: Sat Apr 2 14:24:53 UTC 2011
Modified Files: src/sys/fs/tmpfs: tmpfs_vfsops.c src/tests/fs/vfs: t_vfsops.c Log Message: 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) To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.9 -r1.10 src/tests/fs/vfs/t_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.46 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.47 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.46 Sat Jun 26 03:38:14 2010 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Sat Apr 2 14:24:53 2011 @@ -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 @@ 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 @@ 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; } /* --------------------------------------------------------------------- */ Index: src/tests/fs/vfs/t_vfsops.c diff -u src/tests/fs/vfs/t_vfsops.c:1.9 src/tests/fs/vfs/t_vfsops.c:1.10 --- src/tests/fs/vfs/t_vfsops.c:1.9 Fri Jan 7 12:01:11 2011 +++ src/tests/fs/vfs/t_vfsops.c Sat Apr 2 14:24:53 2011 @@ -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 @@ /* 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 @@ 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 @@ 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);