2

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 Answer 1

3

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).

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.