Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2313360ybv; Mon, 24 Feb 2020 03:07:29 -0800 (PST) X-Google-Smtp-Source: APXvYqxw+zp+PxJseKN7JyRfqCJqM2iwoX8J8bNxKP5Pc3lLIaQlik1Ac9ktd8R5o7VwyXsYyrHI X-Received: by 2002:aca:1704:: with SMTP id j4mr11445453oii.12.1582542449170; Mon, 24 Feb 2020 03:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582542449; cv=none; d=google.com; s=arc-20160816; b=h8l7n312brd7BAw5gLHDYK2mkNiZ9H5Y+w2AKMyMRJRJwo9OI9EJAt3SGuDUyjTAHq stuQ9DUnAC1MndlmH4XRzbPkcV9LxoSLlxvcHrrLbyZXxpEeyekU3JwIf+6YM/9E7LWl 22BzPebkOmMMuqCQWh77JiDAONyR6xIh21w/02EoXZpqwKaYR/EoIvimBPeABx/ErOxl PyowS+A38QyzTTqJA/9DGQUNZ0NSQ3aOaKHmenWxLDCGCupsOUzpyxwQrt/zDUYOxs+A y3+7VG+mHRQANVg9LhIEeK0AKUiHLzmmPunBVDynoLoqZF5FmbV0QrhULYjbab8c5rZ9 BtYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=DiBYU02f2gI+pdwLFPhiANM6kbzShVZgvOqBjoZlZBo=; b=G1j4P1We0W30MRUx9kbQ1YiCyqaFT8y2l4O2tJ+tJ4JCSYQl9LXIBzyUB6L5PFbcUl A/ZmRIR05oDJeCD9Vwq6l3yAznP/Y1oZzy9xUp7F6Nzt2dkGztR71NFXWHOTx1TR+Cer Xl4M84FwsyWK51Sbl5xOBY9cr/uDiVrGhrJY37kJHWnDVA1z0Phf6PmrTFQAApi7WR61 54Xty5Po52PKAAF96YnAD61QK5wCb+iGjSbBN0fb/HXAhAG3NyjX5PZZvKlvOPfp+cOu Lp2dFmBsgJ/zO9d9fDepw5ctWTKaxWx+/MwD6Ib4icAyCVJLpsGuoBnDqGKk04eBpSAD ooCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k16si4755943oiw.128.2020.02.24.03.06.57; Mon, 24 Feb 2020 03:07:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgBXLGw (ORCPT + 99 others); Mon, 24 Feb 2020 06:06:52 -0500 Received: from mail.windriver.com ([147.11.1.11]:49339 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726509AbgBXLGw (ORCPT ); Mon, 24 Feb 2020 06:06:52 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id 01OB6hT8007746 (version=TLSv1 cipher=AES256-SHA bits=256 verify=FAIL); Mon, 24 Feb 2020 03:06:43 -0800 (PST) Received: from pek-lpg-core1.wrs.com (128.224.156.132) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server id 14.3.468.0; Mon, 24 Feb 2020 03:06:43 -0800 From: Robert Yang To: CC: Subject: [PATCH][e2fsprogs] misc/create_inode.c: set dir's mode correctly Date: Mon, 24 Feb 2020 19:08:42 +0800 Message-ID: <1582542522-97508-1-git-send-email-liezhi.yang@windriver.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The dir's mode has been set by ext2fs_mkdir() with umask, so reset it to the source's mode in set_inode_extra(). Fixed when source dir's mode is 521, but dst dir's mode is 721 which was incorrect. Signed-off-by: Robert Yang --- misc/create_inode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/misc/create_inode.c b/misc/create_inode.c index 5161d5e..f82f74e 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -124,7 +124,14 @@ static errcode_t set_inode_extra(ext2_filsys fs, ext2_ino_t ino, ext2fs_set_i_uid_high(inode, st->st_uid >> 16); inode.i_gid = st->st_gid; ext2fs_set_i_gid_high(inode, st->st_gid >> 16); - inode.i_mode |= st->st_mode; + /* + * The dir's mode has been set by ext2fs_mkdir() with umask, so + * reset it to the source's mode + */ + if S_ISDIR(st->st_mode) + inode.i_mode = LINUX_S_IFDIR | st->st_mode; + else + inode.i_mode |= st->st_mode; inode.i_atime = st->st_atime; inode.i_mtime = st->st_mtime; inode.i_ctime = st->st_ctime; -- 2.7.4