1

I need to create (lots of) files whose sole purpose is to signify a boolean condition by their mere existence. These files have no content, and their access/mod time or ownership doesn't matter. Only their existence matters.

I figured the cheapest and fastest way is to create a hard link to some fixed target in the file system.

There is the minor inconvenience of hardlink max count (= 64000 on ext4, I think), but I can work around that by writing a loop to use a variable target.

Is there a simpler way, perhaps using something other than hard links, to do what I want?

Thanks.

Benito Ciaro
  • 1,718
  • 12
  • 25

1 Answers1

1

The Maildir format is a great reference for useful Unix patterns. If your markers refer to other files or directories, you can embed them in file names themselves, as flags are added to mail files in Maildirs. Adding and removing flags is robust as file rename is atomic in POSIX, even across reboots. It also avoids the extra i-node of the marker file and is as space efficient as the original hardlink solution.

As an example, insteat of having somefile and then creating an empty somefile.marker, just rename somefile to somefile:M. To remove the marker, instead of deleting somefile.marker, just rename somefile:M back to somefile. The same can be done for directories.

jop
  • 2,226
  • 15
  • 16
  • Sorry about the incomplete answer. I was pointing you at the "What can I put in info?" section, which describes how to add markers to mail files. Not at the unique file names. – jop Sep 22 '13 at 10:31