2

I'm working on a project where i rely mostly on the file's extended attribute that i set when i create the file. But i'm facing problem while modifying the file.

Solid Example:

When i edit the file in Sublime Text, all the extended attributes are preserved, also the inode value remains the same as before. But when i do the same in Gedit, it is creating new file instead of modifying the existing one. So inode value, user defined/extended attributes are not preserved.

I see this problem is due to the copying behavior of Gedit. But is there a way to preserve them while using Gedit?

3
  • i think that is becaus how gedit works programatically, and is not there a way to preserve that values. Aug 20 '15 at 20:45
  • 1
    Should i report it as a gedit bug? Or should we live with that?
    – iamprem
    Aug 20 '15 at 21:02
  • im not sure really but have you seen when you start to edit a file it create a file with ~ , that haves your current work and when you save your original rodument should be replaced by that. . Aug 21 '15 at 11:17
0

You just can't.

It's a fault in how the file system is working but also an error in gedit that should be reported.

The problem is that you want to have a file change atomically but there is no way other than just write both file and use rename to do an atomic file swap. But unfortuantely most programmers don't handle special cases well and still think a file is a sequence of bytes (it never was on unix because of sparse files).

What would be required would be a content switching API for a file that only switches the file block pointers, but Linux refuses this, because most think a 40 year old design is good enough.

It's definitely a bug that Gedit is not copying the extended attributes. But the inode can't be preserved (it's one of the most important meta data of a file, it's identity) this way.

Most KDE tools usually don't create swap files but just truncate and overwrite the content assuming that crashs in the middle of a save are unusal today. I think this is the best way as it also preserves the inode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.