Search code examples
gofilesystemstemp

What is "Temporary" file mode in Plan 9, and is it available in Linux?


I am manually creating a temporary file using:

tempDir := os.TempDir()
tempFile := filepath.Join(tempDir, "my.file")
ioutil.WriteFile(tempFile, []byte{}, os.ModeTemporary)

I am intentionally avoiding ioutil.TempFile() because I don't want a random suffix to be appended to the filename.

When browsing through the different types of permissions in the os package, ModeTemporary seemed the most fitting but is also commented with:

ModeTemporary                                  // T: temporary file; Plan 9 only

What's Plan 9 and why does only it support ModeTemporary?

Can I use ModeTemporary on normal Linux distributions as well?


Solution

  • "Temporary" mode on Plan 9 marks the file for exclusion from daily backups. From the stat man page:

    Temporary files are not included in nightly archives (see Plan 9’s fossil(4)).

    And no, this is not available on standard Linux filesystems.