@@ -298,7 +298,8 @@ static void disk_identify_fixup_uint16(uint8_t identify[512], unsigned offset_wo
298
298
* non-zero with errno set.
299
299
*/
300
300
static int disk_identify (int fd ,
301
- uint8_t out_identify [512 ]) {
301
+ uint8_t out_identify [512 ],
302
+ int * ret_peripheral_device_type ) {
302
303
uint8_t inquiry_buf [36 ];
303
304
int peripheral_device_type , r ;
304
305
@@ -358,6 +359,9 @@ static int disk_identify(int fd,
358
359
if (all_nul_bytes )
359
360
return log_debug_errno (SYNTHETIC_ERRNO (EIO ), "IDENTIFY data is all zeroes." );
360
361
362
+ if (ret_peripheral_device_type )
363
+ * ret_peripheral_device_type = peripheral_device_type ;
364
+
361
365
return 0 ;
362
366
}
363
367
@@ -407,7 +411,7 @@ static int run(int argc, char *argv[]) {
407
411
char model [41 ], model_enc [256 ], serial [21 ], revision [9 ];
408
412
_cleanup_close_ int fd = - EBADF ;
409
413
uint16_t word ;
410
- int r ;
414
+ int r , peripheral_device_type = -1 ;
411
415
412
416
log_set_target (LOG_TARGET_AUTO );
413
417
udev_parse_config ();
@@ -422,7 +426,7 @@ static int run(int argc, char *argv[]) {
422
426
if (fd < 0 )
423
427
return log_error_errno (errno , "Cannot open %s: %m" , arg_device );
424
428
425
- if (disk_identify (fd , identify .byte ) >= 0 ) {
429
+ if (disk_identify (fd , identify .byte , & peripheral_device_type ) >= 0 ) {
426
430
/*
427
431
* fix up only the fields from the IDENTIFY data that we are going to
428
432
* use and copy it into the hd_driveid struct for convenience
@@ -615,6 +619,9 @@ static int run(int argc, char *argv[]) {
615
619
if (IN_SET (identify .wyde [0 ], 0x848a , 0x844a ) ||
616
620
(identify .wyde [83 ] & 0xc004 ) == 0x4004 )
617
621
printf ("ID_ATA_CFA=1\n" );
622
+
623
+ if (peripheral_device_type >= 0 )
624
+ printf ("ID_ATA_PERIPHERAL_DEVICE_TYPE=%d\n" , peripheral_device_type );
618
625
} else {
619
626
if (serial [0 ] != '\0' )
620
627
printf ("%s_%s\n" , model , serial );
0 commit comments