summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/sh/tests/Makefile17
-rw-r--r--bin/sh/tests/builtins/Makefile8
-rw-r--r--bin/sh/tests/errors/Makefile8
-rw-r--r--bin/sh/tests/errors/bad-parm-exp2.22
-rw-r--r--bin/sh/tests/errors/bad-parm-exp2.2.stderr2
-rw-r--r--bin/sh/tests/errors/bad-parm-exp3.22
-rw-r--r--bin/sh/tests/errors/bad-parm-exp3.2.stderr2
-rw-r--r--bin/sh/tests/errors/bad-parm-exp4.22
-rw-r--r--bin/sh/tests/errors/bad-parm-exp4.2.stderr2
-rw-r--r--bin/sh/tests/errors/bad-parm-exp5.22
-rw-r--r--bin/sh/tests/errors/bad-parm-exp5.2.stderr2
-rw-r--r--bin/sh/tests/errors/bad-parm-exp6.22
-rw-r--r--bin/sh/tests/errors/bad-parm-exp6.2.stderr2
-rw-r--r--bin/sh/tests/execution/Makefile8
-rw-r--r--bin/sh/tests/expansion/Makefile8
-rwxr-xr-xbin/sh/tests/functional_test.sh72
-rw-r--r--bin/sh/tests/legacy_test.sh46
-rw-r--r--bin/sh/tests/parameters/Makefile8
-rw-r--r--bin/sh/tests/parser/Makefile8
-rw-r--r--bin/sh/tests/set-e/Makefile8
-rw-r--r--include/stdio.h1
-rw-r--r--lib/libc/stdio/Symbol.map4
-rw-r--r--lib/libc/stdio/fclose.382
-rw-r--r--lib/libc/stdio/fclose.c75
-rw-r--r--share/examples/tests/tests/plain/cp_test.sh1
-rw-r--r--sys/netsmb/smb_conn.c4
-rw-r--r--sys/netsmb/smb_iod.c3
-rw-r--r--sys/x86/x86/intr_machdep.c15
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc1
29 files changed, 280 insertions, 117 deletions
diff --git a/bin/sh/tests/Makefile b/bin/sh/tests/Makefile
index 51c6dc4..c092962 100644
--- a/bin/sh/tests/Makefile
+++ b/bin/sh/tests/Makefile
@@ -4,15 +4,12 @@
TESTSDIR= ${TESTSBASE}/bin/sh
-TAP_TESTS_SH= legacy_test
-TAP_TESTS_SH_SED_legacy_test= -e 's,__SH__,/bin/sh,g'
-# Some tests in here are silently not run when the tests are executed as
-# root. Explicitly tell Kyua to drop privileges.
-#
-# TODO(jmmv): Kyua needs to do this by default, not only when explicitly
-# requested. See https://code.google.com/p/kyua/issues/detail?id=6
-TEST_METADATA.legacy_test+= required_user="unprivileged"
-
-SUBDIR+= builtins errors execution expansion parameters parser set-e
+TESTS_SUBDIRS+= builtins
+TESTS_SUBDIRS+= errors
+TESTS_SUBDIRS+= execution
+TESTS_SUBDIRS+= expansion
+TESTS_SUBDIRS+= parameters
+TESTS_SUBDIRS+= parser
+TESTS_SUBDIRS+= set-e
.include <bsd.test.mk>
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
index ec4cab6..527c1b3 100644
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -2,8 +2,12 @@
.include <bsd.own.mk>
-FILESDIR= ${TESTSBASE}/bin/sh/builtins
-KYUAFILE= no
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
+
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= alias.0 alias.0.stdout
FILES+= alias.1 alias.1.stderr
diff --git a/bin/sh/tests/errors/Makefile b/bin/sh/tests/errors/Makefile
index ab04f14..51a766f 100644
--- a/bin/sh/tests/errors/Makefile
+++ b/bin/sh/tests/errors/Makefile
@@ -1,9 +1,11 @@
# $FreeBSD$
-.include <bsd.own.mk>
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
-FILESDIR= ${TESTSBASE}/bin/sh/errors
-KYUAFILE= no
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= assignment-error1.0
FILES+= assignment-error2.0
diff --git a/bin/sh/tests/errors/bad-parm-exp2.2 b/bin/sh/tests/errors/bad-parm-exp2.2
index 7e13d2b..a0826ec 100644
--- a/bin/sh/tests/errors/bad-parm-exp2.2
+++ b/bin/sh/tests/errors/bad-parm-exp2.2
@@ -1,2 +1,2 @@
# $FreeBSD$
-${}
+eval '${}'
diff --git a/bin/sh/tests/errors/bad-parm-exp2.2.stderr b/bin/sh/tests/errors/bad-parm-exp2.2.stderr
index d027a5a..51ea69c 100644
--- a/bin/sh/tests/errors/bad-parm-exp2.2.stderr
+++ b/bin/sh/tests/errors/bad-parm-exp2.2.stderr
@@ -1 +1 @@
-./errors/bad-parm-exp2.2: ${}: Bad substitution
+eval: ${}: Bad substitution
diff --git a/bin/sh/tests/errors/bad-parm-exp3.2 b/bin/sh/tests/errors/bad-parm-exp3.2
index a5ecba5..bb41208 100644
--- a/bin/sh/tests/errors/bad-parm-exp3.2
+++ b/bin/sh/tests/errors/bad-parm-exp3.2
@@ -1,2 +1,2 @@
# $FreeBSD$
-${foo/}
+eval '${foo/}'
diff --git a/bin/sh/tests/errors/bad-parm-exp3.2.stderr b/bin/sh/tests/errors/bad-parm-exp3.2.stderr
index ef40251..70473f9 100644
--- a/bin/sh/tests/errors/bad-parm-exp3.2.stderr
+++ b/bin/sh/tests/errors/bad-parm-exp3.2.stderr
@@ -1 +1 @@
-./errors/bad-parm-exp3.2: ${foo/}: Bad substitution
+eval: ${foo/}: Bad substitution
diff --git a/bin/sh/tests/errors/bad-parm-exp4.2 b/bin/sh/tests/errors/bad-parm-exp4.2
index 9eec8d0..2837f9b 100644
--- a/bin/sh/tests/errors/bad-parm-exp4.2
+++ b/bin/sh/tests/errors/bad-parm-exp4.2
@@ -1,2 +1,2 @@
# $FreeBSD$
-${foo:@abc}
+eval '${foo:@abc}'
diff --git a/bin/sh/tests/errors/bad-parm-exp4.2.stderr b/bin/sh/tests/errors/bad-parm-exp4.2.stderr
index 89bd80f..3363f51 100644
--- a/bin/sh/tests/errors/bad-parm-exp4.2.stderr
+++ b/bin/sh/tests/errors/bad-parm-exp4.2.stderr
@@ -1 +1 @@
-./errors/bad-parm-exp4.2: ${foo:@...}: Bad substitution
+eval: ${foo:@...}: Bad substitution
diff --git a/bin/sh/tests/errors/bad-parm-exp5.2 b/bin/sh/tests/errors/bad-parm-exp5.2
index 459281f..1ba343b 100644
--- a/bin/sh/tests/errors/bad-parm-exp5.2
+++ b/bin/sh/tests/errors/bad-parm-exp5.2
@@ -1,2 +1,2 @@
# $FreeBSD$
-${/}
+eval '${/}'
diff --git a/bin/sh/tests/errors/bad-parm-exp5.2.stderr b/bin/sh/tests/errors/bad-parm-exp5.2.stderr
index 89b1997..13763f8 100644
--- a/bin/sh/tests/errors/bad-parm-exp5.2.stderr
+++ b/bin/sh/tests/errors/bad-parm-exp5.2.stderr
@@ -1 +1 @@
-./errors/bad-parm-exp5.2: ${/}: Bad substitution
+eval: ${/}: Bad substitution
diff --git a/bin/sh/tests/errors/bad-parm-exp6.2 b/bin/sh/tests/errors/bad-parm-exp6.2
index ba51442..b53a91b 100644
--- a/bin/sh/tests/errors/bad-parm-exp6.2
+++ b/bin/sh/tests/errors/bad-parm-exp6.2
@@ -1,2 +1,2 @@
# $FreeBSD$
-${#foo^}
+eval '${#foo^}'
diff --git a/bin/sh/tests/errors/bad-parm-exp6.2.stderr b/bin/sh/tests/errors/bad-parm-exp6.2.stderr
index dbf14b5..cc56f65 100644
--- a/bin/sh/tests/errors/bad-parm-exp6.2.stderr
+++ b/bin/sh/tests/errors/bad-parm-exp6.2.stderr
@@ -1 +1 @@
-./errors/bad-parm-exp6.2: ${foo...}: Bad substitution
+eval: ${foo...}: Bad substitution
diff --git a/bin/sh/tests/execution/Makefile b/bin/sh/tests/execution/Makefile
index 302d0d8..2653d5f 100644
--- a/bin/sh/tests/execution/Makefile
+++ b/bin/sh/tests/execution/Makefile
@@ -1,9 +1,11 @@
# $FreeBSD$
-.include <bsd.own.mk>
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
-FILESDIR= ${TESTSBASE}/bin/sh/execution
-KYUAFILE= no
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= bg1.0
FILES+= bg2.0
diff --git a/bin/sh/tests/expansion/Makefile b/bin/sh/tests/expansion/Makefile
index e62fea4..d6f3c1a 100644
--- a/bin/sh/tests/expansion/Makefile
+++ b/bin/sh/tests/expansion/Makefile
@@ -1,9 +1,11 @@
# $FreeBSD$
-.include <bsd.own.mk>
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
-FILESDIR= ${TESTSBASE}/bin/sh/expansion
-KYUAFILE= no
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= arith1.0
FILES+= arith2.0
diff --git a/bin/sh/tests/functional_test.sh b/bin/sh/tests/functional_test.sh
new file mode 100755
index 0000000..6980538
--- /dev/null
+++ b/bin/sh/tests/functional_test.sh
@@ -0,0 +1,72 @@
+#
+# Copyright 2014 EMC Corp.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+# OWNER 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$
+
+SRCDIR=$(atf_get_srcdir)
+
+check()
+{
+ local tc=${1}; shift
+
+ export SH=$(atf_config_get bin.sh.test_shell /bin/sh)
+
+ local err_file="${SRCDIR}/${tc}.stderr"
+ [ -f "${err_file}" ] && err_flag="-e file:${err_file}"
+ local out_file="${SRCDIR}/${tc}.stdout"
+ [ -f "${out_file}" ] && out_flag="-o file:${out_file}"
+
+ atf_check -s exit:${tc##*.} ${err_flag} ${out_flag} ${SH} "${SRCDIR}/${tc}"
+}
+
+add_testcase()
+{
+ local tc=${1}
+ local tc_escaped word
+
+ case "${tc%.*}" in
+ *-*)
+ local IFS="-"
+ for word in ${tc%.*}; do
+ tc_escaped="${tc_escaped:+${tc_escaped}_}${word}"
+ done
+ ;;
+ *)
+ tc_escaped=${tc%.*}
+ ;;
+ esac
+
+ atf_test_case ${tc_escaped}
+ eval "${tc_escaped}_body() { check ${tc}; }"
+ atf_add_test_case ${tc_escaped}
+}
+
+atf_init_test_cases()
+{
+ for path in $(find -Es "${SRCDIR}" -regex '.*\.[0-9]+$'); do
+ add_testcase ${path##*/}
+ done
+}
diff --git a/bin/sh/tests/legacy_test.sh b/bin/sh/tests/legacy_test.sh
deleted file mode 100644
index d43f5dd..0000000
--- a/bin/sh/tests/legacy_test.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-# $FreeBSD$
-
-: ${SH:="__SH__"}
-export SH
-
-# TODO(jmmv): The Kyua TAP interface should be passing us the value of
-# "srcdir" as an environment variable, just as it does with the ATF
-# interface in the form of a configuration variable. For now, just try
-# to guess this.
-: ${TESTS_DATA:=$(dirname ${0})}
-
-COUNTER=1
-
-do_test() {
- c=${COUNTER}
- COUNTER=$((COUNTER+1))
- ${SH} $1 > tmp.stdout 2> tmp.stderr
- if [ $? -ne $2 ]; then
- echo "not ok ${c} - ${1} # wrong exit status"
- rm tmp.stdout tmp.stderr
- return
- fi
- sed -I '' -e "s|^${TESTS_DATA}|.|" tmp.stderr
- for i in stdout stderr; do
- if [ -f ${1}.${i} ]; then
- if ! cmp -s tmp.${i} ${1}.${i}; then
- echo "not ok ${c} - ${1} # wrong output on ${i}"
- rm tmp.stdout tmp.stderr
- return
- fi
- elif [ -s tmp.${i} ]; then
- echo "not ok ${c} - ${1} # wrong output on ${i}"
- rm tmp.stdout tmp.stderr
- return
- fi
- done
- echo "ok ${c} - ${1}"
- rm tmp.stdout tmp.stderr
-}
-
-TESTS=$(find -Es ${TESTS_DATA} -regex ".*\.[0-9]+")
-printf "1..%d\n" $(echo ${TESTS} | wc -w)
-
-for i in ${TESTS} ; do
- do_test ${i} ${i##*.}
-done
diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile
index e31b78f..aa1462f 100644
--- a/bin/sh/tests/parameters/Makefile
+++ b/bin/sh/tests/parameters/Makefile
@@ -1,9 +1,11 @@
# $FreeBSD$
-.include <bsd.own.mk>
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
-FILESDIR= ${TESTSBASE}/bin/sh/parameters
-KYUAFILE= no
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= env1.0
FILES+= exitstatus1.0
diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile
index b769a30..63f4e8f 100644
--- a/bin/sh/tests/parser/Makefile
+++ b/bin/sh/tests/parser/Makefile
@@ -1,9 +1,11 @@
# $FreeBSD$
-.include <bsd.own.mk>
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
-FILESDIR= ${TESTSBASE}/bin/sh/parser
-KYUAFILE= no
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= alias1.0
FILES+= alias2.0
diff --git a/bin/sh/tests/set-e/Makefile b/bin/sh/tests/set-e/Makefile
index 55d7917..f733b60 100644
--- a/bin/sh/tests/set-e/Makefile
+++ b/bin/sh/tests/set-e/Makefile
@@ -1,9 +1,11 @@
# $FreeBSD$
-.include <bsd.own.mk>
+TESTSDIR= ${TESTSBASE}/bin/sh/${.CURDIR:T}
-FILESDIR= ${TESTSBASE}/bin/sh/set-e
-KYUAFILE= no
+.PATH: ${.CURDIR:H}
+ATF_TESTS_SH= functional_test
+
+FILESDIR= ${TESTSDIR}
FILES= and1.0
FILES+= and2.1
diff --git a/include/stdio.h b/include/stdio.h
index d37ea06..5d3e5a2 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -399,6 +399,7 @@ int (dprintf)(int, const char * __restrict, ...);
int asprintf(char **, const char *, ...) __printflike(2, 3);
char *ctermid_r(char *);
void fcloseall(void);
+int fdclose(FILE *, int *);
char *fgetln(FILE *, size_t *);
const char *fmtcheck(const char *, const char *) __format_arg(2);
int fpurge(FILE *);
diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map
index d2a8c92..a332ab2 100644
--- a/lib/libc/stdio/Symbol.map
+++ b/lib/libc/stdio/Symbol.map
@@ -162,6 +162,10 @@ FBSD_1.3 {
mkostemps;
};
+FBSD_1.4 {
+ fdclose;
+};
+
FBSDprivate_1.0 {
_flockfile;
_flockfile_debug_stub;
diff --git a/lib/libc/stdio/fclose.3 b/lib/libc/stdio/fclose.3
index 883aa10..596ee3d 100644
--- a/lib/libc/stdio/fclose.3
+++ b/lib/libc/stdio/fclose.3
@@ -1,5 +1,6 @@
-.\" Copyright (c) 1990, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
+.\" Copyright (c) 1990, 1991, 1993 The Regents of the University of California.
+.\" Copyright (c) 2015 Mariusz Zaborski <oshogbo@FreeBSD.org>
+.\" All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Chris Torek and the American National Standards Committee X3,
@@ -32,11 +33,12 @@
.\" @(#)fclose.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd April 22, 2006
+.Dd July 4, 2015
.Dt FCLOSE 3
.Os
.Sh NAME
.Nm fclose ,
+.Nm fdclose ,
.Nm fcloseall
.Nd close a stream
.Sh LIBRARY
@@ -45,6 +47,8 @@
.In stdio.h
.Ft int
.Fn fclose "FILE *stream"
+.Ft int
+.Fn fdclose "FILE *stream" "int *fdp"
.Ft void
.Fn fcloseall void
.Sh DESCRIPTION
@@ -59,36 +63,77 @@ first, using
.Xr fflush 3 .
.Pp
The
+.Fn fdclose
+function is equivalent to
+.Fn fclose
+except that it does not close the underlying file descriptor.
+If
+.Fa fdp
+is not
+.Dv NULL ,
+the file descriptor will be written to it.
+If the
+.Fa fdp
+argument will be different then NULL the file descriptor will be returned in it,
+If the stream does not have an associated file descriptor,
+.Fa fdp
+will be set to -1.
+This type of stream is created with functions such as
+.Xr fmemopen 3 ,
+.Xr funopen 3 ,
+or
+.Xr open_memstream 3 .
+.Pp
+The
.Fn fcloseall
function calls
.Fn fclose
on all open streams.
.Sh RETURN VALUES
-Upon successful completion 0 is returned.
+.Fn fcloseall
+does not return a value.
+.Pp
+Upon successful completion the
+.Fn fclose
+and
+.Fn fdclose
+functions return 0.
Otherwise,
.Dv EOF
is returned and the global variable
.Va errno
is set to indicate the error.
-In either case no further access to the stream is possible.
.Sh ERRORS
+.Fn fdclose
+fails if:
+.Bl -tag -width Er
+.It Bq Er EOPNOTSUPP
+The stream does not have an associated file descriptor.
+.El
+.Pp
The
.Fn fclose
-function
-may also fail and set
+and
+.Fn fdclose
+functions may also fail and set
.Va errno
-for any of the errors specified for the routines
-.Xr close 2
-or
+for any of the errors specified for
.Xr fflush 3 .
+.Pp
+The
+.Fn fclose
+function may also fail and set errno for any of the errors specified for
+.Xr close 2 .
.Sh NOTES
The
.Fn fclose
-function
-does not handle NULL arguments; they will result in a segmentation
-violation.
-This is intentional - it makes it easier to make sure programs written
-under
+and
+.Fn fdclose
+functions do not handle NULL arguments in the
+.Fa stream
+variable; this will result in a segmentation violation.
+This is intentional.
+It makes it easier to make sure programs written under
.Fx
are bug free.
This behaviour is an implementation detail, and programs should not
@@ -104,8 +149,13 @@ The
function
conforms to
.St -isoC .
-.Pp
+.Sh HISTORY
The
.Fn fcloseall
function first appeared in
.Fx 7.0 .
+.Pp
+The
+.Fn fdclose
+function first appeared in
+.Fx 11.0 .
diff --git a/lib/libc/stdio/fclose.c b/lib/libc/stdio/fclose.c
index 5ed8b2c..24b9b90 100644
--- a/lib/libc/stdio/fclose.c
+++ b/lib/libc/stdio/fclose.c
@@ -1,6 +1,7 @@
/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1990, 1993 The Regents of the University of California.
+ * Copyright (c) 2013 Mariusz Zaborski <oshogbo@FreeBSD.org>
+ * All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Chris Torek.
@@ -38,6 +39,7 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <errno.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "un-namespace.h"
@@ -45,19 +47,17 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "local.h"
-int
-fclose(FILE *fp)
+static int
+cleanfile(FILE *fp, bool c)
{
int r;
- if (fp->_flags == 0) { /* not open! */
- errno = EBADF;
- return (EOF);
- }
- FLOCKFILE(fp);
r = fp->_flags & __SWR ? __sflush(fp) : 0;
- if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0)
- r = EOF;
+ if (c) {
+ if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0)
+ r = EOF;
+ }
+
if (fp->_flags & __SMBF)
free((char *)fp->_bf._base);
if (HASUB(fp))
@@ -80,6 +80,59 @@ fclose(FILE *fp)
STDIO_THREAD_LOCK();
fp->_flags = 0; /* Release this FILE for reuse. */
STDIO_THREAD_UNLOCK();
+
+ return (r);
+}
+
+int
+fdclose(FILE *fp, int *fdp)
+{
+ int r, err;
+
+ if (fdp != NULL)
+ *fdp = -1;
+
+ if (fp->_flags == 0) { /* not open! */
+ errno = EBADF;
+ return (EOF);
+ }
+
+ FLOCKFILE(fp);
+ r = 0;
+ if (fp->_close != __sclose) {
+ r = EOF;
+ errno = EOPNOTSUPP;
+ } else if (fp->_file < 0) {
+ r = EOF;
+ errno = EBADF;
+ }
+ if (r == EOF) {
+ err = errno;
+ (void)cleanfile(fp, true);
+ errno = err;
+ } else {
+ if (fdp != NULL)
+ *fdp = fp->_file;
+ r = cleanfile(fp, false);
+ }
FUNLOCKFILE(fp);
+
+ return (r);
+}
+
+int
+fclose(FILE *fp)
+{
+ int r;
+
+ if (fp->_flags == 0) { /* not open! */
+ errno = EBADF;
+ return (EOF);
+ }
+
+ FLOCKFILE(fp);
+ r = cleanfile(fp, true);
+ FUNLOCKFILE(fp);
+
return (r);
}
diff --git a/share/examples/tests/tests/plain/cp_test.sh b/share/examples/tests/tests/plain/cp_test.sh
index ea64705..c45d684 100644
--- a/share/examples/tests/tests/plain/cp_test.sh
+++ b/share/examples/tests/tests/plain/cp_test.sh
@@ -1,3 +1,4 @@
+#! /bin/sh
# $FreeBSD$
#
# Copyright 2013 Google Inc.
diff --git a/sys/netsmb/smb_conn.c b/sys/netsmb/smb_conn.c
index d58bc72..adc171c 100644
--- a/sys/netsmb/smb_conn.c
+++ b/sys/netsmb/smb_conn.c
@@ -683,7 +683,9 @@ int
smb_vc_disconnect(struct smb_vc *vcp)
{
- smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT | SMBIOD_EV_SYNC, NULL);
+ if (vcp->vc_iod != NULL)
+ smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT |
+ SMBIOD_EV_SYNC, NULL);
return 0;
}
diff --git a/sys/netsmb/smb_iod.c b/sys/netsmb/smb_iod.c
index ae5c6f7..412f816 100644
--- a/sys/netsmb/smb_iod.c
+++ b/sys/netsmb/smb_iod.c
@@ -690,6 +690,9 @@ smb_iod_create(struct smb_vc *vcp)
RFNOWAIT, 0, "smbiod%d", iod->iod_id);
if (error) {
SMBERROR("can't start smbiod: %d", error);
+ vcp->vc_iod = NULL;
+ smb_sl_destroy(&iod->iod_rqlock);
+ smb_sl_destroy(&iod->iod_evlock);
free(iod, M_SMBIOD);
return error;
}
diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c
index 9a5e463..cc50321 100644
--- a/sys/x86/x86/intr_machdep.c
+++ b/sys/x86/x86/intr_machdep.c
@@ -197,19 +197,28 @@ int
intr_remove_handler(void *cookie)
{
struct intsrc *isrc;
- int error;
+ int error, mtx_owned;
isrc = intr_handler_source(cookie);
error = intr_event_remove_handler(cookie);
if (error == 0) {
- mtx_lock(&intr_table_lock);
+ /*
+ * Recursion is needed here so PICs can remove interrupts
+ * while resuming. It was previously not possible due to
+ * intr_resume holding the intr_table_lock and
+ * intr_remove_handler recursing on it.
+ */
+ mtx_owned = mtx_owned(&intr_table_lock);
+ if (mtx_owned == 0)
+ mtx_lock(&intr_table_lock);
isrc->is_handlers--;
if (isrc->is_handlers == 0) {
isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI);
isrc->is_pic->pic_disable_intr(isrc);
}
intrcnt_updatename(isrc);
- mtx_unlock(&intr_table_lock);
+ if (mtx_owned == 0)
+ mtx_unlock(&intr_table_lock);
}
return (error);
}
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 549b7b6..4361d08 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -4468,6 +4468,7 @@ OLD_FILES+=usr/share/aclocal/atf-common.m4
OLD_FILES+=usr/share/aclocal/atf-sh.m4
OLD_DIRS+=usr/share/aclocal
OLD_FILES+=usr/tests/bin/date/legacy_test
+OLD_FILES+=usr/tests/bin/sh/legacy_test
OLD_FILES+=usr/tests/lib/atf/libatf-c/test_helpers_test
OLD_FILES+=usr/tests/lib/atf/test-programs/fork_test
OLD_FILES+=usr/tests/lib/atf/libatf-c++/application_test
OpenPOWER on IntegriCloud