From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 594E1C433DF for ; Fri, 17 Jul 2020 10:11:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BE7B20775 for ; Fri, 17 Jul 2020 10:11:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726013AbgGQKLX (ORCPT ); Fri, 17 Jul 2020 06:11:23 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:60821 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgGQKLW (ORCPT ); Fri, 17 Jul 2020 06:11:22 -0400 Received: from localhost (lfbn-tou-1-1075-236.w90-76.abo.wanadoo.fr [90.76.143.236]) (Authenticated sender: antoine.tenart@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 2BA6B24001F; Fri, 17 Jul 2020 10:10:02 +0000 (UTC) From: Antoine Tenart To: linux-ext4@vger.kernel.org Cc: Antoine Tenart , matthew.weber@rockwellcollins.com, thomas.petazzoni@bootlin.com, adilger@dilger.ca Subject: [PATCH v2] create_inode: set xattrs to the root directory as well Date: Fri, 17 Jul 2020 12:08:46 +0200 Message-Id: <20200717100846.497546-1-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org populate_fs do copy the xattrs for all files and directories, but the root directory is skipped and as a result its extended attributes aren't set. This is an issue when using mkfs to build a full system image that can be used with SElinux in enforcing mode without making any runtime fix at first boot. This patch adds logic to set the root directory's extended attributes. Signed-off-by: Antoine Tenart --- Since v1: - Moved the set_inode_xattr logic for the root directory from __populate_fs to populate_fs2. misc/create_inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/misc/create_inode.c b/misc/create_inode.c index e8d1df6b55a5..fe66faf1b53d 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -1050,9 +1050,17 @@ errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino, file_info.path_max_len = 255; file_info.path = calloc(file_info.path_max_len, 1); + retval = set_inode_xattr(fs, root, source_dir); + if (retval) { + com_err(__func__, retval, + _("while copying xattrs on root directory")); + goto out; + } + retval = __populate_fs(fs, parent_ino, source_dir, root, &hdlinks, &file_info, fs_callbacks); +out: free(file_info.path); free(hdlinks.hdl); return retval; -- 2.26.2