List Info

Thread: Re: GTK+ (concepts and advice)




Re: GTK+ (concepts and advice)
user name
2008-06-16 15:01:37
On Mon, Jun 16, 2008 at 08:19:31PM -0000, John Emmas wrote:

> Interesting....  how complicated is it to use this
feature and how much
> faster is it - and why is "copying" in
inverted commas??  

In a Unix filesystem a directory is just a list of 

(file-or-directory-name, number).

All information about the file itself is not kept in the
directory but in a separate list of 'inodes' as they are
called, which is indexed by the number. There is one such
list oif inodes for each partition.

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 if you do 
this, there is just a new pointer to the inode created.
The inodes maintain a count of the number of directory
entries pointing to them. A file is deleted - the disk
space it occupies is marked as free - if the count becomes
zero. There is nothing special about the first 'original'
link which in most cases is the only one. Any other is
just as good. 

These are what is called 'hard' links. There are also
'soft' links - these are just a file containing the full
path name of another one, and treated specially by the
system.  Soft links exist in Windows as well (called
'shortcuts' IIRC), but hard links don't.

-- 
FA

Laboratorio di Acustica ed Elettroacustica
Parma, Italia

Lascia la spina, cogli la rosa.

_______________________________________________
ardour-dev mailing list
ardour-devlists.ardour.org
http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour
.org

Re: GTK+ (concepts and advice)
user name
2008-06-16 17:08:04
----- Original Message ----- 
From: "John Emmas" <johne53tiscali.co.uk>
Subject: Re: [Ardour-Dev] GTK+ (concepts and advice)
>
> I suppose this raises some obvious questions:-
>
Oh.... and a fourth obvious question....

4)  Suppose some process opens the file (for exclusive
access) using the
first hard link - then some other process tries to open it
using the second
hard link, does the second attempt fail or does a new (e.g.
temporary) copy
get created?

Thanks,

John

_______________________________________________
ardour-dev mailing list
ardour-devlists.ardour.org
http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour
.org

Re: GTK+ (concepts and advice)
user name
2008-06-16 16:51:43
----- Original Message ----- 
From: "Fons Adriaensen" <fonskokkinizita.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) 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?

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

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?

Thanks,

John



----- Original Message ----- 
From: "Fons Adriaensen" <fonskokkinizita.net>
To: <ardour-devlists.ardour.org>
Sent: 16 June 2008 20:01
Subject: Re: [Ardour-Dev] GTK+ (concepts and advice)


> On Mon, Jun 16, 2008 at 08:19:31PM -0000, John Emmas
wrote:
>
>> Interesting....  how complicated is it to use this
feature and how much
>> faster is it - and why is "copying" in
inverted commas??  
>
> In a Unix filesystem a directory is just a list of
>
> (file-or-directory-name, number).
>
> All information about the file itself is not kept in
the
> directory but in a separate list of 'inodes' as they
are
> called, which is indexed by the number. There is one
such
> list oif inodes for each partition.
>
> 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 if you
do
> this, there is just a new pointer to the inode
created.
> The inodes maintain a count of the number of directory
> entries pointing to them. A file is deleted - the disk
> space it occupies is marked as free - if the count
becomes
> zero. There is nothing special about the first
'original'
> link which in most cases is the only one. Any other is
> just as good.
>
> These are what is called 'hard' links. There are also
> 'soft' links - these are just a file containing the
full
> path name of another one, and treated specially by the
> system.  Soft links exist in Windows as well (called
> 'shortcuts' IIRC), but hard links don't.
>
> -- 
> FA
>
> Laboratorio di Acustica ed Elettroacustica
> Parma, Italia
>
> Lascia la spina, cogli la rosa.
>
> _______________________________________________
> ardour-dev mailing list
> ardour-devlists.ardour.org
> http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour
.org 

_______________________________________________
ardour-dev mailing list
ardour-devlists.ardour.org
http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour
.org

Re: GTK+ (concepts and advice)
user name
2008-06-16 16:54:00
On Mon, Jun 16, 2008 at 09:51:43PM -0000, John Emmas wrote:

> 1)  If we have 2 x hard links to a particular file, can
they each refer to 
> the file by a different name?
>
> 2)  Whether they can or they can't can both hard links
be in the same 
> directory?

If by 'name' you mean the complete path, then of course
they
have to be different, otherwise there's only one name.

Apart from that, you can have 

/dir1/file.dat
/dir2/file.dat

pointing to the same inode, and hence the same file,
and also

/dir/file1.dat
/dir/file2.dat

can point to the same inode, and the same file.

> 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?

On the command line, the commands are 'ln' to create a new
link,
and 'rm' to remove one.

>From C, you use

  int link (const char *oldpath, const char *newpath);

and

  int unlink (const char *path);

both declared in <unistd.h>

Ciao,

-- 
FA

Laboratorio di Acustica ed Elettroacustica
Parma, Italia

Lascia la spina, cogli la rosa.

_______________________________________________
ardour-dev mailing list
ardour-devlists.ardour.org
http://lists.ardour.org/listinfo.cgi/ardour-dev-ardour
.org

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )