From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.parknet.co.jp (mail.parknet.co.jp [210.171.160.6]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0738F2BB09; Wed, 13 Mar 2024 12:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.171.160.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710333827; cv=none; b=szjkbKdGYsMlr9qH3xnr8gX1XRpxFldtCp9mIUw1w2qzgDdR8uRPPKiN0knQ+ccssDa6gdLECWRT0PO+ajfNeeeM860UaSdRgRw4aiIRRSbXAD+4dMpkwx3KvNikHgU4bMzJaCJRDKXkcEEoMTcSSuEaZNanbNRKMo9uDUv7W8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710333827; c=relaxed/simple; bh=JnCsaxUnb/cF6AyWmh2AiBaTUlyLUY6tgAL031/OaCY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=oPPPDzh20iNhEtm2RaPEJPbSRTwdwIvcV3OHrdwBzilVVltsGQipX/4jqIYGwLWRMlONEpPUw7D2PoMCaEk+hL5uPdCqIVNJayXLu9zN1vQWchkIOeZPBPF30wdHoI5Yj0F9l06Y0zYklfXX/W8rw6IW6iIGRKVMW082unYjaTM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mail.parknet.co.jp; spf=pass smtp.mailfrom=parknet.co.jp; arc=none smtp.client-ip=210.171.160.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mail.parknet.co.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=parknet.co.jp Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id 03914205DB9A; Wed, 13 Mar 2024 21:43:43 +0900 (JST) Received: from devron.myhome.or.jp (foobar@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.18.1/8.18.1/Debian-1) with ESMTPS id 42DChaQV220242 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 21:43:37 +0900 Received: from devron.myhome.or.jp (foobar@localhost [127.0.0.1]) by devron.myhome.or.jp (8.18.1/8.18.1/Debian-1) with ESMTPS id 42DChaaN1323405 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 13 Mar 2024 21:43:36 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.18.1/8.18.1/Submit) id 42DCharF1323404; Wed, 13 Mar 2024 21:43:36 +0900 From: OGAWA Hirofumi To: Thadeu Lima de Souza Cascardo Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gwendal Grignou , dlunev@chromium.org Subject: Re: [PATCH] fat: ignore .. subdir and always add a link to dirs In-Reply-To: (Thadeu Lima de Souza Cascardo's message of "Wed, 13 Mar 2024 08:16:50 -0300") References: <87le75s1fg.fsf@mail.parknet.co.jp> <87h6hek50l.fsf@mail.parknet.co.jp> <87cys2jfop.fsf@mail.parknet.co.jp> <878r2mk14a.fsf@mail.parknet.co.jp> <874jdajsqm.fsf@mail.parknet.co.jp> Date: Wed, 13 Mar 2024 21:43:36 +0900 Message-ID: <87zfv2i9on.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Thadeu Lima de Souza Cascardo writes: > On Wed, Mar 13, 2024 at 08:06:41PM +0900, OGAWA Hirofumi wrote: >> Thadeu Lima de Souza Cascardo writes: >> >> >> So you break the mkdir/rmdir link counting, isn't it? >> >> >> > >> > It is off by one on those images with directories without ".." subdir. >> > Otherwise, everything else works fine. mkdir/rmdir inside such directories work >> > without any issues as rmdir that same directory. >> >> mkdir() increase link count, rmdir decrease link count. Your change set >> a dir link count always 2? So if there are 3 normal subdirs, and rmdir >> all those normal dirs, link count underflow. >> >> Thanks. >> > > No. The main change is as follows: > > int fat_subdirs(struct inode *dir) > { > [...] > int count = 0; > [...] > - if (de->attr & ATTR_DIR) > + if (de->attr & ATTR_DIR && > + strncmp(de->name, MSDOS_DOTDOT, MSDOS_NAME)) > count++; > [...] > return count; > } > > int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) > { > [...] > if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) { > [...] > - set_nlink(inode, fat_subdirs(inode)); > + set_nlink(inode, fat_subdirs(inode) + 1); > [...] > } > > That is, when first instatiating a directory inode, its link count was set to > the number of subdirs it had, including "." and "..". Now it is set to 1 + the > number of subdirs it has ignoring "..". > > mkdir and rmdir still increment and decrement the parent directory link count. Ah, sorry, I misread. So next, it should create "." and ".." on initial create/mkdir or such, like mkdir does. Thanks. -- OGAWA Hirofumi