apps/system/usbmsc: Added Kconfig options to configure write protection for each LUN

This commit is contained in:
Fabio D'Urso 2018-01-14 17:11:32 -06:00 committed by Gregory Nutt
parent e2e53117a5
commit da4472a978
2 changed files with 35 additions and 2 deletions

View File

@ -39,6 +39,13 @@ config SYSTEM_USBMSC_DEVPATH1
The full path to the registered block driver. Default is
"/dev/mmcsd0"
config SYSTEM_USBMSC_WRITEPROTECT1
bool "LUN1 Write-protected"
default n
---help---
Enable this if you want to write-protect the first LUN. Default is
off.
config SYSTEM_USBMSC_DEVMINOR2
int "LUN2 Minor Device Number"
default 1
@ -54,20 +61,34 @@ config SYSTEM_USBMSC_DEVPATH2
The full path to the registered block driver. Ignored if
SYSTEM_USBMSC_NLUNS < 2. Default is "/dev/mmcsd1"
config SYSTEM_USBMSC_WRITEPROTECT2
bool "LUN2 Write-protected"
default n
---help---
Enable this if you want to write-protect the second LUN. Ignored if
SYSTEM_USBMSC_NLUNS < 2. Default is off.
config SYSTEM_USBMSC_DEVMINOR3
int "LUN3 Minor Device Number"
default 2
---help---
The minor device number of the block driver for the third LUN. For
example, N in /dev/mmcsdN. Used for registering the block driver.
Ignored if SYSTEM_USBMSC_NLUNS < 2. Default is two.
Ignored if SYSTEM_USBMSC_NLUNS < 3. Default is two.
config SYSTEM_USBMSC_DEVPATH3
string "LUN3 Device Path"
default "/dev/mmcsd2"
---help---
The full path to the registered block driver. Ignored if
SYSTEM_USBMSC_NLUNS < 2. Default is "/dev/mmcsd2"
SYSTEM_USBMSC_NLUNS < 3. Default is "/dev/mmcsd2"
config SYSTEM_USBMSC_WRITEPROTECT3
bool "LUN3 Write-protected"
default n
---help---
Enable this if you want to write-protect the third LUN. Ignored if
SYSTEM_USBMSC_NLUNS < 3. Default is off.
config SYSTEM_USBMSC_DEBUGMM
bool "USB MSC MM Debug"

View File

@ -510,7 +510,11 @@ int msconn_main(int argc, char *argv[])
check_test_memory_usage("After usbmsc_configure()");
printf("mcsonn_main: Bind LUN=0 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH1);
#ifdef CONFIG_SYSTEM_USBMSC_WRITEPROTECT1
ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH1, 0, 0, 0, true);
#else
ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH1, 0, 0, 0, false);
#endif
if (ret < 0)
{
printf("mcsonn_main: usbmsc_bindlun failed for LUN 1 using %s: %d\n",
@ -524,7 +528,11 @@ int msconn_main(int argc, char *argv[])
#if CONFIG_SYSTEM_USBMSC_NLUNS > 1
printf("mcsonn_main: Bind LUN=1 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH2);
#ifdef CONFIG_SYSTEM_USBMSC_WRITEPROTECT2
ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH2, 1, 0, 0, true);
#else
ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH2, 1, 0, 0, false);
#endif
if (ret < 0)
{
printf("mcsonn_main: usbmsc_bindlun failed for LUN 2 using %s: %d\n",
@ -538,7 +546,11 @@ int msconn_main(int argc, char *argv[])
#if CONFIG_SYSTEM_USBMSC_NLUNS > 2
printf("mcsonn_main: Bind LUN=2 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH3);
#ifdef CONFIG_SYSTEM_USBMSC_WRITEPROTECT3
ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH3, 2, 0, 0, true);
#else
ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH3, 2, 0, 0, false);
#endif
if (ret < 0)
{
printf("mcsonn_main: usbmsc_bindlun failed for LUN 3 using %s: %d\n",