CVS commit: src/tests/fs/vfs
Module Name:src Committed By: andvar Date: Mon May 8 19:23:45 UTC 2023 Modified Files: src/tests/fs/vfs: t_vnops.c Log Message: fix the grammar in comments reported by Jim Spath in misc/57397. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/tests/fs/vfs/t_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_vnops.c diff -u src/tests/fs/vfs/t_vnops.c:1.62 src/tests/fs/vfs/t_vnops.c:1.63 --- src/tests/fs/vfs/t_vnops.c:1.62 Tue Feb 1 18:27:24 2022 +++ src/tests/fs/vfs/t_vnops.c Mon May 8 19:23:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: t_vnops.c,v 1.62 2022/02/01 18:27:24 martin Exp $ */ +/* $NetBSD: t_vnops.c,v 1.63 2023/05/08 19:23:45 andvar Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -104,9 +104,9 @@ lookup_complex(const atf_tc_t *tc, const * The lookup is permitted to modify the access time of * any directories searched - such a directory is the * subject of this test. Any difference should cause - * the 2nd lookup atime tp be >= the first, if it is ==, all is + * the 2nd lookup atime to be >= the first, if it is ==, all is * OK (atime is not required to be modified by the search, or - * both references may happen within the came clock tick), if the + * both references may happen within the same clock tick), if the * 2nd lookup atime is > the first, but not "too much" greater, * just set it back, so the memcmp just below succeeds * (assuming all else is OK). @@ -167,7 +167,7 @@ dir_simple(const atf_tc_t *tc, const cha if (rump_sys_stat(pb, &sb) == -1) atf_tc_fail_errno("stat new directory"); - /* check we can remove then and that it makes them unreachable */ + /* check we can remove them and that it makes them unreachable */ if (rump_sys_rmdir(pb) == -1) atf_tc_fail_errno("rmdir"); if (rump_sys_stat(pb, &sb) != -1 || errno != ENOENT)
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: andvar Date: Mon May 8 19:23:45 UTC 2023 Modified Files: src/tests/fs/vfs: t_vnops.c Log Message: fix the grammar in comments reported by Jim Spath in misc/57397. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/tests/fs/vfs/t_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Wed Mar 30 16:35:28 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: remove zfs from the exception list; it now works like the other fs's. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_link.c diff -u src/tests/fs/vfs/t_link.c:1.4 src/tests/fs/vfs/t_link.c:1.5 --- src/tests/fs/vfs/t_link.c:1.4 Wed Mar 30 10:24:50 2022 +++ src/tests/fs/vfs/t_link.c Wed Mar 30 12:35:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_link.c,v 1.4 2022/03/30 14:24:50 christos Exp $ */ +/* $NetBSD: t_link.c,v 1.5 2022/03/30 16:35:28 christos Exp $ */ /*- * Copyright (c) 2022 The NetBSD Foundation, Inc. @@ -53,10 +53,6 @@ if (FSTYPE_PUFFS(tc) || FSTYPE_P2K_FFS(tc)) \ atf_tc_skip("userlevel pass not supported, " \ "since sysctl might not be set in underlying system") -#define USES_OWNCHECK \ - if (FSTYPE_ZFS(tc)) \ - atf_tc_skip("zfs not supported since it has its " \ - "own rules for hardlinks") static void @@ -69,7 +65,6 @@ hardlink(const atf_tc_t *tc, const char USES_OWNER; USES_USERLEVEL; - USES_OWNCHECK; FSTEST_ENTER();
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Wed Mar 30 16:35:28 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: remove zfs from the exception list; it now works like the other fs's. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Wed Mar 30 14:24:50 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: update copyright. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_link.c diff -u src/tests/fs/vfs/t_link.c:1.3 src/tests/fs/vfs/t_link.c:1.4 --- src/tests/fs/vfs/t_link.c:1.3 Wed Mar 30 09:43:42 2022 +++ src/tests/fs/vfs/t_link.c Wed Mar 30 10:24:50 2022 @@ -1,9 +1,12 @@ -/* $NetBSD: t_link.c,v 1.3 2022/03/30 13:43:42 christos Exp $ */ +/* $NetBSD: t_link.c,v 1.4 2022/03/30 14:24:50 christos Exp $ */ /*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. + * Copyright (c) 2022 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met:
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Wed Mar 30 14:24:50 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: update copyright. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Wed Mar 30 13:43:42 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: skip userlevel filesystems that have their own rules (they depend on the system setting of the sysctl on NetBSD) and zfs because it implements its own rules for hardlinks to files (does its own permission checks). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_link.c diff -u src/tests/fs/vfs/t_link.c:1.2 src/tests/fs/vfs/t_link.c:1.3 --- src/tests/fs/vfs/t_link.c:1.2 Tue Mar 29 18:30:07 2022 +++ src/tests/fs/vfs/t_link.c Wed Mar 30 09:43:42 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_link.c,v 1.2 2022/03/29 22:30:07 christos Exp $ */ +/* $NetBSD: t_link.c,v 1.3 2022/03/30 13:43:42 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -43,9 +43,17 @@ #include "../common/h_fsmacros.h" #include "h_macros.h" -#define USES_OWNER \ - if (FSTYPE_MSDOS(tc)) \ +#define USES_OWNER \ + if (FSTYPE_MSDOS(tc)) \ atf_tc_skip("owner not supported by file system") +#define USES_USERLEVEL \ + if (FSTYPE_PUFFS(tc) || FSTYPE_P2K_FFS(tc)) \ + atf_tc_skip("userlevel pass not supported, " \ + "since sysctl might not be set in underlying system") +#define USES_OWNCHECK \ + if (FSTYPE_ZFS(tc)) \ + atf_tc_skip("zfs not supported since it has its " \ + "own rules for hardlinks") static void @@ -57,6 +65,8 @@ hardlink(const atf_tc_t *tc, const char int one = 1, fd; USES_OWNER; + USES_USERLEVEL; + USES_OWNCHECK; FSTEST_ENTER();
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Wed Mar 30 13:43:42 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: skip userlevel filesystems that have their own rules (they depend on the system setting of the sysctl on NetBSD) and zfs because it implements its own rules for hardlinks to files (does its own permission checks). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Tue Mar 29 22:30:07 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: ignore EOPNOTSUPP errors for fs's that don't support hard links. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_link.c diff -u src/tests/fs/vfs/t_link.c:1.1 src/tests/fs/vfs/t_link.c:1.2 --- src/tests/fs/vfs/t_link.c:1.1 Mon Mar 28 16:51:04 2022 +++ src/tests/fs/vfs/t_link.c Tue Mar 29 18:30:07 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_link.c,v 1.1 2022/03/28 20:51:04 christos Exp $ */ +/* $NetBSD: t_link.c,v 1.2 2022/03/29 22:30:07 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -82,7 +82,7 @@ hardlink(const atf_tc_t *tc, const char if (rump_sys_setuid(u2) == -1) atf_tc_fail_errno("setuid"); if (rump_sys_link(name, link) == -1) { - if (allowed) + if (errno != EOPNOTSUPP && allowed) atf_tc_fail_errno("link"); } else { if (!allowed)
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Tue Mar 29 22:30:07 UTC 2022 Modified Files: src/tests/fs/vfs: t_link.c Log Message: ignore EOPNOTSUPP errors for fs's that don't support hard links. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Mon Mar 28 20:51:04 UTC 2022 Modified Files: src/tests/fs/vfs: Makefile Added Files: src/tests/fs/vfs: t_link.c Log Message: Add a test for hardlink sysctl limiting. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/fs/vfs/Makefile cvs rdiff -u -r0 -r1.1 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/Makefile diff -u src/tests/fs/vfs/Makefile:1.27 src/tests/fs/vfs/Makefile:1.28 --- src/tests/fs/vfs/Makefile:1.27 Mon Mar 2 06:09:13 2020 +++ src/tests/fs/vfs/Makefile Mon Mar 28 16:51:04 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.27 2020/03/02 11:09:13 christos Exp $ +# $NetBSD: Makefile,v 1.28 2022/03/28 20:51:04 christos Exp $ # .include @@ -6,6 +6,7 @@ TESTSDIR= ${TESTSBASE}/fs/vfs WARNS= 4 +TESTS_C+= t_link TESTS_C+= t_full TESTS_C+= t_io TESTS_C+= t_renamerace @@ -19,6 +20,12 @@ TESTS_C+= t_mtime_write TESTS_C+= t_vfsops TESTS_C+= t_vnops + +.PATH: ${NETBSDSRCDIR}/lib/libc/gen +CPPFLAGS.sysctlbyname.c += -DRUMP_ACTION +CPPFLAGS.sysctlgetmibinfo.c += -DRUMP_ACTION +SRCS.t_link+= sysctlbyname.c sysctlgetmibinfo.c t_link.c + LDADD+=-lrumpnet_shmif -lrumpnet -lrumpnet_net -lrumpnet_netinet# TCP/IP LDADD+=-lrumpfs_nfs # NFS LDADD+=-lrumpfs_ext2fs # ext2fs Added files: Index: src/tests/fs/vfs/t_link.c diff -u /dev/null src/tests/fs/vfs/t_link.c:1.1 --- /dev/null Mon Mar 28 16:51:05 2022 +++ src/tests/fs/vfs/t_link.c Mon Mar 28 16:51:04 2022 @@ -0,0 +1,150 @@ +/* $NetBSD: t_link.c,v 1.1 2022/03/28 20:51:04 christos Exp $ */ + +/*- + * Copyright (c) 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include "../common/h_fsmacros.h" +#include "h_macros.h" + +#define USES_OWNER \ + if (FSTYPE_MSDOS(tc)) \ + atf_tc_skip("owner not supported by file system") + + +static void +hardlink(const atf_tc_t *tc, const char *mp, uid_t u1, uid_t u2, +bool sysctl, bool allowed) +{ + const char name[] = "foo"; + const char link[] = "bar"; + int one = 1, fd; + + USES_OWNER; + + FSTEST_ENTER(); + + if (sysctl) { + if (sysctlbyname( + "security.models.extensions.hardlink_check_uid", + NULL, 0, &one, sizeof(one)) == -1) + atf_tc_fail_errno("sysctlbyname"); + } + + rump_pub_lwproc_rfork(RUMP_RFCFDG); + if (rump_sys_chmod(".", 0777) == -1) + atf_tc_fail_errno("chmod"); + if (rump_sys_setuid(u1) == -1) + atf_tc_fail_errno("setuid"); +if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1) + atf_tc_fail_errno("open"); + if (rump_sys_close(fd) == -1) + atf_tc_fail_errno("close"); + rump_pub_lwproc_releaselwp(); + + rump_pub_lwproc_rfork(RUMP_RFCFDG); + if (rump_sys_setuid(u2) == -1) + atf_tc_fail_errno("setuid"); +if (rump_sys_link(name, link) == -1) { + if (allowed) + atf_tc_fail_errno("link"); + } else { + if (!allowed) + atf_tc_fail("failed to disallow hard link"); + } + rump_pub_lwproc_releaselwp(); + + FSTEST_EXIT(); +} + + +static void +hardlink_sameuser(const atf_tc_t *tc, const char *mp) +{ + hardlink(tc, mp, 1, 1, false, true); +} + +static void +hardlink_sameuser_sysctl(const atf_tc_t *tc, const char *mp) +{ + hardlink(tc, mp, 1, 1, true, true); +} + +static void +hardlink_otheruser(const atf_tc_t *tc, const char *mp) +{ + hardlink(tc, mp, 1, 2, false, true); +} + +static void +hardlink_otheruser_sysctl(const atf_tc_t *tc, const char *mp) +{ + hardlink(
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Mon Mar 28 20:51:04 UTC 2022 Modified Files: src/tests/fs/vfs: Makefile Added Files: src/tests/fs/vfs: t_link.c Log Message: Add a test for hardlink sysctl limiting. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/fs/vfs/Makefile cvs rdiff -u -r0 -r1.1 src/tests/fs/vfs/t_link.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/tests/fs/vfs
Date:Sat, 5 Feb 2022 22:20:16 + From:David Brownlee Message-ID: | Oops, my earliest unix experience was on a BSD4.3 variant, so I was | spoiled by ffs and didn't realise the (in this context) helpful v7fs | behaviour with overlong filename components. To clarify ... I meant7th edition (and earlier) filesystems, not necessarily the thing we have called v7fs about which I know nothing ... thiugh I wondered when I saw your PR whether a name length problem might be what caused that. kre
Re: CVS commit: src/tests/fs/vfs
On Wed, 2 Feb 2022 at 17:24, Robert Elz wrote: > > Date:Wed, 2 Feb 2022 15:26:21 + > From:David Brownlee > Message-ID: > > > | So, we just need an optional flag when mounting v7fs to truncate any > | looked up filename component to 14 characters > > That's not, or shouldn't be, necessary - that always happened, the limit was > what was stored in the directory, not on the length of the pathname components > passed to namei. > > Further, v7fs (systems of that vintage) had no concept at all of a maximum > pathname length (provided there was available ram to store the string). > (Apologies for continuing further down this rabbit hole :) Oops, my earliest unix experience was on a BSD4.3 variant, so I was spoiled by ffs and didn't realise the (in this context) helpful v7fs behaviour with overlong filename components. As a quick test extracting rescue.tar.xz into a v7fs and chrooting into rescue/sh works, and rsyncing enough to get /bin/sh chrooting also works (extracting base.tar.xz runs into issues - PR bin/56690) Actually, there were enough other issues found in PR bin/56690 that I would have to regretfully recommend against v7fs for production NetBSD systems (ahem :) David
Re: CVS commit: src/tests/fs/vfs
Date:Wed, 2 Feb 2022 15:26:21 + From:David Brownlee Message-ID: | So, we just need an optional flag when mounting v7fs to truncate any | looked up filename component to 14 characters That's not, or shouldn't be, necessary - that always happened, the limit was what was stored in the directory, not on the length of the pathname components passed to namei. Further, v7fs (systems of that vintage) had no concept at all of a maximum pathname length (provided there was available ram to store the string). kre
Re: CVS commit: src/tests/fs/vfs
> On Feb 2, 2022, at 6:47 AM, Robert Elz wrote: > >Date:Wed, 2 Feb 2022 07:11:45 + >From:David Holland >Message-ID: > > | v7fs isn't a compat interface for old users, > > That's sad, I could do with something just for me! > > | it's a compat interface for old disk images :-) > > And makefs -t v7fs fits into that purpose how? > > So maybe it is for us truly old fogies (can we have v6fs as well? > Then I'd really feel at home.) Can I have a v7fs as root, and > boot from it? Does sysinst support it? I thought we maybe supported a system whose ROM boots from it? -- thorpej
Re: CVS commit: src/tests/fs/vfs
Hello, On Wed, 02 Feb 2022 21:47:25 +0700 Robert Elz wrote: > So maybe it is for us truly old fogies (can we have v6fs as well? Well, there is this thing... https://github.com/jaylogue/retro-fuse A user-space filesystem (FUSE) for accessing ancient Unix filesystems. retro-fuse provides a way to mount filesystems created by ancient Unix systems on modern OSes. The current version of retro-fuse supports mounting filesystems created by fifth, sixth and seventh-edition research Unix, as well as 2.9BSD and 2.11BSD. It can also initialize such filesystems. have fun Michael
Re: CVS commit: src/tests/fs/vfs
On Wed, 2 Feb 2022 at 14:47, Robert Elz wrote: > > Date:Wed, 2 Feb 2022 07:11:45 + > From:David Holland > Message-ID: > > | v7fs isn't a compat interface for old users, > > That's sad, I could do with something just for me! Sounds like we need a compat_kre(8) - assuming it would be more correct to provide the appropriate trailing slash behaviour for all filesystems in that mode? :-p > | it's a compat interface for old disk images :-) > > And makefs -t v7fs fits into that purpose how? > > So maybe it is for us truly old fogies (can we have v6fs as well? > Then I'd really feel at home.) Can I have a v7fs as root, and > boot from it? Maybe? - Throw together a bootxx_v7fs - Leave /dev with just MAKEDEV so the system will mount a mfs /dev - Convert symlinks to hard links or file copies when setting up - Then it's just the 14 character filename component limit: excluding drm firmware, kernel modules and X config most filename components are 14 characters or less - but there are a few libraries in /lib with longer filenames - lib/libcrypto.so.14 lib/libtermcap.so.0 lib/libterminfo.so.1 and lib/libpthread.so.1 are likely to be problematic So, we just need an optional flag when mounting v7fs to truncate any looked up filename component to 14 characters, then we're good to go. Actually, I'm a little concerned about how close it could be to being possible! :) > Does sysinst support it? It would be under the --spinal-tap option David
Re: CVS commit: src/tests/fs/vfs
Date:Wed, 2 Feb 2022 07:11:45 + From:David Holland Message-ID: | v7fs isn't a compat interface for old users, That's sad, I could do with something just for me! | it's a compat interface for old disk images :-) And makefs -t v7fs fits into that purpose how? So maybe it is for us truly old fogies (can we have v6fs as well? Then I'd really feel at home.) Can I have a v7fs as root, and boot from it? Does sysinst support it? kre
Re: CVS commit: src/tests/fs/vfs
On Wed, Feb 02, 2022 at 05:43:45AM +0700, Robert Elz wrote: > | Test mkdir(2) with one or more trailing slashes - this currently fails > | for v7fs. > > As it should I think, trailing slashes are not simply deleted in v7fs. > > [...] > > If this was ever changed, it would not truly be a v7fs any more. v7fs isn't a compat interface for old users, it's a compat interface for old disk images :-) -- David A. Holland dholl...@netbsd.org
Re: CVS commit: src/tests/fs/vfs
Date:Tue, 1 Feb 2022 18:27:24 + From:"Martin Husemann" Message-ID: <20220201182724.90f82f...@cvs.netbsd.org> | Test mkdir(2) with one or more trailing slashes - this currently fails | for v7fs. As it should I think, trailing slashes are not simply deleted in v7fs. If you do mkdir /path/to/dir/ in a v7 fs, then you're guaranteed (unless some other error happens earlier) either ENOENT if /path/to/dir doesn't already exist, ENOTDIR if it it does but isn't a directory, or EEXIST if it exists and is a directory. The thing to be created always follows the final slash, everything prior to that is path to look up, and must all exist and be directories (with appropriate permissions, etc).In this case the "thing" is "" which is (kind of) an alias for "." (without ever actually looking up "."). It can never not exist if the preceding path all exists. If this was ever changed, it would not truly be a v7fs any more. kre ps: I never understood the fascination with always writing directory names with a trailing / - it seems to come largely from filename completion where the '/' is added if the name found is a directory, so you can just go on typing anything that is to follow in the path (but could easily be removed again if no more components are added - just isn't) but it makes no sense for this to have happened with mkdir, filename completion can only find files that exist, not ones to be created, so it couldn't be that which adds the '/' after the directory name - some human must be doing that, but why? It seems to be to be just meaningless extra unneeded typing.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: martin Date: Tue Feb 1 18:27:24 UTC 2022 Modified Files: src/tests/fs/vfs: t_vnops.c Log Message: Test mkdir(2) with one or more trailing slashes - this currently fails for v7fs. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/tests/fs/vfs/t_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_vnops.c diff -u src/tests/fs/vfs/t_vnops.c:1.61 src/tests/fs/vfs/t_vnops.c:1.62 --- src/tests/fs/vfs/t_vnops.c:1.61 Thu Sep 16 21:29:42 2021 +++ src/tests/fs/vfs/t_vnops.c Tue Feb 1 18:27:24 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_vnops.c,v 1.61 2021/09/16 21:29:42 andvar Exp $ */ +/* $NetBSD: t_vnops.c,v 1.62 2022/02/01 18:27:24 martin Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -175,6 +175,45 @@ dir_simple(const atf_tc_t *tc, const cha } static void +do_dir_slash(const atf_tc_t *tc, const char *mountpath, const char *addend) +{ + char plain[MAXPATHLEN], with_slash[MAXPATHLEN]; + struct stat sb; + + USES_DIRS; + + /* check we can create directories with one or more / appended */ + snprintf(plain, sizeof(plain), "%s/dir%s", mountpath, addend); + snprintf(with_slash, sizeof(with_slash), "%s/dir/", mountpath); + if (rump_sys_mkdir(with_slash, 0777) == -1) + atf_tc_fail_errno("mkdir"); + if (rump_sys_stat(plain, &sb) == -1) + atf_tc_fail_errno("stat new directory"); + if (rump_sys_rmdir(plain) == -1) + atf_tc_fail_errno("rmdir"); + if (rump_sys_stat(with_slash, &sb) != -1 || errno != ENOENT) + atf_tc_fail("ENOENT expected from stat"); +} + +static void +dir_slash(const atf_tc_t *tc, const char *mountpath) +{ + do_dir_slash(tc, mountpath, "/"); +} + +static void +dir_2slash(const atf_tc_t *tc, const char *mountpath) +{ + do_dir_slash(tc, mountpath, "//"); +} + +static void +dir_3slash(const atf_tc_t *tc, const char *mountpath) +{ + do_dir_slash(tc, mountpath, "///"); +} + +static void dir_notempty(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN], pb2[MAXPATHLEN]; @@ -1026,6 +1065,9 @@ lstat_symlink(const atf_tc_t *tc, const ATF_TC_FSAPPLY(lookup_simple, "simple lookup (./.. on root)"); ATF_TC_FSAPPLY(lookup_complex, "lookup of non-dot entries"); ATF_TC_FSAPPLY(dir_simple, "mkdir/rmdir"); +ATF_TC_FSAPPLY(dir_slash, "mkdir with appended slash"); +ATF_TC_FSAPPLY(dir_2slash, "mkdir with two slashes appended"); +ATF_TC_FSAPPLY(dir_3slash, "mkdir with three slashes appended"); ATF_TC_FSAPPLY(dir_notempty, "non-empty directories cannot be removed"); ATF_TC_FSAPPLY(dir_rmdirdotdot, "remove .. and try to cd out (PR kern/44657)"); ATF_TC_FSAPPLY(rename_dir, "exercise various directory renaming ops " @@ -1058,6 +1100,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_FSAPPLY(dir_simple); ATF_TP_FSAPPLY(dir_notempty); ATF_TP_FSAPPLY(dir_rmdirdotdot); + ATF_TP_FSAPPLY(dir_slash); + ATF_TP_FSAPPLY(dir_2slash); + ATF_TP_FSAPPLY(dir_3slash); ATF_TP_FSAPPLY(rename_dir); ATF_TP_FSAPPLY(rename_dotdot); ATF_TP_FSAPPLY(rename_reg_nodir);
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: martin Date: Tue Feb 1 18:27:24 UTC 2022 Modified Files: src/tests/fs/vfs: t_vnops.c Log Message: Test mkdir(2) with one or more trailing slashes - this currently fails for v7fs. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/tests/fs/vfs/t_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: ryo Date: Mon Jan 31 17:23:37 UTC 2022 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: Extend the time to wait for the thread to quit. It seems that alarm(1) is not enough time for the thread to actually exit after quittingtime = 1. It randomly failed with "Test program received signal 14" on a slow environment. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_renamerace.c diff -u src/tests/fs/vfs/t_renamerace.c:1.43 src/tests/fs/vfs/t_renamerace.c:1.44 --- src/tests/fs/vfs/t_renamerace.c:1.43 Sat Nov 27 15:23:33 2021 +++ src/tests/fs/vfs/t_renamerace.c Mon Jan 31 17:23:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: t_renamerace.c,v 1.43 2021/11/27 15:23:33 gson Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.44 2022/01/31 17:23:37 ryo Exp $ */ /* * Modified for rump and atf from a program supplied @@ -244,7 +244,7 @@ renamerace_cycle(const atf_tc_t *tc, con sleep(10); quittingtime = 1; - alarm(1); + alarm(5); pthread_join(pt_rmdir, NULL); pthread_join(pt_rename1, NULL); pthread_join(pt_rename2, NULL);
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: ryo Date: Mon Jan 31 17:23:37 UTC 2022 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: Extend the time to wait for the thread to quit. It seems that alarm(1) is not enough time for the thread to actually exit after quittingtime = 1. It randomly failed with "Test program received signal 14" on a slow environment. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: gson Date: Sat Nov 27 15:23:33 UTC 2021 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: Force failure of the nfs_renamerace_cycle, p2k_ffs_renamerace_cycle, and puffs_renamerace_cycle test cases as they fail only randomly or only on some systems. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_renamerace.c diff -u src/tests/fs/vfs/t_renamerace.c:1.42 src/tests/fs/vfs/t_renamerace.c:1.43 --- src/tests/fs/vfs/t_renamerace.c:1.42 Sat Oct 23 17:43:08 2021 +++ src/tests/fs/vfs/t_renamerace.c Sat Nov 27 15:23:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_renamerace.c,v 1.42 2021/10/23 17:43:08 hannken Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.43 2021/11/27 15:23:33 gson Exp $ */ /* * Modified for rump and atf from a program supplied @@ -253,6 +253,12 @@ renamerace_cycle(const atf_tc_t *tc, con if (FSTYPE_UDF(tc)) atf_tc_fail("PR kern/56253 did not trigger this time"); + if (FSTYPE_P2K_FFS(tc)) + atf_tc_fail("did not fail this time"); + if (FSTYPE_PUFFS(tc)) + atf_tc_fail("did not fail this time"); + if (FSTYPE_NFS(tc)) + atf_tc_fail("did not fail this time"); } ATF_TC_FSAPPLY(renamerace, "rename(2) race with file unlinked mid-operation");
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: gson Date: Sat Nov 27 15:23:33 UTC 2021 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: Force failure of the nfs_renamerace_cycle, p2k_ffs_renamerace_cycle, and puffs_renamerace_cycle test cases as they fail only randomly or only on some systems. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: hannken Date: Sat Oct 23 17:43:08 UTC 2021 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: After converting msdosfs_rename() to use genfs_sane_rename() the MSDOS tests should pass. Tested on QEMU/nvmm archs i386 and amd64. Should resolve PR kern/43626 (directory renaming more than a little racy) To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_renamerace.c diff -u src/tests/fs/vfs/t_renamerace.c:1.41 src/tests/fs/vfs/t_renamerace.c:1.42 --- src/tests/fs/vfs/t_renamerace.c:1.41 Wed Jun 16 23:58:07 2021 +++ src/tests/fs/vfs/t_renamerace.c Sat Oct 23 17:43:08 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: t_renamerace.c,v 1.41 2021/06/16 23:58:07 riastradh Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.42 2021/10/23 17:43:08 hannken Exp $ */ /* * Modified for rump and atf from a program supplied @@ -183,19 +183,6 @@ renamerace(const atf_tc_t *tc, const cha if (FSTYPE_UDF(tc)) atf_tc_fail("race did not trigger this time"); - - if (FSTYPE_MSDOS(tc)) { - atf_tc_expect_fail("PR kern/43626"); - /* - * XXX: race does not trigger every time at least - * on amd64/qemu. - */ - if (msdosfs_fstest_unmount(tc, mp, 0) != 0) { - rump_pub_vfs_mount_print(mp, 1); - atf_tc_fail_errno("unmount failed"); - } - atf_tc_fail("race did not trigger this time"); - } } static void @@ -210,10 +197,6 @@ renamerace_dirs(const atf_tc_t *tc, cons if (FSTYPE_UDF(tc)) atf_tc_expect_fail("PR kern/53865"); - /* XXX: msdosfs also sometimes hangs */ - if (FSTYPE_MSDOS(tc)) - atf_tc_expect_signal(-1, "PR kern/43626"); - RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(wrkpid = rump_sys_getpid()); @@ -230,13 +213,6 @@ renamerace_dirs(const atf_tc_t *tc, cons if (FSTYPE_UDF(tc)) atf_tc_fail("race did not trigger this time"); - - /* - * Doesn't always trigger when run on a slow backend - * (i.e. not on tmpfs/mfs). So do the usual kludge. - */ - if (FSTYPE_MSDOS(tc)) - abort(); } static void @@ -257,10 +233,6 @@ renamerace_cycle(const atf_tc_t *tc, con if (FSTYPE_UDF(tc)) atf_tc_expect_fail("sometimes fails with ENOSPC, PR kern/56253"); - /* XXX: msdosfs also sometimes hangs */ - if (FSTYPE_MSDOS(tc)) - atf_tc_expect_signal(-1, "PR kern/43626"); - RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(wrkpid = rump_sys_getpid()); @@ -281,13 +253,6 @@ renamerace_cycle(const atf_tc_t *tc, con if (FSTYPE_UDF(tc)) atf_tc_fail("PR kern/56253 did not trigger this time"); - - /* - * Doesn't always trigger when run on a slow backend - * (i.e. not on tmpfs/mfs). So do the usual kludge. - */ - if (FSTYPE_MSDOS(tc)) - abort(); } ATF_TC_FSAPPLY(renamerace, "rename(2) race with file unlinked mid-operation");
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: hannken Date: Sat Oct 23 17:43:08 UTC 2021 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: After converting msdosfs_rename() to use genfs_sane_rename() the MSDOS tests should pass. Tested on QEMU/nvmm archs i386 and amd64. Should resolve PR kern/43626 (directory renaming more than a little racy) To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: kre Date: Sat Sep 21 14:25:42 UTC 2019 Modified Files: src/tests/fs/vfs: t_ro.c Log Message: Initialise the sometvs array of struct timeval that is to be used to validate that utimes() cannot update the times of a file on a read only filesystem. The values are never actually used, but since src/sys/kern/vfs_syscalls.c 1.535 they are validated for sanity, and the syscall returns EINVAL if the values passed are invalid (tv_usec <0 or >= 100). If that happens we don't get as far as the test which produces the EROFS that is expected from this test (these tests - one for each filesystem type). So, init the timeval structs (just to 0, the values will still not be used) so that the EINVAL doesn't bite us before we're eaten by the EROFS which is the way we're supposed to die. If the syscall API args were labelled as "const" the compiler probably would have caught the use of uninit'd vars and complained much sooner. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/fs/vfs/t_ro.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_ro.c diff -u src/tests/fs/vfs/t_ro.c:1.7 src/tests/fs/vfs/t_ro.c:1.8 --- src/tests/fs/vfs/t_ro.c:1.7 Tue Jul 16 17:29:17 2019 +++ src/tests/fs/vfs/t_ro.c Sat Sep 21 14:25:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ro.c,v 1.7 2019/07/16 17:29:17 martin Exp $ */ +/* $NetBSD: t_ro.c,v 1.8 2019/09/21 14:25:42 kre Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -120,7 +120,7 @@ fileio(const atf_tc_t *tc, const char *m static void attrs(const atf_tc_t *tc, const char *mp) { - struct timeval sometvs[2]; + struct timeval sometvs[2] = { {0,0}, {0,0} }; struct stat sb; int fd;
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: kre Date: Sat Sep 21 14:25:42 UTC 2019 Modified Files: src/tests/fs/vfs: t_ro.c Log Message: Initialise the sometvs array of struct timeval that is to be used to validate that utimes() cannot update the times of a file on a read only filesystem. The values are never actually used, but since src/sys/kern/vfs_syscalls.c 1.535 they are validated for sanity, and the syscall returns EINVAL if the values passed are invalid (tv_usec <0 or >= 100). If that happens we don't get as far as the test which produces the EROFS that is expected from this test (these tests - one for each filesystem type). So, init the timeval structs (just to 0, the values will still not be used) so that the EINVAL doesn't bite us before we're eaten by the EROFS which is the way we're supposed to die. If the syscall API args were labelled as "const" the compiler probably would have caught the use of uninit'd vars and complained much sooner. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/fs/vfs/t_ro.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: gson Date: Sat Aug 17 09:44:02 UTC 2019 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: The udf_renamerace test case no longer fails due to PR kern/49046, but it does fail due to PR kern/53865 on real hardware. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: gson Date: Sat Aug 17 09:44:02 UTC 2019 Modified Files: src/tests/fs/vfs: t_renamerace.c Log Message: The udf_renamerace test case no longer fails due to PR kern/49046, but it does fail due to PR kern/53865 on real hardware. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/tests/fs/vfs/t_renamerace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_renamerace.c diff -u src/tests/fs/vfs/t_renamerace.c:1.35 src/tests/fs/vfs/t_renamerace.c:1.36 --- src/tests/fs/vfs/t_renamerace.c:1.35 Sun Jan 13 14:35:00 2019 +++ src/tests/fs/vfs/t_renamerace.c Sat Aug 17 09:44:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_renamerace.c,v 1.35 2019/01/13 14:35:00 gson Exp $ */ +/* $NetBSD: t_renamerace.c,v 1.36 2019/08/17 09:44:01 gson Exp $ */ /* * Modified for rump and atf from a program supplied @@ -102,7 +102,7 @@ renamerace(const atf_tc_t *tc, const cha if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (FSTYPE_UDF(tc)) - atf_tc_expect_fail("PR kern/49046"); + atf_tc_expect_fail("PR kern/53865"); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); RL(wrkpid = rump_sys_getpid());
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Tue Jul 16 21:13:28 UTC 2019 Modified Files: src/tests/fs/vfs: t_io.c Log Message: fix misplaced paren To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/fs/vfs/t_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/fs/vfs/t_io.c diff -u src/tests/fs/vfs/t_io.c:1.18 src/tests/fs/vfs/t_io.c:1.19 --- src/tests/fs/vfs/t_io.c:1.18 Tue Jul 16 13:29:17 2019 +++ src/tests/fs/vfs/t_io.c Tue Jul 16 17:13:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: t_io.c,v 1.18 2019/07/16 17:29:17 martin Exp $ */ +/* $NetBSD: t_io.c,v 1.19 2019/07/16 21:13:28 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ extendbody(const atf_tc_t *tc, off_t see FSTEST_ENTER(); RL(fd = rump_sys_open("testfile", - O_CREAT | O_RDWR | (seekcnt ? O_APPEND : 0)), 0600); + O_CREAT | O_RDWR | (seekcnt ? O_APPEND : 0), 0600)); RL(rump_sys_ftruncate(fd, seekcnt)); RL(rump_sys_fstat(fd, &sb)); ATF_REQUIRE_EQ(sb.st_size, seekcnt);
CVS commit: src/tests/fs/vfs
Module Name:src Committed By: christos Date: Tue Jul 16 21:13:28 UTC 2019 Modified Files: src/tests/fs/vfs: t_io.c Log Message: fix misplaced paren To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/tests/fs/vfs/t_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.