File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -139,13 +139,21 @@ impl RepartOutput {
139
139
// We need to sanitize the label for the mapper device name, as it can't contain slashes
140
140
//
141
141
// I forgot to account for this when I refactored it -Cappy
142
- let label = {
142
+ let mut label = {
143
143
if mntpoint == "/" {
144
144
"root" . to_owned ( )
145
145
} else {
146
146
mntpoint. trim_start_matches ( '/' ) . replace ( "/" , "-" )
147
147
}
148
148
} ;
149
+
150
+ // Check if mapper device already exists and append counter if needed
151
+ let mut counter = 0 ;
152
+ let base_label = label. clone ( ) ;
153
+ while std:: path:: Path :: new ( & format ! ( "/dev/mapper/{}" , label) ) . exists ( ) {
154
+ counter += 1 ;
155
+ label = format ! ( "{}-{}" , base_label, counter) ;
156
+ }
149
157
let mapper = luks_decrypt ( & node, pass, & label) ?;
150
158
decrypted_partitions. insert ( node. clone ( ) , mapper. clone ( ) ) ;
151
159
mapper
You can’t perform that action at this time.
0 commit comments