Commit 682f2bc
committed
mountinfo.mountedByMountinfo: normalize path
Currently, the path provided to mountinfo.Mounted() must be
- an absolute path;
- with all symlinks resolved;
- cleaned.
Otherwise, the function may return a false negative (in case this is
a bind mount and the kernel is too old to have openat2) -- i.e. it
will return "not mounted" while the path is in fact mounted.
This commit removes the above limitation by doing a path normalization.
This should slow things down but it's not affecting any of the fast
paths, so the slowdown will only be seen in the "bind mount and older
kernel" case (which is already pretty slow since we have to parse
mountinfo).
v2: as in mountedByOpenat2 and mountedByStat, treat ENOENT as "not
mounted".
Signed-off-by: Kir Kolyshkin <[email protected]>1 parent 0c38c02 commit 682f2bc
2 files changed
Lines changed: 25 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 17 | + | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
36 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
37 | 60 | | |
38 | 61 | | |
39 | 62 | | |
| |||
0 commit comments