Commit 922eb71
committed
Do not clean tempdir if we fail to unmount
Ran into this issue by chance in bootupd where the following drop ordering
```rust
drop(tempdir)
drop(mount) // unmounts thing mounted at tempdir
```
was causing all the contents of the mounted device to be deleted because
the tempdir was being deleted. We might run into the same issue with our
Tempdir impl if we fail to unount the ESP and tempdir is dropped
deleting everything in the ESP.
To prevent that, we now have a separate struct `MountpointTempdir` which
creates the tempdir for us, explicitly sets `disable_cleanup` to false
so that the dir isn't cleaned up on Drop. On drop, we clean it up
ourselves intentionally using `remove_dir` and not `remove_dir_all` to
make sure we don't end up deleting stuff in the dir.
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>1 parent c818e03 commit 922eb71
1 file changed
Lines changed: 37 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
52 | 84 | | |
53 | 85 | | |
54 | 86 | | |
55 | 87 | | |
56 | | - | |
| 88 | + | |
57 | 89 | | |
58 | 90 | | |
59 | 91 | | |
| |||
67 | 99 | | |
68 | 100 | | |
69 | 101 | | |
70 | | - | |
| 102 | + | |
71 | 103 | | |
72 | 104 | | |
73 | 105 | | |
| |||
81 | 113 | | |
82 | 114 | | |
83 | 115 | | |
84 | | - | |
| 116 | + | |
85 | 117 | | |
86 | 118 | | |
87 | 119 | | |
| |||
91 | 123 | | |
92 | 124 | | |
93 | 125 | | |
94 | | - | |
| 126 | + | |
95 | 127 | | |
96 | 128 | | |
97 | 129 | | |
| |||
109 | 141 | | |
110 | 142 | | |
111 | 143 | | |
112 | | - | |
| 144 | + | |
113 | 145 | | |
114 | 146 | | |
115 | 147 | | |
| |||
0 commit comments