手动操作挂载ssd到pc上唯一的逻辑盘
echo "/dev/block/vold/8:0">/sys/devices/platform/sw_usb_udc/gadget/lun0/file //pc挂载ssd
echo "">/sys/devices/platform/sw_usb_udc/gadget/lun0/file //pc卸载ssd
==============================================================================
android部分保证强制操作硬盘
android4.0/system/vold/Volume.cpp
shareVol函数中强制指定写入字段和节点路径
#if 0//kll
snprintf(nodepath,
sizeof(nodepath), "/dev/block/vold/%d:%d",
MAJOR(d), MINOR(d));
#else
snprintf(nodepath, sizeof(nodepath), "/dev/block/vold/8:0");
#endif
if(1/*mSharelun[i] == 0*/)//kll
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun/file");//这个file链接文件指向/sys/devices/platform/sw_usb_udc/gadget/lun0/file
else
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun%d/file", mSharelun[i]);
unshareVol函数强制指定卸载节点路径
if(1/*mSharelun[i] == 0*/)//kll
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun/file");//这个file链接文件指向/sys/devices/platform/sw_usb_udc/gadget/lun0/file
else
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun%d/file", mSharelun[i]);
==============================================================================
内核部分保证只创建一个逻辑盘节点/sys/devices/platform/sw_usb_udc/gadget/lun0
lichee/linux-3.0/drivers/usb/gadget/Android.c
mass_storage_function_init函数中config->fsg.nluns = g_android_usb_config.luns;
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
lichee/linux-3.0/drivers/usb/gadget/Composite.c
static struct android_usb_config g_android_usb_config;//申明一个usb配置结构
static s32 get_android_config(struct android_usb_config *config)//将usb配置fetch到config结构
s32 get_android_usb_config(struct android_usb_config *config)//将config中的数据转移到 g_android_usb_config 结构
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
从sys_config1.fex读取luns值(在pc上呈现的可移动盘符数)
echo "/dev/block/vold/8:0">/sys/devices/platform/sw_usb_udc/gadget/lun0/file //pc挂载ssd
echo "">/sys/devices/platform/sw_usb_udc/gadget/lun0/file //pc卸载ssd
==============================================================================
android部分保证强制操作硬盘
android4.0/system/vold/Volume.cpp
shareVol函数中强制指定写入字段和节点路径
#if 0//kll
snprintf(nodepath,
sizeof(nodepath), "/dev/block/vold/%d:%d",
MAJOR(d), MINOR(d));
#else
snprintf(nodepath, sizeof(nodepath), "/dev/block/vold/8:0");
#endif
if(1/*mSharelun[i] == 0*/)//kll
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun/file");//这个file链接文件指向/sys/devices/platform/sw_usb_udc/gadget/lun0/file
else
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun%d/file", mSharelun[i]);
unshareVol函数强制指定卸载节点路径
if(1/*mSharelun[i] == 0*/)//kll
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun/file");//这个file链接文件指向/sys/devices/platform/sw_usb_udc/gadget/lun0/file
else
snprintf(umslun, sizeof(umslun), "/sys/class/android_usb/android0/f_mass_storage/lun%d/file", mSharelun[i]);
==============================================================================
内核部分保证只创建一个逻辑盘节点/sys/devices/platform/sw_usb_udc/gadget/lun0
lichee/linux-3.0/drivers/usb/gadget/Android.c
mass_storage_function_init函数中config->fsg.nluns = g_android_usb_config.luns;
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
lichee/linux-3.0/drivers/usb/gadget/Composite.c
static struct android_usb_config g_android_usb_config;//申明一个usb配置结构
static s32 get_android_config(struct android_usb_config *config)//将usb配置fetch到config结构
s32 get_android_usb_config(struct android_usb_config *config)//将config中的数据转移到 g_android_usb_config 结构
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
从sys_config1.fex读取luns值(在pc上呈现的可移动盘符数)