Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp765494ybh; Sat, 7 Mar 2020 09:45:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vt55BuqvmMk/cZAquELRnK5IWHAS4Qcq6BTFXcGZNnXUUEvT7u9URYAyozcPuJKKq6KZuwU X-Received: by 2002:aca:4e58:: with SMTP id c85mr6676557oib.115.1583603105481; Sat, 07 Mar 2020 09:45:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583603105; cv=none; d=google.com; s=arc-20160816; b=yhMGeEJ34PbluyENLvjKcHwBnLFYQ2JUFMd9q6inwDoZTs0yxuT7asJy9c6aLG/FZM 3fYqq2FwkZwrVcuMSq0ubXs6W5Zb3+4N92oBVCDp1ZqySriXcQcamsEZttFRVSGGMLNZ kgTmEneG4LGwunLpN0QRM8smTWEHcrhobUYUZgqiDyf/u21aMjWjgawyM2dhTmqqOsvs ENHZSc5Qaj8yhgY8fPCzpbDTe8p2r2+TML6RYdoLu3vJw105TuM9uS2B+l+bRGabSX7R hLfqhIv3WYV1cKqsGtoaaU4TSLrmVThLcX7ClYhpJSGrGiriSPuB7/VAYLLaPnVH6qI0 8KZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=oT2f+IFh3cz644h0ItPJ8hoE9bR/R6F6KF20vfZlgrM=; b=PzvAW5Dw9dRC4jzQczh68Alq/J2nGg+XA2yHcsafMiE0icDqgDWS5698sY5+blnrM/ ufOWdVJWPgf7AlGaHC02BOvWB/7i8M/zJR3wTpmukpitAN9NNw4S5Mw5M8QBK7WBdK5N b0+w4cZOKsjEJ/Tx1xiXrVfKGtggNWr+/+4vYt3qh82JXWLE9HlOlsHhol5gak5giJKC 41rbuN3ru2tWaz+zuQOary90cXI8MFHlHkmFBiBgJtr5zrcSHaB7bE/gmjMQKncCZ4OW fuxNTbtkWKVPNGf8jFjCJImBkINToYdX//DvKFq52EHeeWBv3Ue9+QYnOM4NeWBUk0K8 aVFw== 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 a21si1650965oib.166.2020.03.07.09.44.39; Sat, 07 Mar 2020 09:45:05 -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 S1726109AbgCGRnu (ORCPT + 99 others); Sat, 7 Mar 2020 12:43:50 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:43437 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726105AbgCGRnu (ORCPT ); Sat, 7 Mar 2020 12:43:50 -0500 Received: from callcc.thunk.org (pool-72-93-95-157.bstnma.fios.verizon.net [72.93.95.157]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 027Hhk56011289 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 7 Mar 2020 12:43:46 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 2DFE642045B; Sat, 7 Mar 2020 12:43:46 -0500 (EST) Date: Sat, 7 Mar 2020 12:43:46 -0500 From: "Theodore Y. Ts'o" To: Robert Yang Cc: linux-ext4@vger.kernel.org Subject: Re: [PATCH][e2fsprogs] misc/create_inode.c: set dir's mode correctly Message-ID: <20200307174346.GB99899@mit.edu> References: <1582542522-97508-1-git-send-email-liezhi.yang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1582542522-97508-1-git-send-email-liezhi.yang@windriver.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Feb 24, 2020 at 07:08:42PM +0800, Robert Yang wrote: > 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 Thanks for the report. I've fixed in a slightly different way: commit f106b01c98d7abc12af39aad4024f17ffa14dc06 Author: Theodore Ts'o Date: Sat Mar 7 12:35:48 2020 -0500 mke2fs: fix permissions setting with "mke2fs -d /path/files" Set the directory for directories in cases where the owner permissions is not rwx. This was reported[1] by Robert Yang but we are using a different approach to fixing the issue. [1] https://lore.kernel.org/r/1582542522-97508-1-git-send-email-liezhi.yang@windriver.com Also set the permissions in a more portable way by making a distinction between the host OS's permissions stats and Linux's permissions. We still assume the low 12 bits are the historical Unix assignments, but we don't assume ST_IFMT bits are the same as Linux's. Reported-by: Robert Yang Signed-off-by: Theodore Ts'o diff --git a/misc/create_inode.c b/misc/create_inode.c index 1d9a596e..e8d1df6b 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -124,7 +124,7 @@ 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; + inode.i_mode = (LINUX_S_IFMT & inode.i_mode) | (~S_IFMT & st->st_mode); inode.i_atime = st->st_atime; inode.i_mtime = st->st_mtime; inode.i_ctime = st->st_ctime; @@ -662,7 +662,7 @@ errcode_t do_write_internal(ext2_filsys fs, ext2_ino_t cwd, const char *src, com_err(__func__, 0, "Warning: inode already set"); ext2fs_inode_alloc_stats2(fs, newfile, +1, 0); memset(&inode, 0, sizeof(inode)); - inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG; + inode.i_mode = (statbuf.st_mode & ~S_IFMT) | LINUX_S_IFREG; inode.i_atime = inode.i_ctime = inode.i_mtime = fs->now ? fs->now : time(0); inode.i_links_count = 1;