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 1D8BC2957BE for ; Mon, 12 May 2025 13:19:31 +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=1747055974; cv=none; b=irwTBnmZcJUHIfvkKvm8khfcjJHpeg0YaA2jSP6CYu39Bd7Kk8vr6P31SAZ6GpgeTQddgRx8FvwA9xlubMZ+wJ8P5e8YPU2FuG7OIemn5kDtxdoXxq54fqMpm+MymhNhcchWF2dvg7/aIpWgJYV57joMHM5uGXDbEpWn9Wq2s+I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747055974; c=relaxed/simple; bh=Sow3ieK523EXyMicqcCSjkd/TH+5nWsIoTZ6MRpL6MI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lgpLVO9u+2OycL5652ISOtW2suqlnwrjkTT3uODcZ/nJ6AIwcYxoqkjHqN6fKxwIXyPCzv0ETaEDKko5cXDtqZ26IPAnRuAWx+GbzTpdRk9uC+Emptg+X82tXyQ3onOGBx0nQchrqvjIW665MBZ7Ze/axVlOjlju21rHJXTyg+8= 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-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-H3ZBetpVN0OYzM2nNIcevw-1; Mon, 12 May 2025 09:19:29 -0400 X-MC-Unique: H3ZBetpVN0OYzM2nNIcevw-1 X-Mimecast-MFC-AGG-ID: H3ZBetpVN0OYzM2nNIcevw_1747055968 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-ace99fe4282so515687866b.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=oeKipUZJxvIs02UHoLYhAXOIITHhapnm2zQW80mnoJh9YAvOqnb+Yvg4DMJrV2Rb+m iJUukRvhMt4OwHOj0gUQzY+pvwYdwkZMHaHQkL/DS4Eb/JGrK5o9g4zVNWv7qGTjJZql v8kmO2qo8N0tgoOuFUSubjXd1Feozah6MR9QpycWl7dJSdIlxiUPbh+su52705wPXOFg ccF87tFcXwHHVClsBrtaAjZkOMUvBXFNC8orgW1+TBtESv7OlkqOiOgli6b189jnR48D xNbD/035tHeUVFxTz2DpaLYchfqCCrTX3iJ6wORtAv4JDXSLgEHiWhrrWGFuEDkgarQO X5eA== X-Forwarded-Encrypted: i=1; AJvYcCUUlRs1Zhsw/FWFKSnzcNMwP5LWOPaKaqZs0qMK0HDtWTvjMIruLLnu+dsIvtyW/7X8tdvMr92exeK6@vger.kernel.org X-Gm-Message-State: AOJu0YziJ1Q/OAeUx7VOXCnkGj4CkmT3/S/+AKFYGOC6/2jOWSR51+Mj +/9KZL7XhUUaLIm/AXiqzgdPjw7XO7xZsEp71OAkN6ZP8Hs2wsJXMOCkthUYVaLG9RYgkg3anoM dkQknxrioqsc4FXPcnpYvHKybO0djSqqhawc4urr6wjxhKrFGUO68acYjwQ== X-Gm-Gg: ASbGncss2ou2xS3CHngWFxukPmW1FpNJ2gV6La6rEsYnB/W2xAO6HHWFqn56FJ1eAAQ AIt2GF7XhaRIap03YjF96yT/yTSPw7fLNZrrBR9iEjMDBNd1EDc4y/IdRIvkzya4XNRnc7nPUQk G4R+kRN+MX4LO7SGeDydaIiWbajGeFckE3OPxPV8uInEPXBQaKZTeXUc6XF8dmk/lStxPrInH7S W92pHnDS0Yl7/BwAA/FTedXlGf3VOKJmlRwDVVOmyicof7zS+IryZFf3eMeUZzmIlj35obiPWho Dx8f+3BIfQnUsHHoewkFodIYtxw= X-Received: by 2002:a17:906:6a22:b0:ad2:cce:8d5e with SMTP id a640c23a62f3a-ad21b16d4d8mr1361756866b.7.1747055967924; 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: sparclinux@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