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

Paul Davis paul at linuxaudiosystems.com
Mon Jun 16 14:24:12 PDT 2008

On Mon, 2008-06-16 at 22:08 +0000, John Emmas wrote:
> ----- Original Message ----- 
> From: "John Emmas" <johne53 at tiscali.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?

there is no such thing as "exclusive" access open() unless its with
O_CREAT (i.e. the file is being created as well, and the app wants to
ensure that it didn't exist before, so that it has an exclusive handle
on a known-to-be-new file). O_CREAT|O_EXCL is common in Unix/POSIX
programs, O_EXCL is not because it doesn't really do anything useful.
See "man 2 open" for details.

POSIX doesn't offer mandatory file locking, only advisory file locking
via flock. Linux does offer mandatory file locking, via the fcntl(2)
system call. Support for it must be provided by the filesystem - its not
done by the kernel for any and all filesystems, and it must have been
enabled for the particular filesystem/partition in question.

More generally, your question is ill-formed. When a process opens a
file, it uses a path to refer to the file. Either the path already
exists, or it does not. If the open(2) call was made with O_CREAT and
the path doesn't exist, a new file will be created. If the open(2) call
was made without O_CREAT, then no new file will be created, and an error
will be returned. 

Opening and closing files has nothing to do with creating links, it only
alters the link count on the inode. 

More information about the Ardour-Dev mailing list