linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Gwendal Grignou <gwendal@chromium.org>,
	dlunev@chromium.org
Subject: Re: [PATCH] fat: ignore .. subdir and always add a link to dirs
Date: Wed, 13 Mar 2024 21:43:36 +0900	[thread overview]
Message-ID: <87zfv2i9on.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <ZfGLIl7riu0w2pAm@quatroqueijos.cascardo.eti.br> (Thadeu Lima de Souza Cascardo's message of "Wed, 13 Mar 2024 08:16:50 -0300")

Thadeu Lima de Souza Cascardo <cascardo@igalia.com> writes:

> On Wed, Mar 13, 2024 at 08:06:41PM +0900, OGAWA Hirofumi wrote:
>> Thadeu Lima de Souza Cascardo <cascardo@igalia.com> 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 <hirofumi@mail.parknet.co.jp>

      reply	other threads:[~2024-03-13 12:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 20:30 [PATCH] fat: ignore .. subdir and always add a link to dirs Thadeu Lima de Souza Cascardo
2024-02-23  1:52 ` OGAWA Hirofumi
2024-02-23  2:02   ` Thadeu Lima de Souza Cascardo
2024-02-23  8:27     ` OGAWA Hirofumi
2024-02-23  8:32       ` OGAWA Hirofumi
2024-02-23  9:58         ` Thadeu Lima de Souza Cascardo
2024-02-23 12:29           ` OGAWA Hirofumi
2024-02-23 13:16             ` Thadeu Lima de Souza Cascardo
2024-02-23 13:33             ` Thadeu Lima de Souza Cascardo
2024-02-28  1:42             ` Thadeu Lima de Souza Cascardo
2024-02-28  3:38               ` OGAWA Hirofumi
2024-02-28  9:10                 ` Thadeu Lima de Souza Cascardo
2024-03-04 23:37                   ` Thadeu Lima de Souza Cascardo
2024-03-05  4:14                     ` OGAWA Hirofumi
2024-03-10  5:52                   ` OGAWA Hirofumi
2024-03-10 10:14                     ` Thadeu Lima de Souza Cascardo
2024-03-10 14:59                       ` OGAWA Hirofumi
2024-03-13  7:58                         ` Thadeu Lima de Souza Cascardo
2024-03-13  8:05                           ` OGAWA Hirofumi
2024-03-13  8:41                             ` Thadeu Lima de Souza Cascardo
2024-03-13 11:06                               ` OGAWA Hirofumi
2024-03-13 11:16                                 ` Thadeu Lima de Souza Cascardo
2024-03-13 12:43                                   ` OGAWA Hirofumi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zfv2i9on.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=cascardo@igalia.com \
    --cc=dlunev@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).