From patchwork Thu Sep 28 13:01:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 13402977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A867BE732CA for ; Thu, 28 Sep 2023 13:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232582AbjI1NCq (ORCPT ); Thu, 28 Sep 2023 09:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbjI1NCp (ORCPT ); Thu, 28 Sep 2023 09:02:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 766BD19B for ; Thu, 28 Sep 2023 06:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695906113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SAsGsjUp2akFOXe3NzL6P0KjpNsT5cDYxfpTwl+LFa4=; b=LsF8LBeE3niA3hXbf2pWhubb12/D6OQ0V0FYQggPDoeUNFWYI75aDkPZ7L2fnn3q71avuV Sx7d7k2dyX18YMZKbCByJckNfWMZi7QaB8OMBb9AfbEn5nSuM3gbzC0o18n61T9IvAFJQf ygoYKvSi0SjBgXBYdr8KHFCbuEKarGg= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-513-gp10HT6UMAK_VlaewNvFhw-1; Thu, 28 Sep 2023 09:01:52 -0400 X-MC-Unique: gp10HT6UMAK_VlaewNvFhw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9ae686dafedso1100616966b.3 for ; Thu, 28 Sep 2023 06:01:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695906111; x=1696510911; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SAsGsjUp2akFOXe3NzL6P0KjpNsT5cDYxfpTwl+LFa4=; b=XfhylslsTbX5D8Yc6NA9/aoIm96UYAnVAk72CKK+fhnbzsTiL6pOUJY21SThF/hSEa 15I9Wz4C+0VljsatWWXkyvQmmRpVwtqRedGkWw8oJOhjjzie+WF2nztLgyKIMD7qR7tI GMt6qv6W2zKkiGdSUHnTIVnSFdDavfzJU/u9iqrUcMRsW2zgI0N61k1RYnFqT/54vryl MNkO+XZqLmvSFSKrJVrbqU5hoVnQX5SWyngS0sddzllergIqx0NvT0VYkYCSM5m+LBgL udHye9yRQprAt2qSNAYATMrY+5n7SD8+W8DwyAMilL76AmI9VhSg18b86chobwpbglEZ 8ibw== X-Gm-Message-State: AOJu0Yx/fsQXdnxo1uI+68kN1vbUVZ3grDeI9uBTrW19DGFNEheIPr2w vA576doEkB3f4reIs/4b+efOb/PLQK7DmXCsdEhOt6dzn74P8l0iLsm0C1iViLu7EXmaZKxkM+J 9fmevlxO+8EfXZfXLbsNmgHF87tGJfZ5cZglu X-Received: by 2002:a17:906:4d2:b0:9a2:1e03:1572 with SMTP id g18-20020a17090604d200b009a21e031572mr1101940eja.19.1695906110739; Thu, 28 Sep 2023 06:01:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbkaqxJ9P/J0/LxrJDvMMLHi+yyUi9xLnBaJSvjWu4NDQEasTuE+Qb7BbbAr66wxOa1CBnPA== X-Received: by 2002:a17:906:4d2:b0:9a2:1e03:1572 with SMTP id g18-20020a17090604d200b009a21e031572mr1101898eja.19.1695906110228; Thu, 28 Sep 2023 06:01:50 -0700 (PDT) Received: from maszat.piliscsaba.szeredi.hu (94-21-53-31.pool.digikabel.hu. [94.21.53.31]) by smtp.gmail.com with ESMTPSA id v6-20020a170906380600b0099c53c4407dsm10784863ejc.78.2023.09.28.06.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 06:01:49 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-man@vger.kernel.org, linux-security-module@vger.kernel.org, Karel Zak , Ian Kent , David Howells , Linus Torvalds , Al Viro , Christian Brauner , Amir Goldstein , Matthew House , Florian Weimer , Arnd Bergmann Subject: [PATCH v3 0/4] querying mount attributes Date: Thu, 28 Sep 2023 15:01:42 +0200 Message-ID: <20230928130147.564503-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: bulk List-ID: Implement mount querying syscalls agreed on at LSF/MM 2023. Features: - statx-like want/got mask - allows returning ascii strings (fs type, root, mount point) - returned buffer is relocatable (no pointers) Still missing: - man pages - kselftest - syscalls on non-x86 archs Please find the test utility at the end of this mail. Usage: statmnt [-l] (mnt_id|path) Git tree: git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs.git#statmount-v3 Changes v1..v3: - rename statmnt(2) -> statmount(2) - rename listmnt(2) -> listmount(2) - make ABI 32bit compatible by passing 64bit args in a struct (tested on i386 and x32) - only accept new 64bit mount IDs - fix compile on !CONFIG_PROC_FS - call security_sb_statfs() in both syscalls - make lookup_mnt_in_ns() static - add LISTMOUNT_UNREACHABLE flag to listmnt() to explicitly ask for listing unreachable mounts - remove .sb_opts - remove subtype from .fs_type - return the number of bytes used (including strings) in .size - rename .mountpoint -> .mnt_point - point strings by an offset against char[] VLA at the end of the struct. E.g. printf("fs_type: %s\n", st->str + st->fs_type); - don't save string lengths - extend spare space in struct statmnt (complete size is now 512 bytes) --- Miklos Szeredi (4): add unique mount ID namespace: extract show_path() helper add statmount(2) syscall add listmount(2) syscall arch/x86/entry/syscalls/syscall_32.tbl | 2 + arch/x86/entry/syscalls/syscall_64.tbl | 2 + fs/internal.h | 2 + fs/mount.h | 3 +- fs/namespace.c | 365 +++++++++++++++++++++++++ fs/proc_namespace.c | 10 +- fs/stat.c | 9 +- fs/statfs.c | 1 + include/linux/syscalls.h | 8 + include/uapi/asm-generic/unistd.h | 8 +- include/uapi/linux/mount.h | 59 ++++ include/uapi/linux/stat.h | 1 + 12 files changed, 459 insertions(+), 11 deletions(-)