stress2: open(2) tests with BENEATH flags.

Update tests to reflect the changes of "open(2): Remove O_BENEATH and
AT_BENEATH" in 20e91ca36a.
This commit is contained in:
Peter Holm 2021-03-08 09:08:58 +01:00
parent 2b82c94acf
commit e0fd837a30
4 changed files with 18 additions and 23 deletions

View File

@ -27,7 +27,7 @@
# SUCH DAMAGE.
#
# Test of open(2) with the O_BENEATH flag.
# Test of open(2) with the O_RESOLVE_BENEATH flag.
# userret: returning with the following locks held:
# shared lockmgr ufs (ufs) r = 0 (0xfffff804ec0d2a48) locked @
@ -46,11 +46,6 @@ cat > $top/beneath.c <<EOF
#include <string.h>
#include <unistd.h>
#ifndef O_BENEATH
#define O_BENEATH 0x00400000 /* Fail if not under cwd */
#define AT_BENEATH 0x1000 /* Fail if not under dirfd */
#endif
int
main(int argc, char *argv[])
{
@ -61,7 +56,7 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
name = argv[i];
alarm(120);
fd = open(name, O_RDONLY | O_BENEATH);
fd = open(name, O_RDONLY | O_RESOLVE_BENEATH);
if (fd == -1) {
fprintf(stderr, "open(\"%s\") failed, error %d %s\n",
name, errno, strerror(errno));
@ -69,7 +64,7 @@ main(int argc, char *argv[])
fprintf(stderr, "open(\"%s\") succeeded\n", name);
close(fd);
}
error = fstatat(AT_FDCWD, name, &st, AT_BENEATH);
error = fstatat(AT_FDCWD, name, &st, AT_RESOLVE_BENEATH);
if (error == -1){
fprintf(stderr, "stat(\"%s\") failed, error %d %s\n",
name, errno, strerror(errno));

View File

@ -27,7 +27,7 @@
# SUCH DAMAGE.
#
# O_BENEATH test with a relative path, which is a symbolic link pointing
# O_RESOLVE_BENEATH test with a relative path, which is a symbolic link pointing
# to an absolute path.
# "panic: Assertion (ndp->ni_lcf & NI_LCF_LATCH) != 0 failed at
@ -93,7 +93,7 @@ main(int argc, char *argv[])
exit(1);
}
file = argv[1];
if ((fd = open(file, O_RDONLY | O_BENEATH)) != 0 &&
if ((fd = open(file, O_RDONLY | O_RESOLVE_BENEATH)) != 0 &&
errno != ENOTCAPABLE)
err(1, "open(%s)", file);

View File

@ -84,7 +84,7 @@ main(void)
char file[] = "/..";
errno = 0;
fd = open(file, O_CREAT | O_RDONLY | O_BENEATH);
fd = open(file, O_CREAT | O_RDONLY | O_RESOLVE_BENEATH);
if (fd != -1 || errno != ENOTCAPABLE)
err(1, "open(%s) returns %d", file, fd);

View File

@ -69,7 +69,7 @@ main(int argc, char *argv[])
sscanf(argv[3], "%x", &flag);
exp = atoi(argv[4]);
#if 0
if ((flag & (AT_BENEATH | AT_RESOLVE_BENEATH)) == 0) {
if ((flag & AT_RESOLVE_BENEATH) == 0) {
fprintf(stderr, "Flag must be %#x or %#x\n",
AT_BENEATH, AT_RESOLVE_BENEATH);
return (1);
@ -105,17 +105,17 @@ top=$dir/a
cd $here
s=0
ls -lR $dir
echo AT_BENEATH
$dir/beneath4 $top a 0x1000 0 || s=1
$dir/beneath4 $top b 0x1000 2 || s=1
$dir/beneath4 $top c 0x1000 0 || s=1
$dir/beneath4 $top d 0x1000 0 || s=1
$dir/beneath4 $top e 0x1000 2 || s=1
$dir/beneath4 $top fifo 0x1000 0 || s=1
$dir/beneath4 $top $top/../../beneath4.d/a/a 0x1000 93 || s=1
$dir/beneath4 $top $top/.. 0x1000 93 || s=1
$dir/beneath4 $top ../a 0x1000 0 || s=1
#ls -lR $dir
#echo AT_BENEATH
#$dir/beneath4 $top a 0x1000 0 || s=1
#$dir/beneath4 $top b 0x1000 2 || s=1
#$dir/beneath4 $top c 0x1000 0 || s=1
#$dir/beneath4 $top d 0x1000 0 || s=1
#$dir/beneath4 $top e 0x1000 2 || s=1
#$dir/beneath4 $top fifo 0x1000 0 || s=1
#$dir/beneath4 $top $top/../../beneath4.d/a/a 0x1000 93 || s=1
#$dir/beneath4 $top $top/.. 0x1000 93 || s=1
#$dir/beneath4 $top ../a 0x1000 0 || s=1
printf "\nAT_RESOLVE_BENEATH\n"
$dir/beneath4 $top a 0x2000 0 || s=1