17d03e081SKyle Evans /*
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
37d03e081SKyle Evans *
47d03e081SKyle Evans * Copyright (c) 2020 Kyle Evans <kevans@FreeBSD.org>
57d03e081SKyle Evans *
67d03e081SKyle Evans * Redistribution and use in source and binary forms, with or without
77d03e081SKyle Evans * modification, are permitted provided that the following conditions
87d03e081SKyle Evans * are met:
97d03e081SKyle Evans * 1. Redistributions of source code must retain the above copyright
107d03e081SKyle Evans * notice, this list of conditions and the following disclaimer.
117d03e081SKyle Evans * 2. Redistributions in binary form must reproduce the above copyright
127d03e081SKyle Evans * notice, this list of conditions and the following disclaimer in the
137d03e081SKyle Evans * documentation and/or other materials provided with the distribution.
147d03e081SKyle Evans *
157d03e081SKyle Evans * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
167d03e081SKyle Evans * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
177d03e081SKyle Evans * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
187d03e081SKyle Evans * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
197d03e081SKyle Evans * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
207d03e081SKyle Evans * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
217d03e081SKyle Evans * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
227d03e081SKyle Evans * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
237d03e081SKyle Evans * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
247d03e081SKyle Evans * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
257d03e081SKyle Evans * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
267d03e081SKyle Evans */
277d03e081SKyle Evans
287851fb8eSKyle Evans #include <sys/param.h>
297d03e081SKyle Evans #include <unistd.h>
307d03e081SKyle Evans
317d03e081SKyle Evans #include "libc_private.h"
327d03e081SKyle Evans
337d03e081SKyle Evans void
closefrom(int lowfd)347d03e081SKyle Evans closefrom(int lowfd)
357d03e081SKyle Evans {
367851fb8eSKyle Evans __sys_close_range(MAX(0, lowfd), ~0U, 0);
377d03e081SKyle Evans }
38