20
20
#include <waiter/waiter.h>
21
21
#include <system/system.h>
22
22
#include <process/process.h>
23
+ #include <i18n/i18n.h>
23
24
24
25
#include "event.h"
25
26
#include "udev.h"
@@ -101,6 +102,7 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
101
102
const char * prop ;
102
103
const char * type ;
103
104
const char * devname ;
105
+ const char * idpath ;
104
106
const char * ignored_types [] = {
105
107
"linux_raid_member" ,
106
108
"swap" ,
@@ -179,11 +181,19 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
179
181
/* We may see multipath devices; they'll have the same uuid as an
180
182
* existing device, so only parse the first. */
181
183
uuid = udev_device_get_property_value (dev , "ID_FS_UUID" );
184
+ idpath = udev_device_get_property_value (dev , "ID_PATH" );
182
185
if (uuid ) {
183
186
ddev = device_lookup_by_uuid (udev -> handler , uuid );
184
187
if (ddev ) {
185
188
pb_log ("SKIP: %s UUID [%s] already present (as %s)\n" ,
186
189
name , uuid , ddev -> device -> id );
190
+ /* Only warn once in petitboot status log to remind users */
191
+ if (strcmp (idpath , ddev -> id_path ) && !ddev -> dup_warn ) {
192
+ device_handler_status_info (udev -> handler ,
193
+ _ ("Duplicate filesystem as %s detected; skipping duplicates" ),
194
+ ddev -> device -> id );
195
+ ddev -> dup_warn = true;
196
+ }
187
197
return 0 ;
188
198
}
189
199
}
@@ -211,6 +221,7 @@ static int udev_handle_block_add(struct pb_udev *udev, struct udev_device *dev,
211
221
}
212
222
}
213
223
224
+ ddev -> id_path = talloc_strdup (ddev , idpath );
214
225
ddev -> device_path = talloc_strdup (ddev , node );
215
226
talloc_free (devlinks );
216
227
@@ -355,6 +366,7 @@ static int udev_handle_dev_remove(struct pb_udev *udev, struct udev_device *dev)
355
366
{
356
367
struct discover_device * ddev ;
357
368
const char * name ;
369
+ const char * uuid ;
358
370
359
371
name = udev_device_get_sysname (dev );
360
372
if (!name ) {
@@ -363,8 +375,15 @@ static int udev_handle_dev_remove(struct pb_udev *udev, struct udev_device *dev)
363
375
}
364
376
365
377
ddev = device_lookup_by_id (udev -> handler , name );
366
- if (!ddev )
378
+ if (!ddev ) {
379
+ uuid = udev_device_get_property_value (dev , "ID_FS_UUID" );
380
+ if (uuid ) {
381
+ ddev = device_lookup_by_uuid (udev -> handler , uuid );
382
+ if (ddev )
383
+ ddev -> dup_warn = false;
384
+ }
367
385
return 0 ;
386
+ }
368
387
369
388
device_handler_remove (udev -> handler , ddev );
370
389
0 commit comments