linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesse Pollard <jesse@cats-chateau.net>
To: Stephan von Krawczynski <skraw@ithnet.com>
Cc: aebr@win.tue.nl, linux-kernel@vger.kernel.org
Subject: Re: FS: hardlinks on directories
Date: Tue, 5 Aug 2003 09:12:31 -0500	[thread overview]
Message-ID: <03080509123100.05972@tabby> (raw)
In-Reply-To: <20030805003210.2c7f75f6.skraw@ithnet.com>

On Monday 04 August 2003 17:32, Stephan von Krawczynski wrote:
> On Mon, 4 Aug 2003 16:09:28 -0500
>
> Jesse Pollard <jesse@cats-chateau.net> wrote:
> > > tar --dereference loops on symlinks _today_, to name an example.
> > > All you have to do is to provide a way to find out if a directory is a
> > > hardlink, nothing more. And that should be easy.
> >
> > Yup - because a symlink is NOT a hard link. it is a file.
> >
> > If you use hard links then there is no way to determine which is the
> > "proper" link.
>
> Where does it say that an fs is not allowed to give you this information in
> some way?
>
> > > > It was also done in one of the "popular" code management systems
> > > > under unix. (it allowed a "mount" of the system root to be under the
> > > > CVS repository to detect unauthorized modifications...).
> > > > Unfortunately, the system could not be backed up anymore. 1. A dump
> > > > of the CVS filesystem turned into a dump of the entire system... 2.
> > > > You could not restore the backups... The dumps failed (bru at the
> > > > time) because the pathnames got too long, the restore failed since it
> > > > ran out of disk space due to the multiple copies of the tree being
> > > > created.
> > >
> > > And they never heard of "--exclude" in tar, did they?
> >
> > Doesn't work. Remember - you have to --exclude EVERY possible loop. And
> > unless you know ahead of time, you can't exclude it. The only way we
> > found to reliably do the backup was to dismount the CVS.
>
> And if you completely run out of ideas in your
> wild-mounts-throughout-the-tree problem you should simply use "tar -l".
>
> And in just the same way fs could provide a mode bit saying "hi, I am a
> hardlink", and tar can then easily provide option number 1345 saying "stay
> away from hardlinks".

Do you know what a hard link is? Or a directory entry?

A directory is a file of records with two fields: an inode number, and a
name (string).

Nothing else.

The "hard link" is the inode number. The count of hard links is maintained in 
the inode data structure. One for each (inode, filename) entry in a directory.

Multiple hard links are just having the same inode number used with two names.
Those two names do not have to exist in the same directory.

A directory is a special file. It has a bit that says "hi, i am a directory".
At a minimum it contains two implicit hard links. One to itself, and one to
it's parent. The parent inode is also a directory. The parent, in addition to
its own two hard links, contains a (inode, name) pair where the inode number
is the same as the inode number for the subdirectory. This way each directory
inode ALWAYS has a minimum of two hard links - the one to itself, and the one
from its' parent.

This implements the tree. It permits the concept of "working directory" with
relative path names ("../.." and "./name" contstructs).

What you say when you want additional hard links to a directory is that a
directory will have two (or more) parents.

If the fs provides a mode bit to identify something different that points to
a directory, then you have a SYMLINK. This is because the directory entry
currently only carries inode,name pairs. -- logically carries. Specific
implementations may have ANY choice implementation of a directory file, tree,
hash, whatever. To the VFS it always appears as if it were a linear file 
containing inode,name pairs.

The entry for a symlink is still (inode, name), but the inode structure
referenced contains a bit that says "hi, i am a symlink". The system THEN
knows that the data contents of the inode point to another file. It doesn't
matter whether that file is a regular file, a directory file, or a device
file.

> If you can do the fs patch, I can do the tar patch.

The patch is FAR too extensive. It would have to be a whole new filesystem
where a directory entry would have to carry additional information. And a
rather large patch to the VFS to support it. And a new fsck to try and 
maintain it. Directory locking would no longer be reliable. And modifications
to various system calls and facilities (unlink, link, namei, open, opendir, 
readdir, ...) Certain Linux features would have to be disallowed ("mv dir 
../otherdir" for instance could generate backward loops).

Tar would have to maintain a "pathname,inode" array for each file it backed
up, so that it could verify that if "inode" is already copied, the new name
is the only thing copied... (some graphs will cause the array to grow without
bounds... so watch it...).

It would be interesting in the abstract - as in using a datafile to store
the graph, utilities to insert, delete, store data, retrieve data, 
import/export data.. Fsck would have to be implemented with a "mark and
sweep" garbage collector.

Hmmmm It would support an augmented transition matrix.... (ie most computer
games are ATMs... as are large simulations...)

As a Unix filesystem... It doesn't fit. (which is one reason databases
are used to implement ATMs... The database backup ignores the contents
other than to copy data in/out. The application program uses the data as
an ATM, and the application has to deal with consistancy.)

  parent reply	other threads:[~2003-08-05 14:13 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-04 12:15 FS: hardlinks on directories Stephan von Krawczynski
2003-08-04 12:45 ` Måns Rullgård
2003-08-04 13:22   ` Stephan von Krawczynski
2003-08-04 13:37     ` Christian Reichert
2003-08-04 13:44       ` Stephan von Krawczynski
2003-08-04 14:22         ` Christian Reichert
2003-08-04 15:31     ` Jeff Muizelaar
2003-08-04 16:15       ` Stephan von Krawczynski
2003-08-05  2:45         ` Neil Brown
2003-08-05  9:41           ` Stephan von Krawczynski
2003-08-06  1:12             ` Neil Brown
2003-08-06 10:14               ` Stephan von Krawczynski
2003-08-07  2:27                 ` Neil Brown
2003-08-04 12:47 ` Nikita Danilov
2003-08-04 13:32   ` Stephan von Krawczynski
2003-08-04 13:44 ` Andries Brouwer
2003-08-04 13:56   ` Stephan von Krawczynski
2003-08-04 14:04     ` Anton Altaparmakov
2003-08-04 14:50       ` Stephan von Krawczynski
2003-08-04 20:03         ` Olivier Galibert
2003-08-04 21:16         ` Jesse Pollard
2003-08-04 23:34           ` Stephan von Krawczynski
2003-08-05 14:20             ` Jesse Pollard
2003-08-05 14:44               ` Stephan von Krawczynski
2003-08-04 22:58         ` Andrew Pimlott
2003-08-05  0:19           ` Stephan von Krawczynski
2003-08-05  1:18             ` Andrew Pimlott
2003-08-05  8:04               ` Stephan von Krawczynski
2003-08-05 11:18                 ` Wakko Warner
2003-08-04 14:33     ` Jesse Pollard
2003-08-04 15:05       ` Stephan von Krawczynski
2003-08-04 15:57         ` Richard B. Johnson
2003-08-04 21:23           ` Jesse Pollard
2003-08-04 16:11         ` Adam Sampson
2003-08-04 17:00         ` Hans Reiser
2003-08-04 17:18           ` Sean Neakums
2003-08-05  4:53           ` jw schultz
2003-08-04 18:50         ` jlnance
2003-08-04 21:09         ` Jesse Pollard
2003-08-04 22:13           ` Stephan von Krawczynski
2003-08-04 22:32           ` Stephan von Krawczynski
2003-08-04 23:00             ` Randolph Bentson
2003-08-05  0:10               ` Stephan von Krawczynski
2003-08-05  2:09                 ` Edgar Toernig
2003-08-05  8:05                   ` Stephan von Krawczynski
2003-08-05 12:51             ` Helge Hafting
2003-08-05 13:03               ` Stephan von Krawczynski
2003-08-05 13:13                 ` Bernd Petrovitsch
2003-08-05 13:39                   ` Stephan von Krawczynski
2003-08-05 13:36                 ` Richard B. Johnson
2003-08-05 14:04                   ` Stephan von Krawczynski
2003-08-05 14:57                     ` Richard B. Johnson
2003-08-05 15:08                       ` Stephan von Krawczynski
2003-08-05 15:02                     ` Jesse Pollard
2003-08-05 15:12                       ` Stephan von Krawczynski
2003-08-05 15:44                       ` Trond Myklebust
2003-08-05 14:56                   ` Jesse Pollard
2003-08-05 22:08                 ` Helge Hafting
2003-08-24 17:35                   ` Hans Reiser
2003-08-24 19:02                     ` Helge Hafting
2003-08-25  8:27                     ` Nikita Danilov
2003-08-25 15:48                       ` Hans Reiser
2003-08-05 14:12             ` Jesse Pollard [this message]
2003-08-05 14:21               ` Stephan von Krawczynski
2003-08-05 15:53                 ` Herbert Pötzl
2003-08-04 20:47     ` Jan Harkes
2003-08-04 15:42   ` Brian Pawlowski
2003-08-04 15:56     ` Stephan von Krawczynski
2003-08-04 16:16       ` Herbert Pötzl
2003-08-04 16:35         ` Stephan von Krawczynski
2003-08-04 16:54           ` Herbert Pötzl
2003-08-04 17:18             ` Stephan von Krawczynski
2003-08-04 17:25               ` Herbert Pötzl
2003-08-04 21:38           ` Jesse Pollard
2003-08-05  0:06             ` Stephan von Krawczynski
2003-08-05  3:11           ` Neil Brown
2003-08-04 21:29       ` Jesse Pollard
2003-08-04 23:42         ` Stephan von Krawczynski
2003-08-05 16:46           ` viro

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=03080509123100.05972@tabby \
    --to=jesse@cats-chateau.net \
    --cc=aebr@win.tue.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=skraw@ithnet.com \
    /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).