[Ardour-Dev] GTK+ (concepts and advice)

Paul Davis paul at linuxaudiosystems.com
Mon Jun 16 14:49:22 PDT 2008

On Mon, 2008-06-16 at 21:51 +0000, John Emmas wrote:
> ----- Original Message ----- 
> From: "Fons Adriaensen" <fons at kokkinizita.net>
> Subject: Re: [Ardour-Dev] GTK+ (concepts and advice)
> >
> > This means you can 'copy' a file by just creating a new
> > entry in a directory - as long as you remain on the same
> > partition. The file data itself is not copied
> >
> Sometime last year I remember Paul and one of the other devs (possibly 
> Sampo?) showing me how I could take an entire directory branch (i.e. a 
> folder and all its subfolders) 

that would be the "mv" command.

> and very quickly graft it to some other 
> folder - but I hadn't realised that the same was true for copying.
> I suppose this raises some obvious questions:-
> 1)  If we have 2 x hard links to a particular file, can they each refer to 
> the file by a different name?

sure. demo:

sh% cd
sh% mkdir foobar
sh% cd foobar
sh% touch aNewFile
sh% ln aNewFile aNotherNameForNewFile
sh% ls -l aNewFile
sh% rm aNewFile
sh% ls -l aNewFile
sh% ls -l aNotherNameForNewFile
sh% cd 
sh% ln foobar/aNotherNameForNewFile aNameInADifferentDirectory
sh% ls -l aNameInADifferentDirectory

> 2)  Whether they can or they can't can both hard links be in the same 
> directory?

the only limit is that they have to be on the same partition. this is
because inodes are referred to by a number that is unique only across a
partition. inode 237389 on partition "foo" is a totally different file
than inode 237389 on partition "bar". there is no history in POSIX
operating systems for referring to an inode in a unique way that spans
all partitions except a path. i.e. /path/to/some/file is unique,
but /path/to/another/file might actually point to the same inode. to be
more specific, there is no object/convention for a (partition,inode)
tuple to uniquely identify a file, only paths. if you want to understand
why that is, there are many good books on the design of operating
systems. please pass them along to redmond when you're done reading
them :)

> 3)  Instead of me using fopen/fread on the source file and fopen'fwrite on 
> the destination file, what would be involved in creating one of these hard 
> links?

see the man page for the link system call ("man 2 link")


More information about the Ardour-Dev mailing list