From 95b78c8f790f03af706a65e2e3a4b5a563175f62 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Fri, 5 Dec 2014 11:44:18 +0000 Subject: [PATCH] MFC r272057,r272083,r272084,r272087,r274016: r272057: Import pjdfstest from ^/vendor/pjdfstest/abf03c3a47745d4521b0e4aa141317553ca48f91 - Remove tools/regression/pjdfstest - Add upgrade directions for contrib/pjdfstest - Add a note to UPDATING for the move (the reachover Makefiles are coming soon) Functional differences: - ftruncate testcases are added from upstream (github) Non-functional differences: - The copyright for the project has been updated to 2012 - pjd's contact information has been updated Discussed with: -testing, jmmv, pjd Sponsored by: EMC / Isilon Storage Division r272083: Expect ELOOP on Darwin/Linux with "O_NOFOLLOW was specified and the target is a symbolic link" case. Assume EMLINK on the rest of the OSes (FreeBSD, Solaris, etc) Sponsored by: EMC / Isilon Storage Division r272084: Fix the executed testplan count Sponsored by: EMC / Isilon Storage Division r272087: Increase the memory disk size in the following testcases to avoid mount failures, which would cause cascade failures in the rest of the test run: link/15.t, open/19.t, mkdir/11.t, mkfifo/11.t, symlink/11.t Fail quickly in all of the testcases if mdconfig, mount, umount, etc fails to avoid issues similar to this in the future Submitted by: Casey Peel Sponsored by: EMC / Isilon Storage Division r274016: Integrate pjdfstest test suite execution into kyua pjdfstest execution is opt-in and must be done as root due to some of the assumptions made by the test suite and lack of error checking in the non-root case A description of how to execute pjdfstest with kyua is provided in share/pjdfstest/README Phabric: D824 (an earlier prototype patch) Relnotes: yes Sponsored by: EMC / Isilon Storage Division --- UPDATING | 5 + contrib/pjdfstest/FREEBSD-upgrade | 25 + contrib/pjdfstest/LICENSE | 27 + contrib/pjdfstest/Makefile | 26 + contrib/pjdfstest/README | 22 + contrib/pjdfstest/pjdfstest.c | 1493 ++++++++++++++++++ contrib/pjdfstest/tests/chflags/00.t | 178 +++ contrib/pjdfstest/tests/chflags/01.t | 22 + contrib/pjdfstest/tests/chflags/02.t | 28 + contrib/pjdfstest/tests/chflags/03.t | 32 + contrib/pjdfstest/tests/chflags/04.t | 19 + contrib/pjdfstest/tests/chflags/05.t | 35 + contrib/pjdfstest/tests/chflags/06.t | 21 + contrib/pjdfstest/tests/chflags/07.t | 50 + contrib/pjdfstest/tests/chflags/08.t | 58 + contrib/pjdfstest/tests/chflags/09.t | 66 + contrib/pjdfstest/tests/chflags/10.t | 54 + contrib/pjdfstest/tests/chflags/11.t | 58 + contrib/pjdfstest/tests/chflags/12.t | 68 + contrib/pjdfstest/tests/chflags/13.t | 14 + contrib/pjdfstest/tests/chmod/00.t | 138 ++ contrib/pjdfstest/tests/chmod/01.t | 20 + contrib/pjdfstest/tests/chmod/02.t | 24 + contrib/pjdfstest/tests/chmod/03.t | 28 + contrib/pjdfstest/tests/chmod/04.t | 29 + contrib/pjdfstest/tests/chmod/05.t | 42 + contrib/pjdfstest/tests/chmod/06.t | 29 + contrib/pjdfstest/tests/chmod/07.t | 62 + contrib/pjdfstest/tests/chmod/08.t | 98 ++ contrib/pjdfstest/tests/chmod/09.t | 37 + contrib/pjdfstest/tests/chmod/10.t | 20 + contrib/pjdfstest/tests/chmod/11.t | 118 ++ contrib/pjdfstest/tests/chmod/12.t | 38 + contrib/pjdfstest/tests/chmod/foo | 0 contrib/pjdfstest/tests/chown/00.t | 458 ++++++ contrib/pjdfstest/tests/chown/01.t | 21 + contrib/pjdfstest/tests/chown/02.t | 24 + contrib/pjdfstest/tests/chown/03.t | 28 + contrib/pjdfstest/tests/chown/04.t | 23 + contrib/pjdfstest/tests/chown/05.t | 35 + contrib/pjdfstest/tests/chown/06.t | 23 + contrib/pjdfstest/tests/chown/07.t | 53 + contrib/pjdfstest/tests/chown/08.t | 84 + contrib/pjdfstest/tests/chown/09.t | 32 + contrib/pjdfstest/tests/chown/10.t | 14 + contrib/pjdfstest/tests/conf | 36 + contrib/pjdfstest/tests/ftruncate/00.t | 58 + contrib/pjdfstest/tests/ftruncate/01.t | 18 + contrib/pjdfstest/tests/ftruncate/02.t | 18 + contrib/pjdfstest/tests/ftruncate/03.t | 22 + contrib/pjdfstest/tests/ftruncate/04.t | 17 + contrib/pjdfstest/tests/ftruncate/05.t | 32 + contrib/pjdfstest/tests/ftruncate/06.t | 24 + contrib/pjdfstest/tests/ftruncate/07.t | 19 + contrib/pjdfstest/tests/ftruncate/08.t | 78 + contrib/pjdfstest/tests/ftruncate/09.t | 15 + contrib/pjdfstest/tests/ftruncate/10.t | 32 + contrib/pjdfstest/tests/ftruncate/11.t | 18 + contrib/pjdfstest/tests/ftruncate/12.t | 27 + contrib/pjdfstest/tests/ftruncate/13.t | 16 + contrib/pjdfstest/tests/ftruncate/14.t | 12 + contrib/pjdfstest/tests/granular/00.t | 112 ++ contrib/pjdfstest/tests/granular/01.t | 37 + contrib/pjdfstest/tests/granular/02.t | 144 ++ contrib/pjdfstest/tests/granular/03.t | 134 ++ contrib/pjdfstest/tests/granular/04.t | 80 + contrib/pjdfstest/tests/granular/05.t | 149 ++ contrib/pjdfstest/tests/link/00.t | 93 ++ contrib/pjdfstest/tests/link/01.t | 24 + contrib/pjdfstest/tests/link/02.t | 25 + contrib/pjdfstest/tests/link/03.t | 31 + contrib/pjdfstest/tests/link/04.t | 20 + contrib/pjdfstest/tests/link/05.t | 36 + contrib/pjdfstest/tests/link/06.t | 43 + contrib/pjdfstest/tests/link/07.t | 41 + contrib/pjdfstest/tests/link/08.t | 24 + contrib/pjdfstest/tests/link/09.t | 18 + contrib/pjdfstest/tests/link/10.t | 26 + contrib/pjdfstest/tests/link/11.t | 41 + contrib/pjdfstest/tests/link/12.t | 95 ++ contrib/pjdfstest/tests/link/13.t | 86 + contrib/pjdfstest/tests/link/14.t | 29 + contrib/pjdfstest/tests/link/15.t | 33 + contrib/pjdfstest/tests/link/16.t | 34 + contrib/pjdfstest/tests/link/17.t | 20 + contrib/pjdfstest/tests/misc.sh | 221 +++ contrib/pjdfstest/tests/mkdir/00.t | 73 + contrib/pjdfstest/tests/mkdir/01.t | 20 + contrib/pjdfstest/tests/mkdir/02.t | 16 + contrib/pjdfstest/tests/mkdir/03.t | 20 + contrib/pjdfstest/tests/mkdir/04.t | 16 + contrib/pjdfstest/tests/mkdir/05.t | 29 + contrib/pjdfstest/tests/mkdir/06.t | 29 + contrib/pjdfstest/tests/mkdir/07.t | 19 + contrib/pjdfstest/tests/mkdir/08.t | 66 + contrib/pjdfstest/tests/mkdir/09.t | 29 + contrib/pjdfstest/tests/mkdir/10.t | 21 + contrib/pjdfstest/tests/mkdir/11.t | 31 + contrib/pjdfstest/tests/mkdir/12.t | 12 + contrib/pjdfstest/tests/mkfifo/00.t | 73 + contrib/pjdfstest/tests/mkfifo/01.t | 20 + contrib/pjdfstest/tests/mkfifo/02.t | 17 + contrib/pjdfstest/tests/mkfifo/03.t | 21 + contrib/pjdfstest/tests/mkfifo/04.t | 16 + contrib/pjdfstest/tests/mkfifo/05.t | 29 + contrib/pjdfstest/tests/mkfifo/06.t | 29 + contrib/pjdfstest/tests/mkfifo/07.t | 19 + contrib/pjdfstest/tests/mkfifo/08.t | 29 + contrib/pjdfstest/tests/mkfifo/09.t | 21 + contrib/pjdfstest/tests/mkfifo/10.t | 66 + contrib/pjdfstest/tests/mkfifo/11.t | 31 + contrib/pjdfstest/tests/mkfifo/12.t | 12 + contrib/pjdfstest/tests/mknod/00.t | 73 + contrib/pjdfstest/tests/mknod/01.t | 22 + contrib/pjdfstest/tests/mknod/02.t | 27 + contrib/pjdfstest/tests/mknod/03.t | 31 + contrib/pjdfstest/tests/mknod/04.t | 16 + contrib/pjdfstest/tests/mknod/05.t | 29 + contrib/pjdfstest/tests/mknod/06.t | 29 + contrib/pjdfstest/tests/mknod/07.t | 19 + contrib/pjdfstest/tests/mknod/08.t | 23 + contrib/pjdfstest/tests/mknod/09.t | 64 + contrib/pjdfstest/tests/mknod/10.t | 12 + contrib/pjdfstest/tests/mknod/11.t | 79 + contrib/pjdfstest/tests/open/00.t | 99 ++ contrib/pjdfstest/tests/open/01.t | 21 + contrib/pjdfstest/tests/open/02.t | 17 + contrib/pjdfstest/tests/open/03.t | 21 + contrib/pjdfstest/tests/open/04.t | 17 + contrib/pjdfstest/tests/open/05.t | 29 + contrib/pjdfstest/tests/open/06.t | 187 +++ contrib/pjdfstest/tests/open/07.t | 45 + contrib/pjdfstest/tests/open/08.t | 19 + contrib/pjdfstest/tests/open/09.t | 66 + contrib/pjdfstest/tests/open/10.t | 58 + contrib/pjdfstest/tests/open/11.t | 56 + contrib/pjdfstest/tests/open/12.t | 19 + contrib/pjdfstest/tests/open/13.t | 24 + contrib/pjdfstest/tests/open/14.t | 32 + contrib/pjdfstest/tests/open/15.t | 27 + contrib/pjdfstest/tests/open/16.t | 27 + contrib/pjdfstest/tests/open/17.t | 15 + contrib/pjdfstest/tests/open/18.t | 20 + contrib/pjdfstest/tests/open/19.t | 31 + contrib/pjdfstest/tests/open/20.t | 20 + contrib/pjdfstest/tests/open/21.t | 12 + contrib/pjdfstest/tests/open/22.t | 21 + contrib/pjdfstest/tests/open/23.t | 17 + contrib/pjdfstest/tests/open/24.t | 17 + contrib/pjdfstest/tests/rename/00.t | 91 ++ contrib/pjdfstest/tests/rename/01.t | 23 + contrib/pjdfstest/tests/rename/02.t | 24 + contrib/pjdfstest/tests/rename/03.t | 20 + contrib/pjdfstest/tests/rename/04.t | 43 + contrib/pjdfstest/tests/rename/05.t | 41 + contrib/pjdfstest/tests/rename/06.t | 61 + contrib/pjdfstest/tests/rename/07.t | 66 + contrib/pjdfstest/tests/rename/08.t | 63 + contrib/pjdfstest/tests/rename/09.t | 191 +++ contrib/pjdfstest/tests/rename/10.t | 156 ++ contrib/pjdfstest/tests/rename/11.t | 24 + contrib/pjdfstest/tests/rename/12.t | 24 + contrib/pjdfstest/tests/rename/13.t | 24 + contrib/pjdfstest/tests/rename/14.t | 24 + contrib/pjdfstest/tests/rename/15.t | 34 + contrib/pjdfstest/tests/rename/16.t | 32 + contrib/pjdfstest/tests/rename/17.t | 20 + contrib/pjdfstest/tests/rename/18.t | 22 + contrib/pjdfstest/tests/rename/19.t | 22 + contrib/pjdfstest/tests/rename/20.t | 29 + contrib/pjdfstest/tests/rename/21.t | 47 + contrib/pjdfstest/tests/rmdir/00.t | 28 + contrib/pjdfstest/tests/rmdir/01.t | 30 + contrib/pjdfstest/tests/rmdir/02.t | 17 + contrib/pjdfstest/tests/rmdir/03.t | 22 + contrib/pjdfstest/tests/rmdir/04.t | 17 + contrib/pjdfstest/tests/rmdir/05.t | 19 + contrib/pjdfstest/tests/rmdir/06.t | 24 + contrib/pjdfstest/tests/rmdir/07.t | 27 + contrib/pjdfstest/tests/rmdir/08.t | 27 + contrib/pjdfstest/tests/rmdir/09.t | 65 + contrib/pjdfstest/tests/rmdir/10.t | 67 + contrib/pjdfstest/tests/rmdir/11.t | 57 + contrib/pjdfstest/tests/rmdir/12.t | 20 + contrib/pjdfstest/tests/rmdir/13.t | 22 + contrib/pjdfstest/tests/rmdir/14.t | 27 + contrib/pjdfstest/tests/rmdir/15.t | 12 + contrib/pjdfstest/tests/symlink/00.t | 32 + contrib/pjdfstest/tests/symlink/01.t | 18 + contrib/pjdfstest/tests/symlink/02.t | 22 + contrib/pjdfstest/tests/symlink/03.t | 22 + contrib/pjdfstest/tests/symlink/04.t | 16 + contrib/pjdfstest/tests/symlink/05.t | 34 + contrib/pjdfstest/tests/symlink/06.t | 34 + contrib/pjdfstest/tests/symlink/07.t | 19 + contrib/pjdfstest/tests/symlink/08.t | 21 + contrib/pjdfstest/tests/symlink/09.t | 66 + contrib/pjdfstest/tests/symlink/10.t | 32 + contrib/pjdfstest/tests/symlink/11.t | 31 + contrib/pjdfstest/tests/symlink/12.t | 18 + contrib/pjdfstest/tests/truncate/00.t | 51 + contrib/pjdfstest/tests/truncate/01.t | 18 + contrib/pjdfstest/tests/truncate/02.t | 18 + contrib/pjdfstest/tests/truncate/03.t | 22 + contrib/pjdfstest/tests/truncate/04.t | 17 + contrib/pjdfstest/tests/truncate/05.t | 32 + contrib/pjdfstest/tests/truncate/06.t | 24 + contrib/pjdfstest/tests/truncate/07.t | 19 + contrib/pjdfstest/tests/truncate/08.t | 78 + contrib/pjdfstest/tests/truncate/09.t | 15 + contrib/pjdfstest/tests/truncate/10.t | 32 + contrib/pjdfstest/tests/truncate/11.t | 18 + contrib/pjdfstest/tests/truncate/12.t | 27 + contrib/pjdfstest/tests/truncate/13.t | 16 + contrib/pjdfstest/tests/truncate/14.t | 12 + contrib/pjdfstest/tests/unlink/00.t | 212 +++ contrib/pjdfstest/tests/unlink/01.t | 18 + contrib/pjdfstest/tests/unlink/02.t | 17 + contrib/pjdfstest/tests/unlink/03.t | 21 + contrib/pjdfstest/tests/unlink/04.t | 17 + contrib/pjdfstest/tests/unlink/05.t | 27 + contrib/pjdfstest/tests/unlink/06.t | 27 + contrib/pjdfstest/tests/unlink/07.t | 19 + contrib/pjdfstest/tests/unlink/08.t | 16 + contrib/pjdfstest/tests/unlink/09.t | 65 + contrib/pjdfstest/tests/unlink/10.t | 67 + contrib/pjdfstest/tests/unlink/11.t | 63 + contrib/pjdfstest/tests/unlink/12.t | 27 + contrib/pjdfstest/tests/unlink/13.t | 12 + etc/mtree/BSD.tests.dist | 34 + share/doc/Makefile | 2 + share/doc/pjdfstest/Makefile | 8 + share/doc/pjdfstest/README | 36 + tests/sys/Makefile | 8 +- tests/sys/pjdfstest/Makefile | 6 + tests/sys/pjdfstest/pjdfstest/Makefile | 20 + tests/sys/pjdfstest/tests/Makefile | 39 + tests/sys/pjdfstest/tests/chflags/Makefile | 18 + tests/sys/pjdfstest/tests/chmod/Makefile | 17 + tests/sys/pjdfstest/tests/chown/Makefile | 15 + tests/sys/pjdfstest/tests/conf | 15 + tests/sys/pjdfstest/tests/ftruncate/Makefile | 19 + tests/sys/pjdfstest/tests/granular/Makefile | 10 + tests/sys/pjdfstest/tests/link/Makefile | 22 + tests/sys/pjdfstest/tests/mkdir/Makefile | 17 + tests/sys/pjdfstest/tests/mkfifo/Makefile | 17 + tests/sys/pjdfstest/tests/mknod/Makefile | 16 + tests/sys/pjdfstest/tests/open/Makefile | 29 + tests/sys/pjdfstest/tests/pjdfstest.test.mk | 14 + tests/sys/pjdfstest/tests/rename/Makefile | 26 + tests/sys/pjdfstest/tests/rmdir/Makefile | 20 + tests/sys/pjdfstest/tests/symlink/Makefile | 17 + tests/sys/pjdfstest/tests/truncate/Makefile | 19 + tests/sys/pjdfstest/tests/unlink/Makefile | 18 + tools/build/mk/OptionalObsoleteFiles.inc | 7 +- 255 files changed, 11320 insertions(+), 5 deletions(-) create mode 100644 contrib/pjdfstest/FREEBSD-upgrade create mode 100644 contrib/pjdfstest/LICENSE create mode 100644 contrib/pjdfstest/Makefile create mode 100644 contrib/pjdfstest/README create mode 100644 contrib/pjdfstest/pjdfstest.c create mode 100644 contrib/pjdfstest/tests/chflags/00.t create mode 100644 contrib/pjdfstest/tests/chflags/01.t create mode 100644 contrib/pjdfstest/tests/chflags/02.t create mode 100644 contrib/pjdfstest/tests/chflags/03.t create mode 100644 contrib/pjdfstest/tests/chflags/04.t create mode 100644 contrib/pjdfstest/tests/chflags/05.t create mode 100644 contrib/pjdfstest/tests/chflags/06.t create mode 100644 contrib/pjdfstest/tests/chflags/07.t create mode 100644 contrib/pjdfstest/tests/chflags/08.t create mode 100644 contrib/pjdfstest/tests/chflags/09.t create mode 100644 contrib/pjdfstest/tests/chflags/10.t create mode 100644 contrib/pjdfstest/tests/chflags/11.t create mode 100644 contrib/pjdfstest/tests/chflags/12.t create mode 100644 contrib/pjdfstest/tests/chflags/13.t create mode 100644 contrib/pjdfstest/tests/chmod/00.t create mode 100644 contrib/pjdfstest/tests/chmod/01.t create mode 100644 contrib/pjdfstest/tests/chmod/02.t create mode 100644 contrib/pjdfstest/tests/chmod/03.t create mode 100644 contrib/pjdfstest/tests/chmod/04.t create mode 100644 contrib/pjdfstest/tests/chmod/05.t create mode 100644 contrib/pjdfstest/tests/chmod/06.t create mode 100644 contrib/pjdfstest/tests/chmod/07.t create mode 100644 contrib/pjdfstest/tests/chmod/08.t create mode 100644 contrib/pjdfstest/tests/chmod/09.t create mode 100644 contrib/pjdfstest/tests/chmod/10.t create mode 100644 contrib/pjdfstest/tests/chmod/11.t create mode 100644 contrib/pjdfstest/tests/chmod/12.t create mode 100755 contrib/pjdfstest/tests/chmod/foo create mode 100644 contrib/pjdfstest/tests/chown/00.t create mode 100644 contrib/pjdfstest/tests/chown/01.t create mode 100644 contrib/pjdfstest/tests/chown/02.t create mode 100644 contrib/pjdfstest/tests/chown/03.t create mode 100644 contrib/pjdfstest/tests/chown/04.t create mode 100644 contrib/pjdfstest/tests/chown/05.t create mode 100644 contrib/pjdfstest/tests/chown/06.t create mode 100644 contrib/pjdfstest/tests/chown/07.t create mode 100644 contrib/pjdfstest/tests/chown/08.t create mode 100644 contrib/pjdfstest/tests/chown/09.t create mode 100644 contrib/pjdfstest/tests/chown/10.t create mode 100644 contrib/pjdfstest/tests/conf create mode 100644 contrib/pjdfstest/tests/ftruncate/00.t create mode 100644 contrib/pjdfstest/tests/ftruncate/01.t create mode 100644 contrib/pjdfstest/tests/ftruncate/02.t create mode 100644 contrib/pjdfstest/tests/ftruncate/03.t create mode 100644 contrib/pjdfstest/tests/ftruncate/04.t create mode 100644 contrib/pjdfstest/tests/ftruncate/05.t create mode 100644 contrib/pjdfstest/tests/ftruncate/06.t create mode 100644 contrib/pjdfstest/tests/ftruncate/07.t create mode 100644 contrib/pjdfstest/tests/ftruncate/08.t create mode 100644 contrib/pjdfstest/tests/ftruncate/09.t create mode 100644 contrib/pjdfstest/tests/ftruncate/10.t create mode 100644 contrib/pjdfstest/tests/ftruncate/11.t create mode 100644 contrib/pjdfstest/tests/ftruncate/12.t create mode 100644 contrib/pjdfstest/tests/ftruncate/13.t create mode 100644 contrib/pjdfstest/tests/ftruncate/14.t create mode 100644 contrib/pjdfstest/tests/granular/00.t create mode 100644 contrib/pjdfstest/tests/granular/01.t create mode 100644 contrib/pjdfstest/tests/granular/02.t create mode 100644 contrib/pjdfstest/tests/granular/03.t create mode 100644 contrib/pjdfstest/tests/granular/04.t create mode 100644 contrib/pjdfstest/tests/granular/05.t create mode 100644 contrib/pjdfstest/tests/link/00.t create mode 100644 contrib/pjdfstest/tests/link/01.t create mode 100644 contrib/pjdfstest/tests/link/02.t create mode 100644 contrib/pjdfstest/tests/link/03.t create mode 100644 contrib/pjdfstest/tests/link/04.t create mode 100644 contrib/pjdfstest/tests/link/05.t create mode 100644 contrib/pjdfstest/tests/link/06.t create mode 100644 contrib/pjdfstest/tests/link/07.t create mode 100644 contrib/pjdfstest/tests/link/08.t create mode 100644 contrib/pjdfstest/tests/link/09.t create mode 100644 contrib/pjdfstest/tests/link/10.t create mode 100644 contrib/pjdfstest/tests/link/11.t create mode 100644 contrib/pjdfstest/tests/link/12.t create mode 100644 contrib/pjdfstest/tests/link/13.t create mode 100644 contrib/pjdfstest/tests/link/14.t create mode 100644 contrib/pjdfstest/tests/link/15.t create mode 100644 contrib/pjdfstest/tests/link/16.t create mode 100644 contrib/pjdfstest/tests/link/17.t create mode 100755 contrib/pjdfstest/tests/misc.sh create mode 100644 contrib/pjdfstest/tests/mkdir/00.t create mode 100644 contrib/pjdfstest/tests/mkdir/01.t create mode 100644 contrib/pjdfstest/tests/mkdir/02.t create mode 100644 contrib/pjdfstest/tests/mkdir/03.t create mode 100644 contrib/pjdfstest/tests/mkdir/04.t create mode 100644 contrib/pjdfstest/tests/mkdir/05.t create mode 100644 contrib/pjdfstest/tests/mkdir/06.t create mode 100644 contrib/pjdfstest/tests/mkdir/07.t create mode 100644 contrib/pjdfstest/tests/mkdir/08.t create mode 100644 contrib/pjdfstest/tests/mkdir/09.t create mode 100644 contrib/pjdfstest/tests/mkdir/10.t create mode 100644 contrib/pjdfstest/tests/mkdir/11.t create mode 100644 contrib/pjdfstest/tests/mkdir/12.t create mode 100644 contrib/pjdfstest/tests/mkfifo/00.t create mode 100644 contrib/pjdfstest/tests/mkfifo/01.t create mode 100644 contrib/pjdfstest/tests/mkfifo/02.t create mode 100644 contrib/pjdfstest/tests/mkfifo/03.t create mode 100644 contrib/pjdfstest/tests/mkfifo/04.t create mode 100644 contrib/pjdfstest/tests/mkfifo/05.t create mode 100644 contrib/pjdfstest/tests/mkfifo/06.t create mode 100644 contrib/pjdfstest/tests/mkfifo/07.t create mode 100644 contrib/pjdfstest/tests/mkfifo/08.t create mode 100644 contrib/pjdfstest/tests/mkfifo/09.t create mode 100644 contrib/pjdfstest/tests/mkfifo/10.t create mode 100644 contrib/pjdfstest/tests/mkfifo/11.t create mode 100644 contrib/pjdfstest/tests/mkfifo/12.t create mode 100644 contrib/pjdfstest/tests/mknod/00.t create mode 100644 contrib/pjdfstest/tests/mknod/01.t create mode 100644 contrib/pjdfstest/tests/mknod/02.t create mode 100644 contrib/pjdfstest/tests/mknod/03.t create mode 100644 contrib/pjdfstest/tests/mknod/04.t create mode 100644 contrib/pjdfstest/tests/mknod/05.t create mode 100644 contrib/pjdfstest/tests/mknod/06.t create mode 100644 contrib/pjdfstest/tests/mknod/07.t create mode 100644 contrib/pjdfstest/tests/mknod/08.t create mode 100644 contrib/pjdfstest/tests/mknod/09.t create mode 100644 contrib/pjdfstest/tests/mknod/10.t create mode 100644 contrib/pjdfstest/tests/mknod/11.t create mode 100644 contrib/pjdfstest/tests/open/00.t create mode 100644 contrib/pjdfstest/tests/open/01.t create mode 100644 contrib/pjdfstest/tests/open/02.t create mode 100644 contrib/pjdfstest/tests/open/03.t create mode 100644 contrib/pjdfstest/tests/open/04.t create mode 100644 contrib/pjdfstest/tests/open/05.t create mode 100644 contrib/pjdfstest/tests/open/06.t create mode 100644 contrib/pjdfstest/tests/open/07.t create mode 100644 contrib/pjdfstest/tests/open/08.t create mode 100644 contrib/pjdfstest/tests/open/09.t create mode 100644 contrib/pjdfstest/tests/open/10.t create mode 100644 contrib/pjdfstest/tests/open/11.t create mode 100644 contrib/pjdfstest/tests/open/12.t create mode 100644 contrib/pjdfstest/tests/open/13.t create mode 100644 contrib/pjdfstest/tests/open/14.t create mode 100644 contrib/pjdfstest/tests/open/15.t create mode 100644 contrib/pjdfstest/tests/open/16.t create mode 100644 contrib/pjdfstest/tests/open/17.t create mode 100644 contrib/pjdfstest/tests/open/18.t create mode 100644 contrib/pjdfstest/tests/open/19.t create mode 100644 contrib/pjdfstest/tests/open/20.t create mode 100644 contrib/pjdfstest/tests/open/21.t create mode 100644 contrib/pjdfstest/tests/open/22.t create mode 100644 contrib/pjdfstest/tests/open/23.t create mode 100644 contrib/pjdfstest/tests/open/24.t create mode 100644 contrib/pjdfstest/tests/rename/00.t create mode 100644 contrib/pjdfstest/tests/rename/01.t create mode 100644 contrib/pjdfstest/tests/rename/02.t create mode 100644 contrib/pjdfstest/tests/rename/03.t create mode 100644 contrib/pjdfstest/tests/rename/04.t create mode 100644 contrib/pjdfstest/tests/rename/05.t create mode 100644 contrib/pjdfstest/tests/rename/06.t create mode 100644 contrib/pjdfstest/tests/rename/07.t create mode 100644 contrib/pjdfstest/tests/rename/08.t create mode 100644 contrib/pjdfstest/tests/rename/09.t create mode 100644 contrib/pjdfstest/tests/rename/10.t create mode 100644 contrib/pjdfstest/tests/rename/11.t create mode 100644 contrib/pjdfstest/tests/rename/12.t create mode 100644 contrib/pjdfstest/tests/rename/13.t create mode 100644 contrib/pjdfstest/tests/rename/14.t create mode 100644 contrib/pjdfstest/tests/rename/15.t create mode 100644 contrib/pjdfstest/tests/rename/16.t create mode 100644 contrib/pjdfstest/tests/rename/17.t create mode 100644 contrib/pjdfstest/tests/rename/18.t create mode 100644 contrib/pjdfstest/tests/rename/19.t create mode 100644 contrib/pjdfstest/tests/rename/20.t create mode 100644 contrib/pjdfstest/tests/rename/21.t create mode 100644 contrib/pjdfstest/tests/rmdir/00.t create mode 100644 contrib/pjdfstest/tests/rmdir/01.t create mode 100644 contrib/pjdfstest/tests/rmdir/02.t create mode 100644 contrib/pjdfstest/tests/rmdir/03.t create mode 100644 contrib/pjdfstest/tests/rmdir/04.t create mode 100644 contrib/pjdfstest/tests/rmdir/05.t create mode 100644 contrib/pjdfstest/tests/rmdir/06.t create mode 100644 contrib/pjdfstest/tests/rmdir/07.t create mode 100644 contrib/pjdfstest/tests/rmdir/08.t create mode 100644 contrib/pjdfstest/tests/rmdir/09.t create mode 100644 contrib/pjdfstest/tests/rmdir/10.t create mode 100644 contrib/pjdfstest/tests/rmdir/11.t create mode 100644 contrib/pjdfstest/tests/rmdir/12.t create mode 100644 contrib/pjdfstest/tests/rmdir/13.t create mode 100644 contrib/pjdfstest/tests/rmdir/14.t create mode 100644 contrib/pjdfstest/tests/rmdir/15.t create mode 100644 contrib/pjdfstest/tests/symlink/00.t create mode 100644 contrib/pjdfstest/tests/symlink/01.t create mode 100644 contrib/pjdfstest/tests/symlink/02.t create mode 100644 contrib/pjdfstest/tests/symlink/03.t create mode 100644 contrib/pjdfstest/tests/symlink/04.t create mode 100644 contrib/pjdfstest/tests/symlink/05.t create mode 100644 contrib/pjdfstest/tests/symlink/06.t create mode 100644 contrib/pjdfstest/tests/symlink/07.t create mode 100644 contrib/pjdfstest/tests/symlink/08.t create mode 100644 contrib/pjdfstest/tests/symlink/09.t create mode 100644 contrib/pjdfstest/tests/symlink/10.t create mode 100644 contrib/pjdfstest/tests/symlink/11.t create mode 100644 contrib/pjdfstest/tests/symlink/12.t create mode 100644 contrib/pjdfstest/tests/truncate/00.t create mode 100644 contrib/pjdfstest/tests/truncate/01.t create mode 100644 contrib/pjdfstest/tests/truncate/02.t create mode 100644 contrib/pjdfstest/tests/truncate/03.t create mode 100644 contrib/pjdfstest/tests/truncate/04.t create mode 100644 contrib/pjdfstest/tests/truncate/05.t create mode 100644 contrib/pjdfstest/tests/truncate/06.t create mode 100644 contrib/pjdfstest/tests/truncate/07.t create mode 100644 contrib/pjdfstest/tests/truncate/08.t create mode 100644 contrib/pjdfstest/tests/truncate/09.t create mode 100644 contrib/pjdfstest/tests/truncate/10.t create mode 100644 contrib/pjdfstest/tests/truncate/11.t create mode 100644 contrib/pjdfstest/tests/truncate/12.t create mode 100644 contrib/pjdfstest/tests/truncate/13.t create mode 100644 contrib/pjdfstest/tests/truncate/14.t create mode 100644 contrib/pjdfstest/tests/unlink/00.t create mode 100644 contrib/pjdfstest/tests/unlink/01.t create mode 100644 contrib/pjdfstest/tests/unlink/02.t create mode 100644 contrib/pjdfstest/tests/unlink/03.t create mode 100644 contrib/pjdfstest/tests/unlink/04.t create mode 100644 contrib/pjdfstest/tests/unlink/05.t create mode 100644 contrib/pjdfstest/tests/unlink/06.t create mode 100644 contrib/pjdfstest/tests/unlink/07.t create mode 100644 contrib/pjdfstest/tests/unlink/08.t create mode 100644 contrib/pjdfstest/tests/unlink/09.t create mode 100644 contrib/pjdfstest/tests/unlink/10.t create mode 100644 contrib/pjdfstest/tests/unlink/11.t create mode 100644 contrib/pjdfstest/tests/unlink/12.t create mode 100644 contrib/pjdfstest/tests/unlink/13.t create mode 100644 share/doc/pjdfstest/Makefile create mode 100644 share/doc/pjdfstest/README create mode 100644 tests/sys/pjdfstest/Makefile create mode 100644 tests/sys/pjdfstest/pjdfstest/Makefile create mode 100644 tests/sys/pjdfstest/tests/Makefile create mode 100644 tests/sys/pjdfstest/tests/chflags/Makefile create mode 100644 tests/sys/pjdfstest/tests/chmod/Makefile create mode 100644 tests/sys/pjdfstest/tests/chown/Makefile create mode 100644 tests/sys/pjdfstest/tests/conf create mode 100644 tests/sys/pjdfstest/tests/ftruncate/Makefile create mode 100644 tests/sys/pjdfstest/tests/granular/Makefile create mode 100644 tests/sys/pjdfstest/tests/link/Makefile create mode 100644 tests/sys/pjdfstest/tests/mkdir/Makefile create mode 100644 tests/sys/pjdfstest/tests/mkfifo/Makefile create mode 100644 tests/sys/pjdfstest/tests/mknod/Makefile create mode 100644 tests/sys/pjdfstest/tests/open/Makefile create mode 100644 tests/sys/pjdfstest/tests/pjdfstest.test.mk create mode 100644 tests/sys/pjdfstest/tests/rename/Makefile create mode 100644 tests/sys/pjdfstest/tests/rmdir/Makefile create mode 100644 tests/sys/pjdfstest/tests/symlink/Makefile create mode 100644 tests/sys/pjdfstest/tests/truncate/Makefile create mode 100644 tests/sys/pjdfstest/tests/unlink/Makefile diff --git a/UPDATING b/UPDATING index 4aa2e14ac567..4e92514cf234 100644 --- a/UPDATING +++ b/UPDATING @@ -16,6 +16,11 @@ from older versions of FreeBSD, try WITHOUT_CLANG to bootstrap to the tip of stable/10, and then rebuild without this option. The bootstrap process from older version of current is a bit fragile. +20141205: + pjdfstest has been integrated into kyua as an opt-in test suite. + Please see share/doc/pjdfstest/README for a more details on how to + execute it. + 20141118: 10.1-RELEASE. diff --git a/contrib/pjdfstest/FREEBSD-upgrade b/contrib/pjdfstest/FREEBSD-upgrade new file mode 100644 index 000000000000..eff295fbfdc0 --- /dev/null +++ b/contrib/pjdfstest/FREEBSD-upgrade @@ -0,0 +1,25 @@ +$FreeBSD$ + +This document contains a collection of notes specific to the import +of pjdfstest into head. These notes are built on the instructions in +the FreeBSD Subversion Primer that detail how to deal with vendor +branches and you are supposed to follow those: + + http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html + +The pjdfstest source code is hosted on GitHub: + + https://github.com/pjd/pjdfstest + +and is imported into the pjdfstest vendor branch (see base/vendor/pjdfstest/). + +To merge the vendor branch into head do something like this: + + cd .../base/head/contrib/pjdfstest + svn merge --accept=postpone \ + svn+ssh://svn.freebsd.org/base/vendor/pjdfstest/dist . + +and resolve any conflicts that may arise at this point. + +Lastly, with the list of old and new files in this import, make sure +to update the reachover Makefiles accordingly. diff --git a/contrib/pjdfstest/LICENSE b/contrib/pjdfstest/LICENSE new file mode 100644 index 000000000000..f91e71b37bf4 --- /dev/null +++ b/contrib/pjdfstest/LICENSE @@ -0,0 +1,27 @@ +$FreeBSD: head/tools/regression/pjdfstest/LICENSE 211354 2010-08-15 21:29:03Z pjd $ + +License for all regression tests available with pjdfstest: + +Copyright (c) 2006-2012 Pawel Jakub Dawidek +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 AUTHORS 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 AUTHORS 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. diff --git a/contrib/pjdfstest/Makefile b/contrib/pjdfstest/Makefile new file mode 100644 index 000000000000..a3e35f89b382 --- /dev/null +++ b/contrib/pjdfstest/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +PROG= pjdfstest + +${PROG}: ${PROG}.c + @OSTYPE=`uname`; \ + CFLAGS=-D__OS_$${OSTYPE}__; \ + if [ $$OSTYPE = "FreeBSD" ]; then \ + CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS -DHAS_CHFLAGSAT -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL -DHAS_BINDAT -DHAS_CONNECTAT -DHAS_LPATHCONF"; \ + elif [ $$OSTYPE = "SunOS" ]; then \ + CFLAGS="$$CFLAGS -DHAS_TRUNCATE64 -DHAS_STAT64"; \ + CFLAGS="$$CFLAGS -lsocket"; \ + elif [ $$OSTYPE = "Darwin" ]; then \ + CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS"; \ + elif [ $$OSTYPE == "Linux" ]; then \ + CFLAGS="$$CFLAGS -D_GNU_SOURCE"; \ + else \ + echo "Unsupported operating system: ${OSTYPE}."; \ + exit 1; \ + fi; \ + cmd="gcc -Wall $$CFLAGS ${PROG}.c -o ${PROG}"; \ + echo $$cmd; \ + $$cmd + +clean: + rm -f ${PROG} diff --git a/contrib/pjdfstest/README b/contrib/pjdfstest/README new file mode 100644 index 000000000000..dcc5a64ba3f4 --- /dev/null +++ b/contrib/pjdfstest/README @@ -0,0 +1,22 @@ +$FreeBSD: head/tools/regression/pjdfstest/README 211354 2010-08-15 21:29:03Z pjd $ + +Few notes on how to use pjdfstest in short steps: + + # cd pjdfstest + # vi tests/conf + Change 'fs' to file system type you want to test (UFS or ZFS). + # vi Makefile + You need to manually tweak few things by editing CFLAGS lines + at the top of the file. + # make + It will compile pjdfstest utility which is used by regression tests. + # cd /path/to/file/system/you/want/to/test/ + # prove -r /path/to/pjdfstest/tests + +That's all. Enjoy. + +Currently supported operating systems: FreeBSD, Solaris. +Currently supported file system types: UFS, ZFS. + +-- +Pawel Jakub Dawidek diff --git a/contrib/pjdfstest/pjdfstest.c b/contrib/pjdfstest/pjdfstest.c new file mode 100644 index 000000000000..046df490e4f7 --- /dev/null +++ b/contrib/pjdfstest/pjdfstest.c @@ -0,0 +1,1493 @@ +/*- + * Copyright (c) 2006-2010 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#ifndef makedev +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef HAS_TRUNCATE64 +#define truncate64 truncate +#define ftruncate64 ftruncate +#endif +#ifndef HAS_STAT64 +#define stat64 stat +#define fstat64 fstat +#define lstat64 lstat +#endif +#ifdef HAS_FREEBSD_ACL +#include +#endif + +#ifndef ALLPERMS +#define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO) +#endif + +enum action { + ACTION_OPEN, + ACTION_OPENAT, + ACTION_CREATE, + ACTION_UNLINK, + ACTION_UNLINKAT, + ACTION_MKDIR, + ACTION_MKDIRAT, + ACTION_RMDIR, + ACTION_LINK, + ACTION_LINKAT, + ACTION_SYMLINK, + ACTION_SYMLINKAT, + ACTION_RENAME, + ACTION_RENAMEAT, + ACTION_MKFIFO, + ACTION_MKFIFOAT, + ACTION_MKNOD, + ACTION_MKNODAT, + ACTION_BIND, +#ifdef HAS_BINDAT + ACTION_BINDAT, +#endif + ACTION_CONNECT, +#ifdef HAS_CONNECTAT + ACTION_CONNECTAT, +#endif + ACTION_CHMOD, + ACTION_FCHMOD, +#ifdef HAS_LCHMOD + ACTION_LCHMOD, +#endif + ACTION_FCHMODAT, + ACTION_CHOWN, + ACTION_FCHOWN, + ACTION_LCHOWN, + ACTION_FCHOWNAT, +#ifdef HAS_CHFLAGS + ACTION_CHFLAGS, +#endif +#ifdef HAS_FCHFLAGS + ACTION_FCHFLAGS, +#endif +#ifdef HAS_CHFLAGSAT + ACTION_CHFLAGSAT, +#endif +#ifdef HAS_LCHFLAGS + ACTION_LCHFLAGS, +#endif + ACTION_TRUNCATE, + ACTION_FTRUNCATE, + ACTION_STAT, + ACTION_FSTAT, + ACTION_LSTAT, + ACTION_FSTATAT, + ACTION_PATHCONF, + ACTION_FPATHCONF, +#ifdef HAS_LPATHCONF + ACTION_LPATHCONF, +#endif +#ifdef HAS_FREEBSD_ACL + ACTION_PREPENDACL, + ACTION_READACL, +#endif + ACTION_WRITE, +}; + +#define TYPE_NONE 0x0000 +#define TYPE_STRING 0x0001 +#define TYPE_NUMBER 0x0002 +#define TYPE_DESCRIPTOR 0x0003 +#define TYPE_MASK 0x000f + +#define TYPE_OPTIONAL 0x0100 + +#define MAX_ARGS 8 + +struct syscall_desc { + const char *sd_name; + enum action sd_action; + int sd_args[MAX_ARGS]; +}; + +static struct syscall_desc syscalls[] = { + { "open", ACTION_OPEN, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } }, + { "openat", ACTION_OPENAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } }, + { "create", ACTION_CREATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "unlink", ACTION_UNLINK, { TYPE_STRING, TYPE_NONE } }, + { "unlinkat", ACTION_UNLINKAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "mkdir", ACTION_MKDIR, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mkdirat", ACTION_MKDIRAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "rmdir", ACTION_RMDIR, { TYPE_STRING, TYPE_NONE } }, + { "link", ACTION_LINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "linkat", ACTION_LINKAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "symlinkat", ACTION_SYMLINKAT, { TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, + { "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "renameat", ACTION_RENAMEAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, + { "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mkfifoat", ACTION_MKFIFOAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, + { "mknodat", ACTION_MKNODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, + { "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } }, +#ifdef HAS_BINDAT + { "bindat", ACTION_BINDAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, +#endif + { "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } }, +#ifdef HAS_CONNECTAT + { "connectat", ACTION_CONNECTAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, +#endif + { "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "fchmod", ACTION_FCHMOD, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NONE } }, +#ifdef HAS_LCHMOD + { "lchmod", ACTION_LCHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, +#endif + { "fchmodat", ACTION_FCHMODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, + { "chown", ACTION_CHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchown", ACTION_FCHOWN, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "lchown", ACTION_LCHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchownat", ACTION_FCHOWNAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, +#ifdef HAS_CHFLAGS + { "chflags", ACTION_CHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, +#endif +#ifdef HAS_FCHFLAGS + { "fchflags", ACTION_FCHFLAGS, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, +#endif +#ifdef HAS_CHFLAGSAT + { "chflagsat", ACTION_CHFLAGSAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, +#endif +#ifdef HAS_LCHFLAGS + { "lchflags", ACTION_LCHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, +#endif + { "truncate", ACTION_TRUNCATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "ftruncate", ACTION_FTRUNCATE, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NONE } }, + { "stat", ACTION_STAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "fstat", ACTION_FSTAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, + { "lstat", ACTION_LSTAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "fstatat", ACTION_FSTATAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "pathconf", ACTION_PATHCONF, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "fpathconf", ACTION_FPATHCONF, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, +#ifdef HAS_LPATHCONF + { "lpathconf", ACTION_LPATHCONF, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, +#endif +#ifdef HAS_FREEBSD_ACL + { "prependacl", ACTION_PREPENDACL, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "readacl", ACTION_READACL, { TYPE_STRING, TYPE_NONE } }, +#endif + { "write", ACTION_WRITE, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, + { NULL, -1, { TYPE_NONE } } +}; + +struct flag { + long long f_flag; + const char *f_str; +}; + +static struct flag open_flags[] = { +#ifdef O_RDONLY + { O_RDONLY, "O_RDONLY" }, +#endif +#ifdef O_WRONLY + { O_WRONLY, "O_WRONLY" }, +#endif +#ifdef O_RDWR + { O_RDWR, "O_RDWR" }, +#endif +#ifdef O_NONBLOCK + { O_NONBLOCK, "O_NONBLOCK" }, +#endif +#ifdef O_APPEND + { O_APPEND, "O_APPEND" }, +#endif +#ifdef O_CREAT + { O_CREAT, "O_CREAT" }, +#endif +#ifdef O_TRUNC + { O_TRUNC, "O_TRUNC" }, +#endif +#ifdef O_EXCL + { O_EXCL, "O_EXCL" }, +#endif +#ifdef O_SHLOCK + { O_SHLOCK, "O_SHLOCK" }, +#endif +#ifdef O_EXLOCK + { O_EXLOCK, "O_EXLOCK" }, +#endif +#ifdef O_DIRECT + { O_DIRECT, "O_DIRECT" }, +#endif +#ifdef O_FSYNC + { O_FSYNC, "O_FSYNC" }, +#endif +#ifdef O_SYNC + { O_SYNC, "O_SYNC" }, +#endif +#ifdef O_NOFOLLOW + { O_NOFOLLOW, "O_NOFOLLOW" }, +#endif +#ifdef O_NOCTTY + { O_NOCTTY, "O_NOCTTY" }, +#endif +#ifdef O_DIRECTORY + { O_DIRECTORY, "O_DIRECTORY" }, +#endif + { 0, NULL } +}; + +#ifdef HAS_CHFLAGS +static struct flag chflags_flags[] = { +#ifdef UF_NODUMP + { UF_NODUMP, "UF_NODUMP" }, +#endif +#ifdef UF_IMMUTABLE + { UF_IMMUTABLE, "UF_IMMUTABLE" }, +#endif +#ifdef UF_APPEND + { UF_APPEND, "UF_APPEND" }, +#endif +#ifdef UF_NOUNLINK + { UF_NOUNLINK, "UF_NOUNLINK" }, +#endif +#ifdef UF_OPAQUE + { UF_OPAQUE, "UF_OPAQUE" }, +#endif +#ifdef SF_ARCHIVED + { SF_ARCHIVED, "SF_ARCHIVED" }, +#endif +#ifdef SF_IMMUTABLE + { SF_IMMUTABLE, "SF_IMMUTABLE" }, +#endif +#ifdef SF_APPEND + { SF_APPEND, "SF_APPEND" }, +#endif +#ifdef SF_NOUNLINK + { SF_NOUNLINK, "SF_NOUNLINK" }, +#endif +#ifdef SF_SNAPSHOT + { SF_SNAPSHOT, "SF_SNAPSHOT" }, +#endif + { 0, NULL } +}; +#endif + +static struct flag unlinkat_flags[] = { + { AT_REMOVEDIR, "AT_REMOVEDIR" }, + { 0, NULL } +}; + +static struct flag linkat_flags[] = { + { AT_SYMLINK_FOLLOW, "AT_SYMLINK_FOLLOW" }, + { 0, NULL } +}; + +static struct flag chflagsat_flags[] = { + { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" }, + { 0, NULL } +}; + +static struct flag fchmodat_flags[] = { + { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" }, + { 0, NULL } +}; + +static struct flag fchownat_flags[] = { + { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" }, + { 0, NULL } +}; + +static struct flag fstatat_flags[] = { + { AT_SYMLINK_NOFOLLOW, "AT_SYMLINK_NOFOLLOW" }, + { 0, NULL } +}; + +struct name { + int n_name; + const char *n_str; +}; + +static struct name pathconf_names[] = { +#ifdef _PC_LINK_MAX + { _PC_LINK_MAX, "_PC_LINK_MAX" }, +#endif +#ifdef _PC_NAME_MAX + { _PC_NAME_MAX, "_PC_NAME_MAX" }, +#endif +#ifdef _PC_PATH_MAX + { _PC_PATH_MAX, "_PC_PATH_MAX" }, +#endif +#ifdef _PC_SYMLINK_MAX + { _PC_SYMLINK_MAX, "_PC_SYMLINK_MAX" }, +#endif + { 0, NULL } +}; + +static const char *err2str(int error); + +static int *descriptors; +static int ndescriptors; + +static void +usage(void) +{ + + fprintf(stderr, "usage: pjdfstest [-U umask] [-u uid] [-g gid1[,gid2[...]]] syscall args ...\n"); + exit(1); +} + +static long long +str2flags(struct flag *tflags, char *sflags) +{ + long long flags = 0; + unsigned int i; + char *f; + + /* 'none' or '0' means no flags */ + if (strcmp(sflags, "none") == 0 || strcmp(sflags, "0") == 0) + return (0); + for (f = strtok(sflags, ",|"); f != NULL; f = strtok(NULL, ",|")) { + for (i = 0; tflags[i].f_str != NULL; i++) { + if (strcmp(tflags[i].f_str, f) == 0) + break; + } + if (tflags[i].f_str == NULL) { + fprintf(stderr, "unknown flag '%s'\n", f); + exit(1); + } + flags |= tflags[i].f_flag; + } + return (flags); +} + +#ifdef HAS_CHFLAGS +static char * +flags2str(struct flag *tflags, long long flags) +{ + static char sflags[1024]; + unsigned int i; + + sflags[0] = '\0'; + for (i = 0; tflags[i].f_str != NULL; i++) { + if (flags & tflags[i].f_flag) { + if (sflags[0] != '\0') + strlcat(sflags, ",", sizeof(sflags)); + strlcat(sflags, tflags[i].f_str, sizeof(sflags)); + } + } + if (sflags[0] == '\0') + strlcpy(sflags, "none", sizeof(sflags)); + return (sflags); +} +#endif + +static int +str2name(struct name *names, char *name) +{ + unsigned int i; + + for (i = 0; names[i].n_str != NULL; i++) { + if (strcmp(names[i].n_str, name) == 0) + return (names[i].n_name); + } + return (-1); +} + +static struct syscall_desc * +find_syscall(const char *name) +{ + int i; + + for (i = 0; syscalls[i].sd_name != NULL; i++) { + if (strcmp(syscalls[i].sd_name, name) == 0) + return (&syscalls[i]); + } + return (NULL); +} + +static void +show_stat(struct stat64 *sp, const char *what) +{ + + if (strcmp(what, "mode") == 0) + printf("0%o", (unsigned int)(sp->st_mode & ALLPERMS)); + else if (strcmp(what, "inode") == 0) + printf("%lld", (long long)sp->st_ino); + else if (strcmp(what, "nlink") == 0) + printf("%lld", (long long)sp->st_nlink); + else if (strcmp(what, "uid") == 0) + printf("%d", (int)sp->st_uid); + else if (strcmp(what, "gid") == 0) + printf("%d", (int)sp->st_gid); + else if (strcmp(what, "size") == 0) + printf("%lld", (long long)sp->st_size); + else if (strcmp(what, "blocks") == 0) + printf("%lld", (long long)sp->st_blocks); + else if (strcmp(what, "atime") == 0) + printf("%lld", (long long)sp->st_atime); + else if (strcmp(what, "mtime") == 0) + printf("%lld", (long long)sp->st_mtime); + else if (strcmp(what, "ctime") == 0) + printf("%lld", (long long)sp->st_ctime); +#ifdef HAS_CHFLAGS + else if (strcmp(what, "flags") == 0) + printf("%s", flags2str(chflags_flags, (long long)sp->st_flags)); +#endif + else if (strcmp(what, "major") == 0) + printf("%u", (unsigned int)major(sp->st_rdev)); + else if (strcmp(what, "minor") == 0) + printf("%u", (unsigned int)minor(sp->st_rdev)); + else if (strcmp(what, "type") == 0) { + switch (sp->st_mode & S_IFMT) { + case S_IFIFO: + printf("fifo"); + break; + case S_IFCHR: + printf("char"); + break; + case S_IFDIR: + printf("dir"); + break; + case S_IFBLK: + printf("block"); + break; + case S_IFREG: + printf("regular"); + break; + case S_IFLNK: + printf("symlink"); + break; + case S_IFSOCK: + printf("socket"); + break; + default: + printf("unknown"); + break; + } + } else { + printf("unknown"); + } +} + +static void +show_stats(struct stat64 *sp, char *what) +{ + const char *s = ""; + char *w; + + for (w = strtok(what, ","); w != NULL; w = strtok(NULL, ",")) { + printf("%s", s); + show_stat(sp, w); + s = ","; + } + printf("\n"); +} + +static void +descriptor_add(int fd) +{ + + ndescriptors++; + if (descriptors == NULL) { + descriptors = malloc(sizeof(descriptors[0]) * ndescriptors); + } else { + descriptors = realloc(descriptors, + sizeof(descriptors[0]) * ndescriptors); + } + assert(descriptors != NULL); + descriptors[ndescriptors - 1] = fd; +} + +static int +descriptor_get(int pos) +{ + + if (pos < 0 || pos >= ndescriptors) { + fprintf(stderr, "invalid descriptor %d\n", pos); + exit(1); + } + + return (descriptors[pos]); +} + +static unsigned int +call_syscall(struct syscall_desc *scall, char *argv[]) +{ + struct stat64 sb; + long long flags; + unsigned int i; + char *endp; + int name, rval; + union { + char *str; + long long num; + } args[MAX_ARGS]; +#ifdef HAS_FREEBSD_ACL + int entry_id = ACL_FIRST_ENTRY; + acl_t acl, newacl; + acl_entry_t entry, newentry; +#endif + + /* + * Verify correctness of the arguments. + */ + for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) { + if (scall->sd_args[i] == TYPE_NONE) { + if (argv[i] == NULL || strcmp(argv[i], ":") == 0) + break; + fprintf(stderr, "too many arguments [%s]\n", argv[i]); + exit(1); + } else { + if (argv[i] == NULL || strcmp(argv[i], ":") == 0) { + if (scall->sd_args[i] & TYPE_OPTIONAL) + break; + fprintf(stderr, "too few arguments\n"); + exit(1); + } + if ((scall->sd_args[i] & TYPE_MASK) == TYPE_STRING) { + if (strcmp(argv[i], "NULL") == 0) + args[i].str = NULL; + else if (strcmp(argv[i], "DEADCODE") == 0) + args[i].str = (void *)0xdeadc0de; + else + args[i].str = argv[i]; + } else if ((scall->sd_args[i] & TYPE_MASK) == + TYPE_NUMBER) { + args[i].num = strtoll(argv[i], &endp, 0); + if (*endp != '\0' && + !isspace((unsigned char)*endp)) { + fprintf(stderr, + "invalid argument %u, number expected [%s]\n", + i, endp); + exit(1); + } + } else if ((scall->sd_args[i] & TYPE_MASK) == + TYPE_DESCRIPTOR) { + if (strcmp(argv[i], "AT_FDCWD") == 0) { + args[i].num = AT_FDCWD; + } else if (strcmp(argv[i], "BADFD") == 0) { + /* In case AT_FDCWD is -1 on some systems... */ + if (AT_FDCWD == -1) + args[i].num = -2; + else + args[i].num = -1; + } else { + int pos; + + pos = strtoll(argv[i], &endp, 0); + if (*endp != '\0' && + !isspace((unsigned char)*endp)) { + fprintf(stderr, + "invalid argument %u, number expected [%s]\n", + i, endp); + exit(1); + } + args[i].num = descriptor_get(pos); + } + } + } + } + /* + * Call the given syscall. + */ +#define NUM(n) (args[(n)].num) +#define STR(n) (args[(n)].str) + switch (scall->sd_action) { + case ACTION_OPEN: + flags = str2flags(open_flags, STR(1)); + if (flags & O_CREAT) { + if (i == 2) { + fprintf(stderr, "too few arguments\n"); + exit(1); + } + rval = open(STR(0), (int)flags, (mode_t)NUM(2)); + } else { + if (i == 3) { + fprintf(stderr, "too many arguments\n"); + exit(1); + } + rval = open(STR(0), (int)flags); + } + if (rval >= 0) + descriptor_add(rval); + break; + case ACTION_OPENAT: + flags = str2flags(open_flags, STR(2)); + if (flags & O_CREAT) { + if (i == 3) { + fprintf(stderr, "too few arguments\n"); + exit(1); + } + rval = openat(NUM(0), STR(1), (int)flags, + (mode_t)NUM(3)); + } else { + if (i == 4) { + fprintf(stderr, "too many arguments\n"); + exit(1); + } + rval = openat(NUM(0), STR(1), (int)flags); + } + if (rval >= 0) + descriptor_add(rval); + break; + case ACTION_CREATE: + rval = open(STR(0), O_CREAT | O_EXCL, (mode_t)NUM(1)); + if (rval >= 0) + close(rval); + break; + case ACTION_UNLINK: + rval = unlink(STR(0)); + break; + case ACTION_UNLINKAT: + rval = unlinkat(NUM(0), STR(1), + (int)str2flags(unlinkat_flags, STR(2))); + break; + case ACTION_MKDIR: + rval = mkdir(STR(0), (mode_t)NUM(1)); + break; + case ACTION_MKDIRAT: + rval = mkdirat(NUM(0), STR(1), (mode_t)NUM(2)); + break; + case ACTION_RMDIR: + rval = rmdir(STR(0)); + break; + case ACTION_LINK: + rval = link(STR(0), STR(1)); + break; + case ACTION_LINKAT: + rval = linkat(NUM(0), STR(1), NUM(2), STR(3), + (int)str2flags(linkat_flags, STR(4))); + break; + case ACTION_SYMLINK: + rval = symlink(STR(0), STR(1)); + break; + case ACTION_SYMLINKAT: + rval = symlinkat(STR(0), NUM(1), STR(2)); + break; + case ACTION_RENAME: + rval = rename(STR(0), STR(1)); + break; + case ACTION_RENAMEAT: + rval = renameat(NUM(0), STR(1), NUM(2), STR(3)); + break; + case ACTION_MKFIFO: + rval = mkfifo(STR(0), (mode_t)NUM(1)); + break; + case ACTION_MKFIFOAT: + rval = mkfifoat(NUM(0), STR(1), (mode_t)NUM(2)); + break; + case ACTION_MKNOD: + case ACTION_MKNODAT: + { + mode_t ntype; + dev_t dev; + int fa; + + switch (scall->sd_action) { + case ACTION_MKNOD: + fa = 0; + break; + case ACTION_MKNODAT: + fa = 1; + break; + default: + abort(); + } + + dev = makedev(NUM(fa + 3), NUM(fa + 4)); + if (strcmp(STR(fa + 1), "c") == 0) /* character device */ + ntype = S_IFCHR; + else if (strcmp(STR(fa + 1), "b") == 0) /* block device */ + ntype = S_IFBLK; + else if (strcmp(STR(fa + 1), "f") == 0) /* fifo special */ + ntype = S_IFIFO; + else if (strcmp(STR(fa + 1), "d") == 0) /* directory */ + ntype = S_IFDIR; + else if (strcmp(STR(fa + 1), "o") == 0) /* regular file */ + ntype = S_IFREG; + else { + fprintf(stderr, "wrong argument 1\n"); + exit(1); + } + switch (scall->sd_action) { + case ACTION_MKNOD: + rval = mknod(STR(0), ntype | NUM(2), dev); + break; + case ACTION_MKNODAT: + rval = mknodat(NUM(0), STR(1), ntype | NUM(3), dev); + break; + default: + abort(); + } + break; + } + case ACTION_BIND: + { + struct sockaddr_un sunx; + + sunx.sun_family = AF_UNIX; + strncpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path) - 1); + sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; + rval = socket(AF_UNIX, SOCK_STREAM, 0); + if (rval < 0) + break; + rval = bind(rval, (struct sockaddr *)&sunx, sizeof(sunx)); + break; + } +#ifdef HAS_BINDAT + case ACTION_BINDAT: + { + struct sockaddr_un sunx; + + sunx.sun_family = AF_UNIX; + strncpy(sunx.sun_path, STR(1), sizeof(sunx.sun_path) - 1); + sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; + rval = socket(AF_UNIX, SOCK_STREAM, 0); + if (rval < 0) + break; + rval = bindat(NUM(0), rval, (struct sockaddr *)&sunx, + sizeof(sunx)); + break; + } +#endif + case ACTION_CONNECT: + { + struct sockaddr_un sunx; + + sunx.sun_family = AF_UNIX; + strncpy(sunx.sun_path, STR(0), sizeof(sunx.sun_path) - 1); + sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; + rval = socket(AF_UNIX, SOCK_STREAM, 0); + if (rval < 0) + break; + rval = connect(rval, (struct sockaddr *)&sunx, sizeof(sunx)); + break; + } +#ifdef HAS_CONNECTAT + case ACTION_CONNECTAT: + { + struct sockaddr_un sunx; + + sunx.sun_family = AF_UNIX; + strncpy(sunx.sun_path, STR(1), sizeof(sunx.sun_path) - 1); + sunx.sun_path[sizeof(sunx.sun_path) - 1] = '\0'; + rval = socket(AF_UNIX, SOCK_STREAM, 0); + if (rval < 0) + break; + rval = connectat(NUM(0), rval, (struct sockaddr *)&sunx, + sizeof(sunx)); + break; + } +#endif + case ACTION_CHMOD: + rval = chmod(STR(0), (mode_t)NUM(1)); + break; + case ACTION_FCHMOD: + rval = fchmod(NUM(0), (mode_t)NUM(1)); + break; +#ifdef HAS_LCHMOD + case ACTION_LCHMOD: + rval = lchmod(STR(0), (mode_t)NUM(1)); + break; +#endif + case ACTION_FCHMODAT: + rval = fchmodat(NUM(0), STR(1), (mode_t)NUM(2), + str2flags(fchmodat_flags, STR(3))); + break; + case ACTION_CHOWN: + rval = chown(STR(0), (uid_t)NUM(1), (gid_t)NUM(2)); + break; + case ACTION_FCHOWN: + rval = fchown(NUM(0), (uid_t)NUM(1), (gid_t)NUM(2)); + break; + case ACTION_LCHOWN: + rval = lchown(STR(0), (uid_t)NUM(1), (gid_t)NUM(2)); + break; + case ACTION_FCHOWNAT: + rval = fchownat(NUM(0), STR(1), (uid_t)NUM(2), (gid_t)NUM(3), + (int)str2flags(fchownat_flags, STR(4))); + break; +#ifdef HAS_CHFLAGS + case ACTION_CHFLAGS: + rval = chflags(STR(0), + (unsigned long)str2flags(chflags_flags, STR(1))); + break; +#endif +#ifdef HAS_FCHFLAGS + case ACTION_FCHFLAGS: + rval = fchflags(NUM(0), + (unsigned long)str2flags(chflags_flags, STR(1))); + break; +#endif +#ifdef HAS_CHFLAGSAT + case ACTION_CHFLAGSAT: + rval = chflagsat(NUM(0), STR(1), + (unsigned long)str2flags(chflags_flags, STR(2)), + (int)str2flags(chflagsat_flags, STR(3))); + break; +#endif +#ifdef HAS_LCHFLAGS + case ACTION_LCHFLAGS: + rval = lchflags(STR(0), + (unsigned long)str2flags(chflags_flags, STR(1))); + break; +#endif + case ACTION_TRUNCATE: + rval = truncate64(STR(0), NUM(1)); + break; + case ACTION_FTRUNCATE: + rval = ftruncate64(NUM(0), NUM(1)); + break; + case ACTION_STAT: + rval = stat64(STR(0), &sb); + if (rval == 0) { + show_stats(&sb, STR(1)); + return (i); + } + break; + case ACTION_FSTAT: + rval = fstat64(NUM(0), &sb); + if (rval == 0) { + show_stats(&sb, STR(1)); + return (i); + } + break; + case ACTION_LSTAT: + rval = lstat64(STR(0), &sb); + if (rval == 0) { + show_stats(&sb, STR(1)); + return (i); + } + break; + case ACTION_FSTATAT: + rval = fstatat(NUM(0), STR(1), &sb, + (int)str2flags(fstatat_flags, STR(2))); + if (rval == 0) { + show_stats(&sb, STR(3)); + return (i); + } + break; + case ACTION_PATHCONF: + case ACTION_FPATHCONF: +#ifdef HAS_LPATHCONF + case ACTION_LPATHCONF: +#endif + { + long lrval; + + name = str2name(pathconf_names, STR(1)); + if (name == -1) { + fprintf(stderr, "unknown name %s", STR(1)); + exit(1); + } + errno = 0; + switch (scall->sd_action) { + case ACTION_PATHCONF: + lrval = pathconf(STR(0), name); + break; + case ACTION_FPATHCONF: + lrval = fpathconf(NUM(0), name); + break; +#ifdef HAS_LPATHCONF + case ACTION_LPATHCONF: + lrval = lpathconf(STR(0), name); + break; +#endif + default: + abort(); + } + if (lrval == -1 && errno == 0) { + printf("unlimited\n"); + return (i); + } else if (lrval >= 0) { + printf("%ld\n", lrval); + return (i); + } + rval = -1; + break; + } +#ifdef HAS_FREEBSD_ACL + case ACTION_PREPENDACL: + rval = -1; + + acl = acl_get_file(STR(0), ACL_TYPE_NFS4); + if (acl == NULL) + break; + + newacl = acl_from_text(STR(1)); + if (acl == NULL) + break; + + while (acl_get_entry(newacl, entry_id, &newentry) == 1) { + entry_id = ACL_NEXT_ENTRY; + + if (acl_create_entry_np(&acl, &entry, 0)) + break; + + if (acl_copy_entry(entry, newentry)) + break; + } + + rval = acl_set_file(STR(0), ACL_TYPE_NFS4, acl); + break; + case ACTION_READACL: + acl = acl_get_file(STR(0), ACL_TYPE_NFS4); + if (acl == NULL) + rval = -1; + else + rval = 0; + break; +#endif + case ACTION_WRITE: + rval = write(NUM(0), STR(1), strlen(STR(1))); + break; + default: + fprintf(stderr, "unsupported syscall\n"); + exit(1); + } +#undef STR +#undef NUM + if (rval < 0) { + const char *serrno; + + serrno = err2str(errno); + fprintf(stderr, "%s returned %d\n", scall->sd_name, rval); + printf("%s\n", serrno); + exit(1); + } + printf("0\n"); + return (i); +} + +static void +set_gids(char *gids) +{ + gid_t *gidset; + long ngroups; + char *g, *endp; + unsigned i; + + ngroups = sysconf(_SC_NGROUPS_MAX); + assert(ngroups > 0); + gidset = malloc(sizeof(*gidset) * ngroups); + assert(gidset != NULL); + for (i = 0, g = strtok(gids, ","); g != NULL; + g = strtok(NULL, ","), i++) { + if (i >= ngroups) { + fprintf(stderr, "too many gids\n"); + exit(1); + } + gidset[i] = strtol(g, &endp, 0); + if (*endp != '\0' && !isspace((unsigned char)*endp)) { + fprintf(stderr, "invalid gid '%s' - number expected\n", + g); + exit(1); + } + } + if (setgroups(i, gidset) < 0) { + fprintf(stderr, "cannot change groups: %s\n", strerror(errno)); + exit(1); + } + if (setegid(gidset[0]) < 0) { + fprintf(stderr, "cannot change effective gid: %s\n", + strerror(errno)); + exit(1); + } + free(gidset); +} + +int +main(int argc, char *argv[]) +{ + struct syscall_desc *scall; + unsigned int n; + char *gids, *endp; + int uid, umsk, ch; + + uid = -1; + gids = NULL; + umsk = 0; + + while ((ch = getopt(argc, argv, "g:u:U:")) != -1) { + switch(ch) { + case 'g': + gids = optarg; + break; + case 'u': + uid = (int)strtol(optarg, &endp, 0); + if (*endp != '\0' && !isspace((unsigned char)*endp)) { + fprintf(stderr, "invalid uid '%s' - number " + "expected\n", optarg); + exit(1); + } + break; + case 'U': + umsk = (int)strtol(optarg, &endp, 0); + if (*endp != '\0' && !isspace((unsigned char)*endp)) { + fprintf(stderr, "invalid umask '%s' - number " + "expected\n", optarg); + exit(1); + } + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc < 1) { + fprintf(stderr, "too few arguments\n"); + usage(); + } + + if (gids != NULL) { + fprintf(stderr, "changing groups to %s\n", gids); + set_gids(gids); + } + if (uid != -1) { + fprintf(stderr, "changing uid to %d\n", uid); + if (setuid(uid) < 0) { + fprintf(stderr, "cannot change uid: %s\n", + strerror(errno)); + exit(1); + } + } + + /* Change umask to requested value or to 0, if not requested. */ + umask(umsk); + + for (;;) { + scall = find_syscall(argv[0]); + if (scall == NULL) { + fprintf(stderr, "syscall '%s' not supported\n", + argv[0]); + exit(1); + } + argc++; + argv++; + n = call_syscall(scall, argv); + argc += n; + argv += n; + if (argv[0] == NULL) + break; + argc++; + argv++; + } + + exit(0); +} + +static const char * +err2str(int error) +{ + static char errnum[8]; + + switch (error) { +#ifdef EPERM + case EPERM: + return ("EPERM"); +#endif +#ifdef ENOENT + case ENOENT: + return ("ENOENT"); +#endif +#ifdef ESRCH + case ESRCH: + return ("ESRCH"); +#endif +#ifdef EINTR + case EINTR: + return ("EINTR"); +#endif +#ifdef EIO + case EIO: + return ("EIO"); +#endif +#ifdef ENXIO + case ENXIO: + return ("ENXIO"); +#endif +#ifdef E2BIG + case E2BIG: + return ("E2BIG"); +#endif +#ifdef ENOEXEC + case ENOEXEC: + return ("ENOEXEC"); +#endif +#ifdef EBADF + case EBADF: + return ("EBADF"); +#endif +#ifdef ECHILD + case ECHILD: + return ("ECHILD"); +#endif +#ifdef EDEADLK + case EDEADLK: + return ("EDEADLK"); +#endif +#ifdef ENOMEM + case ENOMEM: + return ("ENOMEM"); +#endif +#ifdef EACCES + case EACCES: + return ("EACCES"); +#endif +#ifdef EFAULT + case EFAULT: + return ("EFAULT"); +#endif +#ifdef ENOTBLK + case ENOTBLK: + return ("ENOTBLK"); +#endif +#ifdef EBUSY + case EBUSY: + return ("EBUSY"); +#endif +#ifdef EEXIST + case EEXIST: + return ("EEXIST"); +#endif +#ifdef EXDEV + case EXDEV: + return ("EXDEV"); +#endif +#ifdef ENODEV + case ENODEV: + return ("ENODEV"); +#endif +#ifdef ENOTDIR + case ENOTDIR: + return ("ENOTDIR"); +#endif +#ifdef EISDIR + case EISDIR: + return ("EISDIR"); +#endif +#ifdef EINVAL + case EINVAL: + return ("EINVAL"); +#endif +#ifdef ENFILE + case ENFILE: + return ("ENFILE"); +#endif +#ifdef EMFILE + case EMFILE: + return ("EMFILE"); +#endif +#ifdef ENOTTY + case ENOTTY: + return ("ENOTTY"); +#endif +#ifdef ETXTBSY + case ETXTBSY: + return ("ETXTBSY"); +#endif +#ifdef EFBIG + case EFBIG: + return ("EFBIG"); +#endif +#ifdef ENOSPC + case ENOSPC: + return ("ENOSPC"); +#endif +#ifdef ESPIPE + case ESPIPE: + return ("ESPIPE"); +#endif +#ifdef EROFS + case EROFS: + return ("EROFS"); +#endif +#ifdef EMLINK + case EMLINK: + return ("EMLINK"); +#endif +#ifdef EPIPE + case EPIPE: + return ("EPIPE"); +#endif +#ifdef EDOM + case EDOM: + return ("EDOM"); +#endif +#ifdef ERANGE + case ERANGE: + return ("ERANGE"); +#endif +#ifdef EAGAIN + case EAGAIN: + return ("EAGAIN"); +#endif +#ifdef EINPROGRESS + case EINPROGRESS: + return ("EINPROGRESS"); +#endif +#ifdef EALREADY + case EALREADY: + return ("EALREADY"); +#endif +#ifdef ENOTSOCK + case ENOTSOCK: + return ("ENOTSOCK"); +#endif +#ifdef EDESTADDRREQ + case EDESTADDRREQ: + return ("EDESTADDRREQ"); +#endif +#ifdef EMSGSIZE + case EMSGSIZE: + return ("EMSGSIZE"); +#endif +#ifdef EPROTOTYPE + case EPROTOTYPE: + return ("EPROTOTYPE"); +#endif +#ifdef ENOPROTOOPT + case ENOPROTOOPT: + return ("ENOPROTOOPT"); +#endif +#ifdef EPROTONOSUPPORT + case EPROTONOSUPPORT: + return ("EPROTONOSUPPORT"); +#endif +#ifdef ESOCKTNOSUPPORT + case ESOCKTNOSUPPORT: + return ("ESOCKTNOSUPPORT"); +#endif +#ifdef EOPNOTSUPP + case EOPNOTSUPP: + return ("EOPNOTSUPP"); +#endif +#ifdef EPFNOSUPPORT + case EPFNOSUPPORT: + return ("EPFNOSUPPORT"); +#endif +#ifdef EAFNOSUPPORT + case EAFNOSUPPORT: + return ("EAFNOSUPPORT"); +#endif +#ifdef EADDRINUSE + case EADDRINUSE: + return ("EADDRINUSE"); +#endif +#ifdef EADDRNOTAVAIL + case EADDRNOTAVAIL: + return ("EADDRNOTAVAIL"); +#endif +#ifdef ENETDOWN + case ENETDOWN: + return ("ENETDOWN"); +#endif +#ifdef ENETUNREACH + case ENETUNREACH: + return ("ENETUNREACH"); +#endif +#ifdef ENETRESET + case ENETRESET: + return ("ENETRESET"); +#endif +#ifdef ECONNABORTED + case ECONNABORTED: + return ("ECONNABORTED"); +#endif +#ifdef ECONNRESET + case ECONNRESET: + return ("ECONNRESET"); +#endif +#ifdef ENOBUFS + case ENOBUFS: + return ("ENOBUFS"); +#endif +#ifdef EISCONN + case EISCONN: + return ("EISCONN"); +#endif +#ifdef ENOTCONN + case ENOTCONN: + return ("ENOTCONN"); +#endif +#ifdef ESHUTDOWN + case ESHUTDOWN: + return ("ESHUTDOWN"); +#endif +#ifdef ETOOMANYREFS + case ETOOMANYREFS: + return ("ETOOMANYREFS"); +#endif +#ifdef ETIMEDOUT + case ETIMEDOUT: + return ("ETIMEDOUT"); +#endif +#ifdef ECONNREFUSED + case ECONNREFUSED: + return ("ECONNREFUSED"); +#endif +#ifdef ELOOP + case ELOOP: + return ("ELOOP"); +#endif +#ifdef ENAMETOOLONG + case ENAMETOOLONG: + return ("ENAMETOOLONG"); +#endif +#ifdef EHOSTDOWN + case EHOSTDOWN: + return ("EHOSTDOWN"); +#endif +#ifdef EHOSTUNREACH + case EHOSTUNREACH: + return ("EHOSTUNREACH"); +#endif +#ifdef ENOTEMPTY + case ENOTEMPTY: + return ("ENOTEMPTY"); +#endif +#ifdef EPROCLIM + case EPROCLIM: + return ("EPROCLIM"); +#endif +#ifdef EUSERS + case EUSERS: + return ("EUSERS"); +#endif +#ifdef EDQUOT + case EDQUOT: + return ("EDQUOT"); +#endif +#ifdef ESTALE + case ESTALE: + return ("ESTALE"); +#endif +#ifdef EREMOTE + case EREMOTE: + return ("EREMOTE"); +#endif +#ifdef EBADRPC + case EBADRPC: + return ("EBADRPC"); +#endif +#ifdef ERPCMISMATCH + case ERPCMISMATCH: + return ("ERPCMISMATCH"); +#endif +#ifdef EPROGUNAVAIL + case EPROGUNAVAIL: + return ("EPROGUNAVAIL"); +#endif +#ifdef EPROGMISMATCH + case EPROGMISMATCH: + return ("EPROGMISMATCH"); +#endif +#ifdef EPROCUNAVAIL + case EPROCUNAVAIL: + return ("EPROCUNAVAIL"); +#endif +#ifdef ENOLCK + case ENOLCK: + return ("ENOLCK"); +#endif +#ifdef ENOSYS + case ENOSYS: + return ("ENOSYS"); +#endif +#ifdef EFTYPE + case EFTYPE: + return ("EFTYPE"); +#endif +#ifdef EAUTH + case EAUTH: + return ("EAUTH"); +#endif +#ifdef ENEEDAUTH + case ENEEDAUTH: + return ("ENEEDAUTH"); +#endif +#ifdef EIDRM + case EIDRM: + return ("EIDRM"); +#endif +#ifdef ENOMSG + case ENOMSG: + return ("ENOMSG"); +#endif +#ifdef EOVERFLOW + case EOVERFLOW: + return ("EOVERFLOW"); +#endif +#ifdef ECANCELED + case ECANCELED: + return ("ECANCELED"); +#endif +#ifdef EILSEQ + case EILSEQ: + return ("EILSEQ"); +#endif +#ifdef ENOATTR + case ENOATTR: + return ("ENOATTR"); +#endif +#ifdef EDOOFUS + case EDOOFUS: + return ("EDOOFUS"); +#endif +#ifdef EBADMSG + case EBADMSG: + return ("EBADMSG"); +#endif +#ifdef EMULTIHOP + case EMULTIHOP: + return ("EMULTIHOP"); +#endif +#ifdef ENOLINK + case ENOLINK: + return ("ENOLINK"); +#endif +#ifdef EPROTO + case EPROTO: + return ("EPROTO"); +#endif + default: + snprintf(errnum, sizeof(errnum), "%d", error); + return (errnum); + } +} diff --git a/contrib/pjdfstest/tests/chflags/00.t b/contrib/pjdfstest/tests/chflags/00.t new file mode 100644 index 000000000000..4d7b4c9a3464 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/00.t @@ -0,0 +1,178 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags changes flags" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:UFS) + allflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE,SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + userflags="UF_NODUMP,UF_IMMUTABLE,UF_APPEND,UF_NOUNLINK,UF_OPAQUE" + systemflags="SF_ARCHIVED,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + + echo "1..742" + ;; +FreeBSD:ZFS) + allflags="UF_NODUMP,SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + userflags="UF_NODUMP" + systemflags="SF_IMMUTABLE,SF_APPEND,SF_NOUNLINK" + + echo "1..482" + ;; +*) + quick_exit + ;; +esac + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +for type in regular dir fifo block char socket; do + create_file ${type} ${n0} + expect none stat ${n0} flags + expect 0 chflags ${n0} ${allflags} + expect ${allflags} stat ${n0} flags + expect 0 chflags ${n0} ${userflags} + expect ${userflags} stat ${n0} flags + expect 0 chflags ${n0} ${systemflags} + expect ${systemflags} stat ${n0} flags + expect 0 chflags ${n0} none + expect none stat ${n0} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + + create_file ${type} ${n0} + expect none stat ${n0} flags + expect 0 lchflags ${n0} ${allflags} + expect ${allflags} stat ${n0} flags + expect 0 lchflags ${n0} ${userflags} + expect ${userflags} stat ${n0} flags + expect 0 lchflags ${n0} ${systemflags} + expect ${systemflags} stat ${n0} flags + expect 0 lchflags ${n0} none + expect none stat ${n0} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +expect 0 create ${n0} 0644 +expect 0 symlink ${n0} ${n1} +expect none stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} ${allflags} +expect ${allflags} stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} ${userflags} +expect ${userflags} stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} ${systemflags} +expect ${systemflags} stat ${n1} flags +expect none lstat ${n1} flags +expect 0 chflags ${n1} none +expect none stat ${n1} flags +expect none lstat ${n1} flags +expect 0 unlink ${n1} +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 symlink ${n0} ${n1} +expect none stat ${n1} flags +expect none lstat ${n1} flags +expect 0 lchflags ${n1} ${allflags} +expect ${allflags} lstat ${n1} flags +expect none stat ${n1} flags +expect 0 lchflags ${n1} ${userflags} +expect ${userflags} lstat ${n1} flags +expect none stat ${n1} flags +expect 0 lchflags ${n1} ${systemflags} +expect ${systemflags} lstat ${n1} flags +expect none stat ${n1} flags +expect 0 lchflags ${n1} none +expect none lstat ${n1} flags +expect none stat ${n1} flags +expect 0 unlink ${n1} +expect 0 unlink ${n0} + +# successful chflags(2) updates ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect 0 chflags ${n0} ${flag} + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 lchflags ${n0} ${flag} + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +# unsuccessful chflags(2) does not update ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 chflags ${n0} ${flag} + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + for flag in `echo ${allflags},none | tr ',' ' '`; do + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 lchflags ${n0} ${flag} + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/chflags/01.t b/contrib/pjdfstest/tests/chflags/01.t new file mode 100644 index 000000000000..62713fd0347a --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/01.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="chflags returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..17" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR chflags ${n0}/${n1}/test SF_IMMUTABLE + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/02.t b/contrib/pjdfstest/tests/chflags/02.t new file mode 100644 index 000000000000..d4a0b371b094 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/02.t @@ -0,0 +1,28 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..12" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 chflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 chflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE + +expect 0 create ${nx} 0644 +expect 0 lchflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 lchflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE diff --git a/contrib/pjdfstest/tests/chflags/03.t b/contrib/pjdfstest/tests/chflags/03.t new file mode 100644 index 000000000000..87a62029509b --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/03.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..12" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 chflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 chflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG chflags ${nxx} SF_IMMUTABLE + +expect 0 create ${nx} 0644 +expect 0 lchflags ${nx} SF_IMMUTABLE +expect SF_IMMUTABLE stat ${nx} flags +expect 0 lchflags ${nx} none +expect 0 unlink ${nx} +expect ENAMETOOLONG lchflags ${nxx} SF_IMMUTABLE + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/chflags/04.t b/contrib/pjdfstest/tests/chflags/04.t new file mode 100644 index 000000000000..3d5aa3b42ba3 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/04.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT chflags ${n0}/${n1}/test SF_IMMUTABLE +expect ENOENT chflags ${n0}/${n1} SF_IMMUTABLE +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/05.t b/contrib/pjdfstest/tests/chflags/05.t new file mode 100644 index 000000000000..cc3e04b3ec57 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/05.t @@ -0,0 +1,35 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..16" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP +expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} UF_NODUMP +expect UF_NODUMP -u 65534 -g 65534 stat ${n1}/${n2} flags +expect 0 -u 65534 -g 65534 chflags ${n1}/${n2} none +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/06.t b/contrib/pjdfstest/tests/chflags/06.t new file mode 100644 index 000000000000..e4899eb7642e --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/06.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP chflags ${n0}/test SF_IMMUTABLE +expect ELOOP chflags ${n1}/test SF_IMMUTABLE +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/chflags/07.t b/contrib/pjdfstest/tests/chflags/07.t new file mode 100644 index 000000000000..c2d0af2447b9 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/07.t @@ -0,0 +1,50 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM when the effective user ID does not match the owner of the file and the effective user ID is not the super-user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..93" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP + expect none stat ${n1} flags + expect 0 chown ${n1} 65534 65534 + expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP + expect none stat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP + expect none lstat ${n1} flags + expect 0 lchown ${n1} 65534 65534 + expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP + expect none lstat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/08.t b/contrib/pjdfstest/tests/chflags/08.t new file mode 100644 index 000000000000..62ed480feec0 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/08.t @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and the user is not the super-user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..249" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 chflags ${n1} ${flag} + expect EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + expect EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + done + expect 0 chflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect 0 lchown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 lchflags ${n1} ${flag} + expect EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + expect EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + done + expect 0 lchflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/09.t b/contrib/pjdfstest/tests/chflags/09.t new file mode 100644 index 000000000000..e7bd5cc8d660 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/09.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM when one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK is set and securelevel is greater than 0" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..327" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +old=`sysctl -n security.jail.chflags_allowed` +sysctl security.jail.chflags_allowed=1 >/dev/null + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 chflags ${n1} ${flag} + jexpect 1 `pwd` EPERM chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + jexpect 1 `pwd` EPERM -u 65533 -g 65533 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + jexpect 1 `pwd` EPERM -u 65534 -g 65534 chflags ${n1} UF_NODUMP + expect ${flag} stat ${n1} flags + done + expect 0 chflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect 0 lchown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect 0 lchflags ${n1} ${flag} + jexpect 1 `pwd` EPERM lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + jexpect 1 `pwd` EPERM -u 65533 -g 65533 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + jexpect 1 `pwd` EPERM -u 65534 -g 65534 lchflags ${n1} UF_NODUMP + expect ${flag} lstat ${n1} flags + done + expect 0 lchflags ${n1} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +sysctl security.jail.chflags_allowed=${old} >/dev/null +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/10.t b/contrib/pjdfstest/tests/chflags/10.t new file mode 100644 index 000000000000..11ce36b4d0ab --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/10.t @@ -0,0 +1,54 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM if non-super-user tries to set one of SF_IMMUTABLE, SF_APPEND, or SF_NOUNLINK" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..197" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect EPERM -u 65533 -g 65533 chflags ${n1} ${flag} + expect none stat ${n1} flags + expect EPERM -u 65534 -g 65534 chflags ${n1} ${flag} + expect none stat ${n1} flags + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect 0 lchown ${n1} 65534 65534 + for flag in SF_IMMUTABLE SF_APPEND SF_NOUNLINK; do + expect EPERM -u 65533 -g 65533 lchflags ${n1} ${flag} + expect none lstat ${n1} flags + expect EPERM -u 65534 -g 65534 lchflags ${n1} ${flag} + expect none lstat ${n1} flags + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/11.t b/contrib/pjdfstest/tests/chflags/11.t new file mode 100644 index 000000000000..33acca7f327a --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/11.t @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EPERM if a user tries to set or remove the SF_SNAPSHOT flag" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags_SF_SNAPSHOT + +echo "1..145" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + expect EPERM chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + expect 0 chown ${n1} 65534 65534 + expect EPERM -u 65534 -g 65534 chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + expect EPERM chflags ${n1} SF_SNAPSHOT + expect none stat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + create_file ${type} ${n1} + expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + expect EPERM lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + expect 0 lchown ${n1} 65534 65534 + expect EPERM -u 65534 -g 65534 lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + expect EPERM lchflags ${n1} SF_SNAPSHOT + expect none lstat ${n1} flags + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chflags/12.t b/contrib/pjdfstest/tests/chflags/12.t new file mode 100644 index 000000000000..794139becf59 --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/12.t @@ -0,0 +1,68 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:UFS) + echo "1..14" + + n0=`namegen` + n1=`namegen` + + expect 0 mkdir ${n0} 0755 + n=`mdconfig -a -n -t malloc -s 1m` || exit + newfs /dev/md${n} >/dev/null || exit + mount /dev/md${n} ${n0} + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0}/${n1} UF_IMMUTABLE + expect UF_IMMUTABLE stat ${n0}/${n1} flags + expect 0 chflags ${n0}/${n1} none + expect none stat ${n0}/${n1} flags + mount -ur /dev/md${n} + expect EROFS chflags ${n0}/${n1} UF_IMMUTABLE + expect none stat ${n0}/${n1} flags + mount -uw /dev/md${n} + expect 0 chflags ${n0}/${n1} UF_IMMUTABLE + expect UF_IMMUTABLE stat ${n0}/${n1} flags + expect 0 chflags ${n0}/${n1} none + expect none stat ${n0}/${n1} flags + expect 0 unlink ${n0}/${n1} + umount /dev/md${n} + mdconfig -d -u ${n} || exit + expect 0 rmdir ${n0} + ;; +FreeBSD:ZFS) + echo "1..12" + + n0=`namegen` + n1=`namegen` + + n=`mdconfig -a -n -t malloc -s 128m` || exit + zpool create ${n0} /dev/md${n} + expect 0 create /${n0}/${n1} 0644 + expect 0 chflags /${n0}/${n1} UF_NODUMP + expect UF_NODUMP stat /${n0}/${n1} flags + expect 0 chflags /${n0}/${n1} none + expect none stat /${n0}/${n1} flags + zfs set readonly=on ${n0} + expect EROFS chflags /${n0}/${n1} UF_NODUMP + expect none stat /${n0}/${n1} flags + zfs set readonly=off ${n0} + expect 0 chflags /${n0}/${n1} UF_NODUMP + expect UF_NODUMP stat /${n0}/${n1} flags + expect 0 chflags /${n0}/${n1} none + expect none stat /${n0}/${n1} flags + expect 0 unlink /${n0}/${n1} + zpool destroy ${n0} + mdconfig -d -u ${n} || exit + ;; +*) + quick_exit + ;; +esac diff --git a/contrib/pjdfstest/tests/chflags/13.t b/contrib/pjdfstest/tests/chflags/13.t new file mode 100644 index 000000000000..981122c8b3be --- /dev/null +++ b/contrib/pjdfstest/tests/chflags/13.t @@ -0,0 +1,14 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chflags/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chflags returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..2" + +expect EFAULT chflags NULL UF_NODUMP +expect EFAULT chflags DEADCODE UF_NODUMP diff --git a/contrib/pjdfstest/tests/chmod/00.t b/contrib/pjdfstest/tests/chmod/00.t new file mode 100644 index 000000000000..d68d0cf4e652 --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/00.t @@ -0,0 +1,138 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod changes permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..203" +else + echo "1..119" +fi + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + expect 0 chmod ${n0} 0111 + expect 0111 stat ${n0} mode + + expect 0 symlink ${n0} ${n1} + mode=`${fstest} lstat ${n1} mode` + expect 0 chmod ${n1} 0222 + expect 0222 stat ${n1} mode + expect 0222 stat ${n0} mode + expect ${mode} lstat ${n1} mode + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + if supported lchmod; then + create_file ${type} ${n0} + expect 0 lchmod ${n0} 0111 + expect 0111 lstat ${n0} mode + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi +done + +# successful chmod(2) updates ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect 0 chmod ${n0} 0111 + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + if supported lchmod; then + create_file ${type} ${n0} + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 lchmod ${n0} 0111 + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi +done + +# unsuccessful chmod(2) does not update ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 chmod ${n0} 0111 + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + if supported lchmod; then + create_file ${type} ${n0} + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 lchmod ${n0} 0321 + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi +done + +# POSIX: If the calling process does not have appropriate privileges, and if +# the group ID of the file does not match the effective group ID or one of the +# supplementary group IDs and if the file is a regular file, bit S_ISGID +# (set-group-ID on execution) in the file's mode shall be cleared upon +# successful return from chmod(). + +expect 0 create ${n0} 0755 +expect 0 chown ${n0} 65535 65535 +expect 0 -u 65535 -g 65535 chmod ${n0} 02755 +expect 02755 stat ${n0} mode +expect 0 -u 65535 -g 65535 chmod ${n0} 0755 +expect 0755 stat ${n0} mode + +todo FreeBSD "S_ISGID should be removed and chmod(2) should success and FreeBSD returns EPERM." +expect 0 -u 65535 -g 65534 chmod ${n0} 02755 +expect 0755 stat ${n0} mode + +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/chmod/01.t b/contrib/pjdfstest/tests/chmod/01.t new file mode 100644 index 000000000000..85802fca2439 --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/01.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="chmod returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..17" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR chmod ${n0}/${n1}/test 0644 + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chmod/02.t b/contrib/pjdfstest/tests/chmod/02.t new file mode 100644 index 000000000000..0cadec29bf0c --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/02.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 chmod ${nx} 0620 +expect 0620 stat ${nx} mode +expect 0 unlink ${nx} +expect ENAMETOOLONG chmod ${nxx} 0620 + +expect 0 create ${nx} 0644 +expect 0 lchmod ${nx} 0620 +expect 0620 stat ${nx} mode +expect 0 unlink ${nx} +expect ENAMETOOLONG lchmod ${nxx} 0620 diff --git a/contrib/pjdfstest/tests/chmod/03.t b/contrib/pjdfstest/tests/chmod/03.t new file mode 100644 index 000000000000..fa4580fbcfeb --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/03.t @@ -0,0 +1,28 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 chmod ${nx} 0642 +expect 0642 stat ${nx} mode +expect 0 unlink ${nx} +expect ENAMETOOLONG chmod ${nxx} 0642 + +expect 0 create ${nx} 0644 +expect 0 lchmod ${nx} 0642 +expect 0642 stat ${nx} mode +expect 0 unlink ${nx} +expect ENAMETOOLONG lchmod ${nxx} 0642 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/chmod/04.t b/contrib/pjdfstest/tests/chmod/04.t new file mode 100644 index 000000000000..9386c9a3e6ba --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/04.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..9" +else + echo "1..7" +fi + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT chmod ${n0}/${n1}/test 0644 +expect ENOENT chmod ${n0}/${n1} 0644 +if supported lchmod; then + expect ENOENT lchmod ${n0}/${n1}/test 0644 + expect ENOENT lchmod ${n0}/${n1} 0644 +fi +expect 0 symlink ${n2} ${n0}/${n1} +expect ENOENT chmod ${n0}/${n1} 0644 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chmod/05.t b/contrib/pjdfstest/tests/chmod/05.t new file mode 100644 index 000000000000..5648e46eef8b --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/05.t @@ -0,0 +1,42 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..19" +else + echo "1..14" +fi + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642 +expect 0642 -u 65534 -g 65534 stat ${n1}/${n2} mode +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 chmod ${n1}/${n2} 0620 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0420 +expect 0420 -u 65534 -g 65534 stat ${n1}/${n2} mode +if supported lchmod; then + expect 0 chmod ${n1} 0644 + expect EACCES -u 65534 -g 65534 lchmod ${n1}/${n2} 0410 + expect 0 chmod ${n1} 0755 + expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0710 + expect 0710 -u 65534 -g 65534 stat ${n1}/${n2} mode +fi +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chmod/06.t b/contrib/pjdfstest/tests/chmod/06.t new file mode 100644 index 000000000000..d44b3cb1ea52 --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/06.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/06.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="chmod returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..10" +else + echo "1..8" +fi + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP chmod ${n0} 0644 +expect ELOOP chmod ${n1} 0644 +expect ELOOP chmod ${n0}/test 0644 +expect ELOOP chmod ${n1}/test 0644 +if supported lchmod; then + expect ELOOP lchmod ${n0}/test 0644 + expect ELOOP lchmod ${n1}/test 0644 +fi +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/chmod/07.t b/contrib/pjdfstest/tests/chmod/07.t new file mode 100644 index 000000000000..012e59a97bb5 --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/07.t @@ -0,0 +1,62 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..34" +else + echo "1..25" +fi + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 + +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642 +expect 0642 stat ${n1}/${n2} mode +expect EPERM -u 65533 -g 65533 chmod ${n1}/${n2} 0641 +expect 0642 stat ${n1}/${n2} mode +expect 0 chown ${n1}/${n2} 0 0 +expect EPERM -u 65534 -g 65534 chmod ${n1}/${n2} 0641 +expect 0642 stat ${n1}/${n2} mode +expect 0 unlink ${n1}/${n2} + +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3} +expect 0 -u 65534 -g 65534 chmod ${n1}/${n3} 0642 +expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid +expect EPERM -u 65533 -g 65533 chmod ${n1}/${n3} 0641 +expect 0642,65534,65534 stat ${n1}/${n2} mode,uid,gid +expect 0 chown ${n1}/${n3} 0 0 +expect EPERM -u 65534 -g 65534 chmod ${n1}/${n3} 0641 +expect 0642,0,0 stat ${n1}/${n2} mode,uid,gid +expect 0 unlink ${n1}/${n2} +expect 0 unlink ${n1}/${n3} + +if supported lchmod; then + expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 + expect 0 -u 65534 -g 65534 lchmod ${n1}/${n2} 0642 + expect 0642 stat ${n1}/${n2} mode + expect EPERM -u 65533 -g 65533 lchmod ${n1}/${n2} 0641 + expect 0642 stat ${n1}/${n2} mode + expect 0 chown ${n1}/${n2} 0 0 + expect EPERM -u 65534 -g 65534 lchmod ${n1}/${n2} 0641 + expect 0642 stat ${n1}/${n2} mode + expect 0 unlink ${n1}/${n2} +fi + +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chmod/08.t b/contrib/pjdfstest/tests/chmod/08.t new file mode 100644 index 000000000000..5b37569a82d7 --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/08.t @@ -0,0 +1,98 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns EPERM if the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..29" + ;; +FreeBSD:UFS) + echo "1..54" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM chmod ${n0} 0600 +supported lchmod && expect EPERM lchmod ${n0} 0600 +expect 0644 stat ${n0} mode +expect 0 chflags ${n0} none +expect 0 chmod ${n0} 0600 +expect 0600 stat ${n0} mode +supported lchmod && expect 0 lchmod ${n0} 0400 +supported lchmod && expect 0400 stat ${n0} mode +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 chmod ${n0} 0600 +expect 0600 stat ${n0} mode +supported lchmod && expect 0 lchmod ${n0} 0400 +supported lchmod && expect 0400 stat ${n0} mode +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:ZFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} SF_APPEND + expect 0 chmod ${n0} 0600 + expect 0600 stat ${n0} mode + supported lchmod && expect 0 lchmod ${n0} 0500 + supported lchmod && expect 0500 stat ${n0} mode + expect 0 chflags ${n0} none + expect 0 chmod ${n0} 0400 + expect 0400 stat ${n0} mode + expect 0 unlink ${n0} + ;; +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} SF_APPEND + expect EPERM chmod ${n0} 0600 + supported lchmod && expect EPERM lchmod ${n0} 0600 + expect 0644 stat ${n0} mode + expect 0 chflags ${n0} none + expect 0 chmod ${n0} 0600 + expect 0600 stat ${n0} mode + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM chmod ${n0} 0600 + supported lchmod && expect EPERM lchmod ${n0} 0600 + expect 0644 stat ${n0} mode + expect 0 chflags ${n0} none + expect 0 chmod ${n0} 0600 + expect 0600 stat ${n0} mode + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 chmod ${n0} 0600 + expect 0600 stat ${n0} mode + supported lchmod && expect 0 lchmod ${n0} 0400 + supported lchmod && expect 0400 stat ${n0} mode + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM chmod ${n0} 0600 + supported lchmod && expect EPERM lchmod ${n0} 0600 + expect 0644 stat ${n0} mode + expect 0 chflags ${n0} none + expect 0 chmod ${n0} 0600 + expect 0600 stat ${n0} mode + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/chmod/09.t b/contrib/pjdfstest/tests/chmod/09.t new file mode 100644 index 000000000000..f4b911e2f15a --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/09.t @@ -0,0 +1,37 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..15" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 chmod ${n0}/${n1} 0640 +expect 0640 stat ${n0}/${n1} mode +expect 0 lchmod ${n0}/${n1} 0530 +expect 0530 stat ${n0}/${n1} mode +mount -ur /dev/md${n} +expect EROFS chmod ${n0}/${n1} 0600 +expect EROFS lchmod ${n0}/${n1} 0600 +expect 0530 stat ${n0}/${n1} mode +mount -uw /dev/md${n} +expect 0 chmod ${n0}/${n1} 0600 +expect 0600 stat ${n0}/${n1} mode +expect 0 lchmod ${n0}/${n1} 0640 +expect 0640 stat ${n0}/${n1} mode +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chmod/10.t b/contrib/pjdfstest/tests/chmod/10.t new file mode 100644 index 000000000000..1153429ac1dc --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/10.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..4" +else + echo "1..2" +fi + +expect EFAULT chmod NULL 0644 +expect EFAULT chmod DEADCODE 0644 +if supported lchmod; then + expect EFAULT lchmod NULL 0644 + expect EFAULT lchmod DEADCODE 0644 +fi diff --git a/contrib/pjdfstest/tests/chmod/11.t b/contrib/pjdfstest/tests/chmod/11.t new file mode 100644 index 000000000000..94c5e5f4f319 --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/11.t @@ -0,0 +1,118 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chmod returns EFTYPE if the effective user ID is not the super-user, the mode includes the sticky bit (S_ISVTX), and path does not refer to a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..173" +else + echo "1..109" +fi + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} + expect 0 chmod ${n1} 01621 + expect 01621 stat ${n1} mode + expect 0 symlink ${n1} ${n2} + expect 0 chmod ${n2} 01700 + expect 01700 stat ${n1} mode + expect 0 unlink ${n2} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + if supported lchmod; then + create_file ${type} ${n1} + expect 0 lchmod ${n1} 01621 + expect 01621 lstat ${n1} mode + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi +done + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 chmod ${n1} 01755 +expect 01755 stat ${n1} mode +expect 0 symlink ${n1} ${n2} +expect 0 chmod ${n2} 01700 +expect 01700 stat ${n1} mode +expect 0 unlink ${n2} +expect 0 rmdir ${n1} + +for type in regular fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1} 0640 65534 65534 + expect 0 symlink ${n1} ${n2} + case "${os}" in + FreeBSD) + expect EFTYPE -u 65534 -g 65534 chmod ${n1} 01644 + expect 0640 stat ${n1} mode + expect EFTYPE -u 65534 -g 65534 chmod ${n2} 01644 + expect 0640 stat ${n1} mode + ;; + SunOS) + expect 0 -u 65534 -g 65534 chmod ${n1} 01644 + expect 0644 stat ${n1} mode + expect 0 -u 65534 -g 65534 chmod ${n2} 01640 + expect 0640 stat ${n1} mode + ;; + Linux) + expect 0 -u 65534 -g 65534 chmod ${n1} 01644 + expect 01644 stat ${n1} mode + expect 0 -u 65534 -g 65534 chmod ${n2} 01640 + expect 01640 stat ${n1} mode + ;; + esac + expect 0 unlink ${n2} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi + + if supported lchmod; then + create_file ${type} ${n1} 0640 65534 65534 + case "${os}" in + FreeBSD) + expect EFTYPE -u 65534 -g 65534 lchmod ${n1} 01644 + expect 0640 lstat ${n1} mode + ;; + SunOS) + expect 0 -u 65534 -g 65534 lchmod ${n1} 01644 + expect 0644 lstat ${n1} mode + ;; + Linux) + expect 0 -u 65534 -g 65534 lchmod ${n1} 01644 + expect 01644 lstat ${n1} mode + ;; + esac + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi + fi +done + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chmod/12.t b/contrib/pjdfstest/tests/chmod/12.t new file mode 100644 index 000000000000..b7f7d67997fb --- /dev/null +++ b/contrib/pjdfstest/tests/chmod/12.t @@ -0,0 +1,38 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chmod/12.t 219463 2011-03-10 20:59:02Z pjd $ + +desc="verify SUID/SGID bit behaviour" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..14" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# Check whether writing to the file by non-owner clears the SUID. +expect 0 create ${n0} 04777 +expect 0777 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x : fstat 0 mode +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether writing to the file by non-owner clears the SGID. +expect 0 create ${n0} 02777 +expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether writing to the file by non-owner clears the SUID+SGID. +expect 0 create ${n0} 06777 +expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/chmod/foo b/contrib/pjdfstest/tests/chmod/foo new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/contrib/pjdfstest/tests/chown/00.t b/contrib/pjdfstest/tests/chown/00.t new file mode 100644 index 000000000000..5c6be97d66dd --- /dev/null +++ b/contrib/pjdfstest/tests/chown/00.t @@ -0,0 +1,458 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/00.t 228975 2011-12-30 00:04:11Z uqs $ + +desc="chown changes ownership" + +dir=`dirname $0` +. ${dir}/../misc.sh + +if supported lchmod; then + echo "1..1349" +else + echo "1..1323" +fi + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# super-user can always modify ownership +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + expect 0 chown ${n0} 123 456 + expect 123,456 lstat ${n0} uid,gid + expect 0 chown ${n0} 0 0 + expect 0,0 lstat ${n0} uid,gid + + expect 0 symlink ${n0} ${n1} + uidgid=`${fstest} lstat ${n1} uid,gid` + expect 0 chown ${n1} 123 456 + expect 123,456 stat ${n1} uid,gid + expect 123,456 stat ${n0} uid,gid + expect ${uidgid} lstat ${n1} uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + expect 0 lchown ${n0} 123 456 + expect 123,456 lstat ${n0} uid,gid + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +# non-super-user can modify file group if he is owner of a file and +# gid he is setting is in his groups list. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + expect 0 chown ${n0} 65534 65533 + expect 65534,65533 lstat ${n0} uid,gid + expect 0 -u 65534 -g 65532,65531 -- chown ${n0} -1 65532 + expect 65534,65532 lstat ${n0} uid,gid + expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531 + expect 65534,65531 lstat ${n0} uid,gid + + expect 0 symlink ${n0} ${n1} + uidgid=`${fstest} lstat ${n1} uid,gid` + expect 0 chown ${n1} 65534 65533 + expect 65534,65533 stat ${n0} uid,gid + expect 65534,65533 stat ${n1} uid,gid + expect ${uidgid} lstat ${n1} uid,gid + expect 0 -u 65534 -g 65532,65531 -- chown ${n1} -1 65532 + expect 65534,65532 stat ${n0} uid,gid + expect 65534,65532 stat ${n1} uid,gid + expect ${uidgid} lstat ${n1} uid,gid + expect 0 -u 65534 -g 65532,65531 chown ${n1} 65534 65531 + expect 65534,65531 stat ${n0} uid,gid + expect 65534,65531 stat ${n1} uid,gid + expect ${uidgid} lstat ${n1} uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + expect 0 lchown ${n0} 65534 65533 + expect 65534,65533 lstat ${n0} uid,gid + expect 0 -u 65534 -g 65532,65531 -- lchown ${n0} -1 65532 + expect 65534,65532 lstat ${n0} uid,gid + expect 0 -u 65534 -g 65532,65531 lchown ${n0} 65534 65531 + expect 65534,65531 lstat ${n0} uid,gid + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +# chown(2) return 0 if user is not owner of a file, but chown(2) is called +# with both uid and gid equal to -1. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + expect 0 chown ${n0} 65534 65533 + expect 0 -u 65532 -g 65531 -- chown ${n0} -1 -1 + expect 65534,65533 stat ${n0} uid,gid + + expect 0 symlink ${n0} ${n1} + uidgid=`${fstest} lstat ${n1} uid,gid` + expect 0 chown ${n1} 65534 65533 + expect 65534,65533 stat ${n0} uid,gid + expect 65534,65533 stat ${n1} uid,gid + expect ${uidgid} lstat ${n1} uid,gid + expect 0 -u 65532 -g 65531 -- chown ${n0} -1 -1 + expect 65534,65533 stat ${n0} uid,gid + expect 65534,65533 stat ${n1} uid,gid + expect ${uidgid} lstat ${n1} uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + expect 0 lchown ${n0} 65534 65533 + expect 0 -u 65532 -g 65531 -- lchown ${n0} -1 -1 + expect 65534,65533 lstat ${n0} uid,gid + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +# when super-user calls chown(2), set-uid and set-gid bits may be removed. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + expect 0 chown ${n0} 65534 65533 + expect 0 chmod ${n0} 06555 + expect 06555,65534,65533 stat ${n0} mode,uid,gid + expect 0 chown ${n0} 65532 65531 + expect "(06555|0555),65532,65531" stat ${n0} mode,uid,gid + expect 0 chmod ${n0} 06555 + expect 06555,65532,65531 stat ${n0} mode,uid,gid + expect 0 chown ${n0} 0 0 + expect "(06555|0555),0,0" stat ${n0} mode,uid,gid + + expect 0 symlink ${n0} ${n1} + expect 0 chown ${n1} 65534 65533 + expect 0 chmod ${n1} 06555 + expect 06555,65534,65533 stat ${n0} mode,uid,gid + expect 06555,65534,65533 stat ${n1} mode,uid,gid + expect 0 chown ${n1} 65532 65531 + expect "(06555|0555),65532,65531" stat ${n0} mode,uid,gid + expect "(06555|0555),65532,65531" stat ${n1} mode,uid,gid + expect 0 chmod ${n1} 06555 + expect 06555,65532,65531 stat ${n0} mode,uid,gid + expect 06555,65532,65531 stat ${n1} mode,uid,gid + expect 0 chown ${n1} 0 0 + expect "(06555|0555),0,0" stat ${n0} mode,uid,gid + expect "(06555|0555),0,0" stat ${n1} mode,uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + if [ "${type}" != "symlink" ] || supported lchmod; then + create_file ${type} ${n0} + expect 0 lchown ${n0} 65534 65533 + if supported lchmod; then + expect 0 lchmod ${n0} 06555 + else + expect 0 chmod ${n0} 06555 + fi + expect 06555,65534,65533 lstat ${n0} mode,uid,gid + expect 0 lchown ${n0} 65532 65531 + expect "(06555|0555),65532,65531" lstat ${n0} mode,uid,gid + if supported lchmod; then + expect 0 lchmod ${n0} 06555 + else + expect 0 chmod ${n0} 06555 + fi + expect 06555,65532,65531 lstat ${n0} mode,uid,gid + expect 0 lchown ${n0} 0 0 + expect "(06555|0555),0,0" lstat ${n0} mode,uid,gid + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi +done + +# when non-super-user calls chown(2) successfully, set-uid and set-gid bits may +# be removed, except when both uid and gid are equal to -1. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + expect 0 chown ${n0} 65534 65533 + expect 0 chmod ${n0} 06555 + expect 06555,65534,65533 stat ${n0} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 + expect 0555,65534,65532 stat ${n0} mode,uid,gid + expect 0 chmod ${n0} 06555 + expect 06555,65534,65532 stat ${n0} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 65533 + expect 0555,65534,65533 stat ${n0} mode,uid,gid + expect 0 chmod ${n0} 06555 + expect 06555,65534,65533 stat ${n0} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 -- chown ${n0} -1 -1 + expect "(06555|0555),65534,65533" stat ${n0} mode,uid,gid + + expect 0 symlink ${n0} ${n1} + expect 0 chown ${n1} 65534 65533 + expect 0 chmod ${n1} 06555 + expect 06555,65534,65533 stat ${n0} mode,uid,gid + expect 06555,65534,65533 stat ${n1} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 chown ${n1} 65534 65532 + expect 0555,65534,65532 stat ${n0} mode,uid,gid + expect 0555,65534,65532 stat ${n1} mode,uid,gid + expect 0 chmod ${n1} 06555 + expect 06555,65534,65532 stat ${n0} mode,uid,gid + expect 06555,65534,65532 stat ${n1} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 65533 + expect 0555,65534,65533 stat ${n0} mode,uid,gid + expect 0555,65534,65533 stat ${n1} mode,uid,gid + expect 0 chmod ${n1} 06555 + expect 06555,65534,65533 stat ${n0} mode,uid,gid + expect 06555,65534,65533 stat ${n1} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 -- chown ${n1} -1 -1 + expect "(06555|0555),65534,65533" stat ${n0} mode,uid,gid + expect "(06555|0555),65534,65533" stat ${n1} mode,uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + if [ "${type}" != "symlink" ] || supported lchmod; then + create_file ${type} ${n0} + + expect 0 lchown ${n0} 65534 65533 + if supported lchmod; then + expect 0 lchmod ${n0} 06555 + else + expect 0 chmod ${n0} 06555 + fi + expect 06555,65534,65533 lstat ${n0} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 lchown ${n0} 65534 65532 + expect 0555,65534,65532 lstat ${n0} mode,uid,gid + if supported lchmod; then + expect 0 lchmod ${n0} 06555 + else + expect 0 chmod ${n0} 06555 + fi + expect 06555,65534,65532 lstat ${n0} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 65533 + expect 0555,65534,65533 lstat ${n0} mode,uid,gid + if supported lchmod; then + expect 0 lchmod ${n0} 06555 + else + expect 0 chmod ${n0} 06555 + fi + expect 06555,65534,65533 lstat ${n0} mode,uid,gid + expect 0 -u 65534 -g 65533,65532 -- lchown ${n0} -1 -1 + expect "(06555|0555),65534,65533" lstat ${n0} mode,uid,gid + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi +done + +# successful chown(2) call (except uid and gid equal to -1) updates ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect 0 chown ${n0} 65534 65533 + expect 65534,65533 stat ${n0} uid,gid + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect 0 -u 65534 -g 65532 chown ${n0} 65534 65532 + expect 65534,65532 stat ${n0} uid,gid + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + + expect 0 symlink ${n0} ${n1} + ctime1=`${fstest} stat ${n1} ctime` + sleep 1 + expect 0 chown ${n1} 65533 65532 + expect 65533,65532 stat ${n1} uid,gid + ctime2=`${fstest} stat ${n1} ctime` + test_check $ctime1 -lt $ctime2 + ctime1=`${fstest} stat ${n1} ctime` + sleep 1 + expect 0 -u 65533 -g 65531 chown ${n1} 65533 65531 + expect 65533,65531 stat ${n1} uid,gid + ctime2=`${fstest} stat ${n1} ctime` + test_check $ctime1 -lt $ctime2 + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 lchown ${n0} 65534 65533 + expect 65534,65533 lstat ${n0} uid,gid + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 -u 65534 -g 65532 lchown ${n0} 65534 65532 + expect 65534,65532 lstat ${n0} uid,gid + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect 0 -- chown ${n0} -1 -1 + ctime2=`${fstest} stat ${n0} ctime` + todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated." + test_check $ctime1 -eq $ctime2 + expect 0,0 stat ${n0} uid,gid + + expect 0 symlink ${n0} ${n1} + ctime1=`${fstest} stat ${n1} ctime` + sleep 1 + expect 0 -- chown ${n1} -1 -1 + ctime2=`${fstest} stat ${n1} ctime` + todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated." + test_check $ctime1 -eq $ctime2 + expect 0,0 stat ${n1} uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 -- lchown ${n0} -1 -1 + ctime2=`${fstest} lstat ${n0} ctime` + todo Linux "According to POSIX: If both owner and group are -1, the times need not be updated." + test_check $ctime1 -eq $ctime2 + expect 0,0 lstat ${n0} uid,gid + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +# unsuccessful chown(2) does not update ctime. +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + + ctime1=`${fstest} stat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 -- chown ${n0} 65534 -1 + expect EPERM -u 65534 -g 65534 -- chown ${n0} -1 65534 + expect EPERM -u 65534 -g 65534 chown ${n0} 65534 65534 + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + expect 0,0 stat ${n0} uid,gid + + expect 0 symlink ${n0} ${n1} + ctime1=`${fstest} stat ${n1} ctime` + sleep 1 + expect EPERM -u 65534 -- chown ${n1} 65534 -1 + expect EPERM -u 65534 -g 65534 -- chown ${n1} -1 65534 + expect EPERM -u 65534 -g 65534 chown ${n1} 65534 65534 + ctime2=`${fstest} stat ${n1} ctime` + test_check $ctime1 -eq $ctime2 + expect 0,0 stat ${n1} uid,gid + expect 0 unlink ${n1} + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect EPERM -u 65534 -- lchown ${n0} 65534 -1 + expect EPERM -u 65534 -g 65534 -- lchown ${n0} -1 65534 + expect EPERM -u 65534 -g 65534 lchown ${n0} 65534 65534 + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + expect 0,0 lstat ${n0} uid,gid + + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/chown/01.t b/contrib/pjdfstest/tests/chown/01.t new file mode 100644 index 000000000000..1813394aee83 --- /dev/null +++ b/contrib/pjdfstest/tests/chown/01.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="chown returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..22" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR chown ${n0}/${n1}/test 65534 65534 + expect ENOTDIR lchown ${n0}/${n1}/test 65534 65534 + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chown/02.t b/contrib/pjdfstest/tests/chown/02.t new file mode 100644 index 000000000000..e110db8261ba --- /dev/null +++ b/contrib/pjdfstest/tests/chown/02.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chown returns ENAMETOOLONG if a component of a pathname exceeded ${NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 chown ${nx} 65534 65534 +expect 65534,65534 stat ${nx} uid,gid +expect 0 unlink ${nx} +expect ENAMETOOLONG chown ${nxx} 65534 65534 + +expect 0 create ${nx} 0644 +expect 0 lchown ${nx} 65534 65534 +expect 65534,65534 stat ${nx} uid,gid +expect 0 unlink ${nx} +expect ENAMETOOLONG lchown ${nxx} 65534 65534 diff --git a/contrib/pjdfstest/tests/chown/03.t b/contrib/pjdfstest/tests/chown/03.t new file mode 100644 index 000000000000..031a878f3524 --- /dev/null +++ b/contrib/pjdfstest/tests/chown/03.t @@ -0,0 +1,28 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chown returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 chown ${nx} 65534 65534 +expect 65534,65534 stat ${nx} uid,gid +expect 0 unlink ${nx} +expect ENAMETOOLONG chown ${nxx} 65534 65534 + +expect 0 create ${nx} 0644 +expect 0 lchown ${nx} 65534 65534 +expect 65534,65534 stat ${nx} uid,gid +expect 0 unlink ${nx} +expect ENAMETOOLONG lchown ${nxx} 65534 65534 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/chown/04.t b/contrib/pjdfstest/tests/chown/04.t new file mode 100644 index 000000000000..d6eac198ed1e --- /dev/null +++ b/contrib/pjdfstest/tests/chown/04.t @@ -0,0 +1,23 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/04.t 211410 2010-08-17 06:08:09Z pjd $ + +desc="chown returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..9" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT chown ${n0}/${n1}/test 65534 65534 +expect ENOENT chown ${n0}/${n1} 65534 65534 +expect ENOENT lchown ${n0}/${n1}/test 65534 65534 +expect ENOENT lchown ${n0}/${n1} 65534 65534 +expect 0 symlink ${n2} ${n0}/${n1} +expect ENOENT chown ${n0}/${n1} 65534 65534 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chown/05.t b/contrib/pjdfstest/tests/chown/05.t new file mode 100644 index 000000000000..5a27a9ca90fc --- /dev/null +++ b/contrib/pjdfstest/tests/chown/05.t @@ -0,0 +1,35 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/05.t 211410 2010-08-17 06:08:09Z pjd $ + +desc="chown returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..18" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65533 +expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534 +expect EACCES -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65534 +expect 0 chmod ${n1} 0755 +expect 65534,65533 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid +expect 0 -u 65534 -g 65533,65534 -- chown ${n1}/${n2} -1 65534 +expect 65534,65534 -u 65534 -g 65534 stat ${n1}/${n2} uid,gid +expect 0 -u 65534 -g 65533,65534 -- lchown ${n1}/${n2} -1 65533 +expect 65534,65533 -u 65534 -g 65533 stat ${n1}/${n2} uid,gid +expect 0 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chown/06.t b/contrib/pjdfstest/tests/chown/06.t new file mode 100644 index 000000000000..a7ac349c02f8 --- /dev/null +++ b/contrib/pjdfstest/tests/chown/06.t @@ -0,0 +1,23 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/06.t 211410 2010-08-17 06:08:09Z pjd $ + +desc="chown returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP chown ${n0} 65534 65534 +expect ELOOP chown ${n1} 65534 65534 +expect ELOOP chown ${n0}/test 65534 65534 +expect ELOOP chown ${n1}/test 65534 65534 +expect ELOOP lchown ${n0}/test 65534 65534 +expect ELOOP lchown ${n1}/test 65534 65534 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/chown/07.t b/contrib/pjdfstest/tests/chown/07.t new file mode 100644 index 000000000000..f188080d05ec --- /dev/null +++ b/contrib/pjdfstest/tests/chown/07.t @@ -0,0 +1,53 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/07.t 211410 2010-08-17 06:08:09Z pjd $ + +desc="chown returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user and the process is not an owner of the file" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..132" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n1}/${n2} 65534 65534 + expect EPERM -u 65534 -g 65534 chown ${n1}/${n2} 65533 65533 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65534 65534 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n2} 65533 65533 + expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n2} -1 65533 + expect 0 -u 65534 -g 65534 symlink ${n2} ${n1}/${n3} + expect EPERM -u 65534 -g 65534 chown ${n1}/${n3} 65533 65533 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65534 65534 + expect EPERM -u 65533 -g 65533 chown ${n1}/${n3} 65533 65533 + expect EPERM -u 65534 -g 65534 -- chown ${n1}/${n3} -1 65533 + expect 0 unlink ${n1}/${n3} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1}/${n2} + else + expect 0 unlink ${n1}/${n2} + fi + fi + create_file ${type} ${n1}/${n2} 65534 65534 + expect EPERM -u 65534 -g 65534 lchown ${n1}/${n2} 65533 65533 + expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65534 65534 + expect EPERM -u 65533 -g 65533 lchown ${n1}/${n2} 65533 65533 + expect EPERM -u 65534 -g 65534 -- lchown ${n1}/${n2} -1 65533 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1}/${n2} + else + expect 0 unlink ${n1}/${n2} + fi +done +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chown/08.t b/contrib/pjdfstest/tests/chown/08.t new file mode 100644 index 000000000000..a98f873ff91b --- /dev/null +++ b/contrib/pjdfstest/tests/chown/08.t @@ -0,0 +1,84 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chown returns EPERM if the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..20" + ;; +FreeBSD:UFS) + echo "1..44" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM chown ${n0} 65534 65534 +expect 0,0 stat ${n0} uid,gid +expect 0 chflags ${n0} none +expect 0 chown ${n0} 65534 65534 +expect 65534,65534 stat ${n0} uid,gid +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 chown ${n0} 65534 65534 +expect 65534,65534 stat ${n0} uid,gid +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:ZFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} SF_APPEND + expect 0 chown ${n0} 65534 65534 + expect 65534,65534 stat ${n0} uid,gid + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + ;; +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} SF_APPEND + expect EPERM chown ${n0} 65534 65534 + expect 0,0 stat ${n0} uid,gid + expect 0 chflags ${n0} none + expect 0 chown ${n0} 65534 65534 + expect 65534,65534 stat ${n0} uid,gid + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM chown ${n0} 65534 65534 + expect 0,0 stat ${n0} uid,gid + expect 0 chflags ${n0} none + expect 0 chown ${n0} 65534 65534 + expect 65534,65534 stat ${n0} uid,gid + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 chown ${n0} 65534 65534 + expect 65534,65534 stat ${n0} uid,gid + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM chown ${n0} 65534 65534 + expect 0,0 stat ${n0} uid,gid + expect 0 chflags ${n0} none + expect 0 chown ${n0} 65534 65534 + expect 65534,65534 stat ${n0} uid,gid + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/chown/09.t b/contrib/pjdfstest/tests/chown/09.t new file mode 100644 index 000000000000..a99751e175c8 --- /dev/null +++ b/contrib/pjdfstest/tests/chown/09.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="chown returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 chown ${n0}/${n1} 65534 65534 +expect 65534,65534 stat ${n0}/${n1} uid,gid +mount -ur /dev/md${n} +expect EROFS chown ${n0}/${n1} 65533 65533 +expect 65534,65534 stat ${n0}/${n1} uid,gid +mount -uw /dev/md${n} +expect 0 chown ${n0}/${n1} 65533 65533 +expect 65533,65533 stat ${n0}/${n1} uid,gid +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/chown/10.t b/contrib/pjdfstest/tests/chown/10.t new file mode 100644 index 000000000000..e791008ee54e --- /dev/null +++ b/contrib/pjdfstest/tests/chown/10.t @@ -0,0 +1,14 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/chown/10.t 211410 2010-08-17 06:08:09Z pjd $ + +desc="chown returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +expect EFAULT chown NULL 65534 65534 +expect EFAULT chown DEADCODE 65534 65534 +expect EFAULT lchown NULL 65534 65534 +expect EFAULT lchown DEADCODE 65534 65534 diff --git a/contrib/pjdfstest/tests/conf b/contrib/pjdfstest/tests/conf new file mode 100644 index 000000000000..adb6cd6fb9b5 --- /dev/null +++ b/contrib/pjdfstest/tests/conf @@ -0,0 +1,36 @@ +# $FreeBSD: head/tools/regression/pjdfstest/tests/conf 211354 2010-08-15 21:29:03Z pjd $ +# pjdfstest configuration file + +# Supported operating systems: FreeBSD, Darwin, SunOS, Linux +os=`uname` + +case "${os}" in +FreeBSD|Darwin) + GREP=grep + #fs=`df -T . | tail -1 | awk '{print $2}'` + pattern="`df . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'`" + fs=`mount | ${GREP} -E "^${pattern}" | awk -F '[(,]' '{print toupper($2)}'` + ;; +Solaris|SunOS) + GREP=ggrep + pattern=`df -Pk . | tail -1 | awk '{printf("%s on %s \n", $1, $6)}'` + fs=`mount -v | ${GREP} -E "^${pattern}" | awk '{print $5}' | \ + tr -s '[:lower:]' '[:upper:]'` + ;; +Linux) + GREP=grep + fs=`df -PT . | tail -1 | awk '{print toupper($2)}'` + ;; +*) + echo "Unsupported operating system ${os}." >/dev/stderr + exit 1 + ;; +esac + +# If we cannot figure out file system type, define it here. +#fs="UFS" + +if [ -z "${fs}" ]; then + echo "Cannot figure out file system type, define it by hand." >/dev/stderr + exit 1 +fi diff --git a/contrib/pjdfstest/tests/ftruncate/00.t b/contrib/pjdfstest/tests/ftruncate/00.t new file mode 100644 index 000000000000..0f253017f8f3 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/00.t @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/ftruncate/00.t 219439 2011-03-09 23:11:30Z pjd $ + +desc="ftruncate descrease/increase file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..26" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +expect 0 create ${n0} 0644 +expect 0 open ${n0} O_RDWR : ftruncate 0 1234567 +expect 1234567 lstat ${n0} size +expect 0 open ${n0} O_WRONLY : ftruncate 0 567 +expect 567 lstat ${n0} size +expect 0 unlink ${n0} + +dd if=/dev/random of=${n0} bs=12345 count=1 >/dev/null 2>&1 +expect 0 open ${n0} O_RDWR : ftruncate 0 23456 +expect 23456 lstat ${n0} size +expect 0 open ${n0} O_WRONLY : ftruncate 0 1 +expect 1 lstat ${n0} size +expect 0 unlink ${n0} + +# successful ftruncate(2) updates ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 open ${n0} O_RDWR : ftruncate 0 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +# unsuccessful ftruncate(2) does not update ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EINVAL -u 65534 open ${n0} O_RDONLY : ftruncate 0 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +# third argument should not affect permission. +expect 0 open ${n0} O_CREAT,O_RDWR 0 : ftruncate 0 0 +expect 0 unlink ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 open ${n0} O_CREAT,O_RDWR 0 : ftruncate 0 0 +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/ftruncate/01.t b/contrib/pjdfstest/tests/ftruncate/01.t new file mode 100644 index 000000000000..a8e95ac60181 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR truncate ${n0}/${n1}/test 123 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/02.t b/contrib/pjdfstest/tests/ftruncate/02.t new file mode 100644 index 000000000000..83de38d3244f --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/02.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect 123 stat ${nx} size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 diff --git a/contrib/pjdfstest/tests/ftruncate/03.t b/contrib/pjdfstest/tests/ftruncate/03.t new file mode 100644 index 000000000000..41e98625ba4f --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/03.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect regular,123 stat ${nx} type,size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/ftruncate/04.t b/contrib/pjdfstest/tests/ftruncate/04.t new file mode 100644 index 000000000000..cd1cfc66b2b0 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT truncate ${n0}/${n1}/test 123 +expect ENOENT truncate ${n0}/${n1} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/05.t b/contrib/pjdfstest/tests/ftruncate/05.t new file mode 100644 index 000000000000..f12881581bce --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/05.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..15" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 123 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 0 chmod ${n1} 0755 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 1234 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/06.t b/contrib/pjdfstest/tests/ftruncate/06.t new file mode 100644 index 000000000000..1ce516fa74a6 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/06.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES if the named file is not writable by the user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 create ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 chown ${n1} 65534 65534 +expect 0 chmod ${n1} 0444 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 unlink ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/07.t b/contrib/pjdfstest/tests/ftruncate/07.t new file mode 100644 index 000000000000..44f87e7ea859 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP truncate ${n0}/test 123 +expect ELOOP truncate ${n1}/test 123 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/ftruncate/08.t b/contrib/pjdfstest/tests/ftruncate/08.t new file mode 100644 index 000000000000..6f205ef965f2 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/08.t @@ -0,0 +1,78 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EPERM if the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..22" + ;; +FreeBSD:UFS) + echo "1..44" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM truncate ${n0} 123 +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect EPERM truncate ${n0} 123 +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/ftruncate/09.t b/contrib/pjdfstest/tests/ftruncate/09.t new file mode 100644 index 000000000000..d7e082ddbe0e --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/09.t @@ -0,0 +1,15 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EISDIR if the named file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +expect EISDIR truncate ${n0} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/10.t b/contrib/pjdfstest/tests/ftruncate/10.t new file mode 100644 index 000000000000..ced3583ec21d --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/10.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 truncate ${n0}/${n1} 123 +expect 123 stat ${n0}/${n1} size +mount -ur /dev/md${n} +expect EROFS truncate ${n0}/${n1} 1234 +expect 123 stat ${n0}/${n1} size +mount -uw /dev/md${n} +expect 0 truncate ${n0}/${n1} 1234 +expect 1234 stat ${n0}/${n1} size +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/11.t b/contrib/pjdfstest/tests/ftruncate/11.t new file mode 100644 index 000000000000..b00d7b89c16d --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/11.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ETXTBSY the file is a pure procedure (shared text) file that is being executed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..2" + +n0=`namegen` + +cp -pf `which sleep` ${n0} +./${n0} 3 & +expect ETXTBSY truncate ${n0} 123 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/12.t b/contrib/pjdfstest/tests/ftruncate/12.t new file mode 100644 index 000000000000..1825456a7b13 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/12.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFBIG or EINVAL if the length argument was greater than the maximum file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 create ${n0} 0644 +r=`${fstest} truncate ${n0} 999999999999999 2>/dev/null` +case "${r}" in +EFBIG|EINVAL) + expect 0 stat ${n0} size + ;; +0) + expect 999999999999999 stat ${n0} size + ;; +*) + echo "not ok ${ntest}" + ntest=`expr ${ntest} + 1` + ;; +esac +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/13.t b/contrib/pjdfstest/tests/ftruncate/13.t new file mode 100644 index 000000000000..28307ae40af7 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/13.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="ftruncate returns EINVAL if the length argument was less than 0" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EINVAL -- open ${n0} O_RDWR : ftruncate 0 -1 +expect EINVAL -- open ${n0} O_WRONLY : ftruncate 0 -999999 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/ftruncate/14.t b/contrib/pjdfstest/tests/ftruncate/14.t new file mode 100644 index 000000000000..a238771264f9 --- /dev/null +++ b/contrib/pjdfstest/tests/ftruncate/14.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT truncate NULL 123 +expect EFAULT truncate DEADCODE 123 diff --git a/contrib/pjdfstest/tests/granular/00.t b/contrib/pjdfstest/tests/granular/00.t new file mode 100644 index 000000000000..629f66e419ac --- /dev/null +++ b/contrib/pjdfstest/tests/granular/00.t @@ -0,0 +1,112 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="NFSv4 granular permissions checking - WRITE_DATA vs APPEND_DATA on directories" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit + +echo "1..49" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0755 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` +cd ${n2} + +# Tests 2..7 - check out whether root user can do stuff. +# Can create files? +expect 0 create ${n0} 0644 + +# Can create symlinks? +expect 0 link ${n0} ${n1} +expect 0 unlink ${n1} +expect 0 unlink ${n0} + +# Can create directories? +expect 0 mkdir ${n0} 0755 +expect 0 rmdir ${n0} + +# Check whether user 65534 is permitted to create and remove +# files, but not subdirectories. +expect 0 prependacl . user:65534:write_data::allow,user:65534:append_data::deny + +# Can create files? +expect 0 -u 65534 -g 65534 create ${n0} 0644 + +# Can create symlinks? +expect 0 -u 65534 -g 65534 link ${n0} ${n1} +expect 0 -u 65534 -g 65534 unlink ${n1} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Can create directories? +expect EACCES -u 65534 -g 65534 mkdir ${n0} 0755 +expect ENOENT -u 65534 -g 65534 rmdir ${n0} +expect 0 mkdir ${n0} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Can move files from other directory? +expect 0 create ../${n3}/${n1} 0644 +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move files from other directory overwriting existing files? +expect 0 create ../${n3}/${n1} 0644 +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Can move directories from other directory? +expect 0 mkdir ../${n3}/${n1} 0777 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move directories from other directory overwriting existing directory? +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 -u 65534 -g 65534 rmdir ../${n3}/${n1} + +# Check whether user 65534 is permitted to create +# subdirectories, but not files - and to remove neither of them. +expect 0 prependacl . user:65534:write_data::deny,user:65534:append_data::allow + +# Can create files? +expect EACCES -u 65534 -g 65534 create ${n0} 0644 + +# Can create symlinks? +expect 0 create ${n0} 0644 +expect EACCES -u 65534 -g 65534 link ${n0} ${n1} +expect ENOENT -u 65534 -g 65534 unlink ${n1} +expect EACCES -u 65534 -g 65534 unlink ${n0} +expect 0 unlink ${n0} + +# Can create directories? +expect 0 -u 65534 -g 65534 mkdir ${n0} 0755 +expect EACCES -u 65534 -g 65534 rmdir ${n0} +expect 0 rmdir ${n0} + +# Can move files from other directory? +expect 0 create ../${n3}/${n1} 0644 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move files from other directory overwriting existing files? +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 -u 65534 -g 65534 unlink ../${n3}/${n1} + +# Can move directories from other directory? +expect 0 mkdir ../${n3}/${n1} 0777 +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} + +# Can move directories from other directory overwriting existing directory? +expect 0 mkdir ../${n3}/${n1} 0777 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 prependacl . user:65534:delete_child::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n1} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} +expect 0 rmdir ${n3} diff --git a/contrib/pjdfstest/tests/granular/01.t b/contrib/pjdfstest/tests/granular/01.t new file mode 100644 index 000000000000..f6658cc5f840 --- /dev/null +++ b/contrib/pjdfstest/tests/granular/01.t @@ -0,0 +1,37 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="NFSv4 granular permissions checking - ACL_READ_ATTRIBUTES and ACL_WRITE_ATTRIBUTES" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# Tests 1..12 - check out whether user 65534 is permitted to read attributes. +expect 0 create ${n0} 0644 +expect 0 lstat ${n0} size +expect 0 -u 65534 -g 65534 stat ${n0} size +expect 0 prependacl ${n0} user:65534:read_attributes::deny +expect 0 lstat ${n0} size +expect EACCES -u 65534 -g 65534 stat ${n0} size +expect 0 prependacl ${n0} user:65534:read_attributes::allow +expect 0 -u 65534 -g 65534 stat ${n0} size +expect 0 lstat ${n0} size +expect 0 unlink ${n0} + +# Tests 12..12 - check out whether user 65534 is permitted to write attributes. +# XXX: Check if ACL_WRITE_ATTRIBUTES allows for modifying access times. + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/granular/02.t b/contrib/pjdfstest/tests/granular/02.t new file mode 100644 index 000000000000..32a318cc0d90 --- /dev/null +++ b/contrib/pjdfstest/tests/granular/02.t @@ -0,0 +1,144 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="NFSv4 granular permissions checking - ACL_READ_ACL and ACL_WRITE_ACL" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit + +echo "1..83" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# Check whether user 65534 is permitted to read ACL. +expect 0 create ${n0} 0644 +expect 0 readacl ${n0} +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0 prependacl ${n0} user:65534:read_acl::deny +expect 0 readacl ${n0} +expect EACCES -u 65534 -g 65534 readacl ${n0} +expect 0 prependacl ${n0} user:65534:read_acl::allow +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0 readacl ${n0} +expect 0 unlink ${n0} + +# Check whether user 65534 is permitted to write ACL. +expect 0 create ${n0} 0644 +expect EPERM -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_data::allow +expect 0 unlink ${n0} + +# Check whether user 65534 is permitted to write mode. +expect 0 create ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 unlink ${n0} + +# There is an interesting problem with interaction between ACL_WRITE_ACL +# and SUID/SGID bits. In case user does have ACL_WRITE_ACL, but is not +# a file owner, Solaris does the following: +# 1. Setting SUID fails with EPERM. +# 2. Setting SGID succeeds, but mode is not changed. +# 3. Modifying ACL does not clear SUID nor SGID bits. +# 4. Writing the file does clear both SUID and SGID bits. +# +# What we are doing is the following: +# 1. Setting SUID or SGID fails with EPERM. +# 2. Modifying ACL does not clear SUID nor SGID bits. +# 3. Writing the file does clear both SUID and SGID bits. +# +# Check whether user 65534 is denied to write mode with SUID bit. +expect 0 create ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 04777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect EPERM -u 65534 -g 65534 chmod ${n0} 04777 +expect 0 unlink ${n0} + +# Check whether user 65534 is denied to write mode with SGID bit. +expect 0 create ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 02777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect EPERM -u 65534 -g 65534 chmod ${n0} 02777 +expect 0 unlink ${n0} + +# Check whether user 65534 is allowed to write mode with sticky bit. +expect 0 mkdir ${n0} 0755 +expect EPERM -u 65534 -g 65534 chmod ${n0} 01777 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 chmod ${n0} 01777 +expect 0 rmdir ${n0} + +# Check whether modifying the ACL by not-owner preserves the SUID. +expect 0 create ${n0} 04755 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow +expect 04755 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether modifying the ACL by not-owner preserves the SGID. +expect 0 create ${n0} 02755 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow +expect 02755 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether modifying the ACL by not-owner preserves the sticky bit. +expect 0 mkdir ${n0} 0755 +expect 0 chmod ${n0} 01755 +expect 0 prependacl ${n0} user:65534:write_acl::allow +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_data::allow +expect 01755 stat ${n0} mode +expect 0 rmdir ${n0} + +# Clearing the SUID and SGID bits when being written to by non-owner +# is checked in chmod/12.t. + +# Check whether the file owner is always permitted to get and set +# ACL and file mode, even if ACL_{READ,WRITE}_ACL would deny it. +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65534 create ${n0} 0600 +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0600 -u 65534 -g 65534 stat ${n0} mode +expect 0 -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 unlink ${n0} + +expect 0 -u 65534 -g 65534 mkdir ${n0} 0600 +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:write_acl::deny +expect 0 -u 65534 -g 65534 prependacl ${n0} user:65534:read_acl::deny +expect 0 -u 65534 -g 65534 readacl ${n0} +expect 0600 -u 65534 -g 65534 stat ${n0} mode +expect 0 -u 65534 -g 65534 chmod ${n0} 0777 +expect 0 rmdir ${n0} + +# Check whether the root is allowed for these as well. +expect 0 -u 65534 -g 65534 create ${n0} 0600 +expect 0 prependacl ${n0} everyone@:write_acl::deny +expect 0 prependacl ${n0} everyone@:read_acl::deny +expect 0 readacl ${n0} +expect 0600 stat ${n0} mode +expect 0 chmod ${n0} 0777 +expect 0 unlink ${n0} + +expect 0 -u 65534 -g 65534 mkdir ${n0} 0600 +expect 0 prependacl ${n0} everyone@:write_acl::deny +expect 0 prependacl ${n0} everyone@:read_acl::deny +expect 0600 stat ${n0} mode +expect 0 readacl ${n0} +expect 0600 stat ${n0} mode +expect 0 chmod ${n0} 0777 +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/granular/03.t b/contrib/pjdfstest/tests/granular/03.t new file mode 100644 index 000000000000..3b825ccef3a3 --- /dev/null +++ b/contrib/pjdfstest/tests/granular/03.t @@ -0,0 +1,134 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit + +echo "1..65" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0755 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` +cd ${n2} + +# Unlink allowed on writable directory. +expect 0 create ${n0} 0644 +expect EACCES -u 65534 -g 65534 unlink ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Moving file elsewhere allowed on writable directory. +expect 0 create ${n0} 0644 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# Moving file from elsewhere allowed on writable directory. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Moving file from elsewhere overwriting local file allowed +# on writable directory. +expect 0 create ${n0} 0644 +expect 0 create ../${n3}/${n0} 0644 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Denied DELETE changes nothing wrt removing. +expect 0 create ${n0} 0644 +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Denied DELETE changes nothing wrt moving elsewhere or from elsewhere. +expect 0 create ${n0} 0644 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 unlink ${n0} + +# DELETE_CHILD denies unlink on writable directory. +expect 0 create ${n0} 0644 +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 unlink ${n0} +expect 0 unlink ${n0} + +# DELETE_CHILD denies moving file elsewhere. +expect 0 create ${n0} 0644 +expect EPERM -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 rename ${n0} ../${n3}/${n0} + +# DELETE_CHILD does not deny moving file from elsewhere +# to a writable directory. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE_CHILD denies moving file from elsewhere +# to a writable directory overwriting local file. +expect 0 create ../${n3}/${n0} 0644 +expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE allowed on file allows for unlinking, no matter +# what permissions on containing directory are. +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Same for moving the file elsewhere. +expect 0 create ${n0} 0644 +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# Same for moving the file from elsewhere into a writable +# directory with DELETE_CHILD denied. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 unlink ${n0} + +# DELETE does not allow for overwriting a file in a unwritable +# directory with DELETE_CHILD denied. +expect 0 create ${n0} 0644 +expect 0 create ../${n3}/${n0} 0644 +expect 0 prependacl . user:65534:write_data::deny +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl ${n0} user:65534:delete::allow +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# But it allows for plain deletion. +expect 0 -u 65534 -g 65534 unlink ${n0} + +# DELETE_CHILD allowed on unwritable directory. +expect 0 create ${n0} 0644 +expect 0 prependacl . user:65534:delete_child::allow +expect 0 -u 65534 -g 65534 unlink ${n0} + +# Moving things elsewhere is allowed. +expect 0 create ${n0} 0644 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# Moving things back is not. +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Even if we're overwriting. +expect 0 create ${n0} 0644 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Even if we have DELETE on the existing file. +expect 0 prependacl ${n0} user:65534:delete::allow +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Denied DELETE changes nothing wrt removing. +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/granular/04.t b/contrib/pjdfstest/tests/granular/04.t new file mode 100644 index 000000000000..a06b0d605ebd --- /dev/null +++ b/contrib/pjdfstest/tests/granular/04.t @@ -0,0 +1,80 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="NFSv4 granular permissions checking - ACL_WRITE_OWNER" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit + +echo "1..52" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +# ACL_WRITE_OWNER permits to set gid to our own only. +expect 0 create ${n0} 0644 +expect 0,0 lstat ${n0} uid,gid +expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65532 +expect 0,0 lstat ${n0} uid,gid +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect EPERM -u 65534 -g 65532,65531 chown ${n0} -1 65530 +expect 0,0 lstat ${n0} uid,gid +expect 0 -u 65534 -g 65532,65531 chown ${n0} -1 65532 +expect 0,65532 lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# ACL_WRITE_OWNER permits to set uid to our own only. +expect 0 create ${n0} 0644 +expect 0,0 lstat ${n0} uid,gid +expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65534 65531 +expect 0,0 lstat ${n0} uid,gid +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect EPERM -u 65534 -g 65532,65531 chown ${n0} 65530 65531 +expect 0,0 lstat ${n0} uid,gid +expect 0 -u 65534 -g 65532,65531 chown ${n0} 65534 65531 +expect 65534,65531 lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# When non-owner calls chown(2) successfully, set-uid and set-gid bits are +# removed, except when both uid and gid are equal to -1. +expect 0 create ${n0} 0644 +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 +expect 0555,65534,65532 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533 +expect 0555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1 +expect 06555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 unlink ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 prependacl ${n0} user:65534:write_owner::allow +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} 65534 65532 +expect 0555,65534,65532 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 65533 +expect 0555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 chmod ${n0} 06555 +expect 06555 lstat ${n0} mode +expect 0 -u 65534 -g 65533,65532 chown ${n0} -1 -1 +expect 06555,65534,65533 lstat ${n0} mode,uid,gid +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/granular/05.t b/contrib/pjdfstest/tests/granular/05.t new file mode 100644 index 000000000000..c42f51a90987 --- /dev/null +++ b/contrib/pjdfstest/tests/granular/05.t @@ -0,0 +1,149 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/granular/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="NFSv4 granular permissions checking - DELETE and DELETE_CHILD with directories" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:ZFS" ] || quick_exit + +echo "1..68" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0755 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` +cd ${n2} + +# Unlink allowed on writable directory. +expect 0 mkdir ${n0} 0755 +expect EACCES -u 65534 -g 65534 rmdir ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Moving directory elsewhere allowed on writable directory. +expect 0 mkdir ${n0} 0777 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# 12 +# Moving directory from elsewhere allowed on writable directory. +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl . user:65534:append_data::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Moving directory from elsewhere overwriting local directory allowed +# on writable directory. +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ../${n3}/${n0} 0777 +expect 0 prependacl . user:65534:write_data::deny +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl . user:65534:write_data::allow +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# 23 +# Denied DELETE changes nothing wrt removing. +expect 0 mkdir ${n0} 0755 +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Denied DELETE changes nothing wrt moving elsewhere or from elsewhere. +expect 0 mkdir ${n0} 0777 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# DELETE_CHILD denies unlink on writable directory. +expect 0 mkdir ${n0} 0755 +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 rmdir ${n0} +expect 0 rmdir ${n0} + +# 35 +# DELETE_CHILD denies moving directory elsewhere. +expect 0 mkdir ${n0} 0777 +expect EPERM -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} +expect 0 rename ${n0} ../${n3}/${n0} + +# DELETE_CHILD does not deny moving directory from elsewhere +# to a writable directory. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE_CHILD denies moving directory from elsewhere +# to a writable directory overwriting local directory. +expect 0 mkdir ../${n3}/${n0} 0755 +expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# DELETE allowed on directory allows for unlinking, no matter +# what permissions on containing directory are. +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Same for moving the directory elsewhere. +expect 0 mkdir ${n0} 0777 +expect 0 prependacl ${n0} user:65534:delete::allow +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# 46 +# Same for moving the directory from elsewhere into a writable +# directory with DELETE_CHILD denied. +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 rmdir ${n0} + +# DELETE does not allow for overwriting a directory in a unwritable +# directory with DELETE_CHILD denied. +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ../${n3}/${n0} 0777 +expect 0 prependacl . user:65534:write_data::deny +expect 0 prependacl . user:65534:delete_child::deny +expect EPERM -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 prependacl ${n0} user:65534:delete::allow +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# 54 +# But it allows for plain deletion. +# XXX: expect 0 -u 65534 -g 65534 rmdir ${n0} +expect 0 rmdir ${n0} + +# DELETE_CHILD allowed on unwritable directory. +expect 0 mkdir ${n0} 0755 +expect 0 prependacl . user:65534:delete_child::allow +expect 0 -u 65534 -g 65534 rmdir ${n0} + +# Moving things elsewhere is allowed. +expect 0 mkdir ${n0} 0777 +expect 0 -u 65534 -g 65534 rename ${n0} ../${n3}/${n0} + +# 60 +# Moving things back is not. +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Even if we're overwriting. +# XXX: expect 0 mkdir ${n0} 0755 +expect 0 mkdir ../${n3}/${n0} 0777 +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 mkdir ../${n3}/${n0} 0777 + +# Even if we have DELETE on the existing directory. +expect 0 prependacl ${n0} user:65534:delete::allow +# XXX: expect EACCES -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} +expect 0 -u 65534 -g 65534 rename ../${n3}/${n0} ${n0} + +# Denied DELETE changes nothing wrt removing. +expect 0 prependacl ${n0} user:65534:delete::deny +expect 0 -u 65534 -g 65534 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/link/00.t b/contrib/pjdfstest/tests/link/00.t new file mode 100644 index 000000000000..1bcb32ad17ac --- /dev/null +++ b/contrib/pjdfstest/tests/link/00.t @@ -0,0 +1,93 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link creates hardlinks" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..202" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n3} 0755 +cdir=`pwd` +cd ${n3} + +for type in regular fifo block char socket; do + create_file ${type} ${n0} + expect ${type},1 lstat ${n0} type,nlink + + expect 0 link ${n0} ${n1} + expect ${type},2 lstat ${n0} type,nlink + expect ${type},2 lstat ${n1} type,nlink + + expect 0 link ${n1} ${n2} + expect ${type},3 lstat ${n0} type,nlink + expect ${type},3 lstat ${n1} type,nlink + expect ${type},3 lstat ${n2} type,nlink + + expect 0 chmod ${n1} 0201 + expect 0 chown ${n1} 65534 65533 + + expect ${type},0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid + expect ${type},0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid + expect ${type},0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid + + expect 0 unlink ${n0} + expect ENOENT lstat ${n0} type,mode,nlink,uid,gid + expect ${type},0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid + expect ${type},0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid + + expect 0 unlink ${n2} + expect ENOENT lstat ${n0} type,mode,nlink,uid,gid + expect ${type},0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid + expect ENOENT lstat ${n2} type,mode,nlink,uid,gid + + expect 0 unlink ${n1} + expect ENOENT lstat ${n0} type,mode,nlink,uid,gid + expect ENOENT lstat ${n1} type,mode,nlink,uid,gid + expect ENOENT lstat ${n2} type,mode,nlink,uid,gid +done + +# successful link(2) updates ctime. +for type in regular fifo block char socket; do + create_file ${type} ${n0} + ctime1=`${fstest} stat ${n0} ctime` + dctime1=`${fstest} stat . ctime` + dmtime1=`${fstest} stat . mtime` + sleep 1 + expect 0 link ${n0} ${n1} + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -lt $ctime2 + dctime2=`${fstest} stat . ctime` + test_check $dctime1 -lt $dctime2 + dmtime2=`${fstest} stat . mtime` + test_check $dctime1 -lt $dmtime2 + expect 0 unlink ${n0} + expect 0 unlink ${n1} +done + +# unsuccessful link(2) does not update ctime. +for type in regular fifo block char socket; do + create_file ${type} ${n0} + expect 0 -- chown ${n0} 65534 -1 + ctime1=`${fstest} stat ${n0} ctime` + dctime1=`${fstest} stat . ctime` + dmtime1=`${fstest} stat . mtime` + sleep 1 + expect EACCES -u 65534 link ${n0} ${n1} + ctime2=`${fstest} stat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + dctime2=`${fstest} stat . ctime` + test_check $dctime1 -eq $dctime2 + dmtime2=`${fstest} stat . mtime` + test_check $dctime1 -eq $dmtime2 + expect 0 unlink ${n0} +done + +cd ${cdir} +expect 0 rmdir ${n3} diff --git a/contrib/pjdfstest/tests/link/01.t b/contrib/pjdfstest/tests/link/01.t new file mode 100644 index 000000000000..fe05aeba7119 --- /dev/null +++ b/contrib/pjdfstest/tests/link/01.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="link returns ENOTDIR if a component of either path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..32" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR link ${n0}/${n1}/test ${n0}/${n2} + create_file ${type} ${n0}/${n2} + expect ENOTDIR link ${n0}/${n2} ${n0}/${n1}/test + expect 0 unlink ${n0}/${n1} + expect 0 unlink ${n0}/${n2} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/02.t b/contrib/pjdfstest/tests/link/02.t new file mode 100644 index 000000000000..ca3e092edf99 --- /dev/null +++ b/contrib/pjdfstest/tests/link/02.t @@ -0,0 +1,25 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns ENAMETOOLONG if a component of either pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 link ${nx} ${n0} +expect 0 unlink ${nx} +expect 0 link ${n0} ${nx} +expect 0 unlink ${n0} +expect 0 unlink ${nx} + +expect 0 create ${n0} 0644 +expect ENAMETOOLONG link ${n0} ${nxx} +expect 0 unlink ${n0} +expect ENAMETOOLONG link ${nxx} ${n0} diff --git a/contrib/pjdfstest/tests/link/03.t b/contrib/pjdfstest/tests/link/03.t new file mode 100644 index 000000000000..22f8e55e0cb3 --- /dev/null +++ b/contrib/pjdfstest/tests/link/03.t @@ -0,0 +1,31 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..13" + +n0=`namegen` +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 link ${nx} ${n0} +expect 2 stat ${n0} nlink +expect 2 stat ${nx} nlink +expect 0 unlink ${nx} +expect 0 link ${n0} ${nx} +expect 2 stat ${n0} nlink +expect 2 stat ${nx} nlink +expect 0 unlink ${nx} +expect ENAMETOOLONG link ${n0} ${nxx} +expect 1 stat ${n0} nlink +expect 0 unlink ${n0} +expect ENAMETOOLONG link ${nxx} ${n0} + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/link/04.t b/contrib/pjdfstest/tests/link/04.t new file mode 100644 index 000000000000..bb095396005e --- /dev/null +++ b/contrib/pjdfstest/tests/link/04.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns ENOENT if a component of either path prefix does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT link ${n0}/${n1}/test ${n2} +expect 0 create ${n2} 0644 +expect ENOENT link ${n2} ${n0}/${n1}/test +expect 0 unlink ${n2} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/05.t b/contrib/pjdfstest/tests/link/05.t new file mode 100644 index 000000000000..c6f55fa957dd --- /dev/null +++ b/contrib/pjdfstest/tests/link/05.t @@ -0,0 +1,36 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EMLINK if the link count of the file named by name1 would exceed 32767" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..5" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs -i 1 /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +i=1 +while :; do + link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +test_check $i -eq 32767 + +expect EMLINK link ${n0}/${n1} ${n0}/${n2} + +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/06.t b/contrib/pjdfstest/tests/link/06.t new file mode 100644 index 000000000000..73ab01e9ae15 --- /dev/null +++ b/contrib/pjdfstest/tests/link/06.t @@ -0,0 +1,43 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EACCES when a component of either path prefix denies search permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..18" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` +n4=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 mkdir ${n2} 0755 +expect 0 chown ${n2} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644 + +expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4} +expect 0 -u 65534 -g 65534 unlink ${n2}/${n4} + +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4} +expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4} + +expect 0 chmod ${n1} 0755 +expect 0 chmod ${n2} 0644 +expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4} + +expect 0 unlink ${n1}/${n3} +expect 0 rmdir ${n1} +expect 0 rmdir ${n2} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/07.t b/contrib/pjdfstest/tests/link/07.t new file mode 100644 index 000000000000..68495dd7c0b8 --- /dev/null +++ b/contrib/pjdfstest/tests/link/07.t @@ -0,0 +1,41 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EACCES when the requested link requires writing in a directory with a mode that denies write permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..17" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` +n4=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 mkdir ${n2} 0755 +expect 0 chown ${n2} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644 + +expect 0 -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4} +expect 0 -u 65534 -g 65534 unlink ${n2}/${n4} + +expect 0 chmod ${n2} 0555 +expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n2}/${n4} +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 link ${n1}/${n3} ${n1}/${n4} +expect 0 chmod ${n1} 0755 + +expect 0 unlink ${n1}/${n3} +expect 0 rmdir ${n1} +expect 0 rmdir ${n2} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/08.t b/contrib/pjdfstest/tests/link/08.t new file mode 100644 index 000000000000..f4599d50f01b --- /dev/null +++ b/contrib/pjdfstest/tests/link/08.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns ELOOP if too many symbolic links were encountered in translating one of the pathnames" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP link ${n0}/test ${n2} +expect ELOOP link ${n1}/test ${n2} +expect 0 create ${n2} 0644 +expect ELOOP link ${n2} ${n0}/test +expect ELOOP link ${n2} ${n1}/test +expect 0 unlink ${n0} +expect 0 unlink ${n1} +expect 0 unlink ${n2} diff --git a/contrib/pjdfstest/tests/link/09.t b/contrib/pjdfstest/tests/link/09.t new file mode 100644 index 000000000000..5f89655d3610 --- /dev/null +++ b/contrib/pjdfstest/tests/link/09.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns ENOENT if the source file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 create ${n0} 0644 +expect 0 link ${n0} ${n1} +expect 0 unlink ${n0} +expect 0 unlink ${n1} +expect ENOENT link ${n0} ${n1} diff --git a/contrib/pjdfstest/tests/link/10.t b/contrib/pjdfstest/tests/link/10.t new file mode 100644 index 000000000000..03ebbd25ffdb --- /dev/null +++ b/contrib/pjdfstest/tests/link/10.t @@ -0,0 +1,26 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/10.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="link returns EEXIST if the destination file does exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..23" + +n0=`namegen` +n1=`namegen` + +expect 0 create ${n0} 0644 + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n1} + expect EEXIST link ${n0} ${n1} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/link/11.t b/contrib/pjdfstest/tests/link/11.t new file mode 100644 index 000000000000..260342cd1d31 --- /dev/null +++ b/contrib/pjdfstest/tests/link/11.t @@ -0,0 +1,41 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EPERM if the source file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +case "${os}:${fs}" in +SunOS:UFS) + echo "1..10" + + expect 0 mkdir ${n0} 0755 + expect 0 link ${n0} ${n1} + expect 0 unlink ${n1} + expect 0 rmdir ${n0} + ;; +*) + echo "1..9" + + expect 0 mkdir ${n0} 0755 + expect EPERM link ${n0} ${n1} + expect 0 rmdir ${n0} + ;; +esac + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 +cdir=`pwd` +cd ${n0} + +expect 0 -u 65534 -g 65534 mkdir ${n1} 0755 +expect EPERM -u 65534 -g 65534 link ${n1} ${n2} +expect 0 -u 65534 -g 65534 rmdir ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/12.t b/contrib/pjdfstest/tests/link/12.t new file mode 100644 index 000000000000..a5408b656418 --- /dev/null +++ b/contrib/pjdfstest/tests/link/12.t @@ -0,0 +1,95 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EPERM if the source file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..27" + ;; +FreeBSD:UFS) + echo "1..48" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 create ${n0} 0644 + +expect 1 stat ${n0} nlink +expect 0 link ${n0} ${n1} +expect 2 stat ${n0} nlink +expect 0 unlink ${n1} +expect 1 stat ${n0} nlink + +expect 0 chflags ${n0} SF_IMMUTABLE +todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM." +expect EPERM link ${n0} ${n1} +todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM." +expect 1 stat ${n0} nlink +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Creating a hard link to a file protected by SF_IMMUTABLE should return EPERM." +expect 0 link ${n0} ${n1} +expect 2 stat ${n0} nlink +expect 0 unlink ${n1} +expect 1 stat ${n0} nlink + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 link ${n0} ${n1} +expect 2 stat ${n0} nlink +expect 0 chflags ${n0} none +expect 0 unlink ${n1} +expect 1 stat ${n0} nlink + +case "${os}:${fs}" in +FreeBSD:ZFS) + expect 0 chflags ${n0} SF_APPEND + expect 0 link ${n0} ${n1} + expect 2 stat ${n0} nlink + expect 0 chflags ${n0} none + expect 0 unlink ${n1} + expect 1 stat ${n0} nlink + ;; +FreeBSD:UFS) + expect 0 chflags ${n0} SF_APPEND + expect EPERM link ${n0} ${n1} + expect 0 chflags ${n0} none + expect 0 link ${n0} ${n1} + expect 2 stat ${n0} nlink + expect 0 unlink ${n1} + expect 1 stat ${n0} nlink + + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM link ${n0} ${n1} + expect 0 chflags ${n0} none + expect 0 link ${n0} ${n1} + expect 2 stat ${n0} nlink + expect 0 unlink ${n1} + expect 1 stat ${n0} nlink + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 link ${n0} ${n1} + expect 2 stat ${n0} nlink + expect 0 chflags ${n0} none + expect 0 unlink ${n1} + expect 1 stat ${n0} nlink + + expect 0 chflags ${n0} UF_APPEND + expect EPERM link ${n0} ${n1} + expect 0 chflags ${n0} none + expect 0 link ${n0} ${n1} + expect 2 stat ${n0} nlink + expect 0 unlink ${n1} + expect 1 stat ${n0} nlink + ;; +esac + +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/link/13.t b/contrib/pjdfstest/tests/link/13.t new file mode 100644 index 000000000000..2da8621f23cc --- /dev/null +++ b/contrib/pjdfstest/tests/link/13.t @@ -0,0 +1,86 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EPERM if the parent directory of the destination file has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..29" + ;; +FreeBSD:UFS) + echo "1..49" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 create ${n0}/${n1} 0644 +expect 1 stat ${n0}/${n1} nlink +expect 0 link ${n0}/${n1} ${n0}/${n2} +expect 2 stat ${n0}/${n1} nlink +expect 0 unlink ${n0}/${n2} +expect 1 stat ${n0}/${n1} nlink + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM link ${n0}/${n1} ${n0}/${n2} +expect 1 stat ${n0}/${n1} nlink +expect 0 chflags ${n0} none +expect 0 link ${n0}/${n1} ${n0}/${n2} +expect 2 stat ${n0}/${n1} nlink +expect 0 unlink ${n0}/${n2} +expect 1 stat ${n0}/${n1} nlink + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 link ${n0}/${n1} ${n0}/${n2} +expect 2 stat ${n0}/${n1} nlink +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n2} +expect 1 stat ${n0}/${n1} nlink + +expect 0 chflags ${n0} SF_APPEND +expect 0 link ${n0}/${n1} ${n0}/${n2} +expect 2 stat ${n0}/${n1} nlink +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n2} +expect 1 stat ${n0}/${n1} nlink + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM link ${n0}/${n1} ${n0}/${n2} + expect 1 stat ${n0}/${n1} nlink + expect 0 chflags ${n0} none + expect 0 link ${n0}/${n1} ${n0}/${n2} + expect 2 stat ${n0}/${n1} nlink + expect 0 unlink ${n0}/${n2} + expect 1 stat ${n0}/${n1} nlink + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 link ${n0}/${n1} ${n0}/${n2} + expect 2 stat ${n0}/${n1} nlink + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n2} + expect 1 stat ${n0}/${n1} nlink + + expect 0 chflags ${n0} UF_APPEND + expect 0 link ${n0}/${n1} ${n0}/${n2} + expect 2 stat ${n0}/${n1} nlink + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n2} + expect 1 stat ${n0}/${n1} nlink + ;; +esac + +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/14.t b/contrib/pjdfstest/tests/link/14.t new file mode 100644 index 000000000000..aa587e5a6d67 --- /dev/null +++ b/contrib/pjdfstest/tests/link/14.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EXDEV if the source and the destination files are on different file systems" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..8" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect EXDEV link ${n0}/${n1} ${n2} +expect 0 unlink ${n0}/${n1} +expect 0 create ${n1} 0644 +expect EXDEV link ${n1} ${n0}/${n2} +expect 0 unlink ${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/15.t b/contrib/pjdfstest/tests/link/15.t new file mode 100644 index 000000000000..a740126a0d80 --- /dev/null +++ b/contrib/pjdfstest/tests/link/15.t @@ -0,0 +1,33 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/15.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns ENOSPC if the directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..4" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +i=0 +while :; do + link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +expect ENOSPC link ${n0}/${n1} ${n0}/${n2} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/16.t b/contrib/pjdfstest/tests/link/16.t new file mode 100644 index 000000000000..2d67f30c2a55 --- /dev/null +++ b/contrib/pjdfstest/tests/link/16.t @@ -0,0 +1,34 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/16.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EROFS if the requested link requires writing in a directory on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..9" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 + +expect 0 link ${n0}/${n1} ${n0}/${n2} +expect 0 unlink ${n0}/${n2} +mount -ur /dev/md${n} +expect EROFS link ${n0}/${n1} ${n0}/${n2} +mount -uw /dev/md${n} +expect 0 link ${n0}/${n1} ${n0}/${n2} +expect 0 unlink ${n0}/${n2} + +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/link/17.t b/contrib/pjdfstest/tests/link/17.t new file mode 100644 index 000000000000..9b7e6fc68366 --- /dev/null +++ b/contrib/pjdfstest/tests/link/17.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/link/17.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="link returns EFAULT if one of the pathnames specified is outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EFAULT link ${n0} NULL +expect EFAULT link ${n0} DEADCODE +expect 0 unlink ${n0} +expect EFAULT link NULL ${n0} +expect EFAULT link DEADCODE ${n0} +expect EFAULT link NULL DEADCODE +expect EFAULT link DEADCODE NULL diff --git a/contrib/pjdfstest/tests/misc.sh b/contrib/pjdfstest/tests/misc.sh new file mode 100755 index 000000000000..8978b5fcc6a9 --- /dev/null +++ b/contrib/pjdfstest/tests/misc.sh @@ -0,0 +1,221 @@ +# $FreeBSD$ + +ntest=1 + +case "${dir}" in +/*) + maindir="${dir}/../.." + ;; +*) + maindir="`pwd`/${dir}/../.." + ;; +esac +fstest="${maindir}/pjdfstest" +. ${maindir}/tests/conf + +expect() +{ + e="${1}" + shift + r=`${fstest} $* 2>/dev/null | tail -1` + echo "${r}" | ${GREP} -Eq '^'${e}'$' + if [ $? -eq 0 ]; then + if [ -z "${todomsg}" ]; then + echo "ok ${ntest}" + else + echo "ok ${ntest} # TODO ${todomsg}" + fi + else + if [ -z "${todomsg}" ]; then + echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}" + else + echo "not ok ${ntest} # TODO ${todomsg}" + fi + fi + todomsg="" + ntest=$((ntest+1)) +} + +jexpect() +{ + s="${1}" + d="${2}" + e="${3}" + shift 3 + r=`jail -s ${s} / pjdfstest 127.0.0.1 /bin/sh -c "cd ${d} && ${fstest} $* 2>/dev/null" | tail -1` + echo "${r}" | ${GREP} -Eq '^'${e}'$' + if [ $? -eq 0 ]; then + if [ -z "${todomsg}" ]; then + echo "ok ${ntest}" + else + echo "ok ${ntest} # TODO ${todomsg}" + fi + else + if [ -z "${todomsg}" ]; then + echo "not ok ${ntest} - tried '$*', expected ${e}, got ${r}" + else + echo "not ok ${ntest} # TODO ${todomsg}" + fi + fi + todomsg="" + ntest=$((ntest+1)) +} + +test_check() +{ + if [ $* ]; then + if [ -z "${todomsg}" ]; then + echo "ok ${ntest}" + else + echo "ok ${ntest} # TODO ${todomsg}" + fi + else + if [ -z "${todomsg}" ]; then + echo "not ok ${ntest}" + else + echo "not ok ${ntest} # TODO ${todomsg}" + fi + fi + todomsg="" + ntest=$((ntest+1)) +} + +todo() +{ + if [ "${os}" = "${1}" -o "${os}:${fs}" = "${1}" ]; then + todomsg="${2}" + fi +} + +namegen() +{ + echo "pjdfstest_`dd if=/dev/urandom bs=1k count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`" +} + +namegen_len() +{ + len="${1}" + + name="" + while :; do + namepart="`dd if=/dev/urandom bs=64 count=1 2>/dev/null | openssl md5 | awk '{print $NF}'`" + name="${name}${namepart}" + curlen=`printf "%s" "${name}" | wc -c` + [ ${curlen} -lt ${len} ] || break + done + name=`echo "${name}" | cut -b -${len}` + printf "%s" "${name}" +} + +# POSIX: +# {NAME_MAX} +# Maximum number of bytes in a filename (not including terminating null). +namegen_max() +{ + name_max=`${fstest} pathconf . _PC_NAME_MAX` + namegen_len ${name_max} +} + +# POSIX: +# {PATH_MAX} +# Maximum number of bytes in a pathname, including the terminating null character. +dirgen_max() +{ + name_max=`${fstest} pathconf . _PC_NAME_MAX` + complen=$((name_max/2)) + path_max=`${fstest} pathconf . _PC_PATH_MAX` + # "...including the terminating null character." + path_max=$((path_max-1)) + + name="" + while :; do + name="${name}`namegen_len ${complen}`/" + curlen=`printf "%s" "${name}" | wc -c` + [ ${curlen} -lt ${path_max} ] || break + done + name=`echo "${name}" | cut -b -${path_max}` + name=`echo "${name}" | sed -E 's@/$@x@'` + printf "%s" "${name}" +} + +quick_exit() +{ + echo "1..1" + echo "ok 1" + exit 0 +} + +supported() +{ + case "${1}" in + lchmod) + if [ "${os}" != "FreeBSD" ]; then + return 1 + fi + ;; + chflags) + if [ "${os}" != "FreeBSD" ]; then + return 1 + fi + ;; + chflags_SF_SNAPSHOT) + if [ "${os}" != "FreeBSD" -o "${fs}" != "UFS" ]; then + return 1 + fi + ;; + esac + return 0 +} + +require() +{ + if supported ${1}; then + return + fi + quick_exit +} + +# usage: +# create_file +# create_file +# create_file +# create_file +create_file() { + type="${1}" + name="${2}" + + case "${type}" in + none) + return + ;; + regular) + expect 0 create ${name} 0644 + ;; + dir) + expect 0 mkdir ${name} 0755 + ;; + fifo) + expect 0 mkfifo ${name} 0644 + ;; + block) + expect 0 mknod ${name} b 0644 1 2 + ;; + char) + expect 0 mknod ${name} c 0644 1 2 + ;; + socket) + expect 0 bind ${name} + ;; + symlink) + expect 0 symlink test ${name} + ;; + esac + if [ -n "${3}" -a -n "${4}" -a -n "${5}" ]; then + expect 0 lchmod ${name} ${3} + expect 0 lchown ${name} ${4} ${5} + elif [ -n "${3}" -a -n "${4}" ]; then + expect 0 lchown ${name} ${3} ${4} + elif [ -n "${3}" ]; then + expect 0 lchmod ${name} ${3} + fi +} diff --git a/contrib/pjdfstest/tests/mkdir/00.t b/contrib/pjdfstest/tests/mkdir/00.t new file mode 100644 index 000000000000..fa1cbc126ebe --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/00.t @@ -0,0 +1,73 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir creates directories" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..36" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +# POSIX: The file permission bits of the new directory shall be initialized from +# mode. These file permission bits of the mode argument shall be modified by the +# process' file creation mask. +expect 0 mkdir ${n0} 0755 +expect dir,0755 lstat ${n0} type,mode +expect 0 rmdir ${n0} +expect 0 mkdir ${n0} 0151 +expect dir,0151 lstat ${n0} type,mode +expect 0 rmdir ${n0} +expect 0 -U 077 mkdir ${n0} 0151 +expect dir,0100 lstat ${n0} type,mode +expect 0 rmdir ${n0} +expect 0 -U 070 mkdir ${n0} 0345 +expect dir,0305 lstat ${n0} type,mode +expect 0 rmdir ${n0} +expect 0 -U 0501 mkdir ${n0} 0345 +expect dir,0244 lstat ${n0} type,mode +expect 0 rmdir ${n0} + +# POSIX: The directory's user ID shall be set to the process' effective user ID. +# The directory's group ID shall be set to the group ID of the parent directory +# or to the effective group ID of the process. +expect 0 chown . 65535 65535 +expect 0 -u 65535 -g 65535 mkdir ${n0} 0755 +expect 65535,65535 lstat ${n0} uid,gid +expect 0 rmdir ${n0} +expect 0 -u 65535 -g 65534 mkdir ${n0} 0755 +expect "65535,6553[45]" lstat ${n0} uid,gid +expect 0 rmdir ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65533 mkdir ${n0} 0755 +expect "65534,6553[35]" lstat ${n0} uid,gid +expect 0 rmdir ${n0} + +# POSIX: Upon successful completion, mkdir() shall mark for update the st_atime, +# st_ctime, and st_mtime fields of the directory. Also, the st_ctime and +# st_mtime fields of the directory that contains the new entry shall be marked +# for update. +expect 0 chown . 0 0 +time=`${fstest} stat . ctime` +sleep 1 +expect 0 mkdir ${n0} 0755 +atime=`${fstest} stat ${n0} atime` +test_check $time -lt $atime +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +mtime=`${fstest} stat . mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat . ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/mkdir/01.t b/contrib/pjdfstest/tests/mkdir/01.t new file mode 100644 index 000000000000..c33ce1fe9a09 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/01.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="mkdir returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..17" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR mkdir ${n0}/${n1}/test 0755 + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/02.t b/contrib/pjdfstest/tests/mkdir/02.t new file mode 100644 index 000000000000..e877f20f4c10 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/02.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 mkdir ${nx} 0755 +expect 0 rmdir ${nx} +expect ENAMETOOLONG mkdir ${nxx} 0755 diff --git a/contrib/pjdfstest/tests/mkdir/03.t b/contrib/pjdfstest/tests/mkdir/03.t new file mode 100644 index 000000000000..57ddd20a8627 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/03.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 mkdir ${nx} 0755 +expect 0 rmdir ${nx} +expect ENAMETOOLONG mkdir ${nxx} 0755 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/mkdir/04.t b/contrib/pjdfstest/tests/mkdir/04.t new file mode 100644 index 000000000000..0917ef15516d --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/04.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns ENOENT if a component of the path prefix does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT mkdir ${n0}/${n1}/test 0755 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/05.t b/contrib/pjdfstest/tests/mkdir/05.t new file mode 100644 index 000000000000..de351ca37ca7 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/05.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/06.t b/contrib/pjdfstest/tests/mkdir/06.t new file mode 100644 index 000000000000..2d2b8c22234b --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/06.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns EACCES when write permission is denied on the parent directory of the directory to be created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/07.t b/contrib/pjdfstest/tests/mkdir/07.t new file mode 100644 index 000000000000..72ac2b69499f --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP mkdir ${n0}/test 0755 +expect ELOOP mkdir ${n1}/test 0755 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/mkdir/08.t b/contrib/pjdfstest/tests/mkdir/08.t new file mode 100644 index 000000000000..366f223a8074 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/08.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns EPERM if the parent directory of the directory to be created has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..17" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 rmdir ${n0}/${n1} + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM mkdir ${n0}/${n1} 0755 +expect 0 chflags ${n0} none +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 rmdir ${n0}/${n1} + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 rmdir ${n0}/${n1} +expect 0 chflags ${n0} none + +expect 0 chflags ${n0} SF_APPEND +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 chflags ${n0} none +expect 0 rmdir ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM mkdir ${n0}/${n1} 0755 + expect 0 chflags ${n0} none + expect 0 mkdir ${n0}/${n1} 0755 + expect 0 rmdir ${n0}/${n1} + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 mkdir ${n0}/${n1} 0755 + expect 0 rmdir ${n0}/${n1} + expect 0 chflags ${n0} none + + expect 0 chflags ${n0} UF_APPEND + expect 0 mkdir ${n0}/${n1} 0755 + expect 0 chflags ${n0} none + expect 0 rmdir ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/09.t b/contrib/pjdfstest/tests/mkdir/09.t new file mode 100644 index 000000000000..2035b31fbbf4 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/09.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..7" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 rmdir ${n0}/${n1} +mount -ur /dev/md${n} +expect EROFS mkdir ${n0}/${n1} 0755 +mount -uw /dev/md${n} +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 rmdir ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/10.t b/contrib/pjdfstest/tests/mkdir/10.t new file mode 100644 index 000000000000..732dcb882562 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/10.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns EEXIST if the named file exists" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + expect EEXIST mkdir ${n0} 0755 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done diff --git a/contrib/pjdfstest/tests/mkdir/11.t b/contrib/pjdfstest/tests/mkdir/11.t new file mode 100644 index 000000000000..a0c905545c4a --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/11.t @@ -0,0 +1,31 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns ENOSPC if there are no free inodes on the file system on which the directory is being created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +i=0 +while :; do + mkdir ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +expect ENOSPC mkdir ${n0}/${n1} 0755 +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkdir/12.t b/contrib/pjdfstest/tests/mkdir/12.t new file mode 100644 index 000000000000..7c27f74264f6 --- /dev/null +++ b/contrib/pjdfstest/tests/mkdir/12.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkdir/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkdir returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT mkdir NULL 0755 +expect EFAULT mkdir DEADCODE 0755 diff --git a/contrib/pjdfstest/tests/mkfifo/00.t b/contrib/pjdfstest/tests/mkfifo/00.t new file mode 100644 index 000000000000..ad88e2836fbb --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/00.t @@ -0,0 +1,73 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo creates fifo files" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..36" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +# POSIX: The file permission bits of the new FIFO shall be initialized from +# mode. The file permission bits of the mode argument shall be modified by the +# process' file creation mask. +expect 0 mkfifo ${n0} 0755 +expect fifo,0755 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 mkfifo ${n0} 0151 +expect fifo,0151 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 077 mkfifo ${n0} 0151 +expect fifo,0100 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 070 mkfifo ${n0} 0345 +expect fifo,0305 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 0501 mkfifo ${n0} 0345 +expect fifo,0244 lstat ${n0} type,mode +expect 0 unlink ${n0} + +# POSIX: The FIFO's user ID shall be set to the process' effective user ID. +# The FIFO's group ID shall be set to the group ID of the parent directory or to +# the effective group ID of the process. +expect 0 chown . 65535 65535 +expect 0 -u 65535 -g 65535 mkfifo ${n0} 0755 +expect 65535,65535 lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 -u 65535 -g 65534 mkfifo ${n0} 0755 +expect "65535,6553[45]" lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65533 mkfifo ${n0} 0755 +expect "65534,6553[35]" lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# POSIX: Upon successful completion, mkfifo() shall mark for update the +# st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and +# st_mtime fields of the directory that contains the new entry shall be marked +# for update. +expect 0 chown . 0 0 +time=`${fstest} stat . ctime` +sleep 1 +expect 0 mkfifo ${n0} 0755 +atime=`${fstest} stat ${n0} atime` +test_check $time -lt $atime +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +mtime=`${fstest} stat . mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat . ctime` +test_check $time -lt $ctime +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/mkfifo/01.t b/contrib/pjdfstest/tests/mkfifo/01.t new file mode 100644 index 000000000000..fae5c23091bc --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/01.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="mkfifo returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..17" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR mkfifo ${n0}/${n1}/test 0644 + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/02.t b/contrib/pjdfstest/tests/mkfifo/02.t new file mode 100644 index 000000000000..e51bcd5fdff2 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/02.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 mkfifo ${nx} 0644 +expect fifo,0644 stat ${nx} type,mode +expect 0 unlink ${nx} +expect ENAMETOOLONG mkfifo ${nxx} 0644 diff --git a/contrib/pjdfstest/tests/mkfifo/03.t b/contrib/pjdfstest/tests/mkfifo/03.t new file mode 100644 index 000000000000..06265293517b --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/03.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 mkfifo ${nx} 0644 +expect fifo stat ${nx} type +expect 0 unlink ${nx} +expect ENAMETOOLONG mkfifo ${nxx} 0644 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/mkfifo/04.t b/contrib/pjdfstest/tests/mkfifo/04.t new file mode 100644 index 000000000000..981015808a18 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/04.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns ENOENT if a component of the path prefix does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT mkfifo ${n0}/${n1}/test 0644 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/05.t b/contrib/pjdfstest/tests/mkfifo/05.t new file mode 100644 index 000000000000..a9510e284841 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/05.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/06.t b/contrib/pjdfstest/tests/mkfifo/06.t new file mode 100644 index 000000000000..a1fa76135152 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/06.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns EACCES when write permission is denied on the parent directory of the file to be created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 mkfifo ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/07.t b/contrib/pjdfstest/tests/mkfifo/07.t new file mode 100644 index 000000000000..0ba1ac4bde30 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP mkfifo ${n0}/test 0644 +expect ELOOP mkfifo ${n1}/test 0644 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/mkfifo/08.t b/contrib/pjdfstest/tests/mkfifo/08.t new file mode 100644 index 000000000000..8e1bd2759524 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/08.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..7" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 mkfifo ${n0}/${n1} 0644 +expect 0 unlink ${n0}/${n1} +mount -ur /dev/md${n} +expect EROFS mkfifo ${n0}/${n1} 0644 +mount -uw /dev/md${n} +expect 0 mkfifo ${n0}/${n1} 0644 +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/09.t b/contrib/pjdfstest/tests/mkfifo/09.t new file mode 100644 index 000000000000..15af5d106180 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/09.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/09.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="mkfifo returns EEXIST if the named file exists" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + expect EEXIST mkfifo ${n0} 0644 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done diff --git a/contrib/pjdfstest/tests/mkfifo/10.t b/contrib/pjdfstest/tests/mkfifo/10.t new file mode 100644 index 000000000000..4c8bcab5ff21 --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/10.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns EPERM if the parent directory of the file to be created has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..17" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 mkfifo ${n0}/${n1} 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM mkfifo ${n0}/${n1} 0644 +expect 0 chflags ${n0} none +expect 0 mkfifo ${n0}/${n1} 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 mkfifo ${n0}/${n1} 0644 +expect 0 unlink ${n0}/${n1} +expect 0 chflags ${n0} none + +expect 0 chflags ${n0} SF_APPEND +expect 0 mkfifo ${n0}/${n1} 0644 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM mkfifo ${n0}/${n1} 0644 + expect 0 chflags ${n0} none + expect 0 mkfifo ${n0}/${n1} 0644 + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 mkfifo ${n0}/${n1} 0644 + expect 0 unlink ${n0}/${n1} + expect 0 chflags ${n0} none + + expect 0 chflags ${n0} UF_APPEND + expect 0 mkfifo ${n0}/${n1} 0644 + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/11.t b/contrib/pjdfstest/tests/mkfifo/11.t new file mode 100644 index 000000000000..8b2396f3be0e --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/11.t @@ -0,0 +1,31 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns ENOSPC if there are no free inodes on the file system on which the file is being created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +i=0 +while :; do + mkfifo ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +expect ENOSPC mkfifo ${n0}/${n1} 0644 +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mkfifo/12.t b/contrib/pjdfstest/tests/mkfifo/12.t new file mode 100644 index 000000000000..ad044b9f702c --- /dev/null +++ b/contrib/pjdfstest/tests/mkfifo/12.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mkfifo/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT mkfifo NULL 0644 +expect EFAULT mkfifo DEADCODE 0644 diff --git a/contrib/pjdfstest/tests/mknod/00.t b/contrib/pjdfstest/tests/mknod/00.t new file mode 100644 index 000000000000..67f4046a6ffb --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/00.t @@ -0,0 +1,73 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod creates fifo files" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..36" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +# POSIX: The file permission bits of the new FIFO shall be initialized from +# mode. The file permission bits of the mode argument shall be modified by the +# process' file creation mask. +expect 0 mknod ${n0} f 0755 0 0 +expect fifo,0755 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 mknod ${n0} f 0151 0 0 +expect fifo,0151 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 077 mknod ${n0} f 0151 0 0 +expect fifo,0100 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 070 mknod ${n0} f 0345 0 0 +expect fifo,0305 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 0501 mknod ${n0} f 0345 0 0 +expect fifo,0244 lstat ${n0} type,mode +expect 0 unlink ${n0} + +# POSIX: The FIFO's user ID shall be set to the process' effective user ID. +# The FIFO's group ID shall be set to the group ID of the parent directory or to +# the effective group ID of the process. +expect 0 chown . 65535 65535 +expect 0 -u 65535 -g 65535 mknod ${n0} f 0755 0 0 +expect 65535,65535 lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 -u 65535 -g 65534 mknod ${n0} f 0755 0 0 +expect "65535,6553[45]" lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65533 mknod ${n0} f 0755 0 0 +expect "65534,6553[35]" lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# POSIX: Upon successful completion, mkfifo() shall mark for update the +# st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and +# st_mtime fields of the directory that contains the new entry shall be marked +# for update. +expect 0 chown . 0 0 +time=`${fstest} stat . ctime` +sleep 1 +expect 0 mknod ${n0} f 0755 0 0 +atime=`${fstest} stat ${n0} atime` +test_check $time -lt $atime +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +mtime=`${fstest} stat . mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat . ctime` +test_check $time -lt $ctime +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/mknod/01.t b/contrib/pjdfstest/tests/mknod/01.t new file mode 100644 index 000000000000..84a0a9731cd7 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/01.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="mknod returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..27" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR mknod ${n0}/${n1}/test b 0644 1 2 + expect ENOTDIR mknod ${n0}/${n1}/test c 0644 1 2 + expect ENOTDIR mknod ${n0}/${n1}/test f 0644 0 0 + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mknod/02.t b/contrib/pjdfstest/tests/mknod/02.t new file mode 100644 index 000000000000..4e864fe69f69 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/02.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 mknod ${nx} f 0644 0 0 +expect fifo,0644 stat ${nx} type,mode +expect 0 unlink ${nx} +expect ENAMETOOLONG mknod ${nxx} f 0644 0 0 + +expect 0 mknod ${nx} b 0644 1 2 +expect block,0644 stat ${nx} type,mode +expect 0 unlink ${nx} +expect ENAMETOOLONG mknod ${nxx} b 0644 0 0 + +expect 0 mknod ${nx} c 0644 1 2 +expect char,0644 stat ${nx} type,mode +expect 0 unlink ${nx} +expect ENAMETOOLONG mknod ${nxx} c 0644 0 0 diff --git a/contrib/pjdfstest/tests/mknod/03.t b/contrib/pjdfstest/tests/mknod/03.t new file mode 100644 index 000000000000..d5c572cbf460 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/03.t @@ -0,0 +1,31 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 mknod ${nx} f 0644 0 0 +expect fifo stat ${nx} type +expect 0 unlink ${nx} +expect ENAMETOOLONG mknod ${nxx} f 0644 0 0 + +expect 0 mknod ${nx} b 0644 1 2 +expect block stat ${nx} type +expect 0 unlink ${nx} +expect ENAMETOOLONG mknod ${nxx} b 0644 1 2 + +expect 0 mknod ${nx} c 0644 1 2 +expect char stat ${nx} type +expect 0 unlink ${nx} +expect ENAMETOOLONG mknod ${nxx} c 0644 1 2 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/mknod/04.t b/contrib/pjdfstest/tests/mknod/04.t new file mode 100644 index 000000000000..4b80208caffe --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/04.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mkfifo returns ENOENT if a component of the path prefix does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT mknod ${n0}/${n1}/test f 0644 0 0 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mknod/05.t b/contrib/pjdfstest/tests/mknod/05.t new file mode 100644 index 000000000000..deafda620750 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/05.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mknod ${n1}/${n2} f 0644 0 0 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 mknod ${n1}/${n2} f 0644 0 0 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 mknod ${n1}/${n2} f 0644 0 0 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mknod/06.t b/contrib/pjdfstest/tests/mknod/06.t new file mode 100644 index 000000000000..da7a5497b5a6 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/06.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns EACCES when write permission is denied on the parent directory of the file to be created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mknod ${n1}/${n2} f 0644 0 0 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 mknod ${n1}/${n2} f 0644 0 0 +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 mknod ${n1}/${n2} f 0644 0 0 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mknod/07.t b/contrib/pjdfstest/tests/mknod/07.t new file mode 100644 index 000000000000..1b39cc7c6d94 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP mknod ${n0}/test f 0644 0 0 +expect ELOOP mknod ${n1}/test f 0644 0 0 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/mknod/08.t b/contrib/pjdfstest/tests/mknod/08.t new file mode 100644 index 000000000000..a8055629de07 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/08.t @@ -0,0 +1,23 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/08.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="mknod returns EEXIST if the named file exists" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..35" + +n0=`namegen` + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + expect EEXIST mknod ${n0} b 0644 0 0 + expect EEXIST mknod ${n0} c 0644 0 0 + expect EEXIST mknod ${n0} f 0644 0 0 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done diff --git a/contrib/pjdfstest/tests/mknod/09.t b/contrib/pjdfstest/tests/mknod/09.t new file mode 100644 index 000000000000..00c2a2f6d8b5 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/09.t @@ -0,0 +1,64 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns EPERM if the parent directory of the file to be created has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:UFS) + echo "1..30" + ;; +*) + echo "1..17" + ;; +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 mknod ${n0}/${n1} f 0644 0 0 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM mknod ${n0}/${n1} f 0644 0 0 +expect 0 chflags ${n0} none +expect 0 mknod ${n0}/${n1} f 0644 0 0 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_APPEND +expect 0 mknod ${n0}/${n1} f 0644 0 0 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 mknod ${n0}/${n1} f 0644 0 0 +expect 0 unlink ${n0}/${n1} +expect 0 chflags ${n0} none + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM mknod ${n0}/${n1} f 0644 0 0 + expect 0 chflags ${n0} none + expect 0 mknod ${n0}/${n1} f 0644 0 0 + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_APPEND + expect 0 mknod ${n0}/${n1} f 0644 0 0 + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 mknod ${n0}/${n1} f 0644 0 0 + expect 0 unlink ${n0}/${n1} + expect 0 chflags ${n0} none + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/mknod/10.t b/contrib/pjdfstest/tests/mknod/10.t new file mode 100644 index 000000000000..5bf18d37adc4 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/10.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT mknod NULL f 0644 0 0 +expect EFAULT mknod DEADCODE f 0644 0 0 diff --git a/contrib/pjdfstest/tests/mknod/11.t b/contrib/pjdfstest/tests/mknod/11.t new file mode 100644 index 000000000000..309f71695f31 --- /dev/null +++ b/contrib/pjdfstest/tests/mknod/11.t @@ -0,0 +1,79 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="mknod creates device files" + +dir=`dirname $0` +. ${dir}/../misc.sh + +case "${os}" in +SunOS) + echo "1..40" + ;; +*) + echo "1..28" + ;; +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +for type in c b; do + case "${type}" in + c) + stattype="char" + ;; + b) + stattype="block" + ;; + esac + + # Create char special with old-style numbers + expect 0 mknod ${n0} ${type} 0755 1 2 + expect ${stattype},0755 lstat ${n0} type,mode + expect 1,2 lstat ${n0} major,minor + expect EEXIST mknod ${n0} ${type} 0777 3 4 + expect 0 unlink ${n0} + + case "${os}" in + SunOS) + # Create char special with new-style numbers + expect 0 mknod ${n0} ${type} 0755 4095 4095 + expect ${stattype},0755 lstat ${n0} type,mode + expect 4095,4095 lstat ${n0} major,minor + expect EEXIST mknod ${n0} ${type} 0777 4000 4000 + expect 0 unlink ${n0} + + # mknod returns EINVAL if device's numbers are too big + # for 32-bit solaris !! + expect EINVAL mknod ${n0} ${type} 0755 4096 262144 + ;; + esac + + # POSIX: Upon successful completion, mknod(2) shall mark for update the + # st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and + # st_mtime fields of the directory that contains the new entry shall be marked + # for update. + expect 0 chown . 0 0 + time=`${fstest} stat . ctime` + sleep 1 + expect 0 mknod ${n0} ${type} 0755 1 2 + atime=`${fstest} stat ${n0} atime` + test_check $time -lt $atime + mtime=`${fstest} stat ${n0} mtime` + test_check $time -lt $mtime + ctime=`${fstest} stat ${n0} ctime` + test_check $time -lt $ctime + mtime=`${fstest} stat . mtime` + test_check $time -lt $mtime + ctime=`${fstest} stat . ctime` + test_check $time -lt $ctime + expect 0 unlink ${n0} +done + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/open/00.t b/contrib/pjdfstest/tests/open/00.t new file mode 100644 index 000000000000..cf11a9290e8e --- /dev/null +++ b/contrib/pjdfstest/tests/open/00.t @@ -0,0 +1,99 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open opens (and eventually creates) a file" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..47" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +# POSIX: (If O_CREAT is specified and the file doesn't exist) [...] the access +# permission bits of the file mode shall be set to the value of the third +# argument taken as type mode_t modified as follows: a bitwise AND is performed +# on the file-mode bits and the corresponding bits in the complement of the +# process' file mode creation mask. Thus, all bits in the file mode whose +# corresponding bit in the file mode creation mask is set are cleared. +expect 0 open ${n0} O_CREAT,O_WRONLY 0755 +expect regular,0755 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 open ${n0} O_CREAT,O_WRONLY 0151 +expect regular,0151 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 077 open ${n0} O_CREAT,O_WRONLY 0151 +expect regular,0100 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 070 open ${n0} O_CREAT,O_WRONLY 0345 +expect regular,0305 lstat ${n0} type,mode +expect 0 unlink ${n0} +expect 0 -U 0501 open ${n0} O_CREAT,O_WRONLY 0345 +expect regular,0244 lstat ${n0} type,mode +expect 0 unlink ${n0} + +# POSIX: (If O_CREAT is specified and the file doesn't exist) [...] the user ID +# of the file shall be set to the effective user ID of the process; the group ID +# of the file shall be set to the group ID of the file's parent directory or to +# the effective group ID of the process [...] +expect 0 chown . 65535 65535 +expect 0 -u 65535 -g 65535 open ${n0} O_CREAT,O_WRONLY 0644 +expect 65535,65535 lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 -u 65535 -g 65534 open ${n0} O_CREAT,O_WRONLY 0644 +expect "65535,6553[45]" lstat ${n0} uid,gid +expect 0 unlink ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 -g 65533 open ${n0} O_CREAT,O_WRONLY 0644 +expect "65534,6553[35]" lstat ${n0} uid,gid +expect 0 unlink ${n0} + +# Update parent directory ctime/mtime if file didn't exist. +expect 0 chown . 0 0 +time=`${fstest} stat . ctime` +sleep 1 +expect 0 open ${n0} O_CREAT,O_WRONLY 0644 +atime=`${fstest} stat ${n0} atime` +test_check $time -lt $atime +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +mtime=`${fstest} stat . mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat . ctime` +test_check $time -lt $ctime +expect 0 unlink ${n0} + +# Don't update parent directory ctime/mtime if file existed. +expect 0 create ${n0} 0644 +dmtime=`${fstest} stat . mtime` +dctime=`${fstest} stat . ctime` +sleep 1 +expect 0 open ${n0} O_CREAT,O_RDONLY 0644 +mtime=`${fstest} stat . mtime` +test_check $dmtime -eq $mtime +ctime=`${fstest} stat . ctime` +test_check $dctime -eq $ctime +expect 0 unlink ${n0} + +echo test > ${n0} +expect 5 stat ${n0} size +mtime1=`${fstest} stat ${n0} mtime` +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 open ${n0} O_WRONLY,O_TRUNC +mtime2=`${fstest} stat ${n0} mtime` +test_check $mtime1 -lt $mtime2 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 stat ${n0} size +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/open/01.t b/contrib/pjdfstest/tests/open/01.t new file mode 100644 index 000000000000..df17590113ab --- /dev/null +++ b/contrib/pjdfstest/tests/open/01.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/01.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="open returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..22" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR open ${n0}/${n1}/test O_RDONLY + expect ENOTDIR open ${n0}/${n1}/test O_CREAT 0644 + expect 0 unlink ${n0}/${n1} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/02.t b/contrib/pjdfstest/tests/open/02.t new file mode 100644 index 000000000000..adb3bb09d39b --- /dev/null +++ b/contrib/pjdfstest/tests/open/02.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 open ${nx} O_CREAT 0620 +expect regular,0620 stat ${nx} type,mode +expect 0 unlink ${nx} +expect ENAMETOOLONG open ${nxx} O_CREAT 0620 diff --git a/contrib/pjdfstest/tests/open/03.t b/contrib/pjdfstest/tests/open/03.t new file mode 100644 index 000000000000..89e67bb46eb2 --- /dev/null +++ b/contrib/pjdfstest/tests/open/03.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ENAMETOOLONG if an entire path name exceeded ${PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 open ${nx} O_CREAT 0642 +expect regular,0642 stat ${nx} type,mode +expect 0 unlink ${nx} +expect ENAMETOOLONG open ${nxx} O_CREAT 0642 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/open/04.t b/contrib/pjdfstest/tests/open/04.t new file mode 100644 index 000000000000..84b0441f11d8 --- /dev/null +++ b/contrib/pjdfstest/tests/open/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ENOENT if a component of the path name that must exist does not exist or O_CREAT is not set and the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT open ${n0}/${n1}/test O_CREAT 0644 +expect ENOENT open ${n0}/${n1} O_RDONLY +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/05.t b/contrib/pjdfstest/tests/open/05.t new file mode 100644 index 000000000000..1b69c61333c3 --- /dev/null +++ b/contrib/pjdfstest/tests/open/05.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 open ${n1}/${n2} O_RDONLY +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/06.t b/contrib/pjdfstest/tests/open/06.t new file mode 100644 index 000000000000..b33e6404e70b --- /dev/null +++ b/contrib/pjdfstest/tests/open/06.t @@ -0,0 +1,187 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EACCES when the required permissions (for reading and/or writing) are denied for the given flags" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..144" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 +cdir=`pwd` +cd ${n0} + +# Regular file. + +expect 0 -u 65534 -g 65534 create ${n1} 0644 + +expect 0 -u 65534 -g 65534 chmod ${n1} 0600 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY, +expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY, +expect 0 -u 65534 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0060 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY, +expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY, +expect 0 -u 65533 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0006 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY, +expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY, +expect 0 -u 65533 -g 65533 open ${n1} O_RDWR, + +expect 0 -u 65534 -g 65534 chmod ${n1} 0477 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0747 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0774 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, + +expect 0 -u 65534 -g 65534 chmod ${n1} 0277 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY, +expect 0 -u 65534 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0727 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY, +expect 0 -u 65533 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0772 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY, +expect 0 -u 65533 -g 65533 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, + +expect 0 -u 65534 -g 65534 chmod ${n1} 0177 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0717 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0771 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, + +expect 0 -u 65534 -g 65534 chmod ${n1} 0077 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0707 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR, +expect 0 -u 65534 -g 65534 chmod ${n1} 0770 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY, +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR, + +expect 0 -u 65534 -g 65534 unlink ${n1} + +# FIFO. + +expect 0 -u 65534 -g 65534 mkfifo ${n1} 0644 + +expect 0 -u 65534 -g 65534 chmod ${n1} 0600 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK +expect 0 -u 65534 -g 65534 open ${n1} O_RDWR,O_NONBLOCK +expect 0 -u 65534 -g 65534 chmod ${n1} 0060 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK +expect 0 -u 65533 -g 65534 open ${n1} O_RDWR,O_NONBLOCK +expect 0 -u 65534 -g 65534 chmod ${n1} 0006 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK +expect 0 -u 65533 -g 65533 open ${n1} O_RDWR,O_NONBLOCK + +expect 0 -u 65534 -g 65534 chmod ${n1} 0477 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0747 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY,O_NONBLOCK +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0774 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY,O_NONBLOCK +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 chmod ${n1} 0177 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0717 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0771 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 chmod ${n1} 0077 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65534 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0707 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65534 open ${n1} O_RDWR +expect 0 -u 65534 -g 65534 chmod ${n1} 0770 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_WRONLY +expect EACCES -u 65533 -g 65533 open ${n1} O_RDWR + +expect 0 -u 65534 -g 65534 unlink ${n1} + +# Directory. + +expect 0 -u 65534 -g 65534 mkdir ${n1} 0755 + +expect 0 -u 65534 -g 65534 chmod ${n1} 0600 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0060 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0006 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY + +expect 0 -u 65534 -g 65534 chmod ${n1} 0477 +expect 0 -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0747 +expect 0 -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0774 +expect 0 -u 65533 -g 65533 open ${n1} O_RDONLY + +expect 0 -u 65534 -g 65534 chmod ${n1} 0277 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0727 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0772 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY + +expect 0 -u 65534 -g 65534 chmod ${n1} 0177 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0717 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0771 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY + +expect 0 -u 65534 -g 65534 chmod ${n1} 0077 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0707 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY +expect 0 -u 65534 -g 65534 chmod ${n1} 0770 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY + +expect 0 -u 65534 -g 65534 rmdir ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/07.t b/contrib/pjdfstest/tests/open/07.t new file mode 100644 index 000000000000..edc4be13649b --- /dev/null +++ b/contrib/pjdfstest/tests/open/07.t @@ -0,0 +1,45 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EACCES when O_TRUNC is specified and write permission is denied" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..23" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 +cdir=`pwd` +cd ${n0} + +expect 0 -u 65534 -g 65534 create ${n1} 0644 + +expect 0 -u 65534 -g 65534 chmod ${n1} 0477 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0747 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0774 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC + +expect 0 -u 65534 -g 65534 chmod ${n1} 0177 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0717 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0771 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC + +expect 0 -u 65534 -g 65534 chmod ${n1} 0077 +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0707 +expect EACCES -u 65533 -g 65534 open ${n1} O_RDONLY,O_TRUNC +expect 0 -u 65534 -g 65534 chmod ${n1} 0770 +expect EACCES -u 65533 -g 65533 open ${n1} O_RDONLY,O_TRUNC + +expect 0 -u 65534 -g 65534 unlink ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/08.t b/contrib/pjdfstest/tests/open/08.t new file mode 100644 index 000000000000..f47ff8720419 --- /dev/null +++ b/contrib/pjdfstest/tests/open/08.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EACCES when O_CREAT is specified, the file does not exist, and the directory in which it is to be created does not permit writing" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect EACCES -u 65534 -g 65534 open ${n1} O_RDONLY,O_CREAT 0644 +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/09.t b/contrib/pjdfstest/tests/open/09.t new file mode 100644 index 000000000000..b76c70da8190 --- /dev/null +++ b/contrib/pjdfstest/tests/open/09.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="O_CREAT is specified, the file does not exist, and the directory in which it is to be created has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..17" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_APPEND +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644 + expect 0 chflags ${n0} none + expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 symlink test ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_APPEND + expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/10.t b/contrib/pjdfstest/tests/open/10.t new file mode 100644 index 000000000000..bd6fdd25241f --- /dev/null +++ b/contrib/pjdfstest/tests/open/10.t @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EPERM when the named file has its immutable flag set and the file is to be modified" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..14" + ;; +FreeBSD:UFS) + echo "1..28" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM open ${n0} O_WRONLY +expect EPERM open ${n0} O_RDWR +expect EPERM open ${n0} O_RDONLY,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 open ${n0} O_WRONLY +expect 0 open ${n0} O_RDWR +expect 0 open ${n0} O_RDONLY,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM open ${n0} O_WRONLY + expect EPERM open ${n0} O_RDWR + expect EPERM open ${n0} O_RDONLY,O_TRUNC + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 open ${n0} O_WRONLY + expect 0 open ${n0} O_RDWR + expect 0 open ${n0} O_RDONLY,O_TRUNC + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/open/11.t b/contrib/pjdfstest/tests/open/11.t new file mode 100644 index 000000000000..e4a3a2d45e8f --- /dev/null +++ b/contrib/pjdfstest/tests/open/11.t @@ -0,0 +1,56 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EPERM when the named file has its append-only flag set, the file is to be modified, and O_TRUNC is specified or O_APPEND is not specified" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..12" + ;; +FreeBSD:UFS) + echo "1..24" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +expect 0 open ${n0} O_WRONLY,O_APPEND +expect 0 open ${n0} O_RDWR,O_APPEND +expect EPERM open ${n0} O_WRONLY +expect EPERM open ${n0} O_RDWR +todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." +expect EPERM open ${n0} O_RDONLY,O_TRUNC +todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." +expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC +todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." +expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC +todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." +expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect 0 open ${n0} O_WRONLY,O_APPEND + expect 0 open ${n0} O_RDWR,O_APPEND + expect EPERM open ${n0} O_WRONLY + expect EPERM open ${n0} O_RDWR + expect EPERM open ${n0} O_RDONLY,O_TRUNC + expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC + expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC + expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/open/12.t b/contrib/pjdfstest/tests/open/12.t new file mode 100644 index 000000000000..d38309d4a118 --- /dev/null +++ b/contrib/pjdfstest/tests/open/12.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP open ${n0}/test O_RDONLY +expect ELOOP open ${n1}/test O_RDONLY +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/open/13.t b/contrib/pjdfstest/tests/open/13.t new file mode 100644 index 000000000000..64bb0b8f825f --- /dev/null +++ b/contrib/pjdfstest/tests/open/13.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EISDIR when trying to open a directory for writing" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +echo "1..8" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 open ${n0} O_RDONLY +expect EISDIR open ${n0} O_WRONLY +expect EISDIR open ${n0} O_RDWR +expect EISDIR open ${n0} O_RDONLY,O_TRUNC +expect EISDIR open ${n0} O_WRONLY,O_TRUNC +expect EISDIR open ${n0} O_RDWR,O_TRUNC + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/14.t b/contrib/pjdfstest/tests/open/14.t new file mode 100644 index 000000000000..8d90065f7171 --- /dev/null +++ b/contrib/pjdfstest/tests/open/14.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EROFS if the named file resides on a read-only file system, and the file is to be modified" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 open ${n0}/${n1} O_WRONLY +expect 0 open ${n0}/${n1} O_RDWR +expect 0 open ${n0}/${n1} O_RDONLY,O_TRUNC +mount -ur /dev/md${n} +expect EROFS open ${n0}/${n1} O_WRONLY +expect EROFS open ${n0}/${n1} O_RDWR +expect EROFS open ${n0}/${n1} O_RDONLY,O_TRUNC +mount -uw /dev/md${n} +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/15.t b/contrib/pjdfstest/tests/open/15.t new file mode 100644 index 000000000000..a8230d89e2f0 --- /dev/null +++ b/contrib/pjdfstest/tests/open/15.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/15.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EROFS when O_CREAT is specified and the named file would reside on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +expect 0 unlink ${n0}/${n1} +mount -ur /dev/md${n} +expect EROFS open ${n0}/${n1} O_RDONLY,O_CREAT 0644 +mount -uw /dev/md${n} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/16.t b/contrib/pjdfstest/tests/open/16.t new file mode 100644 index 000000000000..7f796d61a365 --- /dev/null +++ b/contrib/pjdfstest/tests/open/16.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/16.t 219621 2011-03-13 19:35:13Z pjd $ + +dir=`dirname $0` +. ${dir}/../misc.sh + +case "${os}" in +Darwin|Linux) + error=ELOOP + ;; +*) + error=EMLINK + ;; +esac +desc="open returns $error when O_NOFOLLOW was specified and the target is a symbolic link" + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect $error open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 +expect $error open ${n1} O_RDONLY,O_NOFOLLOW +expect $error open ${n1} O_WRONLY,O_NOFOLLOW +expect $error open ${n1} O_RDWR,O_NOFOLLOW +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/open/17.t b/contrib/pjdfstest/tests/open/17.t new file mode 100644 index 000000000000..e5888fc176f2 --- /dev/null +++ b/contrib/pjdfstest/tests/open/17.t @@ -0,0 +1,15 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/17.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ENXIO when O_NONBLOCK is set, the named file is a fifo, O_WRONLY is set, and no process has the file open for reading" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkfifo ${n0} 0644 +expect ENXIO open ${n0} O_WRONLY,O_NONBLOCK +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/open/18.t b/contrib/pjdfstest/tests/open/18.t new file mode 100644 index 000000000000..6d0713b43a89 --- /dev/null +++ b/contrib/pjdfstest/tests/open/18.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/18.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EWOULDBLOCK when O_NONBLOCK and one of O_SHLOCK or O_EXLOCK is specified and the file is locked" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..6" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 open ${n0} O_RDONLY,O_SHLOCK : open ${n0} O_RDONLY,O_SHLOCK,O_NONBLOCK +expect "EWOULDBLOCK|EAGAIN" open ${n0} O_RDONLY,O_EXLOCK : open ${n0} O_RDONLY,O_EXLOCK,O_NONBLOCK +expect "EWOULDBLOCK|EAGAIN" open ${n0} O_RDONLY,O_SHLOCK : open ${n0} O_RDONLY,O_EXLOCK,O_NONBLOCK +expect "EWOULDBLOCK|EAGAIN" open ${n0} O_RDONLY,O_EXLOCK : open ${n0} O_RDONLY,O_SHLOCK,O_NONBLOCK +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/open/19.t b/contrib/pjdfstest/tests/open/19.t new file mode 100644 index 000000000000..c9d98eb5480e --- /dev/null +++ b/contrib/pjdfstest/tests/open/19.t @@ -0,0 +1,31 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/19.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ENOSPC when O_CREAT is specified, the file does not exist, and there are no free inodes on the file system on which the file is being created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +i=0 +while :; do + touch ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +expect ENOSPC open ${n0}/${i} O_RDONLY,O_CREAT 0644 +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/open/20.t b/contrib/pjdfstest/tests/open/20.t new file mode 100644 index 000000000000..de80b6122b7d --- /dev/null +++ b/contrib/pjdfstest/tests/open/20.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/20.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns ETXTBSY when the file is a pure procedure (shared text) file that is being executed and the open() system call requests write access" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..4" + +n0=`namegen` + +cp -pf `which sleep` ${n0} +./${n0} 3 & +expect ETXTBSY open ${n0} O_WRONLY +expect ETXTBSY open ${n0} O_RDWR +expect ETXTBSY open ${n0} O_RDONLY,O_TRUNC +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/open/21.t b/contrib/pjdfstest/tests/open/21.t new file mode 100644 index 000000000000..4a2422cfa6aa --- /dev/null +++ b/contrib/pjdfstest/tests/open/21.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/21.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT open NULL O_RDONLY +expect EFAULT open DEADCODE O_RDONLY diff --git a/contrib/pjdfstest/tests/open/22.t b/contrib/pjdfstest/tests/open/22.t new file mode 100644 index 000000000000..55d4b9b3f8a3 --- /dev/null +++ b/contrib/pjdfstest/tests/open/22.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/22.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EEXIST when O_CREAT and O_EXCL were specified and the file exists" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + expect EEXIST open ${n0} O_CREAT,O_EXCL 0644 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done diff --git a/contrib/pjdfstest/tests/open/23.t b/contrib/pjdfstest/tests/open/23.t new file mode 100644 index 000000000000..4728c18896cd --- /dev/null +++ b/contrib/pjdfstest/tests/open/23.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/23.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open may return EINVAL when an attempt was made to open a descriptor with an illegal combination of O_RDONLY, O_WRONLY, and O_RDWR" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect "0|EINVAL" open ${n0} O_RDONLY,O_RDWR +expect "0|EINVAL" open ${n0} O_WRONLY,O_RDWR +expect "0|EINVAL" open ${n0} O_RDONLY,O_WRONLY,O_RDWR +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/open/24.t b/contrib/pjdfstest/tests/open/24.t new file mode 100644 index 000000000000..ca709f221214 --- /dev/null +++ b/contrib/pjdfstest/tests/open/24.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/open/24.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="open returns EOPNOTSUPP when trying to open UNIX domain socket" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` + +expect 0 bind ${n0} +expect "EOPNOTSUPP" open ${n0} O_RDONLY +expect "EOPNOTSUPP" open ${n0} O_WRONLY +expect "EOPNOTSUPP" open ${n0} O_RDWR +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/rename/00.t b/contrib/pjdfstest/tests/rename/00.t new file mode 100644 index 000000000000..2126a86a5488 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/00.t @@ -0,0 +1,91 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename changes file name" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..150" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n3} 0755 +cdir=`pwd` +cd ${n3} + +for type in regular fifo block char socket; do + create_file ${type} ${n0} 0644 + expect ${type},0644,1 lstat ${n0} type,mode,nlink + inode=`${fstest} lstat ${n0} inode` + expect 0 rename ${n0} ${n1} + expect ENOENT lstat ${n0} type,mode,nlink + expect ${type},${inode},0644,1 lstat ${n1} type,inode,mode,nlink + expect 0 link ${n1} ${n0} + expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink + expect ${type},${inode},0644,2 lstat ${n1} type,inode,mode,nlink + expect 0 rename ${n1} ${n2} + expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink + expect ENOENT lstat ${n1} type,mode,nlink + expect ${type},${inode},0644,2 lstat ${n2} type,inode,mode,nlink + expect 0 unlink ${n0} + expect 0 unlink ${n2} +done + +expect 0 mkdir ${n0} 0755 +expect dir,0755 lstat ${n0} type,mode +inode=`${fstest} lstat ${n0} inode` +expect 0 rename ${n0} ${n1} +expect ENOENT lstat ${n0} type,mode +expect dir,${inode},0755 lstat ${n1} type,inode,mode +expect 0 rmdir ${n1} + +expect 0 create ${n0} 0644 +rinode=`${fstest} lstat ${n0} inode` +expect regular,0644 lstat ${n0} type,mode +expect 0 symlink ${n0} ${n1} +sinode=`${fstest} lstat ${n1} inode` +expect regular,${rinode},0644 stat ${n1} type,inode,mode +expect symlink,${sinode} lstat ${n1} type,inode +expect 0 rename ${n1} ${n2} +expect regular,${rinode},0644 stat ${n0} type,inode,mode +expect ENOENT lstat ${n1} type,mode +expect symlink,${sinode} lstat ${n2} type,inode +expect 0 unlink ${n0} +expect 0 unlink ${n2} + +# successful rename(2) updates ctime. +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect 0 rename ${n0} ${n1} + ctime2=`${fstest} lstat ${n1} ctime` + test_check $ctime1 -lt $ctime2 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +# unsuccessful link(2) does not update ctime. +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + ctime1=`${fstest} lstat ${n0} ctime` + sleep 1 + expect EACCES -u 65534 rename ${n0} ${n1} + ctime2=`${fstest} lstat ${n0} ctime` + test_check $ctime1 -eq $ctime2 + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done + +cd ${cdir} +expect 0 rmdir ${n3} diff --git a/contrib/pjdfstest/tests/rename/01.t b/contrib/pjdfstest/tests/rename/01.t new file mode 100644 index 000000000000..dbb9c0660d41 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/01.t @@ -0,0 +1,23 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns ENAMETOOLONG if a component of either pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 rename ${nx} ${n0} +expect 0 rename ${n0} ${nx} +expect 0 unlink ${nx} + +expect 0 create ${n0} 0644 +expect ENAMETOOLONG rename ${n0} ${nxx} +expect 0 unlink ${n0} +expect ENAMETOOLONG rename ${nxx} ${n0} diff --git a/contrib/pjdfstest/tests/rename/02.t b/contrib/pjdfstest/tests/rename/02.t new file mode 100644 index 000000000000..23425bada559 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/02.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${n0} 0644 +expect 0 rename ${n0} ${nx} +expect 0 rename ${nx} ${n0} +expect ENAMETOOLONG rename ${n0} ${nxx} +expect 0 unlink ${n0} +expect ENAMETOOLONG rename ${nxx} ${n0} + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/rename/03.t b/contrib/pjdfstest/tests/rename/03.t new file mode 100644 index 000000000000..fb1d16f10d10 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/03.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns ENOENT if a component of the 'from' path does not exist, or a path prefix of 'to' does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT rename ${n0}/${n1}/test ${n2} +expect 0 create ${n2} 0644 +expect ENOENT rename ${n2} ${n0}/${n1}/test +expect 0 unlink ${n2} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/04.t b/contrib/pjdfstest/tests/rename/04.t new file mode 100644 index 000000000000..19d1791a71a8 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/04.t @@ -0,0 +1,43 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EACCES when a component of either path prefix denies search permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..18" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` +n4=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 mkdir ${n2} 0755 +expect 0 chown ${n2} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644 + +expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4} +expect 0 -u 65534 -g 65534 rename ${n2}/${n4} ${n1}/${n3} + +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n1}/${n4} +expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4} + +expect 0 chmod ${n1} 0755 +expect 0 chmod ${n2} 0644 +expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4} + +expect 0 unlink ${n1}/${n3} +expect 0 rmdir ${n1} +expect 0 rmdir ${n2} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/05.t b/contrib/pjdfstest/tests/rename/05.t new file mode 100644 index 000000000000..52deac153b8c --- /dev/null +++ b/contrib/pjdfstest/tests/rename/05.t @@ -0,0 +1,41 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EACCES when the requested link requires writing in a directory with a mode that denies write permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..17" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` +n4=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 mkdir ${n2} 0755 +expect 0 chown ${n2} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n3} 0644 + +expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4} +expect 0 -u 65534 -g 65534 rename ${n2}/${n4} ${n1}/${n3} + +expect 0 chmod ${n2} 0555 +expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n2}/${n4} +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 rename ${n1}/${n3} ${n1}/${n4} +expect 0 chmod ${n1} 0755 + +expect 0 unlink ${n1}/${n3} +expect 0 rmdir ${n1} +expect 0 rmdir ${n2} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/06.t b/contrib/pjdfstest/tests/rename/06.t new file mode 100644 index 000000000000..ffcf61e83a5c --- /dev/null +++ b/contrib/pjdfstest/tests/rename/06.t @@ -0,0 +1,61 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EPERM if the file pointed at by the 'from' argument has its immutable, undeletable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND" + echo "1..195" + ;; +FreeBSD:UFS) + flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND UF_IMMUTABLE UF_NOUNLINK UF_APPEND" + echo "1..351" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +for type in regular dir fifo block char socket symlink; do + if [ "${type}" != "symlink" ]; then + create_file ${type} ${n0} + for flag in ${flags}; do + expect 0 chflags ${n0} ${flag} + expect ${flag} stat ${n0} flags + [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." + expect EPERM rename ${n0} ${n1} + [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." + expect ENOENT rename ${n1} ${n0} + done + expect 0 chflags ${n0} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi + fi + + create_file ${type} ${n0} + for flag in ${flags}; do + expect 0 lchflags ${n0} ${flag} + expect ${flag} lstat ${n0} flags + [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." + expect EPERM rename ${n0} ${n1} + [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." + expect ENOENT rename ${n1} ${n0} + done + expect 0 lchflags ${n0} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done diff --git a/contrib/pjdfstest/tests/rename/07.t b/contrib/pjdfstest/tests/rename/07.t new file mode 100644 index 000000000000..522e67df9181 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/07.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EPERM if the parent directory of the file pointed at by the 'from' argument has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + flags1="SF_IMMUTABLE SF_APPEND" + flags2="SF_NOUNLINK" + echo "1..128" + ;; +FreeBSD:UFS) + flags1="SF_IMMUTABLE SF_APPEND UF_IMMUTABLE UF_APPEND" + flags2="SF_NOUNLINK UF_NOUNLINK" + echo "1..212" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0}/${n1} + for flag in ${flags1}; do + expect 0 chflags ${n0} ${flag} + expect ${flag} stat ${n0} flags + [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." + expect EPERM rename ${n0}/${n1} ${n2} + [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." + expect ENOENT rename ${n2} ${n0}/${n1} + done + expect 0 chflags ${n0} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0}/${n1} + else + expect 0 unlink ${n0}/${n1} + fi +done + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0}/${n1} + for flag in ${flags2}; do + expect 0 chflags ${n0} ${flag} + expect ${flag} stat ${n0} flags + expect 0 rename ${n0}/${n1} ${n2} + expect 0 rename ${n2} ${n0}/${n1} + done + expect 0 chflags ${n0} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0}/${n1} + else + expect 0 unlink ${n0}/${n1} + fi +done + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/08.t b/contrib/pjdfstest/tests/rename/08.t new file mode 100644 index 000000000000..beffb41f8785 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/08.t @@ -0,0 +1,63 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EPERM if the parent directory of the file pointed at by the 'to' argument has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + flags1="SF_IMMUTABLE" + flags2="SF_NOUNLINK SF_APPEND" + echo "1..128" + ;; +FreeBSD:UFS) + flags1="SF_IMMUTABLE UF_IMMUTABLE" + flags2="SF_NOUNLINK SF_APPEND UF_NOUNLINK UF_APPEND" + echo "1..219" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n1} + for flag in ${flags1}; do + expect 0 chflags ${n0} ${flag} + expect ${flag} stat ${n0} flags + expect EPERM rename ${n1} ${n0}/${n2} + done + expect 0 chflags ${n0} none + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n1} + for flag in ${flags2}; do + expect 0 chflags ${n0} ${flag} + expect ${flag} stat ${n0} flags + expect 0 rename ${n1} ${n0}/${n2} + expect 0 chflags ${n0} none + expect 0 rename ${n0}/${n2} ${n1} + done + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1} + else + expect 0 unlink ${n1} + fi +done + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/09.t b/contrib/pjdfstest/tests/rename/09.t new file mode 100644 index 000000000000..299ff64c57e0 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/09.t @@ -0,0 +1,191 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EACCES or EPERM if the directory containing 'from' is marked sticky, and neither the containing directory nor 'from' are owned by the effective user ID" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2353" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` +n4=`namegen` + +expect 0 mkdir ${n4} 0755 +cdir=`pwd` +cd ${n4} + +expect 0 mkdir ${n0} 0755 +expect 0 chmod ${n0} 01777 +expect 0 chown ${n0} 65534 65534 + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 + +for type in regular fifo block char socket symlink; do + # User owns both: the source sticky directory and the source file. + expect 0 chown ${n0} 65534 65534 + create_file ${type} ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in none regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} 65534 65534 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} inode + expect ${inode},65534,65534 lstat ${n1}/${n3} inode,uid,gid + expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2} + expect ${inode} lstat ${n0}/${n2} inode + expect ENOENT lstat ${n1}/${n3} inode + done + + expect 0 unlink ${n0}/${n2} + + # User owns the source sticky directory, but doesn't own the source file. + for id in 0 65533; do + expect 0 chown ${n0} 65534 65534 + create_file ${type} ${n0}/${n2} ${id} ${id} + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in none regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} 65534 65534 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} inode + expect ${inode},${id},${id} lstat ${n1}/${n3} inode,uid,gid + expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2} + expect ${inode} lstat ${n0}/${n2} inode + expect ENOENT lstat ${n1}/${n3} inode + done + + expect 0 unlink ${n0}/${n2} + done + + # User owns the source file, but doesn't own the source sticky directory. + for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file ${type} ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in none regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} 65534 65534 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} inode + expect ${inode},65534,65534 lstat ${n1}/${n3} inode,uid,gid + expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2} + expect ${inode} lstat ${n0}/${n2} inode + expect ENOENT lstat ${n1}/${n3} inode + done + + expect 0 unlink ${n0}/${n2} + done + + # User doesn't own the source sticky directory nor the source file. + for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file ${type} ${n0}/${n2} ${id} ${id} + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in none regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} 65534 65534 + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode},${id},${id} lstat ${n0}/${n2} inode,uid,gid + if [ "${type}" != "none" ]; then + expect 65534,65534 lstat ${n1}/${n3} uid,gid + expect 0 unlink ${n1}/${n3} + fi + done + + expect 0 unlink ${n0}/${n2} + done +done + +# User owns both: the source sticky directory and the source directory. +expect 0 chown ${n0} 65534 65534 +create_file dir ${n0}/${n2} 65534 65534 +inode=`${fstest} lstat ${n0}/${n2} inode` + +expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} +expect ENOENT lstat ${n0}/${n2} type +expect ${inode},65534,65534 lstat ${n1}/${n3} inode,uid,gid +expect 0 rename ${n1}/${n3} ${n0}/${n2} + +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755 +expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} +expect ENOENT lstat ${n0}/${n2} type +expect ${inode},65534,65534 lstat ${n1}/${n3} inode,uid,gid +expect 0 rmdir ${n1}/${n3} + +# User owns the source sticky directory, but doesn't own the source directory. +# This fails when changing parent directory, because this will modify +# source directory inode (the .. link in it), but we can still rename it +# without changing its parent directory. +for id in 0 65533; do + expect 0 chown ${n0} 65534 65534 + create_file dir ${n0}/${n2} ${id} ${id} + inode=`${fstest} lstat ${n0}/${n2} inode` + + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode},${id},${id} lstat ${n0}/${n2} inode,uid,gid + expect ENOENT lstat ${n1}/${n3} type + + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n0}/${n3} + expect ENOENT lstat ${n0}/${n2} type + expect ${inode},${id},${id} lstat ${n0}/${n3} inode,uid,gid + expect 0 rename ${n0}/${n3} ${n0}/${n2} + + expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755 + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode},${id},${id} lstat ${n0}/${n2} inode,uid,gid + expect dir,${id},${id} lstat ${n0}/${n2} type,uid,gid + expect 0 rmdir ${n1}/${n3} + + expect 0 -u 65534 -g 65534 mkdir ${n0}/${n3} 0755 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n0}/${n3} + expect ENOENT lstat ${n0}/${n2} type + expect ${inode},${id},${id} lstat ${n0}/${n3} inode,uid,gid + expect 0 rmdir ${n0}/${n3} +done + +# User owns the source directory, but doesn't own the source sticky directory. +for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file dir ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} type + expect ${inode},65534,65534 lstat ${n1}/${n3} inode,uid,gid + expect 0 rename ${n1}/${n3} ${n0}/${n2} + + expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} type + expect ${inode},65534,65534 lstat ${n1}/${n3} inode,uid,gid + expect 0 rmdir ${n1}/${n3} +done + +# User doesn't own the source sticky directory nor the source directory. +for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file dir ${n0}/${n2} ${id} ${id} + inode=`${fstest} lstat ${n0}/${n2} inode` + + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode},${id},${id} lstat ${n0}/${n2} inode,uid,gid + expect ENOENT lstat ${n1}/${n3} type + + expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755 + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode},${id},${id} lstat ${n0}/${n2} inode,uid,gid + expect dir,65534,65534 lstat ${n1}/${n3} type,uid,gid + expect 0 rmdir ${n0}/${n2} + expect 0 rmdir ${n1}/${n3} +done + +expect 0 rmdir ${n1} +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n4} diff --git a/contrib/pjdfstest/tests/rename/10.t b/contrib/pjdfstest/tests/rename/10.t new file mode 100644 index 000000000000..268c3b647de1 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/10.t @@ -0,0 +1,156 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EACCES or EPERM if the file pointed at by the 'to' argument exists, the directory containing 'to' is marked sticky, and neither the containing directory nor 'to' are owned by the effective user ID" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2099" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` +n4=`namegen` + +expect 0 mkdir ${n4} 0755 +cdir=`pwd` +cd ${n4} + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 + +expect 0 mkdir ${n1} 0755 +expect 0 chmod ${n1} 01777 + +for type in regular fifo block char socket symlink; do + # User owns both: the sticky directory and the destination file. + expect 0 chown ${n1} 65534 65534 + create_file ${type} ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} 65534 65534 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} inode + expect ${inode} lstat ${n1}/${n3} inode + expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2} + expect ${inode} lstat ${n0}/${n2} inode + expect ENOENT lstat ${n1}/${n3} inode + done + + expect 0 unlink ${n0}/${n2} + + # User owns the sticky directory, but doesn't own the destination file. + for id in 0 65533; do + expect 0 chown ${n1} 65534 65534 + create_file ${type} ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} ${id} ${id} + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} inode + expect ${inode} lstat ${n1}/${n3} inode + expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2} + expect ${inode} lstat ${n0}/${n2} inode + expect ENOENT lstat ${n1}/${n3} inode + done + + expect 0 unlink ${n0}/${n2} + done + + # User owns the destination file, but doesn't own the sticky directory. + for id in 0 65533; do + expect 0 chown ${n1} ${id} ${id} + create_file ${type} ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} 65534 65534 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} inode + expect ${inode} lstat ${n1}/${n3} inode + expect 0 -u 65534 -g 65534 rename ${n1}/${n3} ${n0}/${n2} + expect ${inode} lstat ${n0}/${n2} inode + expect ENOENT lstat ${n1}/${n3} inode + done + + expect 0 unlink ${n0}/${n2} + done + + # User doesn't own the sticky directory nor the destination file. + for id in 0 65533; do + expect 0 chown ${n1} ${id} ${id} + create_file ${type} ${n0}/${n2} 65534 65534 + inode=`${fstest} lstat ${n0}/${n2} inode` + + for type in regular fifo block char socket symlink; do + create_file ${type} ${n1}/${n3} ${id} ${id} + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode} lstat ${n0}/${n2} inode + expect ${id},${id} lstat ${n1}/${n3} uid,gid + expect 0 unlink ${n1}/${n3} + done + + expect 0 unlink ${n0}/${n2} + done +done + +# User owns both: the sticky directory and the destination directory. +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755 +inode=`${fstest} lstat ${n0}/${n2} inode` + +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755 +expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} +expect ENOENT lstat ${n0}/${n2} type +expect ${inode} lstat ${n1}/${n3} inode +expect 0 rmdir ${n1}/${n3} + +# User owns the sticky directory, but doesn't own the destination directory. +for id in 0 65533; do + expect 0 chown ${n1} 65534 65534 + expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755 + inode=`${fstest} lstat ${n0}/${n2} inode` + + expect 0 -u ${id} -g ${id} mkdir ${n1}/${n3} 0755 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} type + expect ${inode} lstat ${n1}/${n3} inode + expect 0 rmdir ${n1}/${n3} +done + +# User owns the destination directory, but doesn't own the sticky directory. +for id in 0 65533; do + expect 0 chown ${n1} ${id} ${id} + expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755 + inode=`${fstest} lstat ${n0}/${n2} inode` + + expect 0 -u 65534 -g 65534 mkdir ${n1}/${n3} 0755 + expect 0 -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ENOENT lstat ${n0}/${n2} type + expect ${inode} lstat ${n1}/${n3} inode + expect 0 rmdir ${n1}/${n3} +done + +# User doesn't own the sticky directory nor the destination directory. +for id in 0 65533; do + expect 0 chown ${n1} ${id} ${id} + expect 0 -u 65534 -g 65534 mkdir ${n0}/${n2} 0755 + inode=`${fstest} lstat ${n0}/${n2} inode` + + expect 0 -u ${id} -g ${id} mkdir ${n1}/${n3} 0755 + expect "EACCES|EPERM" -u 65534 -g 65534 rename ${n0}/${n2} ${n1}/${n3} + expect ${inode} lstat ${n0}/${n2} inode + expect ${id},${id} lstat ${n1}/${n3} uid,gid + expect 0 rmdir ${n0}/${n2} + expect 0 rmdir ${n1}/${n3} +done + +expect 0 rmdir ${n1} +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n4} diff --git a/contrib/pjdfstest/tests/rename/11.t b/contrib/pjdfstest/tests/rename/11.t new file mode 100644 index 000000000000..3bcd97ed18f3 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/11.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns ELOOP if too many symbolic links were encountered in translating one of the pathnames" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP rename ${n0}/test ${n2} +expect ELOOP rename ${n1}/test ${n2} +expect 0 create ${n2} 0644 +expect ELOOP rename ${n2} ${n0}/test +expect ELOOP rename ${n2} ${n1}/test +expect 0 unlink ${n0} +expect 0 unlink ${n1} +expect 0 unlink ${n2} diff --git a/contrib/pjdfstest/tests/rename/12.t b/contrib/pjdfstest/tests/rename/12.t new file mode 100644 index 000000000000..c8939fe85ebf --- /dev/null +++ b/contrib/pjdfstest/tests/rename/12.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/12.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="rename returns ENOTDIR if a component of either path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..32" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular fifo block char socket; do + create_file ${type} ${n0}/${n1} + expect ENOTDIR rename ${n0}/${n1}/test ${n0}/${n2} + create_file ${type} ${n0}/${n2} + expect ENOTDIR link ${n0}/${n2} ${n0}/${n1}/test + expect 0 unlink ${n0}/${n1} + expect 0 unlink ${n0}/${n2} +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/13.t b/contrib/pjdfstest/tests/rename/13.t new file mode 100644 index 000000000000..00b0bfb6f577 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/13.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns ENOTDIR when the 'from' argument is a directory, but 'to' is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..32" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +for type in regular fifo block char socket symlink; do + create_file ${type} ${n1} + expect ENOTDIR rename ${n0} ${n1} + expect dir lstat ${n0} type + expect ${type} lstat ${n1} type + expect 0 unlink ${n1} +done + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/14.t b/contrib/pjdfstest/tests/rename/14.t new file mode 100644 index 000000000000..251a1bd66393 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/14.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EISDIR when the 'to' argument is a directory, but 'from' is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..32" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +for type in regular fifo block char socket symlink; do + create_file ${type} ${n1} + expect EISDIR rename ${n1} ${n0} + expect dir lstat ${n0} type + expect ${type} lstat ${n1} type + expect 0 unlink ${n1} +done + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/15.t b/contrib/pjdfstest/tests/rename/15.t new file mode 100644 index 000000000000..cd2e44b4830b --- /dev/null +++ b/contrib/pjdfstest/tests/rename/15.t @@ -0,0 +1,34 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/15.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EXDEV if the link named by 'to' and the file named by 'from' are on different file systems" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..23" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0}/${n1} + expect EXDEV rename ${n0}/${n1} ${n2} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0}/${n1} + else + expect 0 unlink ${n0}/${n1} + fi +done + +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/16.t b/contrib/pjdfstest/tests/rename/16.t new file mode 100644 index 000000000000..102657d59cef --- /dev/null +++ b/contrib/pjdfstest/tests/rename/16.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/16.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EROFS if the requested link requires writing in a directory on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..8" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +mount -ur /dev/md${n} + +expect EROFS rename ${n0}/${n1} ${n0}/${n2} +expect EROFS rename ${n0}/${n1} ${n2} +expect 0 create ${n2} 0644 +expect EROFS rename ${n2} ${n0}/${n2} +expect 0 unlink ${n2} + +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/17.t b/contrib/pjdfstest/tests/rename/17.t new file mode 100644 index 000000000000..6deb7b704f06 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/17.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/17.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EFAULT if one of the pathnames specified is outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EFAULT rename ${n0} NULL +expect EFAULT rename ${n0} DEADCODE +expect 0 unlink ${n0} +expect EFAULT rename NULL ${n0} +expect EFAULT rename DEADCODE ${n0} +expect EFAULT rename NULL DEADCODE +expect EFAULT rename DEADCODE NULL diff --git a/contrib/pjdfstest/tests/rename/18.t b/contrib/pjdfstest/tests/rename/18.t new file mode 100644 index 000000000000..8a9594ec4127 --- /dev/null +++ b/contrib/pjdfstest/tests/rename/18.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/18.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EINVAL when the 'from' argument is a parent directory of 'to'" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ${n0}/${n1} 0755 + +expect EINVAL rename ${n0} ${n0}/${n1} +expect EINVAL rename ${n0} ${n0}/${n1}/${n2} + +expect 0 rmdir ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/19.t b/contrib/pjdfstest/tests/rename/19.t new file mode 100644 index 000000000000..2cd95615e42b --- /dev/null +++ b/contrib/pjdfstest/tests/rename/19.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/19.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EINVAL/EBUSY when an attempt is made to rename '.' or '..'" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ${n0}/${n1} 0755 + +expect "EINVAL|EBUSY" rename ${n0}/${n1}/. ${n2} +expect "EINVAL|EBUSY" rename ${n0}/${n1}/.. ${n2} + +expect 0 rmdir ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/20.t b/contrib/pjdfstest/tests/rename/20.t new file mode 100644 index 000000000000..8ec37cf7d4cc --- /dev/null +++ b/contrib/pjdfstest/tests/rename/20.t @@ -0,0 +1,29 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/20.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rename returns EEXIST or ENOTEMPTY if the 'to' argument is a directory and is not empty" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..25" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ${n1} 0755 + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n1}/${n2} + expect "EEXIST|ENOTEMPTY" rename ${n0} ${n1} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n1}/${n2} + else + expect 0 unlink ${n1}/${n2} + fi +done + +expect 0 rmdir ${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rename/21.t b/contrib/pjdfstest/tests/rename/21.t new file mode 100644 index 000000000000..bba1467069da --- /dev/null +++ b/contrib/pjdfstest/tests/rename/21.t @@ -0,0 +1,47 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/21.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="write access to subdirectory is required to move it to another directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..16" + +n0=`namegen` +n1=`namegen` +n2=`namegen` +n3=`namegen` + +expect 0 mkdir ${n2} 0777 +expect 0 mkdir ${n3} 0777 +cdir=`pwd` + +# Check that write permission on containing directory (${n2}) is enough +# to rename subdirectory (${n0}). If we rename directory write access +# to this directory may also be required. +expect 0 mkdir ${n2}/${n0} 0700 +expect "0|EACCES" -u 65534 -g 65534 rename ${n2}/${n0} ${n2}/${n1} +expect "0|EACCES" -u 65534 -g 65534 rename ${n2}/${n1} ${n2}/${n0} + +# Check that write permission on containing directory (${n2}) is not enough +# to move subdirectory (${n0}) from that directory. +# Actually POSIX says that write access to ${n2} and ${n3} may be enough +# to move ${n0} from ${n2} to ${n3}. +expect "0|EACCES" -u 65534 -g 65534 rename ${n2}/${n0} ${n3}/${n1} + +expect "0|ENOENT" rmdir ${n2}/${n0} +expect ENOENT rmdir ${n2}/${n0} +expect "0|ENOENT" rmdir ${n3}/${n1} +expect ENOENT rmdir ${n3}/${n1} + +# Check that write permission on containing directory (${n2}) is enough +# to move file (${n0}) from that directory. +expect 0 create ${n2}/${n0} 0644 +expect 0 -u 65534 -g 65534 rename ${n2}/${n0} ${n3}/${n1} + +expect 0 unlink ${n3}/${n1} +expect ENOENT unlink ${n2}/${n0} + +expect 0 rmdir ${n3} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/rmdir/00.t b/contrib/pjdfstest/tests/rmdir/00.t new file mode 100644 index 000000000000..9e75be6b9884 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/00.t @@ -0,0 +1,28 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir removes directories" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect dir lstat ${n0} type +expect 0 rmdir ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ${n0}/${n1} 0755 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 rmdir ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/01.t b/contrib/pjdfstest/tests/rmdir/01.t new file mode 100644 index 000000000000..b89ffefbe763 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/01.t @@ -0,0 +1,30 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns ENOTDIR if a component of the path is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..14" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR rmdir ${n0}/${n1}/test +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} + +expect 0 create ${n0} 0644 +expect ENOTDIR rmdir ${n0} +expect 0 unlink ${n0} + +expect 0 symlink ${n1} ${n0} +expect ENOTDIR rmdir ${n0} +expect 0 unlink ${n0} + +expect 0 mkfifo ${n0} 0644 +expect ENOTDIR rmdir ${n0} +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/02.t b/contrib/pjdfstest/tests/rmdir/02.t new file mode 100644 index 000000000000..eb8a774bf240 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/02.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 mkdir ${nx} 0755 +expect 0 rmdir ${nx} +expect ENOENT rmdir ${nx} +expect ENAMETOOLONG rmdir ${nxx} diff --git a/contrib/pjdfstest/tests/rmdir/03.t b/contrib/pjdfstest/tests/rmdir/03.t new file mode 100644 index 000000000000..3d5a11a3611d --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/03.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns ENAMETOOLONG if an entire path name exceeded ${PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 mkdir ${nx} 0755 +expect dir,0755 stat ${nx} type,mode +expect 0 rmdir ${nx} +expect ENOENT rmdir ${nx} +expect ENAMETOOLONG rmdir ${nxx} + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/rmdir/04.t b/contrib/pjdfstest/tests/rmdir/04.t new file mode 100644 index 000000000000..d5abc31cfd18 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns ENOENT if the named directory does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 rmdir ${n0} +expect ENOENT rmdir ${n0} +expect ENOENT rmdir ${n1} diff --git a/contrib/pjdfstest/tests/rmdir/05.t b/contrib/pjdfstest/tests/rmdir/05.t new file mode 100644 index 000000000000..eb984533d057 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/05.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP rmdir ${n0}/test +expect ELOOP rmdir ${n1}/test +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/rmdir/06.t b/contrib/pjdfstest/tests/rmdir/06.t new file mode 100644 index 000000000000..64a6ac85fe49 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/06.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/06.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="rmdir returns EEXIST or ENOTEMPTY the named directory contains files other than '.' and '..' in it" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..23" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0}/${n1} + expect "EEXIST|ENOTEMPTY" rmdir ${n0} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0}/${n1} + else + expect 0 unlink ${n0}/${n1} + fi +done +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/07.t b/contrib/pjdfstest/tests/rmdir/07.t new file mode 100644 index 000000000000..10a78a71e9d5 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/07.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/08.t b/contrib/pjdfstest/tests/rmdir/08.t new file mode 100644 index 000000000000..fe70c8683d0b --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/08.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EACCES when write permission is denied on the directory containing the link to be removed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 mkdir ${n1}/${n2} 0755 +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 rmdir ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/09.t b/contrib/pjdfstest/tests/rmdir/09.t new file mode 100644 index 000000000000..8b0276c980ed --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/09.t @@ -0,0 +1,65 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EPERM if the named directory has its immutable, undeletable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..15" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM rmdir ${n0} +expect 0 chflags ${n0} none +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 chflags ${n0} SF_NOUNLINK +expect EPERM rmdir ${n0} +expect 0 chflags ${n0} none +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Removing a directory protected by SF_APPEND should return EPERM." +expect EPERM rmdir ${n0} +todo FreeBSD:ZFS "Removing a directory protected by SF_APPEND should return EPERM." +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Removing a directory protected by SF_APPEND should return EPERM." +expect 0 rmdir ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 mkdir ${n0} 0755 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM rmdir ${n0} + expect 0 chflags ${n0} none + expect 0 rmdir ${n0} + + expect 0 mkdir ${n0} 0755 + expect 0 chflags ${n0} UF_NOUNLINK + expect EPERM rmdir ${n0} + expect 0 chflags ${n0} none + expect 0 rmdir ${n0} + + expect 0 mkdir ${n0} 0755 + expect 0 chflags ${n0} UF_APPEND + expect EPERM rmdir ${n0} + expect 0 chflags ${n0} none + expect 0 rmdir ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/rmdir/10.t b/contrib/pjdfstest/tests/rmdir/10.t new file mode 100644 index 000000000000..5d2e37ef4557 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/10.t @@ -0,0 +1,67 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EPERM if the parent directory of the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..16" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM rmdir ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 rmdir ${n0}/${n1} + +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 rmdir ${n0}/${n1} +expect 0 chflags ${n0} none + +expect 0 mkdir ${n0}/${n1} 0755 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Removing an entry from directory protected by SF_APPEND should return EPERM." +expect EPERM rmdir ${n0}/${n1} +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Removing an entry from directory protected by SF_APPEND should return EPERM." +expect 0 rmdir ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 mkdir ${n0}/${n1} 0755 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM rmdir ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 rmdir ${n0}/${n1} + + expect 0 mkdir ${n0}/${n1} 0755 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 rmdir ${n0}/${n1} + expect 0 chflags ${n0} none + + expect 0 mkdir ${n0}/${n1} 0755 + expect 0 chflags ${n0} UF_APPEND + expect EPERM rmdir ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 rmdir ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/11.t b/contrib/pjdfstest/tests/rmdir/11.t new file mode 100644 index 000000000000..b8e059135400 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/11.t @@ -0,0 +1,57 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EACCES or EPERM if the directory containing the directory to be removed is marked sticky, and neither the containing directory nor the directory to be removed are owned by the effective user ID" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..47" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +expect 0 mkdir ${n0} 0755 +expect 0 chown ${n0} 65534 65534 +expect 0 chmod ${n0} 01777 + +# User owns both: the sticky directory and the directory to be removed. +expect 0 -u 65534 -g 65534 mkdir ${n0}/${n1} 0755 +expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid +expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1} +expect ENOENT lstat ${n0}/${n1} type +# User owns the directory to be removed, but doesn't own the sticky directory. +for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file dir ${n0}/${n1} 65534 65534 + expect dir,65534,65534 lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type +done +# User owns the sticky directory, but doesn't own the directory to be removed. +expect 0 chown ${n0} 65534 65534 +for id in 0 65533; do + create_file dir ${n0}/${n1} ${id} ${id} + expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 rmdir ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type +done +# User doesn't own the sticky directory nor the directory to be removed. +for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file dir ${n0}/${n1} ${id} ${id} + expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid + expect "EACCES|EPERM" -u 65534 -g 65534 rmdir ${n0}/${n1} + expect dir,${id},${id} lstat ${n0}/${n1} type,uid,gid + expect 0 rmdir ${n0}/${n1} +done + +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/rmdir/12.t b/contrib/pjdfstest/tests/rmdir/12.t new file mode 100644 index 000000000000..57d144da58f2 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/12.t @@ -0,0 +1,20 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EINVAL if the last component of the path is '.' and EEXIST or ENOTEMPTY if the last component of the path is '..'" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 mkdir ${n0}/${n1} 0755 +expect EINVAL rmdir ${n0}/${n1}/. +todo FreeBSD "According to POSIX: EEXIST or ENOTEMPTY - The path argument names a directory that is not an empty directory, or there are hard links to the directory other than dot or a single entry in dot-dot." +expect "ENOTEMPTY|EEXIST" rmdir ${n0}/${n1}/.. +expect 0 rmdir ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/13.t b/contrib/pjdfstest/tests/rmdir/13.t new file mode 100644 index 000000000000..4a1a88542d64 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/13.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EBUSY if the directory to be removed is the mount point for a mounted file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect EBUSY rmdir ${n0} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/14.t b/contrib/pjdfstest/tests/rmdir/14.t new file mode 100644 index 000000000000..bdefeaedac08 --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/14.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 mkdir ${n0}/${n1} 0755 +mount -ur /dev/md${n} +expect EROFS rmdir ${n0}/${n1} +mount -uw /dev/md${n} +expect 0 rmdir ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/rmdir/15.t b/contrib/pjdfstest/tests/rmdir/15.t new file mode 100644 index 000000000000..5390403bcb3e --- /dev/null +++ b/contrib/pjdfstest/tests/rmdir/15.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/15.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="rmdir returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT rmdir NULL +expect EFAULT rmdir DEADCODE diff --git a/contrib/pjdfstest/tests/symlink/00.t b/contrib/pjdfstest/tests/symlink/00.t new file mode 100644 index 000000000000..1f2693938a35 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/00.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink creates symbolic links" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..14" + +n0=`namegen` +n1=`namegen` + +expect 0 create ${n0} 0644 +expect regular,0644 lstat ${n0} type,mode +expect 0 symlink ${n0} ${n1} +expect symlink lstat ${n1} type +expect regular,0644 stat ${n1} type,mode +expect 0 unlink ${n0} +expect ENOENT stat ${n1} type,mode +expect 0 unlink ${n1} + +expect 0 mkdir ${n0} 0755 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 symlink test ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/01.t b/contrib/pjdfstest/tests/symlink/01.t new file mode 100644 index 000000000000..3a40b54a45c2 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns ENOTDIR if a component of the name2 path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR symlink test ${n0}/${n1}/test +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/02.t b/contrib/pjdfstest/tests/symlink/02.t new file mode 100644 index 000000000000..4b81f169f7a6 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/02.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns ENAMETOOLONG if a component of the name2 pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..7" + +n0=`namegen` +nx=`namegen_max` +nxx="${nx}x" + +expect 0 symlink ${nx} ${n0} +expect 0 unlink ${n0} +expect 0 symlink ${n0} ${nx} +expect 0 unlink ${nx} + +expect ENAMETOOLONG symlink ${n0} ${nxx} +expect 0 symlink ${nxx} ${n0} +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/symlink/03.t b/contrib/pjdfstest/tests/symlink/03.t new file mode 100644 index 000000000000..68ecfbdfecbc --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/03.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns ENAMETOOLONG if an entire length of either path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" +expect 0 symlink ${nx} ${n0} +expect 0 unlink ${n0} +expect 0 symlink ${n0} ${nx} +expect 0 unlink ${nx} +expect ENAMETOOLONG symlink ${n0} ${nxx} +expect ENAMETOOLONG symlink ${nxx} ${n0} +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/symlink/04.t b/contrib/pjdfstest/tests/symlink/04.t new file mode 100644 index 000000000000..ca1c8eedf48b --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/04.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns ENOENT if a component of the name2 path prefix does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT symlink test ${n0}/${n1}/test +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/05.t b/contrib/pjdfstest/tests/symlink/05.t new file mode 100644 index 000000000000..801e46714a96 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/05.t @@ -0,0 +1,34 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns EACCES when a component of the name2 path prefix denies search permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 + +expect 0 -u 65534 -g 65534 symlink test ${n1}/${n2} +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} + +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 symlink test ${n1}/${n2} +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 symlink test ${n1}/${n2} +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} + +expect 0 rmdir ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/06.t b/contrib/pjdfstest/tests/symlink/06.t new file mode 100644 index 000000000000..db61ad01c392 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/06.t @@ -0,0 +1,34 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns EACCES if the parent directory of the file to be created denies write permission" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..12" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} + +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 + +expect 0 -u 65534 -g 65534 symlink test ${n1}/${n2} +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} + +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 symlink test ${n1}/${n2} +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 symlink test ${n1}/${n2} +expect 0 unlink ${n1}/${n2} + +expect 0 rmdir ${n1} + +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/07.t b/contrib/pjdfstest/tests/symlink/07.t new file mode 100644 index 000000000000..c6aedc0570e0 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns ELOOP if too many symbolic links were encountered in translating the name2 path name" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP symlink test ${n0}/test +expect ELOOP symlink test ${n1}/test +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/symlink/08.t b/contrib/pjdfstest/tests/symlink/08.t new file mode 100644 index 000000000000..ef7915dbe72b --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/08.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/08.t 211474 2010-08-18 22:06:43Z pjd $ + +desc="symlink returns EEXIST if the name2 argument already exists" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` + +for type in regular dir fifo block char socket symlink; do + create_file ${type} ${n0} + expect EEXIST symlink test ${n0} + if [ "${type}" = "dir" ]; then + expect 0 rmdir ${n0} + else + expect 0 unlink ${n0} + fi +done diff --git a/contrib/pjdfstest/tests/symlink/09.t b/contrib/pjdfstest/tests/symlink/09.t new file mode 100644 index 000000000000..6292aaf7649f --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/09.t @@ -0,0 +1,66 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns EPERM if the parent directory of the file named by name2 has its immutable flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..17" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 symlink test ${n0}/${n1} +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM symlink test ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 symlink test ${n0}/${n1} +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 symlink test ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 chflags ${n0} SF_APPEND +expect 0 symlink test ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM symlink test ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 symlink test ${n0}/${n1} + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 symlink test ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + + expect 0 chflags ${n0} UF_APPEND + expect 0 symlink test ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/10.t b/contrib/pjdfstest/tests/symlink/10.t new file mode 100644 index 000000000000..47a6eb4b636a --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/10.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns EROFS if the file name2 would reside on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..7" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit + +expect 0 symlink test ${n0}/${n1} +expect 0 unlink ${n0}/${n1} +mount -ur /dev/md${n} +expect EROFS symlink test ${n0}/${n1} +mount -uw /dev/md${n} +expect 0 symlink test ${n0}/${n1} +expect 0 unlink ${n0}/${n1} + +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/11.t b/contrib/pjdfstest/tests/symlink/11.t new file mode 100644 index 000000000000..e9f78e845c8b --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/11.t @@ -0,0 +1,31 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns ENOSPC if there are no free inodes on the file system on which the symbolic link is being created" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..3" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 512k` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +i=0 +while :; do + ln -s test ${n0}/${i} >/dev/null 2>&1 + if [ $? -ne 0 ]; then + break + fi + i=`expr $i + 1` +done +expect ENOSPC symlink test ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/symlink/12.t b/contrib/pjdfstest/tests/symlink/12.t new file mode 100644 index 000000000000..2c699050e673 --- /dev/null +++ b/contrib/pjdfstest/tests/symlink/12.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/symlink/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="symlink returns EFAULT if one of the pathnames specified is outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` + +expect EFAULT symlink NULL ${n0} +expect EFAULT symlink DEADCODE ${n0} +expect EFAULT symlink test NULL +expect EFAULT symlink test DEADCODE +expect EFAULT symlink NULL DEADCODE +expect EFAULT symlink DEADCODE NULL diff --git a/contrib/pjdfstest/tests/truncate/00.t b/contrib/pjdfstest/tests/truncate/00.t new file mode 100644 index 000000000000..6a77a8f796b0 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/00.t @@ -0,0 +1,51 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate descrease/increase file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +expect 0 create ${n0} 0644 +expect 0 truncate ${n0} 1234567 +expect 1234567 lstat ${n0} size +expect 0 truncate ${n0} 567 +expect 567 lstat ${n0} size +expect 0 unlink ${n0} + +dd if=/dev/random of=${n0} bs=12345 count=1 >/dev/null 2>&1 +expect 0 truncate ${n0} 23456 +expect 23456 lstat ${n0} size +expect 0 truncate ${n0} 1 +expect 1 lstat ${n0} size +expect 0 unlink ${n0} + +# successful truncate(2) updates ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 truncate ${n0} 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +# unsuccessful truncate(2) does not update ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 truncate ${n0} 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} diff --git a/contrib/pjdfstest/tests/truncate/01.t b/contrib/pjdfstest/tests/truncate/01.t new file mode 100644 index 000000000000..a8e95ac60181 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR truncate ${n0}/${n1}/test 123 +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/02.t b/contrib/pjdfstest/tests/truncate/02.t new file mode 100644 index 000000000000..83de38d3244f --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/02.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect 123 stat ${nx} size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 diff --git a/contrib/pjdfstest/tests/truncate/03.t b/contrib/pjdfstest/tests/truncate/03.t new file mode 100644 index 000000000000..41e98625ba4f --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/03.t @@ -0,0 +1,22 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 truncate ${nx} 123 +expect regular,123 stat ${nx} type,size +expect 0 unlink ${nx} +expect ENAMETOOLONG truncate ${nxx} 123 + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/truncate/04.t b/contrib/pjdfstest/tests/truncate/04.t new file mode 100644 index 000000000000..cd1cfc66b2b0 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect ENOENT truncate ${n0}/${n1}/test 123 +expect ENOENT truncate ${n0}/${n1} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/05.t b/contrib/pjdfstest/tests/truncate/05.t new file mode 100644 index 000000000000..f12881581bce --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/05.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..15" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 123 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 0 chmod ${n1} 0755 +expect 123 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 truncate ${n1}/${n2} 1234 +expect 1234 -u 65534 -g 65534 stat ${n1}/${n2} size +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/06.t b/contrib/pjdfstest/tests/truncate/06.t new file mode 100644 index 000000000000..1ce516fa74a6 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/06.t @@ -0,0 +1,24 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EACCES if the named file is not writable by the user" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..8" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 create ${n1} 0644 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 chown ${n1} 65534 65534 +expect 0 chmod ${n1} 0444 +expect EACCES -u 65534 -g 65534 truncate ${n1} 123 +expect 0 unlink ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/07.t b/contrib/pjdfstest/tests/truncate/07.t new file mode 100644 index 000000000000..44f87e7ea859 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP truncate ${n0}/test 123 +expect ELOOP truncate ${n1}/test 123 +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/truncate/08.t b/contrib/pjdfstest/tests/truncate/08.t new file mode 100644 index 000000000000..6f205ef965f2 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/08.t @@ -0,0 +1,78 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EPERM if the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..22" + ;; +FreeBSD:UFS) + echo "1..44" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM truncate ${n0} 123 +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect EPERM truncate ${n0} 123 +todo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." +expect 0 stat ${n0} size +expect 0 chflags ${n0} none +expect 0 truncate ${n0} 123 +expect 123 stat ${n0} size +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM truncate ${n0} 123 + expect 0 stat ${n0} size + expect 0 chflags ${n0} none + expect 0 truncate ${n0} 123 + expect 123 stat ${n0} size + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/truncate/09.t b/contrib/pjdfstest/tests/truncate/09.t new file mode 100644 index 000000000000..d7e082ddbe0e --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/09.t @@ -0,0 +1,15 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EISDIR if the named file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +expect EISDIR truncate ${n0} 123 +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/10.t b/contrib/pjdfstest/tests/truncate/10.t new file mode 100644 index 000000000000..ced3583ec21d --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/10.t @@ -0,0 +1,32 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..10" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +expect 0 truncate ${n0}/${n1} 123 +expect 123 stat ${n0}/${n1} size +mount -ur /dev/md${n} +expect EROFS truncate ${n0}/${n1} 1234 +expect 123 stat ${n0}/${n1} size +mount -uw /dev/md${n} +expect 0 truncate ${n0}/${n1} 1234 +expect 1234 stat ${n0}/${n1} size +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/truncate/11.t b/contrib/pjdfstest/tests/truncate/11.t new file mode 100644 index 000000000000..b00d7b89c16d --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/11.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns ETXTBSY the file is a pure procedure (shared text) file that is being executed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}" = "FreeBSD" ] || quick_exit + +echo "1..2" + +n0=`namegen` + +cp -pf `which sleep` ${n0} +./${n0} 3 & +expect ETXTBSY truncate ${n0} 123 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/12.t b/contrib/pjdfstest/tests/truncate/12.t new file mode 100644 index 000000000000..1825456a7b13 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/12.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFBIG or EINVAL if the length argument was greater than the maximum file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 create ${n0} 0644 +r=`${fstest} truncate ${n0} 999999999999999 2>/dev/null` +case "${r}" in +EFBIG|EINVAL) + expect 0 stat ${n0} size + ;; +0) + expect 999999999999999 stat ${n0} size + ;; +*) + echo "not ok ${ntest}" + ntest=`expr ${ntest} + 1` + ;; +esac +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/13.t b/contrib/pjdfstest/tests/truncate/13.t new file mode 100644 index 000000000000..7c9f0d4e14ec --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/13.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EINVAL if the length argument was less than 0" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect EINVAL -- truncate ${n0} -1 +expect EINVAL -- truncate ${n0} -999999 +expect 0 unlink ${n0} diff --git a/contrib/pjdfstest/tests/truncate/14.t b/contrib/pjdfstest/tests/truncate/14.t new file mode 100644 index 000000000000..a238771264f9 --- /dev/null +++ b/contrib/pjdfstest/tests/truncate/14.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/truncate/14.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="truncate returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT truncate NULL 123 +expect EFAULT truncate DEADCODE 123 diff --git a/contrib/pjdfstest/tests/unlink/00.t b/contrib/pjdfstest/tests/unlink/00.t new file mode 100644 index 000000000000..0b9b1f1b59cf --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/00.t @@ -0,0 +1,212 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/00.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink removes regular files, symbolic links, fifos and sockets" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..112" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +expect 0 create ${n0} 0644 +expect regular lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 symlink ${n1} ${n0} +expect symlink lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mkfifo ${n0} 0644 +expect fifo lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mknod ${n0} b 0644 1 2 +expect block lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 mknod ${n0} c 0644 1 2 +expect char lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +expect 0 bind ${n0} +expect socket lstat ${n0} type +expect 0 unlink ${n0} +expect ENOENT lstat ${n0} type + +# successful unlink(2) updates ctime. +expect 0 create ${n0} 0644 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 mkfifo ${n0} 0644 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} b 0644 1 2 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} c 0644 1 2 +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +expect 0 bind ${n0} +expect 0 link ${n0} ${n1} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +# unsuccessful unlink(2) does not update ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mkfifo ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} b 0644 1 2 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mknod ${n0} c 0644 1 2 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 bind ${n0} +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EACCES -u 65534 unlink ${n0} +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 mkfifo ${n0}/${n1} 0644 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 mknod ${n0}/${n1} b 0644 1 2 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 mknod ${n0}/${n1} c 0644 1 2 +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 bind ${n0}/${n1} +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 mkdir ${n0} 0755 +expect 0 symlink test ${n0}/${n1} +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n0}/${n1} +mtime=`${fstest} stat ${n0} mtime` +test_check $time -lt $mtime +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 rmdir ${n0} + +expect 0 create ${n0} 0644 +expect 0 link ${n0} ${n1} +time=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 unlink ${n1} +ctime=`${fstest} stat ${n0} ctime` +test_check $time -lt $ctime +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/unlink/01.t b/contrib/pjdfstest/tests/unlink/01.t new file mode 100644 index 000000000000..7e29671ecb70 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/01.t @@ -0,0 +1,18 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/01.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENOTDIR if a component of the path prefix is not a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +expect 0 create ${n0}/${n1} 0644 +expect ENOTDIR unlink ${n0}/${n1}/test +expect 0 unlink ${n0}/${n1} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/02.t b/contrib/pjdfstest/tests/unlink/02.t new file mode 100644 index 000000000000..e624d987e813 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/02.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/02.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENAMETOOLONG if a component of a pathname exceeded {NAME_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`namegen_max` +nxx="${nx}x" + +expect 0 create ${nx} 0644 +expect 0 unlink ${nx} +expect ENOENT unlink ${nx} +expect ENAMETOOLONG unlink ${nxx} diff --git a/contrib/pjdfstest/tests/unlink/03.t b/contrib/pjdfstest/tests/unlink/03.t new file mode 100644 index 000000000000..f4c939e721e6 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/03.t @@ -0,0 +1,21 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/03.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENAMETOOLONG if an entire path name exceeded {PATH_MAX} characters" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +nx=`dirgen_max` +nxx="${nx}x" + +mkdir -p "${nx%/*}" + +expect 0 create ${nx} 0644 +expect 0 unlink ${nx} +expect ENOENT unlink ${nx} +expect ENAMETOOLONG unlink ${nxx} + +rm -rf "${nx%%/*}" diff --git a/contrib/pjdfstest/tests/unlink/04.t b/contrib/pjdfstest/tests/unlink/04.t new file mode 100644 index 000000000000..0717eaad01b9 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/04.t @@ -0,0 +1,17 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/04.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ENOENT if the named file does not exist" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..4" + +n0=`namegen` +n1=`namegen` + +expect 0 create ${n0} 0644 +expect 0 unlink ${n0} +expect ENOENT unlink ${n0} +expect ENOENT unlink ${n1} diff --git a/contrib/pjdfstest/tests/unlink/05.t b/contrib/pjdfstest/tests/unlink/05.t new file mode 100644 index 000000000000..91dccf90afea --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/05.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/05.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EACCES when search permission is denied for a component of the path prefix" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 chmod ${n1} 0644 +expect EACCES -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/06.t b/contrib/pjdfstest/tests/unlink/06.t new file mode 100644 index 000000000000..293742966c0e --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/06.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/06.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EACCES when write permission is denied on the directory containing the link to be removed" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..10" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n0} 0755 +cdir=`pwd` +cd ${n0} +expect 0 mkdir ${n1} 0755 +expect 0 chown ${n1} 65534 65534 +expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644 +expect 0 chmod ${n1} 0555 +expect EACCES -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 chmod ${n1} 0755 +expect 0 -u 65534 -g 65534 unlink ${n1}/${n2} +expect 0 rmdir ${n1} +cd ${cdir} +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/07.t b/contrib/pjdfstest/tests/unlink/07.t new file mode 100644 index 000000000000..e63eafa6e7a4 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/07.t @@ -0,0 +1,19 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/07.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns ELOOP if too many symbolic links were encountered in translating the pathname" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..6" + +n0=`namegen` +n1=`namegen` + +expect 0 symlink ${n0} ${n1} +expect 0 symlink ${n1} ${n0} +expect ELOOP unlink ${n0}/test +expect ELOOP unlink ${n1}/test +expect 0 unlink ${n0} +expect 0 unlink ${n1} diff --git a/contrib/pjdfstest/tests/unlink/08.t b/contrib/pjdfstest/tests/unlink/08.t new file mode 100644 index 000000000000..666400cd2a2e --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/08.t @@ -0,0 +1,16 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/08.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink may return EPERM if the named file is a directory" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..3" + +n0=`namegen` + +expect 0 mkdir ${n0} 0755 +todo Linux "According to POSIX: EPERM - The file named by path is a directory, and either the calling process does not have appropriate privileges, or the implementation prohibits using unlink() on directories." +expect "0|EPERM" unlink ${n0} +expect "0|ENOENT" rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/09.t b/contrib/pjdfstest/tests/unlink/09.t new file mode 100644 index 000000000000..dbc202a6954d --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/09.t @@ -0,0 +1,65 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/09.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EPERM if the named file has its immutable, undeletable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..15" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM unlink ${n0} +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect EPERM unlink ${n0} +expect 0 chflags ${n0} none +expect 0 unlink ${n0} + +expect 0 create ${n0} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Removing a file protected by SF_APPEND should return EPERM." +expect EPERM unlink ${n0} +todo FreeBSD:ZFS "Removing a file protected by SF_APPEND should return EPERM." +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Removing a file protected by SF_APPEND should return EPERM." +expect 0 unlink ${n0} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM unlink ${n0} + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect EPERM unlink ${n0} + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + + expect 0 create ${n0} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM unlink ${n0} + expect 0 chflags ${n0} none + expect 0 unlink ${n0} + ;; +esac diff --git a/contrib/pjdfstest/tests/unlink/10.t b/contrib/pjdfstest/tests/unlink/10.t new file mode 100644 index 000000000000..9ca1d5bc3fb1 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/10.t @@ -0,0 +1,67 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/10.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EPERM if the parent directory of the named file has its immutable or append-only flag set" + +dir=`dirname $0` +. ${dir}/../misc.sh + +require chflags + +case "${os}:${fs}" in +FreeBSD:ZFS) + echo "1..16" + ;; +FreeBSD:UFS) + echo "1..30" + ;; +*) + quick_exit +esac + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 + +expect 0 create ${n0}/${n1} 0644 +expect 0 chflags ${n0} SF_IMMUTABLE +expect EPERM unlink ${n0}/${n1} +expect 0 chflags ${n0} none +expect 0 unlink ${n0}/${n1} + +expect 0 create ${n0}/${n1} 0644 +expect 0 chflags ${n0} SF_NOUNLINK +expect 0 unlink ${n0}/${n1} +expect 0 chflags ${n0} none + +expect 0 create ${n0}/${n1} 0644 +expect 0 chflags ${n0} SF_APPEND +todo FreeBSD:ZFS "Removing a file from a directory protected by SF_APPEND should return EPERM." +expect EPERM unlink ${n0}/${n1} +expect 0 chflags ${n0} none +todo FreeBSD:ZFS "Removing a file from a directory protected by SF_APPEND should return EPERM." +expect 0 unlink ${n0}/${n1} + +case "${os}:${fs}" in +FreeBSD:UFS) + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0} UF_IMMUTABLE + expect EPERM unlink ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0} UF_NOUNLINK + expect 0 unlink ${n0}/${n1} + expect 0 chflags ${n0} none + + expect 0 create ${n0}/${n1} 0644 + expect 0 chflags ${n0} UF_APPEND + expect EPERM unlink ${n0}/${n1} + expect 0 chflags ${n0} none + expect 0 unlink ${n0}/${n1} + ;; +esac + +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/11.t b/contrib/pjdfstest/tests/unlink/11.t new file mode 100644 index 000000000000..d7d71d842d0d --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/11.t @@ -0,0 +1,63 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/11.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EACCES or EPERM if the directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..270" + +n0=`namegen` +n1=`namegen` +n2=`namegen` + +expect 0 mkdir ${n2} 0755 +cdir=`pwd` +cd ${n2} + +expect 0 mkdir ${n0} 0755 +expect 0 chmod ${n0} 01777 +expect 0 chown ${n0} 65534 65534 + +for type in regular fifo block char socket symlink; do + # User owns both: the sticky directory and the file. + expect 0 chown ${n0} 65534 65534 + create_file ${type} ${n0}/${n1} 65534 65534 + expect ${type},65534,65534 lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 unlink ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type + + # User owns the sticky directory, but doesn't own the file. + for id in 0 65533; do + expect 0 chown ${n0} 65534 65534 + create_file ${type} ${n0}/${n1} ${id} ${id} + expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 unlink ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type + done + + # User owns the file, but doesn't own the sticky directory. + for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file ${type} ${n0}/${n1} 65534 65534 + expect ${type},65534,65534 lstat ${n0}/${n1} type,uid,gid + expect 0 -u 65534 -g 65534 unlink ${n0}/${n1} + expect ENOENT lstat ${n0}/${n1} type + done + + # User doesn't own the sticky directory nor the file. + for id in 0 65533; do + expect 0 chown ${n0} ${id} ${id} + create_file ${type} ${n0}/${n1} ${id} ${id} + expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid + expect "EACCES|EPERM" -u 65534 -g 65534 unlink ${n0}/${n1} + expect ${type},${id},${id} lstat ${n0}/${n1} type,uid,gid + expect 0 unlink ${n0}/${n1} + done +done + +expect 0 rmdir ${n0} + +cd ${cdir} +expect 0 rmdir ${n2} diff --git a/contrib/pjdfstest/tests/unlink/12.t b/contrib/pjdfstest/tests/unlink/12.t new file mode 100644 index 000000000000..ae39724faeab --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/12.t @@ -0,0 +1,27 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/12.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EROFS if the named file resides on a read-only file system" + +dir=`dirname $0` +. ${dir}/../misc.sh + +[ "${os}:${fs}" = "FreeBSD:UFS" ] || quick_exit + +echo "1..5" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n0} 0755 +n=`mdconfig -a -n -t malloc -s 1m` || exit +newfs /dev/md${n} >/dev/null || exit +mount /dev/md${n} ${n0} || exit +expect 0 create ${n0}/${n1} 0644 +mount -ur /dev/md${n} +expect EROFS unlink ${n0}/${n1} +mount -uw /dev/md${n} +expect 0 unlink ${n0}/${n1} +umount /dev/md${n} +mdconfig -d -u ${n} || exit +expect 0 rmdir ${n0} diff --git a/contrib/pjdfstest/tests/unlink/13.t b/contrib/pjdfstest/tests/unlink/13.t new file mode 100644 index 000000000000..c424b7ed0094 --- /dev/null +++ b/contrib/pjdfstest/tests/unlink/13.t @@ -0,0 +1,12 @@ +#!/bin/sh +# $FreeBSD: head/tools/regression/pjdfstest/tests/unlink/13.t 211352 2010-08-15 21:24:17Z pjd $ + +desc="unlink returns EFAULT if the path argument points outside the process's allocated address space" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..2" + +expect EFAULT unlink NULL +expect EFAULT unlink DEADCODE diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 80e537ad0845..bae20808c26b 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -17,6 +17,8 @@ doc atf .. + pjdfstest + .. .. .. tests @@ -131,6 +133,38 @@ .. netinet .. + pjdfstest + chflags + .. + chmod + .. + chown + .. + ftruncate + .. + granular + .. + link + .. + mkdir + .. + mkfifo + .. + mknod + .. + open + .. + rename + .. + rmdir + .. + symlink + .. + truncate + .. + unlink + .. + .. .. usr.bin apply diff --git a/share/doc/Makefile b/share/doc/Makefile index a4fe61d6c479..d01a2b236726 100644 --- a/share/doc/Makefile +++ b/share/doc/Makefile @@ -7,10 +7,12 @@ SUBDIR= ${_IPv6} \ ${_atf} \ legal \ ${_llvm} \ + ${_pjdfstest} \ ${_roffdocs} .if ${MK_TESTS} != "no" _atf= atf +_pjdfstest= pjdfstest .endif .if ${MK_CLANG} != "no" diff --git a/share/doc/pjdfstest/Makefile b/share/doc/pjdfstest/Makefile new file mode 100644 index 000000000000..21d72f36e353 --- /dev/null +++ b/share/doc/pjdfstest/Makefile @@ -0,0 +1,8 @@ +# $FreeBSD$ + +NO_OBJ= + +FILESDIR= ${SHAREDIR}/doc/pjdfstest +FILES= README + +.include diff --git a/share/doc/pjdfstest/README b/share/doc/pjdfstest/README new file mode 100644 index 000000000000..d09011789e42 --- /dev/null +++ b/share/doc/pjdfstest/README @@ -0,0 +1,36 @@ +pjdfstest test suite execution is integrated into kyua. This README describes +how to use pjdfstest in the default configuration (kyua work directory), and +with a specific filesystem path. + +Method 1. Executing with default configuration (kyua work directory) + + 1. Elevate privileges: + % su - + 2. cd to the tests directory: + % cd /usr/tests/sys/pjdfstest + 3. Run kyua: + % kyua test + + Executing the commands as shown above will run pjdfstest in the kyua work + directory. The kyua work directory defaults to a random generated path under + /tmp; please see TMPDIR in kyua(1) for more details on how the temporary path + is chosen with kyua. + +Method 2. Executing with a specific filesystem path (in this case /mnt) + + 1. Elevate privileges: + % su - + 2. cd to the tests directory: + % cd /usr/tests/sys/pjdfstest + 3. Run kyua: + % env PJDFSTEST_TEST_PATH=/mnt kyua test + + WARNING: the above method violates the test program isolation algorithm + described in kyua(1); as such, $PJDFSTEST_TEST_PATH must be cleaned up after + executing the testcases. + + It's highly recommended that $PJDFSTEST_TEST_PATH be pointed to a sandboxed + filesystem, e.g. a small UFS-formatted memory disk or ZFS dataset with + quotas enabled, so the filesystem can be easily destroyed after the test + execution is complete, and the testcases are properly bounded both in terms + of time and space. diff --git a/tests/sys/Makefile b/tests/sys/Makefile index 498ca040e15d..fbfe367d5004 100644 --- a/tests/sys/Makefile +++ b/tests/sys/Makefile @@ -2,8 +2,12 @@ .include -TESTS_SUBDIRS+= kern -TESTS_SUBDIRS+= netinet TESTSDIR= ${TESTSBASE}/sys +TESTS_SUBDIRS+= kern +TESTS_SUBDIRS+= netinet + +# Items not integrated into kyua runs by default +SUBDIR+= pjdfstest + .include diff --git a/tests/sys/pjdfstest/Makefile b/tests/sys/pjdfstest/Makefile new file mode 100644 index 000000000000..7047811528c2 --- /dev/null +++ b/tests/sys/pjdfstest/Makefile @@ -0,0 +1,6 @@ +# $FreeBSD$ + +SUBDIR+= pjdfstest +SUBDIR+= tests + +.include diff --git a/tests/sys/pjdfstest/pjdfstest/Makefile b/tests/sys/pjdfstest/pjdfstest/Makefile new file mode 100644 index 000000000000..c0e82a41dc72 --- /dev/null +++ b/tests/sys/pjdfstest/pjdfstest/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +TOP= ${.CURDIR:H:H:H:H} + +.PATH: ${TOP}/contrib/pjdfstest + +BINDIR= ${TESTSBASE}/sys/pjdfstest +PROG= pjdfstest +MAN= + +CFLAGS= -D__OS_FreeBSD__ -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS +CFLAGS+= -DHAS_CHFLAGSAT -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL -DHAS_BINDAT +CFLAGS+= -DHAS_CONNECTAT + +# XXX: the upstream sources need some massaging with how it assigns ngroups in +# pjdfstest.c +NO_WERROR= +WARNS?= 6 + +.include diff --git a/tests/sys/pjdfstest/tests/Makefile b/tests/sys/pjdfstest/tests/Makefile new file mode 100644 index 000000000000..248b2095a6b7 --- /dev/null +++ b/tests/sys/pjdfstest/tests/Makefile @@ -0,0 +1,39 @@ +# $FreeBSD$ + +PJDFSTEST_SRCDIR= ${.CURDIR:H:H:H:H}/contrib/pjdfstest + +TESTSDIR= ${TESTSBASE}/sys/pjdfstest + +.PATH: ${.CURDIR} + +FILESDIR= ${TESTSDIR} +FILES= conf +FILES+= misc.sh +CLEANFILES+= misc.sh misc.sh.tmp + +misc.sh: ${PJDFSTEST_SRCDIR}/tests/misc.sh + sed -e '\,maindir=,s,maindir=.*,maindir=`dirname $$0`/../,' < ${.ALLSRC} > ${.TARGET}.tmp + mv ${.TARGET}.tmp ${.TARGET} + +afterinstall: install-tests-symlink +install-tests-symlink: .PHONY + rm -f ${DESTDIR}${TESTSDIR}/tests + ${INSTALL_SYMLINK} . ${DESTDIR}${TESTSDIR}/tests + +TESTS_SUBDIRS= chflags +TESTS_SUBDIRS+= chmod +TESTS_SUBDIRS+= chown +TESTS_SUBDIRS+= ftruncate +TESTS_SUBDIRS+= granular +TESTS_SUBDIRS+= link +TESTS_SUBDIRS+= mkdir +TESTS_SUBDIRS+= mkfifo +TESTS_SUBDIRS+= mknod +TESTS_SUBDIRS+= open +TESTS_SUBDIRS+= rename +TESTS_SUBDIRS+= rmdir +TESTS_SUBDIRS+= symlink +TESTS_SUBDIRS+= truncate +TESTS_SUBDIRS+= unlink + +.include diff --git a/tests/sys/pjdfstest/tests/chflags/Makefile b/tests/sys/pjdfstest/tests/chflags/Makefile new file mode 100644 index 000000000000..3b6a5265fdd4 --- /dev/null +++ b/tests/sys/pjdfstest/tests/chflags/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/chmod/Makefile b/tests/sys/pjdfstest/tests/chmod/Makefile new file mode 100644 index 000000000000..cc0a3bbf1af4 --- /dev/null +++ b/tests/sys/pjdfstest/tests/chmod/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/chown/Makefile b/tests/sys/pjdfstest/tests/chown/Makefile new file mode 100644 index 000000000000..665b6538d19e --- /dev/null +++ b/tests/sys/pjdfstest/tests/chown/Makefile @@ -0,0 +1,15 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/conf b/tests/sys/pjdfstest/tests/conf new file mode 100644 index 000000000000..7a1168efea13 --- /dev/null +++ b/tests/sys/pjdfstest/tests/conf @@ -0,0 +1,15 @@ +#!/bin/sh +# +# $FreeBSD$ + +: ${PJDFSTEST_TEST_PATH=.} +if ! cd ${PJDFSTEST_TEST_PATH}/; then + echo 'Please set PJDFSTEST_TEST_PATH to a valid filesystem path' + echo 'Bail out!' + exit 1 +fi + +GREP=grep +mountpoint=$(df . | tail -1 | awk '{print $6}') +fs=$(mount -p | awk '$2 == "'$mountpoint'" { print toupper($3) }') +os=FreeBSD diff --git a/tests/sys/pjdfstest/tests/ftruncate/Makefile b/tests/sys/pjdfstest/tests/ftruncate/Makefile new file mode 100644 index 000000000000..da2ce584d3af --- /dev/null +++ b/tests/sys/pjdfstest/tests/ftruncate/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 +TAP_TESTS_SH+= 14 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/granular/Makefile b/tests/sys/pjdfstest/tests/granular/Makefile new file mode 100644 index 000000000000..3f935e4e99ce --- /dev/null +++ b/tests/sys/pjdfstest/tests/granular/Makefile @@ -0,0 +1,10 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/link/Makefile b/tests/sys/pjdfstest/tests/link/Makefile new file mode 100644 index 000000000000..14c7525689b0 --- /dev/null +++ b/tests/sys/pjdfstest/tests/link/Makefile @@ -0,0 +1,22 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 +TAP_TESTS_SH+= 14 +TAP_TESTS_SH+= 15 +TAP_TESTS_SH+= 16 +TAP_TESTS_SH+= 17 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/mkdir/Makefile b/tests/sys/pjdfstest/tests/mkdir/Makefile new file mode 100644 index 000000000000..cc0a3bbf1af4 --- /dev/null +++ b/tests/sys/pjdfstest/tests/mkdir/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/mkfifo/Makefile b/tests/sys/pjdfstest/tests/mkfifo/Makefile new file mode 100644 index 000000000000..cc0a3bbf1af4 --- /dev/null +++ b/tests/sys/pjdfstest/tests/mkfifo/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/mknod/Makefile b/tests/sys/pjdfstest/tests/mknod/Makefile new file mode 100644 index 000000000000..1eaeaa09818e --- /dev/null +++ b/tests/sys/pjdfstest/tests/mknod/Makefile @@ -0,0 +1,16 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/open/Makefile b/tests/sys/pjdfstest/tests/open/Makefile new file mode 100644 index 000000000000..bd2f7b5a985d --- /dev/null +++ b/tests/sys/pjdfstest/tests/open/Makefile @@ -0,0 +1,29 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 +TAP_TESTS_SH+= 14 +TAP_TESTS_SH+= 15 +TAP_TESTS_SH+= 16 +TAP_TESTS_SH+= 17 +TAP_TESTS_SH+= 18 +TAP_TESTS_SH+= 19 +TAP_TESTS_SH+= 20 +TAP_TESTS_SH+= 21 +TAP_TESTS_SH+= 22 +TAP_TESTS_SH+= 23 +TAP_TESTS_SH+= 24 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/pjdfstest.test.mk b/tests/sys/pjdfstest/tests/pjdfstest.test.mk new file mode 100644 index 000000000000..3dc784f7eb63 --- /dev/null +++ b/tests/sys/pjdfstest/tests/pjdfstest.test.mk @@ -0,0 +1,14 @@ +# $FreeBSD$ + +PJDFSTEST_SRCDIR= ${.CURDIR:H:H:H:H:H}/contrib/pjdfstest + +.PATH: ${PJDFSTEST_SRCDIR}/tests/${.CURDIR:T} + +TESTSDIR?= ${TESTSBASE}/sys/pjdfstest/${.CURDIR:T} + +.for s in ${TAP_TESTS_SH} +TAP_TESTS_SH_SRC_$s= $s.t +TEST_METADATA.$s+= required_user="root" +.endfor + +.include diff --git a/tests/sys/pjdfstest/tests/rename/Makefile b/tests/sys/pjdfstest/tests/rename/Makefile new file mode 100644 index 000000000000..7eada047ef15 --- /dev/null +++ b/tests/sys/pjdfstest/tests/rename/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 +TAP_TESTS_SH+= 14 +TAP_TESTS_SH+= 15 +TAP_TESTS_SH+= 16 +TAP_TESTS_SH+= 17 +TAP_TESTS_SH+= 18 +TAP_TESTS_SH+= 19 +TAP_TESTS_SH+= 20 +TAP_TESTS_SH+= 21 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/rmdir/Makefile b/tests/sys/pjdfstest/tests/rmdir/Makefile new file mode 100644 index 000000000000..301e4e5c33d1 --- /dev/null +++ b/tests/sys/pjdfstest/tests/rmdir/Makefile @@ -0,0 +1,20 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 +TAP_TESTS_SH+= 14 +TAP_TESTS_SH+= 15 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/symlink/Makefile b/tests/sys/pjdfstest/tests/symlink/Makefile new file mode 100644 index 000000000000..cc0a3bbf1af4 --- /dev/null +++ b/tests/sys/pjdfstest/tests/symlink/Makefile @@ -0,0 +1,17 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/truncate/Makefile b/tests/sys/pjdfstest/tests/truncate/Makefile new file mode 100644 index 000000000000..da2ce584d3af --- /dev/null +++ b/tests/sys/pjdfstest/tests/truncate/Makefile @@ -0,0 +1,19 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 +TAP_TESTS_SH+= 14 + +.include "../pjdfstest.test.mk" diff --git a/tests/sys/pjdfstest/tests/unlink/Makefile b/tests/sys/pjdfstest/tests/unlink/Makefile new file mode 100644 index 000000000000..3b6a5265fdd4 --- /dev/null +++ b/tests/sys/pjdfstest/tests/unlink/Makefile @@ -0,0 +1,18 @@ +# $FreeBSD$ + +TAP_TESTS_SH= 00 +TAP_TESTS_SH+= 01 +TAP_TESTS_SH+= 02 +TAP_TESTS_SH+= 03 +TAP_TESTS_SH+= 04 +TAP_TESTS_SH+= 05 +TAP_TESTS_SH+= 06 +TAP_TESTS_SH+= 07 +TAP_TESTS_SH+= 08 +TAP_TESTS_SH+= 09 +TAP_TESTS_SH+= 10 +TAP_TESTS_SH+= 11 +TAP_TESTS_SH+= 12 +TAP_TESTS_SH+= 13 + +.include "../pjdfstest.test.mk" diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 64c44c861252..729349c85398 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -4016,9 +4016,10 @@ OLD_FILES+=usr/share/sendmail/cf/siteconfig/uucp.ucbarpa.m4 OLD_FILES+=usr/share/sendmail/cf/siteconfig/uucp.ucbvax.m4 .endif -#.if ${MK_SHAREDOCS} == no -# to be filled in -#.endif +.if ${MK_SHAREDOCS} == no +OLD_FILES+=usr/share/doc/pjdfstest/README +OLD_DIRS+=usr/share/doc/pjdfstest +.endif #.if ${MK_SYSCONS} == no # to be filled in