Re: [gedit-list] Gedit and Hard Links
- From: Oran Fry <oranfry cs waikato ac nz>
- To: gedit-list gnome org
- Subject: Re: [gedit-list] Gedit and Hard Links
- Date: Fri, 02 Mar 2007 15:40:11 +1300
For those interested, I have come up with a fairly ad-hod solution to
this problem:
Write a shell script like this and save it ( I saved to to ~/.igedit )
gedit $1
cp $1 $1~
mv $1~ $1
* make it executable
chmod a+x ~/.igedit
* add it to .profile as an alias
alias igedit='~/.igedit'
Now, whenever I want to edit a file 'safely' (that is, without changing
the inode that the file is stored in), i run:
igedit /path/to/file
And when gedit exits, it sorts the files out so that the original file
has the original inode number
It is not a perfect solution. Running igedit with gedit already open
would cause some unexpected behavior. Also, saving a file twice in a
single session would stop the script from working properly.
A better solution would be to edit the part of the gedit code which
makes the backup. Someone might want to do this, and give the user the
choice between the current behavior and the behavior that I have
outlined. Perhaps it is already in there, in fact. I know that Emacs has
the option ( something about 'setq *backup-by-copying-when-linked* t').
I only signed up to the mailing list today so I wouldn't know how to
sumbit it as a feature request, but I might look into it.
Thanks,
Oran.
---------------------
Original Message:
Hi folks,
I am having problems editing a file which has more than one hard link to
it on disk. The problem seems to come from the fact that the backup file
is not another physical copy of the file, but the original file itself!
And the file being edited is the copy. To demonstrate, I ran these commands:
$ echo 'some text' > file1
$ ln file1 file2
$ ls -i1
180819 file1
180819 file2
(this puts some text into file1, and creates a hard link to the same
'inode', called file2. The number printed in front of the filenames here
is the inode number, and we can see that file1 and file2 are indeed
links to the same inode)
$ gedit file2
(run gedit on file2 and append the text 'some more text' )
$ more file2
some text
some more text
(as I expected, the text has been properly appended in file2)
$ more file1
some text
(contrary to what I expected, the text has NOT been appended in file1)
$ s -i1
180819 file1
192210 file2
180819 file2~
(this makes it clear what has happened. The backup file 'file2~' is
a hard link to the same inode as file1, and file2 is a new file)
Does anyone know how to change this behavior in gedit? That is, to make
gedit put the backup in a new inode, and leave the original file in the
original inode?
$ gedit --version
Gnome gedit 2.10.3
Thanks,
Oran.
_______________________________________________
gedit-list mailing list
gedit-list gnome org
http://mail.gnome.org/mailman/listinfo/gedit-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]