From 74a1a22875eae487d856e1b307208d71f7607d3e Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Thu, 24 May 2018 23:17:01 +0200 Subject: [PATCH] libf2fs: read "disk model" from SCSI ioctl the same way kernel does Ref: drivers/scsi/scsi_scan.c scsi_add_lun() Ie, fixed-width 16 bytes, assumed to be filled with spaces -- NOT null-terminated; comments suggest that in some cases this field can be truncated and filled with nulls but printf is fine with that. The old code did read up to 64 characters, which produced garbage for at least some USB-attached card readers. It also special-cased '`' character which the kernel does not. Signed-off-by: Adam Borowski Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- lib/libf2fs.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 102e579..b25fbf2 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -867,13 +867,8 @@ int get_device_info(int i) io_hdr.timeout = 1000; if (!ioctl(fd, SG_IO, &io_hdr)) { - int i = 16; - - MSG(0, "Info: [%s] Disk Model: ", - dev->path); - while (reply_buffer[i] != '`' && i < 80) - printf("%c", reply_buffer[i++]); - printf("\n"); + MSG(0, "Info: [%s] Disk Model: %.16s\n", + dev->path, reply_buffer+16); } #endif } else { -- 2.7.4