Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp473245ybh; Tue, 10 Mar 2020 02:18:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsAC8j61igGTfo/MGBmLr8XsW0nMdkiYwsshGVZl6vp4g4wRbN62OqyoWYV5r2FCXne1bHu X-Received: by 2002:a05:6830:168b:: with SMTP id k11mr16611316otr.156.1583831921427; Tue, 10 Mar 2020 02:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583831921; cv=none; d=google.com; s=arc-20160816; b=zj+Q0dGRBqwRAtnPG9lyXX/LBbO+cLOaM8LTuY2TgyZBhXPZjaI4H7AqjYtGi1FJHa Jhm6+ikuBF9/e05uj9hyXaEIwPpyEeUquTnuwwl3/Co72U92tJeKTEjYvk88elIzwWQH ef4CsYB21ddyiWm1DXoMIuO/YfV9BPZJ4YR758f2L7BcbPJjC1pkv0cSiVS7JoDdkRfN PbgeTrYpf/mYR6srHry6eSUcB2Uu08XINQNMxiVm0wX2KZSP2+pIBr+YZ/ykcmi0NtRJ rmU9xis7v5q/cOfxlVg07maOUGJ9tD6VLpOOqQSsHL7TljxrLqPu2YFH0wyI2Vuhlj60 vcUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Hhr2JQNCTfwAz5fM8AxpKXVAk7m03eW/WPRPp++R3bc=; b=IZAk5dSjKqpwjkq1AIsobUxFm3XvFkrRJNUWZjzaWt0Kdo6eOtPFe8hCpxOLZEYdLp aR/ZCobPwSvKOlE9oZdYrSdnGd0n3/LdfhRxQsE6674ZbqtYHZu2qFo4PuM1cGdydMsF eZbW7iuKsH+ugpnXuMWg85pVHZjVuNz9ikaGfsLAgj49KAH8zeygcwNjQ6npPpCT+kK8 /xc4ohJiQ7scnCJST1YYXOVDOaQ8SY3PMR466T4yHs8B5aT4rNqoaaE6Kd1i5LYJznlr s6cKpqKFVQuC5MwpLsj89ZAz8yVQGmscCP8XC00CcdM3Kxq8dGDKh6sMtH5QV6DRh4+D tMew== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=CLeuNfcd; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 v15si7968386oth.307.2020.03.10.02.18.25; Tue, 10 Mar 2020 02:18:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=CLeuNfcd; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726395AbgCJJSU (ORCPT + 99 others); Tue, 10 Mar 2020 05:18:20 -0400 Received: from mail-il1-f195.google.com ([209.85.166.195]:45454 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbgCJJST (ORCPT ); Tue, 10 Mar 2020 05:18:19 -0400 Received: by mail-il1-f195.google.com with SMTP id p1so7327345ils.12 for ; Tue, 10 Mar 2020 02:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Hhr2JQNCTfwAz5fM8AxpKXVAk7m03eW/WPRPp++R3bc=; b=CLeuNfcd8lneEopBSQtHp3Kt+HipoV0gZP6IuZpydHV2/p4TlsVqkfu5HowfqMTXt4 B6Nes0PUjpXtVP2DD/+CYwm5MJkMF1NpiN6Pigz83+0gVtQu29MQJHpZf1loCCFWgnuY NvSCicUjakpnIekJzu1+qB/DP+TL60iT/Mg+Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hhr2JQNCTfwAz5fM8AxpKXVAk7m03eW/WPRPp++R3bc=; b=CpAhCKCTBX/eAC0cq5oFSPUcdcprIp08FIwvRlyUBw+LMRGAHFYZ/PtOMZB/Q9Zt+N BklzkNGNuGRcPM5u9KVGn7xPqdaT9JMfU9KN98gp7SmU4/tDnGJuG06PvRZNvoWVELQl qMkEqF9ykqa8Q+Q8ITPsxQE/sdHAcjf3yb8BqqtKNcARhKiAF7NPazLo4TujcIwQZxKj AMy770j9/4ZGnE1XPNA62RzwZlwNd2vqWv7E41rbSuV2r+SSszNDenffnHhdN+MtIiEs I2RhMM+6fEUpA4LFJEuYMUux0liB0VvTDVnERkSO8JW2LJFvyD3tsXuVPtYRaO8uqMsx fnOQ== X-Gm-Message-State: ANhLgQ3pqlBzucbPVpbRtnXQmox4DpO+RvG8C4VZlgaE972aCzpFHhLf 46SPIj1NYLuUSm0ljEndkpKrE9Hlz7c4by4xv7mmnw== X-Received: by 2002:a92:9602:: with SMTP id g2mr18883520ilh.212.1583831899169; Tue, 10 Mar 2020 02:18:19 -0700 (PDT) MIME-Version: 1.0 References: <158376244589.344135.12925590041630631412.stgit@warthog.procyon.org.uk> <20200309200238.GB28467@miu.piliscsaba.redhat.com> <537182.1583794373@warthog.procyon.org.uk> In-Reply-To: <537182.1583794373@warthog.procyon.org.uk> From: Miklos Szeredi Date: Tue, 10 Mar 2020 10:18:08 +0100 Message-ID: Subject: Re: [PATCH 00/14] VFS: Filesystem information [ver #18] To: David Howells Cc: Linus Torvalds , Al Viro , "Theodore Ts'o" , Stefan Metzmacher , Andreas Dilger , linux-ext4@vger.kernel.org, Aleksa Sarai , Trond Myklebust , Anna Schumaker , Linux NFS list , Linux API , Ian Kent , Miklos Szeredi , Christian Brauner , Jann Horn , "Darrick J. Wong" , Karel Zak , Jeff Layton , linux-fsdevel@vger.kernel.org, LSM , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Mar 9, 2020 at 11:53 PM David Howells wrote: > > Miklos Szeredi wrote: > > > > (1) It can be targetted. It makes it easy to query directly by path or > > > fd, but can also query by mount ID or fscontext fd. procfs and sysfs > > > cannot do three of these things easily. > > > > See above: with the addition of open(path, O_PATH) it can do all of these. > > That's a horrible interface. To query a file by path, you have to do: > > fd = open(path, O_PATH); > sprintf(procpath, "/proc/self/fdmount/%u/"); > fd2 = open(procpath, O_RDONLY); > read(fd2, ...); > close(fd2); > close(fd); > > See point (3) about efficiency also. You're having to open *two* files. I completely agree, opening two files is surely going to kill performance of application needing to retrieve a billion mount attributes per second. > > > (2) Easier to provide LSM oversight. Is the accessing process allowed to > > > query information pertinent to a particular file? > > > > Not quite sure why this would be easier for a new ad-hoc interface than for > > the well established filesystem API. > > You're right. That's why fsinfo() uses standard pathwalk where possible, > e.g.: > > fsinfo(AT_FDCWD, "/path/to/file", ...); > > or a fairly standard fd-querying interface: > > fsinfo(fd, "", { resolve_flags = RESOLVE_EMPTY_PATH }, ...); > > to query an open file descriptor. These are well-established filesystem APIs. Yes. The problem is with the "..." part where you pass random structures to a function. That's useful sometimes, but at the very least it breaks type safety, and not what I would call a "clean" API. > > Now onto the advantages of a filesystem based API: > > > > - immediately usable from all programming languages, including scripts > > This is not true. You can't open O_PATH from shell scripts, so you can't > query things by path that you can't or shouldn't open (dev file paths, for > example; symlinks). Yes. However, you just wrote the core of a utility that could do this (in 6 lines, no less). Now try that feat with fsinfo(2)! Thanks, Miklos