From nobody Sun Feb 8 18:48:31 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 39A5923026F for ; Fri, 21 Mar 2025 19:49:23 +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=1742586567; cv=none; b=mu/FKOvqsYq82+TF1ZyvvTMVzV8zQYjROdh/jggbpcmKEvWySA19um2yYZmtZdnOTxjHNzje+9dSX3ZCgObex5kQsmNOhAk2HrCsiUOeLAFFXNfuSZw7xkQUWerZUw+ks5PKRA9rNaaYMoDXc4HdTDYQuIG1uR9ihT+Xkcz/xXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742586567; c=relaxed/simple; bh=U65D6SohAEKFKir81pK5H51AE5x6/jUW8l5jaJk9nGM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D+KB+Hr2Yeb88vUu2irT2UMraJEzzhQmpbbnixA8PkRq2ny3IBvlD1IYDqhAntabwhubNDzftINpljjInoyEA+vbOAyV9jS5lKBBJ5fLpjIgCxk7EGk+b5In97oJUiZb3M3SqDh3uTzjfRrL84NDFzW1f7ypuWmr9S+1yJwTgSI= 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=RENNq0pw; 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="RENNq0pw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742586561; 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=P+CKY6hYnggEy5gDUo8IBcPB4aoVwWaaXqwhjqRQh5c=; b=RENNq0pwVu/gW1zgew9EeD8sLwJZ98rjiKjx90RziqKm/ra6+uJaiUjaLZU1ePtqAC5pKE q31bc3Gqi2sNtXdGSQLScpPo5wnfapYlm5dZ3LQ5Q9DwEefKKM6F//VLl2TEkSg48GXqiB 2gQoTFJUkZlOPjNdeK3B0x69K2NEDxg= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-LQxxwT1VOb2wFk2fnM3YWw-1; Fri, 21 Mar 2025 15:49:18 -0400 X-MC-Unique: LQxxwT1VOb2wFk2fnM3YWw-1 X-Mimecast-MFC-AGG-ID: LQxxwT1VOb2wFk2fnM3YWw_1742586556 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-ac3d3cd9accso227531766b.3 for ; Fri, 21 Mar 2025 12:49:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742586556; x=1743191356; 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=P+CKY6hYnggEy5gDUo8IBcPB4aoVwWaaXqwhjqRQh5c=; b=YvxK0rIpZS49X/dYhdrDruxsFaAvy3QsykVCukoAaAECsx9Cs39Vs13GdiDuXKLFTp EFy4RFCguIyXrLNtC0K8u4DIQMBi8ZGYcIo6HiUY2VhMDf0RQnlCpK5XE98BmC7zsmzL ZNK1nLRUsTLxoaenrVEhuZAMemD9Wm6bO0HpeaCUeqlQTm7qs++MTxjjkoB/uznC8/i5 kH7M2uuDer+Qj6Xgsrz9DX10th/0PH7TF4QDI4EJpDzuyHU5+jayS6UB+vcmmJvCkUi/ 79yL5M3tb11pWPoZNrohnfmj7In+qpz9FOmjiYs9rYHOi5EVlLbEshYNiKZ5XXkX8CDU cgQg== X-Forwarded-Encrypted: i=1; AJvYcCWQRvzsRwbECQSAr9MNRgI7avJeIY+oZi5bHhomP1GwuAvWWockYYFmYyuCqDDhN8AoDr9MRGFpKTeGGxM=@vger.kernel.org X-Gm-Message-State: AOJu0YxvnaRy3yvcu1o1dB6e6pDmHKWocHUitHXSHKLQvnUlJvi+NV0G VlyJRC3zJz+kLCKmlitpso0XQSyO4s1DziWKiml7rF7M8GGNEPth4VmFuWk0z9cp3XrdFPxvKAq V3r1dfAv4rpHLL3r+OnBz4cIfwvwk/KO9rQF88IeBIV4Of4C827PhxTwASzee X-Gm-Gg: ASbGncs5Fp8/v+wwwVIhoL/384eLwTGrss/ayNn3aKL2I7MKtG3rf7tKkqQ9c84eKBU GOEjgfQUu1THbyXO27/A9eoZT7xAhHeB+9NMQreYBRDKcJLeaqLeo3oYyWm/hdS2lIwudis7dEi apAOTR6mKDnWk0cnMhLMgq0kkGQ8IibATarI8TK56jlNJAtP0mQPAa416yAZUdQkOdL8NIJFiwN /si9qLKksC8MONpIiHP8dokIQXlZNX2d9B2QU+5SM4tO1+eHiYuK3etFwR6xIKDb+GpzfmorbBl cJOJZ2VddvMLxQP9nwMQ0zy4YrygHKNRuVd46pHSBw== X-Received: by 2002:a17:907:9482:b0:ac2:13f:338b with SMTP id a640c23a62f3a-ac3f2537a13mr417246566b.55.1742586555831; Fri, 21 Mar 2025 12:49:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE364/oBuyn+cE4ig5ONss+vPjSo5TWTy9RSOBlsLCFEbZLg0sVEvc8UiI6SNuN3e2vwFGwrA== X-Received: by 2002:a17:907:9482:b0:ac2:13f:338b with SMTP id a640c23a62f3a-ac3f2537a13mr417237066b.55.1742586555219; Fri, 21 Mar 2025 12:49:15 -0700 (PDT) Received: from [127.0.0.2] (ip-217-030-074-039.aim-net.cz. [217.30.74.39]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3ef8d3d38sm204412266b.39.2025.03.21.12.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Mar 2025 12:49:13 -0700 (PDT) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn Date: Fri, 21 Mar 2025 20:48:41 +0100 Subject: [PATCH v4 2/3] 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: <20250321-xattrat-syscall-v4-2-3e82e6fb3264@kernel.org> References: <20250321-xattrat-syscall-v4-0-3e82e6fb3264@kernel.org> In-Reply-To: <20250321-xattrat-syscall-v4-0-3e82e6fb3264@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" 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, Andrey Albershteyn X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3102; i=aalbersh@kernel.org; h=from:subject:message-id; bh=U65D6SohAEKFKir81pK5H51AE5x6/jUW8l5jaJk9nGM=; b=owJ4nJvAy8zAJea2/JXEGuOHHIyn1ZIY0u8e2nhsqffE2qNHBdc56kpaBv10/G5zKMBMNU5Y1 7+08cOt3t6OUhYGMS4GWTFFlnXSWlOTiqTyjxjUyMPMYWUCGcLAxSkAF7Fl+MO39MOayUtjz0Xc Zf+S85RBZMPrQyk/IssaWQR3V917GlLI8D93Rvvtmb0TdxnrLdm5326CcYQxW4JKaaBU3XVFNfO V51kB1DlIeQ== X-Developer-Key: i=aalbersh@kernel.org; a=openpgp; fpr=AE1B2A9562721A6FC4307C1F46A7EA18AC33E108 This will be helpful for get/setfsxattrat syscalls to convert between fileattr and fsxattr. Signed-off-by: Andrey Albershteyn Reviewed-by: Jan Kara --- fs/ioctl.c | 32 +++++++++++++++++++++----------- include/linux/fileattr.h | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 4434c97bc5dff5a3e8635e28745cd99404ff353e..840283d8c406623d8d26790f89b= 62ebcbd39e2de 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -538,6 +538,16 @@ int vfs_fileattr_get(struct dentry *dentry, struct fil= eattr *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 @@ -549,12 +559,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; @@ -563,6 +568,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) { @@ -571,11 +585,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 47c05a9851d0600964b644c9c7218faacfd865f8..31888fa2edf10050be134f58729= 9256088344365 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