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.133.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 95CDC218AD4 for ; Tue, 13 May 2025 09:18:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747127912; cv=none; b=V5U9COIxQF/O3XOjYzq1pj45Qfw/Lr6b8bjKNQl9TWDWF2DnX5oMDfBCOHPEthWNgLXhl+yQNmoN9VkLnbM4CulX9n16l9Tac4yDtCQlV/hueNfDnUkcw7fq/+T5HItkDo3uGLPAGh60zu+bpVhGNaZ+tDypGhO1BzgbWydoXyg= 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.133.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-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-gTy10d9_MWuGvqS5zztdjw-1; Tue, 13 May 2025 05:18:23 -0400 X-MC-Unique: gTy10d9_MWuGvqS5zztdjw-1 X-Mimecast-MFC-AGG-ID: gTy10d9_MWuGvqS5zztdjw_1747127902 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-442e0e6eb84so17273815e9.0 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=uc9ZYLTtTKxFrZgIoSh4FnwM7RT1BLUOueyJueiJUkoidfc6F3Nuqv5rkQz6zOuq5q v2Hhuc4s5M72/SbYq9CNCN1fJ4D7InAEF4+k2cHHHvsn/xVX89DTaR11TRuedfc7Nrxw 6PmWaHOzKI/RSMfRvmQUFhr+c8VlKsT9ZJUwXGuSxEBOWtoSxAo6b9wKBF5mE32urWNW xRzbwUakFu/t9XryqXbqGoj1X939YWkH9dJGBU4GpHzTbPEPfxcxW3PJK8qcL+Wg4E2O NlWrZNip7aYPbS9RHId5ns3KLtbDlNpX6bEDZTc1IlG5OT24qIDx1AlPUTo8yJEFM9S2 Ga0w== X-Forwarded-Encrypted: i=1; AJvYcCUBhAZaJsfL1kO5aLg5GPlQ1sDa/O5RrFvU10aK1TOw/XAFu3nQF8MraLEDj1s9yKq5DWbZhBEP2btS@vger.kernel.org X-Gm-Message-State: AOJu0Yyn3EctMmB7Cl0GMRSTC8Ksh1zFq5ZxWAABFAQjad77xM1kjIJB OHbdtGcMpr4nJUnBs+3rhstD0uQDfKjP16h+BN2cao9RZFooCn7UVnCDivbkPHsemJofBN0r9h3 +n5B+j6Mli0snkI0r2V2g4a7nfsv6U+hngAjQQXqvtNgHOXf3KEJN80YzUA== X-Gm-Gg: ASbGncs3Zp0onQMPAD5SQMYjoHbkafRR4VyiemXQ87MJ8kAzES5H+0vQQQhzkC8SA4h t/FMY8nNWNneK+H5CXh1ecRS8OIgDPJtvU6ysCjiPnImL/F2Z53t1KDOTgZcZy2mgrL1NfL8db0 ujrUGkU7nMsW5j19d2+rcH7BDJ39Tm8Y8jzxCrxg8vMeI/b6Rj1NgiqXqv+o+JL7IozsAT5zB+x Jrphn+mvpQ200r18sizvUqI91Lw0oy37olnKphY5b/6LVs+maHVWi7sTHizGEdbtNJ5AXBNcKjN 3ns0K10rt/NOCXJJ5Egcu54nO44YN6HaxxXPHlllrcwuTJA= X-Received: by 2002:a05:600c:37c7:b0:43c:efed:733e with SMTP id 5b1f17b1804b1-442d6d379b2mr155020235e9.14.1747127901736; 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-mips@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: <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..d9eab553dc250f84075ac74c1c7d8d6fd6588374 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 6030d0bf7ad32693a0f48a6f28475d97e768bb3e..433efa0f47844ef063373eb390672812682b6388 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