From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by sourceware.org (Postfix) with ESMTPS id 994FF3846457 for ; Tue, 9 Mar 2021 10:03:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 994FF3846457 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ubuntu.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=christian.brauner@ubuntu.com Received: from ip5f5af0a0.dynamic.kabel-deutschland.de ([95.90.240.160] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lJZCf-0008GY-0W; Tue, 09 Mar 2021 10:03:01 +0000 Date: Tue, 9 Mar 2021 11:02:59 +0100 From: Christian Brauner To: Florian Weimer Cc: Adhemerval Zanella via Libc-alpha Subject: Re: [PATCH v3 2/4] Linux: Add close_range Message-ID: <20210309100259.mjuxusxeigoxmsa4@wittgenstein> References: <20201223163651.2634504-1-adhemerval.zanella@linaro.org> <20201223163651.2634504-2-adhemerval.zanella@linaro.org> <87mtvc64kw.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87mtvc64kw.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Mar 2021 10:03:03 -0000 On Tue, Mar 09, 2021 at 10:47:59AM +0100, Florian Weimer via Libc-alpha wrote: > * Adhemerval Zanella via Libc-alpha: > > > diff --git a/manual/llio.texi b/manual/llio.texi > > index c0a53e1a6e..ceb18ac89a 100644 > > --- a/manual/llio.texi > > +++ b/manual/llio.texi > > @@ -284,6 +284,44 @@ of trying to close its underlying file descriptor with @code{close}. > > This flushes any buffered output and updates the stream object to > > indicate that it is closed. > > > > +@deftypefun int close_range (unsigned int @var{lowfd}, unsigned int @var{maxfd}, int @var{flags}) > > +@standards{Linux, unistd.h} > > +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{@acsfd{}}} > > +@c This is a syscall for Linux v5.9. There is no fallback emulation for > > +@c older kernels. > > + > > +The function @code{clode_range} closes the file descriptor from @var{lowfd} > > +to @var{maxfd} (inclusive). This function is similar to call @code{close} in > > +specified file descriptor range depending on the @var{flags}. > > + > > +The @var{flags} add options on how the files are closes. Linux currently > > +supports:. > > Spurios “.” at end of line. > > > +@vtable @code > > +@item CLOSE_RANGE_UNSHARE > > +Unshare the file descriptor table before closing file descriptors. > > +@end vtable > > + > > +The normal return value from @code{close_range} is @math{0}; a value > > +of @math{-1} is returned in case of failure. The following @code{errno} error > > +conditions are defined for this function: > > + > > +@table @code > > +@item EINVAL > > +The @var{lowfd} value is larger than @var{maxfd} or an unsupported @var{flags} > > +is used. > > + > > +@item ENOMEM > > +Either there is not enough memory for the operation, or the process is > > +out of address space. > > + > > +@item EMFILE > > +The process has too many files open. > > +The maximum number of file descriptors is controlled by the > > +@end table > > +@end deftypefun > > The ENOMEM and EMFILE descriptions are not really clear in this context. > Are these failures only possible with CLOSE_RANGE_UNSHARE? Hey, just to confirm: Yes, these errors can only occur with CLOSE_RANGE_UNSHARE when the new file descriptor table is created. Christian