Trim device model string returned from libparted
The device model displayed in GParted has a leading space character when the kernel device driver vendor attribute is blank. # lsblk -o KNAME,VENDOR,MODEL,SERIAL,TYPE,TRAN -d /dev/sde /dev/sdh KNAME VENDOR MODEL SERIAL TYPE TRAN sde SanDisk U3 Cruzer Micro 00001853E473AABA disk usb sdh Patriot Memory 07082AA3E0944E31 disk usb ^^^^^^^^ # cd /sys/block/sde/device # cat vendor SanDisk # cat model U3 Cruzer Micro # cd /sys/block/sdh/device # cat vendor >> # cat model Patriot Memory # ls -l /dev/sde /dev/sdh brw-rw----. 1 root disk 8, 64 Aug 9 18:26 /dev/sde brw-rw----. 1 root disk 8, 112 Aug 9 18:26 /dev/sdh Libparted treats USB keys as SCSI devices because they use the SCSI major device number. This means the libparted device model string is constructed from the kernel device driver vendor and model strings read from /sys, stripped and separated by a space character [1]. Hence the leading space in the libparted model string when vendor is blank. # parted /dev/sde print | head -1 Model: SanDisk U3 Cruzer Micro (scsi) # parted /dev/sdh print | head -1 Model: Patriot Memory (scsi) ^ Trim space characters from the libparted model string to remove the leading space displayed in GParted. [1] parted/libparted/arch/linux.c:init_scsi() http://git.savannah.gnu.org/cgit/parted.git/tree/libparted/arch/linux.c?h=v3.6#n1189 if (scsi_get_product_info (dev, &vendor, &product)) { sprintf (dev->model, "%.8s %.16s", vendor, product);
This commit is contained in:
parent
ebaeb93190
commit
78c1986da5
|
@ -653,7 +653,7 @@ void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring &
|
|||
|
||||
// Device info ...
|
||||
device.set_path(device_path);
|
||||
device.model = lp_device->model;
|
||||
device.model = Utils::trim(lp_device->model);
|
||||
device.length = lp_device->length;
|
||||
device.sector_size = lp_device->sector_size;
|
||||
device.heads = lp_device->bios_geom.heads;
|
||||
|
|
Loading…
Reference in New Issue