News for hackers. Stuff that matters.
Re:Dotfile madness by nine_k on Saturday February 02, 2019 @12:17PM (#19064197)
Adding an interface to access the tag store won't be very hard.

It would be harder to make it so that all the tag-oblivious programs, like mv or vi, to say nothing of rsync, would preserve the attributes when moving or modifying a file.

Re:Dotfile madness by netsec_burn on Saturday February 02, 2019 @12:24PM (#19064241)
Sounds like you might need to hook rename() if you'd like to add that feature too, but I would still say it's straightforward.
Re:Dotfile madness by nine_k on Saturday February 02, 2019 @12:33PM (#19064297)
The way most editors save a file is like this:

  f = open("the_file.new")
  write(f, new_contents);
  close(f);
  rename("the_file", "the_file~");
  rename("the_file.new", "the_file");
So the old file is never modified, it's renamed to the backup copy, and an entirely new file is created to take its place.

This has a number of advantages, but does not play well with any extended info the old file used to have, unless they are copied explicitly. And in a tagging-oblivious program, they won't be.

Re:Dotfile madness by 6c696e7578 on Saturday February 02, 2019 @01:40PM (#19064763)
I see a lot of saves work like this:

    f = open( "the_file.new.$$" );
    write( f, new_contents );
    close( f );
    rename( "the_file.new.$$", "the_file.new" )
If not implemented like this, then something that attempts to read "the_file.new" may get partial contents, normally truncated along the file system block size.

Backups often take place, too, like you mentioned, depending on editor.

Re:Dotfile madness by notyourday on Saturday February 02, 2019 @02:08PM (#19064958)
If you do not rename files while holding their open file descriptors there's no guarantee that you are renaming the file you just wrote to.
Re:Dotfile madness by JdeBP on Saturday February 02, 2019 @06:21PM (#19066523)
There is no guarantee of that if one does retain the open file descriptor.
Re:Dotfile madness by notyourday on Monday February 04, 2019 @11:26AM (#19077604)
before rename:

fstat the fd, get st_dev and st_ino.

rename

stat the new name. Compare st_dev and st_ino.

If the value matches, you renamed the right file. If it does not match, you renamed a wrong file. Without holding the fd, it is impossible to know if it is the right file.

Re:Dotfile madness by JdeBP on Monday February 04, 2019 @11:34AM (#19077673)
"you renamed a wrong file" shows that "there's no guarantee that you are renaming the file you just wrote to".
Re:Dotfile madness by notyourday on Monday February 04, 2019 @11:38AM (#19077704)
In this case you know that you renamed a wrong file. In the close before rename you do not know that you have renamed a wrong file.
Re:Dotfile madness by JdeBP on Tuesday February 05, 2019 @06:16AM (#19084304)
Knowing that something bad happened after the fact is not the same as your idea that there's a guarantee that something bad will not happen.
Re:Dotfile madness by netsec_burn on Saturday February 02, 2019 @12:40PM (#19064350)
Thanks for teaching me this! I wasn't aware. So, the original xattr (and the program that created it) would be deleted and replaced by vi for example. Still technically right, but I'm unsure how you'd keep a history.
Re:Dotfile madness by sneak on Saturday February 02, 2019 @12:27PM (#19064260)
Sidecar files might work, and would also be filesystem-portable.
Re:Dotfile madness by amaccuish on Saturday February 02, 2019 @12:49PM (#19064422)
Please no. This article is literally "Dotfile madness", don't make it worse!

I have to deal already with these on file shares, specifically for Apple: .DS_Store, .Trashes and .AppleDouble, or for Windows: Thumbs.db, $RECYCLE.BIN (for some reason Windows sometimes ignores the fact I've disabled the recycle bin on a share and creates this instead) and desktop.ini. Please don't drop crap around directories where there exist a multitude of tidier alternatives.

Re:Dotfile madness by sneak on Saturday February 02, 2019 @12:52PM (#19064448)
How do you have to “deal with” them? What are the portable tidier alternatives?
Re:Dotfile madness by amaccuish on Saturday February 02, 2019 @03:02PM (#19065316)
Because when you have multiple OSs accessing the same shared folder, they all create their own crap, which is then visible to the other OSs, and fills up directories with stuff that confuses normal users.
Re:Dotfile madness by sneak on Sunday February 03, 2019 @02:41PM (#19071719)
Normal users don’t run multiple OSes.
Re:Dotfile madness by tripzilch on Sunday February 03, 2019 @03:48PM (#19072092)
I don't run multiple OSes, but I do use USB sticks and SD cards on other people's computers and vice versa. I'm pretty sure that is "normal user" behaviour.

It gets annoying real quickly because you see the "crap" files of all the OSes you're not using. And you delete them, you only have to insert the stick and they're back. This happens in different ways for all of Mac, Windows, Android and certain Linuxes.

Re:Dotfile madness by amaccuish on Monday February 04, 2019 @06:12AM (#19075399)
Some users however access our file shares from their Macs, or their Windows PCs, or even some from their Linux machines. That's fairly normal.
Re:Dotfile madness by featherrust on Saturday February 02, 2019 @02:50PM (#19065230)
A daemon with a CLI and a programmatic interface, backed by a SQLite store, hooked into Linux audit and perhaps an LD_PRELOAD?
Re:Dotfile madness by recursive on Sunday February 03, 2019 @11:35AM (#19070500)
For me, mostly exclude them from select all, or perhaps scroll past them to see meaningful files.
Re:Dotfile madness by darkpuma on Saturday February 02, 2019 @02:40PM (#19065156)
Sidecar files for storing file tags make querying the tag system a huge chore; it totally kills performance. I understand the conceptual appeal but it's just not the way to go.
Re:Dotfile madness by netsec_burn on Saturday February 02, 2019 @12:29PM (#19064273)
This is what Mac does to track download locations, if I remember correctly (._file).
Re:Dotfile madness by runxel on Saturday February 02, 2019 @07:17PM (#19066845)
How do you sleep at night?