From nobody Sun Feb 8 22:06:29 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20DD721ABAB for ; Tue, 13 May 2025 09:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747127912; cv=none; b=aIgICqJlP/TqrB9l+/NMFDz08Ld2+ZLAa8VG1u2cUgoISeBu44vReKWau/mwx8WvNuIbHDJZku0y3LF/qR1ZhdCy3P5XCQCI2po2YF8IWxVi3R8xAeat0twJIbZo1bQknlMVBcsnl+07lzdiAarPxXAq56oBRXmpDdXGN9hAoH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747127912; c=relaxed/simple; bh=7/qlLocSDGOnq9HanUewnfKPkCH1bdYdAp9tNZm+5GE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qhma9zRR/MscURhwoeaH1iGquv7Y476HlR/fLrAwr1+uYCTjpEJltqjHJeKeUgCp7wwDpiXfTiDKGO8/bDf3o51uxyqccIWUxi+/5JhCBbSp/OLxB+gistp0fSbXFoZSSWfNtyt7EqfGVOeiWyFIpg74fOdQkt2giQSddzFnQ+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SeBqU9Ns; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SeBqU9Ns" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747127905; 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: in-reply-to:in-reply-to:references:references; bh=ls6EYzWLpzSyrbfDPukFujnVQKFcbGgB9h/N+wiqpNc=; b=SeBqU9NsN/hMeIlBZSIJpLaqE8/lC/Nqu0DiLCtv7NdhYjP/9GdGpqwJr7UQi2sb/topez 5Cbxo9j97l5Aq8wqUiuIgjCw2xjUB3Vli5ELCGcBtQ6d2ISN9Bj/046BjVogy+WErq+yuX h2hC+5dntTbwwqY3T7YZTo5hbl0wCf8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-h2gUSV2eOsOCH6hUC2zWBg-1; Tue, 13 May 2025 05:18:23 -0400 X-MC-Unique: h2gUSV2eOsOCH6hUC2zWBg-1 X-Mimecast-MFC-AGG-ID: h2gUSV2eOsOCH6hUC2zWBg_1747127902 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-442d472cf7fso31673225e9.3 for ; Tue, 13 May 2025 02:18:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747127902; x=1747732702; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ls6EYzWLpzSyrbfDPukFujnVQKFcbGgB9h/N+wiqpNc=; b=G6bQWrUdnKqtVQDrKh6vyoXgZKtKOpLl8tVSDVAeluUSYl/bGekNCpu+bn2KQhQTLm OtLcK2ATfXSPRx5qg6BLNdrzuZLQ4WNj9oPaLld99YckJoDvPqqvOTHZqNl1VGIR3Sc8 sA9QyURkXMC1OBav2r02ATDb+O7sh2pinavtRMgpCT5ZJQU0QQx7URwOn62Otyu416OA Eljz+jFMY/WEateZ3w8iW65hGeOImuKhqSBCbpYMcCm8XruonI0Zdp2zGuvBv2uwwOWK BgnNSo9+b7F8cXYw8VYRfjhTW1Ihouwz3XR4bIu0b9+9QXown454LZ7UL14dW7pZ8GHn v4vg== X-Forwarded-Encrypted: i=1; AJvYcCXmj8npRztYRxF4pyoICpWDkvVbUNovF+1uaK1kisXoyzKcwnXFTqZuUQjh7mwr7b18OyVMUuDcux+PNE0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9D7CcUVzZzHeUBppyQns6o09beCv3d+0eH7RSCrcJj3WE6lvn 1SJ88Fohi9YS8XOgqgoz1c4raTLu4wKhWxycaUZSG5bI2zng8HVZTg55z213Za4xQHu7iwKsDUe GQU7OfD2G5D+xcqTepUQuyLGSe2MKzEtSv7tlQbwR4akDHWbrp2XL8qxe8qXw X-Gm-Gg: ASbGncspHcYXyIaqDx0bTB/k2RPrHzkedBh9s/SHA6v7mYK7GVFlIKS5r/Ps4dWr/lV 83N+8og8KrkMqLQ251j38h0orY/qeIJb/21U6OO+0YwTTeFCrAXgUSCFWhfFQUZI3Nucxp6ztZV qbCR2QatuRiHFHDrgarMieRZN8XmJ8iWjcFpKeb4ADhftVhSPdiM2wisg0IVaEwmHXw4bBhZYlm EwXfMmIEhEmnToTP4KySK7SkDXoFRUpT98SECQ5uwz0b3Lt3Tsl0TTQAbw35S+ffaw3GI29mFNt G596p1VFj2YoLkPxLFckyd8H5Y5McQiHaYY6C53SJnAX2dQ= X-Received: by 2002:a05:600c:37c7:b0:43c:efed:733e with SMTP id 5b1f17b1804b1-442d6d379b2mr155020145e9.14.1747127901732; Tue, 13 May 2025 02:18:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEEtHWgn5s898vXVMD6AEOwzulPPtHZtUMHxI74NvDZ3sPtiUYejsU22j+vwltmbRtQ8fYMg== X-Received: by 2002:a05:600c:37c7:b0:43c:efed:733e with SMTP id 5b1f17b1804b1-442d6d379b2mr155019705e9.14.1747127901297; Tue, 13 May 2025 02:18:21 -0700 (PDT) Received: from [127.0.0.2] (109-92-26-237.static.isp.telekom.rs. [109.92.26.237]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-442ed666dc7sm12345655e9.18.2025.05.13.02.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 May 2025 02:18:20 -0700 (PDT) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn Date: Tue, 13 May 2025 11:17:57 +0200 Subject: [PATCH v5 4/7] fs: split fileattr/fsxattr converters into helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250513-xattrat-syscall-v5-4-22bb9c6c767f@kernel.org> References: <20250513-xattrat-syscall-v5-0-22bb9c6c767f@kernel.org> In-Reply-To: <20250513-xattrat-syscall-v5-0-22bb9c6c767f@kernel.org> To: Richard Henderson , Matt Turner , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Michal Simek , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Chris Zankel , Max Filippov , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , =?utf-8?q?G=C3=BCnther_Noack?= , Arnd Bergmann , =?utf-8?q?Pali_Roh=C3=A1r?= , Paul Moore , James Morris , "Serge E. Hallyn" , Stephen Smalley , Ondrej Mosnacek , Tyler Hicks , Miklos Szeredi , Amir Goldstein Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, selinux@vger.kernel.org, ecryptfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, Andrey Albershteyn X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3154; i=aalbersh@kernel.org; h=from:subject:message-id; bh=7/qlLocSDGOnq9HanUewnfKPkCH1bdYdAp9tNZm+5GE=; b=owJ4nJvAy8zAJea2/JXEGuOHHIyn1ZIYMpT5vBmqeS9Of1kvckyD89yLKSHZd6cITHwR8ON6Q Krbn8kRqyw6SlkYxLgYZMUUWdZJa01NKpLKP2JQIw8zh5UJbAgXpwBMZHojI8Npu1fs2yWveYpu X75O9+PGOXL/F3U+vN7XHFJf5fdw0aozDH/lf/x993b3NibzczpnPr7ddd+5/McRwUl+3zqveq7 g+LeWDwBTZEzV X-Developer-Key: i=aalbersh@kernel.org; a=openpgp; fpr=AE1B2A9562721A6FC4307C1F46A7EA18AC33E108 This will be helpful for file_get/setattr syscalls to convert between fileattr and fsxattr. Signed-off-by: Andrey Albershteyn Reviewed-by: Jan Kara --- fs/file_attr.c | 32 +++++++++++++++++++++----------- include/linux/fileattr.h | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/fs/file_attr.c b/fs/file_attr.c index be62d97cc444a445deac1c8ac8331f4a3766126a..d9eab553dc250f84075ac74c1c7= d8d6fd6588374 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -89,6 +89,16 @@ int vfs_fileattr_get(struct dentry *dentry, struct filea= ttr *fa) } EXPORT_SYMBOL(vfs_fileattr_get); =20 +void fileattr_to_fsxattr(const struct fileattr *fa, struct fsxattr *fsx) +{ + memset(fsx, 0, sizeof(struct fsxattr)); + fsx->fsx_xflags =3D fa->fsx_xflags; + fsx->fsx_extsize =3D fa->fsx_extsize; + fsx->fsx_nextents =3D fa->fsx_nextents; + fsx->fsx_projid =3D fa->fsx_projid; + fsx->fsx_cowextsize =3D fa->fsx_cowextsize; +} + /** * copy_fsxattr_to_user - copy fsxattr to userspace. * @fa: fileattr pointer @@ -100,12 +110,7 @@ int copy_fsxattr_to_user(const struct fileattr *fa, st= ruct fsxattr __user *ufa) { struct fsxattr xfa; =20 - memset(&xfa, 0, sizeof(xfa)); - xfa.fsx_xflags =3D fa->fsx_xflags; - xfa.fsx_extsize =3D fa->fsx_extsize; - xfa.fsx_nextents =3D fa->fsx_nextents; - xfa.fsx_projid =3D fa->fsx_projid; - xfa.fsx_cowextsize =3D fa->fsx_cowextsize; + fileattr_to_fsxattr(fa, &xfa); =20 if (copy_to_user(ufa, &xfa, sizeof(xfa))) return -EFAULT; @@ -114,6 +119,15 @@ int copy_fsxattr_to_user(const struct fileattr *fa, st= ruct fsxattr __user *ufa) } EXPORT_SYMBOL(copy_fsxattr_to_user); =20 +void fsxattr_to_fileattr(const struct fsxattr *fsx, struct fileattr *fa) +{ + fileattr_fill_xflags(fa, fsx->fsx_xflags); + fa->fsx_extsize =3D fsx->fsx_extsize; + fa->fsx_nextents =3D fsx->fsx_nextents; + fa->fsx_projid =3D fsx->fsx_projid; + fa->fsx_cowextsize =3D fsx->fsx_cowextsize; +} + static int copy_fsxattr_from_user(struct fileattr *fa, struct fsxattr __user *ufa) { @@ -122,11 +136,7 @@ static int copy_fsxattr_from_user(struct fileattr *fa, if (copy_from_user(&xfa, ufa, sizeof(xfa))) return -EFAULT; =20 - fileattr_fill_xflags(fa, xfa.fsx_xflags); - fa->fsx_extsize =3D xfa.fsx_extsize; - fa->fsx_nextents =3D xfa.fsx_nextents; - fa->fsx_projid =3D xfa.fsx_projid; - fa->fsx_cowextsize =3D xfa.fsx_cowextsize; + fsxattr_to_fileattr(&xfa, fa); =20 return 0; } diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h index 6030d0bf7ad32693a0f48a6f28475d97e768bb3e..433efa0f47844ef063373eb3906= 72812682b6388 100644 --- a/include/linux/fileattr.h +++ b/include/linux/fileattr.h @@ -33,7 +33,9 @@ struct fileattr { bool fsx_valid:1; }; =20 +void fileattr_to_fsxattr(const struct fileattr *fa, struct fsxattr *fsx); int copy_fsxattr_to_user(const struct fileattr *fa, struct fsxattr __user = *ufa); +void fsxattr_to_fileattr(const struct fsxattr *fsx, struct fileattr *fa); =20 void fileattr_fill_xflags(struct fileattr *fa, u32 xflags); void fileattr_fill_flags(struct fileattr *fa, u32 flags); --=20 2.47.2