usb: storage: make disk cdev name configurable via Kconfig
Subsystems (2)
PATCH 1/1 usb: storage: make disk cdev name configurable via Kconfig
From: Anis Chali <[email protected]>
Add USBDISK_NAME string option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.
--- drivers/usb/storage/Kconfig | 5 +++++ drivers/usb/storage/usb.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/usb/storage/Kconfig +5 -0
@@ -2,3 +2,8 @@ config USB_STORAGE tristate "USB Mass Storage support" select DISK + +config USBDISK_NAME + string "USB storage disk name" + depends on USB_STORAGE + default "disk"
drivers/usb/storage/usb.c +3 -3
@@ -414,12 +414,12 @@ static int usb_stor_add_blkdev(struct us_data *us, unsigned char lun)if (result <0 ) goto BadDevice; - result =cdev_find_free_index ("disk" ); + result =cdev_find_free_index (CONFIG_USBDISK_NAME );if (result ==-1 )pr_err ("Cannot find a free number for the disk node\n" ); -dev_info (dev,"registering as disk%d\n" , result); +dev_info (dev,"registering as %s%d\n" ,CONFIG_USBDISK_NAME , result); - pblk_dev->blk.cdev.name =basprintf ("disk%d" , result); + pblk_dev->blk.cdev.name =basprintf ("%s%d" ,CONFIG_USBDISK_NAME , result); pblk_dev->blk.blockbits =SECTOR_SHIFT ; pblk_dev->blk.type =BLK_TYPE_USB ; pblk_dev->blk.removable = true;
Signature · 1 line
2.54.0
Hi,
Quoted 4 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.
I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Sascha
Quoted 44 lines
Signed-off-by Anis Chali <[email protected]>--- drivers/usb/storage/Kconfig | 5 +++++ drivers/usb/storage/usb.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-)drivers/usb/storage/Kconfig +5
-0@@ -2,3 +2,8 @@ config USB_STORAGE tristate "USB Mass Storage support" select DISK + +config USBDISK_NAME + string "USB storage disk name" + depends on USB_STORAGE + default "disk"drivers/usb/storage/usb.c +3
-3@@ -414,12 +414,12 @@ static int usb_stor_add_blkdev(struct us_data *us, unsigned char lun)if (result <0 ) goto BadDevice; - result =cdev_find_free_index ("disk" ); + result =cdev_find_free_index (CONFIG_USBDISK_NAME );if (result ==-1 )pr_err ("Cannot find a free number for the disk node\n" ); -dev_info (dev,"registering as disk%d\n" , result); +dev_info (dev,"registering as %s%d\n" ,CONFIG_USBDISK_NAME , result); - pblk_dev->blk.cdev.name =basprintf ("disk%d" , result); + pblk_dev->blk.cdev.name =basprintf ("%s%d" ,CONFIG_USBDISK_NAME , result); pblk_dev->blk.blockbits =SECTOR_SHIFT ; pblk_dev->blk.type =BLK_TYPE_USB ; pblk_dev->blk.removable = true;Signature · 1 line
2.54.0
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH] USB: make storage device name configurable
Quoted 11 lines · Sascha Hauer
Hi,
Quoted 4 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Yes, it works for me, it does the job more cleanly, thank you.
Anis.
Quoted 5 lines · Sascha Hauer
Hi,
Quoted 2 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Quoted 9 lines
Quoted 2 lines
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Sascha
Hi,
In my side I am migrating to master so removed my patch for this and I noticed that alias is not mounted to be used as /mnt/usbdiskX, I am just asking to know if it the expected behaviour in which case I will for an other way to get it mounted as /mnt/usbdisk0
Best regards.
Anis
Quoted 53 lines
Quoted 44 lines
Signed-off-by Anis Chali <[email protected]>--- drivers/usb/storage/Kconfig | 5 +++++ drivers/usb/storage/usb.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-)drivers/usb/storage/Kconfig +5
-0@@ -2,3 +2,8 @@ config USB_STORAGE tristate "USB Mass Storage support" select DISK + +config USBDISK_NAME + string "USB storage disk name" + depends on USB_STORAGE + default "disk"drivers/usb/storage/usb.c +3
-3@@ -414,12 +414,12 @@ static int usb_stor_add_blkdev(struct us_data *us, unsigned char lun)if (result <0 ) goto BadDevice; - result =cdev_find_free_index ("disk" ); + result =cdev_find_free_index (CONFIG_USBDISK_NAME );if (result ==-1 )pr_err ("Cannot find a free number for the disk node\n" ); -dev_info (dev,"registering as disk%d\n" , result); +dev_info (dev,"registering as %s%d\n" ,CONFIG_USBDISK_NAME , result); - pblk_dev->blk.cdev.name =basprintf ("disk%d" , result); + pblk_dev->blk.cdev.name =basprintf ("%s%d" ,CONFIG_USBDISK_NAME , result); pblk_dev->blk.blockbits =SECTOR_SHIFT ; pblk_dev->blk.type =BLK_TYPE_USB ; pblk_dev->blk.removable = true;Signature · 1 line
2.54.0Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 13 lines · On 2026-08-27 14:01, chalianis1 wrote:
Quoted 12 lines · Sascha Hauer
Hi,
Quoted 4 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Quoted 8 lines
Quoted 2 lines
Sascha
Hi,
In my side I am migrating to master so removed my patch for this and I noticed that alias is not mounted to be used as
/mnt/usbdiskX, I am just asking to know if it the expected behaviour in which case I will for an other way to get it mounted as/mnt/usbdisk0
But it still is automounted via /mnt/disk0, right? I just had a look into it and yes, my patch doesn't add the automount for the aliases.
I'll look into it next week. I hope we get away to just create a symbolic link from the alias to the real cdev, i.e. from /mnt/usbdisk0 to /mnt/disk0. That would have to be done in cdev_create_default_automount().
Sascha
--
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 18 lines · Sascha Hauer
Quoted 17 lines · On 2026-08-27 14:01, chalianis1 wrote:
Quoted 5 lines · Sascha Hauer
Hi,
Quoted 2 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Quoted 9 lines
Quoted 2 lines
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Sascha
Hi,
Quoted 7 lines
Quoted 4 lines
In my side I am migrating to master so removed my patch for this and I noticed that alias is not mounted to be used as
/mnt/usbdiskX, I am just asking to know if it the expected behaviour in which case I will for an other way to get it mounted as/mnt/usbdisk0But it still is automounted via
/mnt/disk0, right? I just had a look into it and yes, my patch doesn't add the automount for the aliases.
Yes exact it is mounted as /mnt/diskX
Quoted 4 lines
I'll look into it next week. I hope we get away to just create a symbolic link from the alias to the real cdev, i.e. from
/mnt/usbdisk0to/mnt/disk0. That would have to be done incdev_create_default_automount().
Thank you
Quoted 12 lines
Sascha
--
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Best regards
Anis
Quoted 24 lines · On 2026-08-28 18:28, chalianis1 wrote:
Quoted 23 lines · Sascha Hauer
Quoted 21 lines · On 2026-08-27 14:01, chalianis1 wrote:
Quoted 5 lines · Sascha Hauer
Hi,
Quoted 2 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Quoted 9 lines
Quoted 2 lines
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Sascha
Hi,
In my side I am migrating to master so removed my patch for this and I noticed that alias is not mounted to be used as
/mnt/usbdiskX, I am just asking to know if it the expected behaviour in which case I will for an other way to get it mounted as/mnt/usbdisk0
Quoted 8 lines
Quoted 2 lines
But it still is automounted via
/mnt/disk0, right? I just had a look into it and yes, my patch doesn't add the automount for the aliases.Yes exact it is mounted as
/mnt/diskXQuoted 4 lines
I'll look into it next week. I hope we get away to just create a symbolic link from the alias to the real cdev, i.e. from
/mnt/usbdisk0to/mnt/disk0. That would have to be done incdev_create_default_automount().Thank you
See https://lore.barebox.org/barebox/[email protected]/T/#t
Sascha
--
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 36 lines · Sascha Hauer
Quoted 24 lines · On 2026-08-28 18:28, chalianis1 wrote:
Quoted 23 lines · Sascha Hauer
Quoted 21 lines · On 2026-08-27 14:01, chalianis1 wrote:
Quoted 5 lines · Sascha Hauer
Hi,
Quoted 2 lines · On 2026-06-23 10:26, chalianis1 wrote:
From: Anis Chali <[email protected]>
Quoted 9 lines
Quoted 2 lines
Add
USBDISK_NAMEstring option to allow customizing the USB storage device name, defaulting to "disk" to preserve existing behaviour.I just sent a patch which registers USB storage devices with usbdiskx which doesn't require compile time changes. I hope that suits your needs as well.
Sascha
Hi,
In my side I am migrating to master so removed my patch for this and I noticed that alias is not mounted to be used as
/mnt/usbdiskX, I am just asking to know if it the expected behaviour in which case I will for an other way to get it mounted as/mnt/usbdisk0Quoted 8 lines
Quoted 2 lines
But it still is automounted via
/mnt/disk0, right? I just had a look into it and yes, my patch doesn't add the automount for the aliases.Yes exact it is mounted as
/mnt/diskXQuoted 4 lines
I'll look into it next week. I hope we get away to just create a symbolic link from the alias to the real cdev, i.e. from
/mnt/usbdisk0to/mnt/disk0. That would have to be done incdev_create_default_automount().Thank you
Quoted 11 lines
Sascha
--
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Thank's
best regards,
Anis