Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp944286ybm; Tue, 21 May 2019 06:20:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMEBC1HUy4r5NJDsUfz5mKiWgDs4aaoWV2tHTPkZF+dz3IGoIoETujzZRyt5wesGGdsbXi X-Received: by 2002:a17:902:2ae6:: with SMTP id j93mr59715286plb.130.1558444824162; Tue, 21 May 2019 06:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558444824; cv=none; d=google.com; s=arc-20160816; b=Z779KBCQg3KouENsqueMtzIyd2FAtlYfqBdZxpLTfi6/arfBhrNj7QmMsUYZGK/KDv tB18ye9DDFBmC5rbEkB9pPV14s5ZM/vySv9dOD252GiZp5qU7r6CzvokOqn6kcrcVI1X tQ9KCBoFQ3gh0KA0uOLpKgnH0S9c03GcHAJQP5+iuOwH/M1T+R+jo5Y2IEpUNebGLsjj cyCgbHmmBei8qLGQ5rMs/PWz6e/xpEsKce/6XxZCs0ZxTONG83Ln0cXbBT0ElXm+woAO a3Q1Uzc9/kXjfb4RL7x0ROhXqT8D8dUReiS0fBl37jTI4tTEvF/Tlqlwsf+nOVxVN0Oq Rr2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=m/t4nh9Qn5eHvWriEo2lAzUTm+cejgZEB4hMcOrCq4Y=; b=lvTVK+kK0RDZIrB+te7sVHEh2pxi5rzCaN7bB6QRtUZNCatJcBfFJqMrejl54kpj5v u9miOc5LMWZZX6ElcE8VAhey9bwFvrrpIU7ZhEWhrHiqtlY+e7noeFrpdga89rM9RdJ4 pT5gPuVu/TXJtmq5jDTkE6FeLS/cAGadeI4bCriYGo/mh59pdf7fkdKaF3+KTTsx+CEX 4h49cZDtPZLbBCWuOUtGRcCS7N2fr4ZnYV61lgfHvGwF+6CFqUlYkxsaWQpwj2px82C7 dUP/vLGynNZrXS/LubmNJ9cQDD0SpoOD9Ye88E1ibvAQeqC29ZBFtKjb1wvwaw0LVass iZKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=Qzja+tqW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h96si21507526plb.281.2019.05.21.06.20.07; Tue, 21 May 2019 06:20:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=Qzja+tqW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbfEUNS5 (ORCPT + 99 others); Tue, 21 May 2019 09:18:57 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52473 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbfEUNS4 (ORCPT ); Tue, 21 May 2019 09:18:56 -0400 Received: by mail-wm1-f65.google.com with SMTP id y3so2972600wmm.2 for ; Tue, 21 May 2019 06:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=m/t4nh9Qn5eHvWriEo2lAzUTm+cejgZEB4hMcOrCq4Y=; b=Qzja+tqWdJKwhlDJv7ZeHS1krNqDAM++eYcwAp+RKkbv8p1KDPWxxZhzOpavU0EOHV kYWbjNPEjkxc3aEKZdrk9785qJNa6FxJtfkDGm1FLt3j0bk9/8YvawePnukWGCyjpFii 0DMW2p0x+5xPdVsJRuiSOe+/dtlaOGa52u2fWdq9QaNK4Tve8leR5ZqhEKAiqjWW0X06 oTZk1e1uxbJPDBZIKsNtQKeWDeRpwtxnoV5XKv/I6zW+K9rGYAZZ7B8YjZBRwD4kYhWa WgDiIxwS5iY9PCvzQxN+w34XvRhk0st2I0ChEGvAZh7Cr4yOtxIXjdk5keUvD29dcq/r WLUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=m/t4nh9Qn5eHvWriEo2lAzUTm+cejgZEB4hMcOrCq4Y=; b=hHDM4it/GYWd3WK6ElCI6GxXeS2MavvGllPuT4yVtJon4dnCY1wyw4IHPRTavf1+IF Z5UVrtyMSsv38g5ajB787H3rOmFih7aXZGa93i1IBHdkge4h0jtbmLcu+K9+jhFXWtj4 7UmtsZIFNVYLv0X5frW+Uhugi7H8MjLNb6rjcTEeXx3F667P6etsVokctIS2aA11shW/ jCbUCojQLIpSlsdVOHdE6gg3X/aLFX1sMtPwChsGD+OLffzHIG7JvzLnQ7ZQMSOT25Pj BljlBJQ0XkW5WASd8qfJP2knwVQcH5+diyBf8yJqqOhLB9JheQ/Q5NDTho/upcPiI10a QRIA== X-Gm-Message-State: APjAAAX+t97SAC2ckdIaXveKto4CPy3W4f0YRFBs0U7o9CfflUNFm61u GkbT1P7KgA1bz1GZuErPiW4oVA== X-Received: by 2002:a1c:9c8c:: with SMTP id f134mr3258598wme.95.1558444734225; Tue, 21 May 2019 06:18:54 -0700 (PDT) Received: from brauner.io (p548C9938.dip0.t-ipconnect.de. [84.140.153.56]) by smtp.gmail.com with ESMTPSA id n4sm2071899wmk.24.2019.05.21.06.18.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 21 May 2019 06:18:53 -0700 (PDT) Date: Tue, 21 May 2019 15:18:50 +0200 From: Christian Brauner To: Florian Weimer Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, jannh@google.com, oleg@redhat.com, tglx@linutronix.de, torvalds@linux-foundation.org, arnd@arndb.de, shuah@kernel.org, dhowells@redhat.com, tkjos@android.com, ldv@altlinux.org, miklos@szeredi.hu, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH 1/2] open: add close_range() Message-ID: <20190521131849.2mguu5sszhbxhvgu@brauner.io> References: <20190521113448.20654-1-christian@brauner.io> <87tvdoau12.fsf@oldenburg2.str.redhat.com> <20190521130438.q3u4wvve7p6md6cm@brauner.io> <87h89o9cng.fsf@oldenburg2.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87h89o9cng.fsf@oldenburg2.str.redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 21, 2019 at 03:10:11PM +0200, Florian Weimer wrote: > * Christian Brauner: > > >> Solaris has an fdwalk function: > >> > >> > >> > >> So a different way to implement this would expose a nextfd system call > > > > Meh. If nextfd() then I would like it to be able to: > > - get the nextfd(fd) >= fd > > - get highest open fd e.g. nextfd(-1) > > The highest open descriptor isn't istering for fdwalk because nextfd > would just fail. > > > But then I wonder if nextfd() needs to be a syscall and isn't just > > either: > > fcntl(fd, F_GET_NEXT)? > > or > > prctl(PR_GET_NEXT)? > > I think the fcntl route is a bit iffy because you might need it to get > the *first* valid descriptor. Oh, how would that be difficult? Maybe I'm missing context. Couldn't you just do fcntl(0, F_GET_NEXT) > > >> to userspace, so that we can use that to implement both fdwalk and > >> closefrom. But maybe fdwalk is just too obscure, given the existence of > >> /proc. > > > > Yeah we probably don't need fdwalk. > > Agreed. Just wanted to bring it up for completeness. I certainly don't > want to derail the implementation of close_range. No, that's perfectly fine. I mean, you clearly need this and are one of the major stakeholders. For example, Rust (probably also Python) will call down into libc and not use the syscall directly. They kinda do this with getfdtable rn already. So what you say makes sense for libc has some relevance for the other tools as well. Christian