From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustav Munkby Subject: Re: [PATCH] hfsplus: read support for directory hardlinks Date: Wed, 04 May 2011 17:04:18 +0200 Message-ID: <4DC16AF2.6010000@gmail.com> References: <1304072452-6590-1-git-send-email-grddev@gmail.com> <20110502084631.GA14670@lst.de> <20110502124048.GL9487@ZenIV.linux.org.uk> <4DC00D13.5060903@gmail.com> <20110504093025.GA30023@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Al Viro , linux-fsdevel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:62659 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754391Ab1EDPE7 (ORCPT ); Wed, 4 May 2011 11:04:59 -0400 Received: by eyx24 with SMTP id 24so383880eyx.19 for ; Wed, 04 May 2011 08:04:58 -0700 (PDT) In-Reply-To: <20110504093025.GA30023@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 05/04/2011 11:30 AM, Christoph Hellwig wrote: > On Tue, May 03, 2011 at 04:11:31PM +0200, Gustav Munkby wrote: >> On 05/02/2011 02:40 PM, Al Viro wrote: >>> What happens to rename() with that thing? Specifically, what happens to >>> loop detection? >> >> Good point. >> >> Since my main interest was retrieving contents of a backup, I did not much >> consider the impact of write operations. Before the patch, the source files were >> exposed as normal files, and the target directories as normal directories, so >> one could easily have introduced loops with rename operations before. > > Given that you have the filesystem around can you clarify where the additional > directory links live? I was under the impression they are in hidden backup > directories not normally accessible, so there's always just one link in the > normal namespace. > > The basic idea would be that we allow any kind of renames in the normal > namespace, but disallow any kind of operation involving the time machine > backups. > You are correct, the hardlink targets are all inside a hidden private directory. And then there are hardlink sources both inside and outside this hidden directory linking to directories inside this directory. While the hidden directory is not directly accessible to clients, its subdirectories are through the hardlinks. Perhaps it was obvious to everyone else, but I just realized that it is not enough to prevent moving the directory hardlinks themselves, but all directory renames must be limited (or checked), since the old directory might contain a nested directory hardlink.Disallowing renames of directories altogether is clearly not a viable option. The following three (somewhat overlapping) classes of renames should always be possible without any risk for introducing loops. 1) Allow renames where target directory is an ancestor of source directory. 2) Allow renames that doesn't change the closest hardlink ancestor. 3) Allow renames into target directories without hardlinked parents. The first check seems simple enough to implement, but the other two might require additional locking as far as I understand. Alternatively, they could both be implemented by adding some additional flags/data to dentry->d_fsdata.