From owner-svn-src-user@freebsd.org Thu Nov 29 07:41:06 2018 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 216BB11564F0 for ; Thu, 29 Nov 2018 07:41:06 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BB7327B625; Thu, 29 Nov 2018 07:41:05 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9B8AE16870; Thu, 29 Nov 2018 07:41:05 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAT7f5Z3052480; Thu, 29 Nov 2018 07:41:05 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAT7f5UT052479; Thu, 29 Nov 2018 07:41:05 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201811290741.wAT7f5UT052479@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 29 Nov 2018 07:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r341217 - user/pho/stress2/misc X-SVN-Group: user X-SVN-Commit-Author: pho X-SVN-Commit-Paths: user/pho/stress2/misc X-SVN-Commit-Revision: 341217 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: BB7327B625 X-Spamd-Result: default: False [1.33 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_LONG(0.51)[0.512,0]; NEURAL_SPAM_MEDIUM(0.36)[0.355,0]; NEURAL_SPAM_SHORT(0.46)[0.464,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2018 07:41:06 -0000 Author: pho Date: Thu Nov 29 07:41:05 2018 New Revision: 341217 URL: https://svnweb.freebsd.org/changeset/base/341217 Log: Added a O_BENEATH absolute paths test scenario. Submitted by: kib@ Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/beneath.sh (contents, props changed) Added: user/pho/stress2/misc/beneath.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/beneath.sh Thu Nov 29 07:41:05 2018 (r341217) @@ -0,0 +1,87 @@ +#!/bin/sh + +# Test of open(2) with the O_BENEATH flag. +# Test scenario by kib@ + +# userret: returning with the following locks held: +# shared lockmgr ufs (ufs) r = 0 (0xfffff804ec0d2a48) locked @ +# kern/vfs_subr.c:2590 seen in WiP code: +# https://people.freebsd.org/~pho/stress/log/kostik1126.txt + +# $FreeBSD + +#. ../default.cfg + +top=/tmp/beneath.d +mkdir -p $top +cat > $top/beneath.c < +#include +#include +#include +#include +#include + +#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[]) +{ + struct stat st; + char *name; + int error, fd, i; + + for (i = 1; i < argc; i++) { + name = argv[i]; + fd = open(name, O_RDONLY | O_BENEATH); + if (fd == -1) { + fprintf(stderr, "open(\"%s\") failed, error %d %s\n", + name, errno, strerror(errno)); + } else { + fprintf(stderr, "open(\"%s\") succeeded\n", name); + close(fd); + } + error = fstatat(AT_FDCWD, name, &st, AT_BENEATH); + if (error == -1){ + fprintf(stderr, "stat(\"%s\") failed, error %d %s\n", + name, errno, strerror(errno)); + } else { + fprintf(stderr, "stat(\"%s\") succeeded\n", name); + } + } +} +EOF +cc -o $top/beneath -Wall -Wextra $top/beneath.c || exit 1 +rm $top/beneath.c + +# Test with two directories as arguments: +cd $top +mkdir -p a/b +./beneath a/b +./beneath $top/a/b +touch $top/a/c +./beneath a/c +./beneath $top/a/c +./beneath a/d +./beneath $top/a/d + +# CWD is still $top for this test +top2=/var/tmp/beneath.d +mkdir -p $top2 +mkdir -p $top2/a/b +./beneath $top2/a/b > /dev/null 2>&1 + +touch $top2/a/c +./beneath $top2/a/c > /dev/null 2>&1 + +# Other CWDs +(cd /etc; find . | xargs $top/beneath) > /dev/null 2>&1 +(cd /var; find . | xargs $top/beneath) > /dev/null 2>&1 + +rm -rf $top $top2 +exit 0