One of the arguments to mmap
is flags
. To what extent is it possible to reconstruct which flags were used with the information in /proc/self/maps
?
Asked
Active
Viewed 124 times
1

tonysdg
- 1,335
- 11
- 32
-
1Why would `fd` be useful? Only the process itself would know/care. You already have the filename. – Ignacio Vazquez-Abrams Jan 15 '16 at 22:34
-
@IgnacioVazquez-Abrams: hadn't thought about that - I'll edit the question then. My question regarding the flags still remains though - can I determine those from `/proc/self/maps`? – tonysdg Jan 15 '16 at 22:49
-
`MAP_PRIVATE` and `MAP_SHARED` flags may be determined from `permissions` column. `MAP_ANONYMOUS` is determined by empty path. Some flags like `MAP_FIXED` are probably not saved anywhere after `mmap()` returns. Some flags may be probably determined from `/proc/self/smaps`. – gavv Jan 16 '16 at 02:34
-
Related: http://stackoverflow.com/questions/31512704/how-can-i-find-the-mapped-file-when-its-not-shown-in-proc-maps – gavv Jan 16 '16 at 02:36
-
@g-v: I'd consider your second comment to be the answer I was looking for - if you'd like, convert that into an answer and I'll accept it. As for the possible duplicate - I agree these questions are very similar, I was specifically looking for how to reconstruct the `flags` argument, which is how it differs. I can try to edit the question to make that more explicit. – tonysdg Jan 16 '16 at 21:18
-
@tonysdg, ok, I'm not insisting on duplicate. – gavv Jan 17 '16 at 13:10
1 Answers
1
See details on /proc/self/maps
in this question.
Some ideas (actually not a full answer):
MAP_PRIVATE
andMAP_SHARED
flags may be determined from permissions columnMAP_ANONYMOUS
is determined by empty path- some flags (probably
MAP_HUGETLB
,MAP_LOCKED
) may be determined from/proc/self/smaps
- some flags like
MAP_FIXED
(probablyMAP_32BIT
,MAP_UNINITIALIZED
) are most likely not saved anywhere aftermmap()
returns - some flags (
MAP_NONBLOCK
,MAP_NORESERVE
,MAP_POPULATE
) are likely to be stored somewhere, but I don't think they're accessible through/proc
HTH