当前位置: 技术问答>linux和unix
LINUX下最大同时支持多少个U盘 (高分求救)
来源: 互联网 发布时间:2017-05-21
本文导语: 最近项目需要支持50个U盘同时插入使用, 在linux下, 找了些资料说是支持sd[a..p], 不知道此说法对不对??? LINUX下最大同时支持多少个U盘??? 如何突破a-z的限制??? | /** * sd_format_disk_name - format disk name * @prefi...
最近项目需要支持50个U盘同时插入使用, 在linux下, 找了些资料说是支持sd[a..p], 不知道此说法对不对???
LINUX下最大同时支持多少个U盘??? 如何突破a-z的限制???
LINUX下最大同时支持多少个U盘??? 如何突破a-z的限制???
|
/**
* sd_format_disk_name - format disk name
* @prefix: name prefix - ie. "sd" for SCSI disks
* @index: index of the disk to format name for
* @buf: output buffer
* @buflen: length of the output buffer
*
* SCSI disk names starts at sda. The 26th device is sdz and the
* 27th is sdaa. The last one for two lettered suffix is sdzz
* which is followed by sdaaa.
*
* This is basically 26 base counting with one extra 'nil' entry
* at the beginning from the second digit on and can be
* determined using similar method as 26 base conversion with the
* index shifted -1 after each digit is computed.
*
* CONTEXT:
* Don't care.
*
* RETURNS:
* 0 on success, -errno on failure.
*/
static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
{
const int base = 'z' - 'a' + 1;
char *begin = buf + strlen(prefix);
char *end = buf + buflen;
char *p;
int unit;
p = end - 1;
*p = '';
unit = base;
do {
if (p == begin)
return -EINVAL;
*--p = 'a' + (index % unit);
index = (index / unit) - 1;
} while (index >= 0);
memmove(begin, p, end - p);
memcpy(buf, prefix, strlen(prefix));
return 0;
}
|
人家 6 楼不是回答了么,即使你懒得看代码,看下注释也可以啊
* SCSI disk names starts at sda. The 26th device is sdz and the
* 27th is sdaa. The last one for two lettered suffix is sdzz
* which is followed by sdaaa.
* SCSI disk names starts at sda. The 26th device is sdz and the
* 27th is sdaa. The last one for two lettered suffix is sdzz
* which is followed by sdaaa.