1833756 Members
3019 Online
110063 Solutions
New Discussion

Editing linked files

 
SOLVED
Go to solution
Wendi Whetsel
New Member

Editing linked files

I am trying to figure out the "rules" for editing linked files. If the original file and someone tries to access the file from the link, shouldn't they be warned that the file is being edited else where? I am testing this in vi. Can someone share some insight on the subject of ln.
5 REPLIES 5
Alan Riggs
Honored Contributor
Solution

Re: Editing linked files

There is no warning. A soft link is simply a poiner to the inode information of the original file. A hard link is a new inode netry that references the same data as the original file. In neither case is a link "aware" of the existence of other links. vi does not prevent multiple users/sessions from simultaneously editing a file regardless of whether links are involved. Last one out wins.
Wendi Whetsel
New Member

Re: Editing linked files

Is there any editor that monitors open sessions? And what is the point of links if it doesn't save your from overwriting concurrent edits.
Steven Sim Kok Leong
Honored Contributor

Re: Editing linked files

Hi,

In my opinion,links are meant to be readable than writeable.

If you want to lock management when the link and the file is concurrently accessed, you can either use CVS or, write a script to always follow the link to its regular file and load the regular file in the editor eg. "vilink file", and subsequently pass the control to vi.

vilink:
======
#/sbin/sh
if [ -L $1 ] # if argument is a link
then
vi `ls -l $1 | cut -d\> -f2`
else
vi $1
fi
======

Hope this helps. Regards.

Steven Sim Kok Leong.
Brainbench MVP for Unix Admin
http://www.brainbench.com
Alan Riggs
Honored Contributor

Re: Editing linked files

If you want to prevent wimultaneous edits, use any type of revision control system. RCS (ci, co) comes native in HP-UX.

As to links, they have several uses. Soft links are often used to provide transitional links when the location of files has changed (after version upgrades, for instance). Soft links can also be used to ease space demands on small filesystems by "shifting" the data load elsewhere. Hard links can be used to protect access to data from being accidently lost by a careless rm. So long as one hard link remains, the data is still available.
James R. Ferguson
Acclaimed Contributor

Re: Editing linked files

Hi:

...some more useful information on soft (symbolic) links.

When a 'chown' is executed, by default, the owner or group of the target file that a symbolic link points to is changed. If the '-h' chown option is used, the target file that the symbolic link points to is not affected.

By default, a 'find' does not follow symbolic links. The '-follow' option of find can be used to change this behavior.

...JRF...