From mboxrd@z Thu Jan 1 00:00:00 1970 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 7B3DD2957D0 for ; Mon, 12 May 2025 13:19:32 +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=1747055976; cv=none; b=MOOhjs/90rdsbSmqZL7+K76ef91vNGvnuiiSHxgqWCcBrJOtRi8t3Ae0ndhcxsoOCzdr4E4Qx/t4P2Ypiv4FzndcvbO0I2bnNkQ9hqYud5VUf4EChYIclUKw4o7JqquQUI97XTS+Iy0TwF9MGCetYm7LWrpMr2cGmTP4l/q0nWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747055976; c=relaxed/simple; bh=Sow3ieK523EXyMicqcCSjkd/TH+5nWsIoTZ6MRpL6MI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pDgfYaOqAnil72QFRPEjR/0S0GwIfkuLaNgmbV/eIOwvlQ1Ao2fUwVGICFH0UEZR3va4uZf+s7gmtW8bFDdwJN7R0OouZKBf6kpj1HNmrws7VPlS8WEJik76oBGka9DO3SH6x73vzK/JoOnal6uPXLaxdqdgp2LEqony6xLjf1Y= 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=Aj7fCRXB; 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="Aj7fCRXB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747055970; 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=cDXnQGld1rGn7NpA5vNTnzaJVN2Ft1voUe3ylxYDySo=; b=Aj7fCRXBBgGLOiSchMJBtJVGjdm6L41pvBxMqCMZYiCnIy4+2oFgReop+A9ZfSFRQ3bPtm ogRbOrcaxBDFovCCsTbE2taa0vT7adAvOcJvauDAZEANWN/Q/C6CgLyoubNeS1Gx/Bfpa5 JHK9CMAIW1KtODODWpaL0vxssrTNDcQ= 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-249-tQuB3EHyNo2LXigln84aXA-1; Mon, 12 May 2025 09:19:29 -0400 X-MC-Unique: tQuB3EHyNo2LXigln84aXA-1 X-Mimecast-MFC-AGG-ID: tQuB3EHyNo2LXigln84aXA_1747055968 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-ace99fe4282so515689066b.1 for ; Mon, 12 May 2025 06:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747055968; x=1747660768; 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=cDXnQGld1rGn7NpA5vNTnzaJVN2Ft1voUe3ylxYDySo=; b=EhJZDyPJEKi25Bp2yHngI766TwEp9mKYqYZJmnU/cwZEE0Pq86UNjWI5Vv5TJfaw8G YIgLr3tIxlhxmX0QCYV18TMp1Ym8WLGVhujkfCdhTJdhiHapUS0KPbvB1yUftPg32LLE X9EOk0FZ4F5JUNSgE7Gek+npRB+e2Y/ORsEiHwGcKYvmd4eZZIaWhRbn+XSH7YW8b+W+ cvNmj3qHq60mV6GVUTOONdpxZCZ6zGah1RGpWA53/ahLvM7VLTdUgl/ohHU0OsyINHN6 ziOmAZt/28NidRxkcw2kGvIvAbJfDiy8UsH+FO/PSA1Pyh73Pea1YIrrveP8CxT/YVQB UlNw== X-Forwarded-Encrypted: i=1; AJvYcCXPQDbiYpQ4doklFu9aMla9NjS4A5wRP6cvKP0eRDsTXdxuShXownovb4dNy3dbWVTTmKupMn0fXOMSVIM=@vger.kernel.org X-Gm-Message-State: AOJu0YxfCBDNNxyzrjwRu6i9Je+PaqcgSxwRWNztwU14gfYnIP402ts7 OMYlxLiI6oRny12ByhSwrIFx3W181u/dJ1LuzQdoqjLmA6LxQ9lmq6KwqV58PeUzWdJPYRR7Osf vW+Q+rEh8NoWk+DTrpla9f6oxVKxtbmigOV4HkWixHhI6/NaoswRUnVnpP0yl X-Gm-Gg: ASbGncvQq42Z4iu0hqbzrN0dJT644K/4BD/QJYv4ln0XRVD1ftnXv0X8Owlv8YaiRpJ gJ7xHbgkNwZ89WzuJL7ylOeFzpsDccTA28+uYCbDv8BvTCxFTJXXEfnsawYNCvbpZUk4LkWy63N LHdef3zY9yaKENL9952uFupK3CRl4wv/yBh9M6BA6S3tVB+Y+hxvtOCs9Pc3eUlX4o4y1xVzpTZ /CPvVPjWKWDOuXBix08dUZKFIkrmov6cKi/oPd0xcJykThFj8vc90oPCk2aory7gxgZDg8Y/HQB vdglmSU8yvIMZX9A4Fnephp/Wtk= X-Received: by 2002:a17:906:6a22:b0:ad2:cce:8d5e with SMTP id a640c23a62f3a-ad21b16d4d8mr1361757266b.7.1747055967930; Mon, 12 May 2025 06:19:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1Wm34D/72hdzOITX/1P+LJJ3f88CMImIhv4h5FTIdAsUC2LOrFnS2VVLTTqMPzoKoT8uong== X-Received: by 2002:a17:906:6a22:b0:ad2:cce:8d5e with SMTP id a640c23a62f3a-ad21b16d4d8mr1361754066b.7.1747055967429; Mon, 12 May 2025 06:19:27 -0700 (PDT) Received: from [127.0.0.1] (109-92-26-237.static.isp.telekom.rs. [109.92.26.237]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad2197bde09sm612328766b.125.2025.05.12.06.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 06:19:26 -0700 (PDT) From: Andrey Albershteyn X-Google-Original-From: Andrey Albershteyn Date: Mon, 12 May 2025 15:18:57 +0200 Subject: [PATCH v5 4/7] fs: split fileattr/fsxattr converters into helpers Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250512-xattrat-syscall-v5-4-a88b20e37aae@kernel.org> References: <20250512-xattrat-syscall-v5-0-a88b20e37aae@kernel.org> In-Reply-To: <20250512-xattrat-syscall-v5-0-a88b20e37aae@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.15-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3042; i=aalbersh@kernel.org; h=from:subject:message-id; bh=Sow3ieK523EXyMicqcCSjkd/TH+5nWsIoTZ6MRpL6MI=; b=owJ4nJvAy8zAJea2/JXEGuOHHIyn1ZIYMhS/+l+d2NV18V2W7kMGnsp1P5oOhUkzLv1iXWyve u6BgJTb4oCOUhYGMS4GWTFFlnXSWlOTiqTyjxjUyMPMYWUCGcLAxSkAE8kpYPifV7rt5W3p05uf VJmX/T9pu3iZ1uHej6nJczr3l3gX/F8dz8jwtzfAKvXqrcigX7ucu9t/uaQYyQb8rb92wEHraHl ATC03ANV+Srw= 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 be62d97cc444..d9eab553dc25 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -89,6 +89,16 @@ int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa) } EXPORT_SYMBOL(vfs_fileattr_get); +void fileattr_to_fsxattr(const struct fileattr *fa, struct fsxattr *fsx) +{ + memset(fsx, 0, sizeof(struct fsxattr)); + fsx->fsx_xflags = fa->fsx_xflags; + fsx->fsx_extsize = fa->fsx_extsize; + fsx->fsx_nextents = fa->fsx_nextents; + fsx->fsx_projid = fa->fsx_projid; + fsx->fsx_cowextsize = 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, struct fsxattr __user *ufa) { struct fsxattr xfa; - memset(&xfa, 0, sizeof(xfa)); - xfa.fsx_xflags = fa->fsx_xflags; - xfa.fsx_extsize = fa->fsx_extsize; - xfa.fsx_nextents = fa->fsx_nextents; - xfa.fsx_projid = fa->fsx_projid; - xfa.fsx_cowextsize = fa->fsx_cowextsize; + fileattr_to_fsxattr(fa, &xfa); if (copy_to_user(ufa, &xfa, sizeof(xfa))) return -EFAULT; @@ -114,6 +119,15 @@ int copy_fsxattr_to_user(const struct fileattr *fa, struct fsxattr __user *ufa) } EXPORT_SYMBOL(copy_fsxattr_to_user); +void fsxattr_to_fileattr(const struct fsxattr *fsx, struct fileattr *fa) +{ + fileattr_fill_xflags(fa, fsx->fsx_xflags); + fa->fsx_extsize = fsx->fsx_extsize; + fa->fsx_nextents = fsx->fsx_nextents; + fa->fsx_projid = fsx->fsx_projid; + fa->fsx_cowextsize = 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; - fileattr_fill_xflags(fa, xfa.fsx_xflags); - fa->fsx_extsize = xfa.fsx_extsize; - fa->fsx_nextents = xfa.fsx_nextents; - fa->fsx_projid = xfa.fsx_projid; - fa->fsx_cowextsize = xfa.fsx_cowextsize; + fsxattr_to_fileattr(&xfa, fa); return 0; } diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h index 6030d0bf7ad3..433efa0f4784 100644 --- a/include/linux/fileattr.h +++ b/include/linux/fileattr.h @@ -33,7 +33,9 @@ struct fileattr { bool fsx_valid:1; }; +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); void fileattr_fill_xflags(struct fileattr *fa, u32 xflags); void fileattr_fill_flags(struct fileattr *fa, u32 flags); -- 2.47.2