Is it possible to change the name of an already open memory mapped file, or, do I need to close it, rename it and then mmap it again?
+1
A:
Renaming a file while it is open is fine, regardless of whether it is mmaped or not.
In UNIX-like systems, the concept of the file itself is distinct from the name (which is called a "link"). A file may have zero, one, or many separate names. When you have a file open, it is the file itself that you have a reference to - it's OK to change or remove the name (and the file will remain open).
caf
2010-08-23 04:31:02
Thanks, that actually makes a lot of sense because you can mmap a file and close the file descriptor while it's still memory mapped. I'll give that a try.
Matt H
2010-08-23 04:32:33
Yeah renaming it while it's open and/or mmap'd is no problem, it will remain open and mapped. Even if you unlink it, it'll still keep working.
MarkR
2010-08-23 08:46:26