Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1687118lql; Wed, 13 Mar 2024 05:43:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5Q2Qqa8sKO0+KCy5+9OklQuVAO7f+pzl7Lihu+HsxaCJVvAVspTe1yyqpdOzBeqWL18Z14tUAixla7JdlUWj/dhua9Mxi32EH3TyUTw== X-Google-Smtp-Source: AGHT+IEaI0UOO1NE9k/9HkpR6QjKkk2u06RwNtdNjpdd1P4WhKDEMENOQBwqqFj0n3gJTMC14h/a X-Received: by 2002:a05:622a:4ce:b0:42f:210d:e6ff with SMTP id q14-20020a05622a04ce00b0042f210de6ffmr15525921qtx.45.1710333837375; Wed, 13 Mar 2024 05:43:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710333837; cv=pass; d=google.com; s=arc-20160816; b=qylPq3tILkIzWbK9or8Res/IR5AZ4tKn4XUojzogm9jfGS92xI0M+qfBNBSz8/fAMD MZazHs+0Y7dmuFTElAZ4Lluy/mOnR31q3UIYlwRbQOTil14eZDWBavldEWd0hjhg54ei dJmjix1Nmf4dgX1DU6lblBRU6hdmcfOM3ZPhvTZk1M/50gDjrdYyVtKOBJZgtRb1UwR/ +ExN0aTJxYnu8xbQA9gz0Mm4L/rCvFfsfc+C4hBHcLfx+oNEofaCISsn/9hS8Nh+F1XJ JoOr++IqQ5jmWXnaJ38ZNoBFT0G5qQCq40oyX25u1v0ls67E6odpcmiAUn52GvEQJank awvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from; bh=LZJEW1A3os6H5uPis+5vlNYZFqvj0ApKn/wgCouQCuY=; fh=8fMNz5XLes1q6KgZpQVNR7IFjb0t+7u9G1PE29ucuLE=; b=GHpWfqY8sBHqm4zfXna8xnr+fcvfK0mutClaKRGbKPrAshhEwcNG8pvk9rywXA3EHQ 7K8CCVxNQoLevoDplrP0XSGP4Y0UhO3/IZSZkfnO449tuNT/Nt74qNMWCFdyB5LglQif v8W/ZaYJZB0nEro2Q6+/BmBwNLX3vOq7NsB3M5LtqKPLJkUXKEbdGklrg8+V7LOFFMWo i0eLajjt34ncL8UPl5iQ+pQgqT0FOM6+48WbZDmwfSQLVIT1LG9eab26k2w4Jz3N+iwc BE38FFLP8557Gf8SeQden/GCtxRSrTl5UN52d/e+r8TOwKsD5X/lBfOiSk2//E1ertln NH/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=parknet.co.jp); spf=pass (google.com: domain of linux-kernel+bounces-101486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101486-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e8-20020ac85988000000b0043095cd703asi422332qte.405.2024.03.13.05.43.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 05:43:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=parknet.co.jp); spf=pass (google.com: domain of linux-kernel+bounces-101486-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101486-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1FCB31C22739 for ; Wed, 13 Mar 2024 12:43:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 853343E498; Wed, 13 Mar 2024 12:43:47 +0000 (UTC) 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