part.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2001
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <errno.h>
  9. #include <ide.h>
  10. #include <malloc.h>
  11. #include <part.h>
  12. #include <ubifs_uboot.h>
  13. #undef PART_DEBUG
  14. #ifdef PART_DEBUG
  15. #define PRINTF(fmt,args...) printf (fmt ,##args)
  16. #else
  17. #define PRINTF(fmt,args...)
  18. #endif
  19. /* Check all partition types */
  20. #define PART_TYPE_ALL -1
  21. static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
  22. {
  23. struct part_driver *drv =
  24. ll_entry_start(struct part_driver, part_driver);
  25. const int n_ents = ll_entry_count(struct part_driver, part_driver);
  26. struct part_driver *entry;
  27. if (dev_desc->part_type == PART_TYPE_UNKNOWN) {
  28. for (entry = drv; entry != drv + n_ents; entry++) {
  29. int ret;
  30. ret = entry->test(dev_desc);
  31. if (!ret) {
  32. dev_desc->part_type = entry->part_type;
  33. return entry;
  34. }
  35. }
  36. } else {
  37. for (entry = drv; entry != drv + n_ents; entry++) {
  38. if (dev_desc->part_type == entry->part_type)
  39. return entry;
  40. }
  41. }
  42. /* Not found */
  43. return NULL;
  44. }
  45. #ifdef CONFIG_HAVE_BLOCK_DEVICE
  46. static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
  47. {
  48. struct blk_desc *dev_desc;
  49. int ret;
  50. dev_desc = blk_get_devnum_by_typename(ifname, dev);
  51. if (!dev_desc) {
  52. debug("%s: No device for iface '%s', dev %d\n", __func__,
  53. ifname, dev);
  54. return NULL;
  55. }
  56. ret = blk_dselect_hwpart(dev_desc, hwpart);
  57. if (ret) {
  58. debug("%s: Failed to select h/w partition: err-%d\n", __func__,
  59. ret);
  60. return NULL;
  61. }
  62. return dev_desc;
  63. }
  64. struct blk_desc *blk_get_dev(const char *ifname, int dev)
  65. {
  66. return get_dev_hwpart(ifname, dev, 0);
  67. }
  68. #else
  69. struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
  70. {
  71. return NULL;
  72. }
  73. struct blk_desc *blk_get_dev(const char *ifname, int dev)
  74. {
  75. return NULL;
  76. }
  77. #endif
  78. #ifdef CONFIG_HAVE_BLOCK_DEVICE
  79. /* ------------------------------------------------------------------------- */
  80. /*
  81. * reports device info to the user
  82. */
  83. #ifdef CONFIG_LBA48
  84. typedef uint64_t lba512_t;
  85. #else
  86. typedef lbaint_t lba512_t;
  87. #endif
  88. /*
  89. * Overflowless variant of (block_count * mul_by / div_by)
  90. * when div_by > mul_by
  91. */
  92. static lba512_t lba512_muldiv(lba512_t block_count, lba512_t mul_by, lba512_t div_by)
  93. {
  94. lba512_t bc_quot, bc_rem;
  95. /* x * m / d == x / d * m + (x % d) * m / d */
  96. bc_quot = block_count / div_by;
  97. bc_rem = block_count - div_by * bc_quot;
  98. return bc_quot * mul_by + (bc_rem * mul_by) / div_by;
  99. }
  100. void dev_print (struct blk_desc *dev_desc)
  101. {
  102. lba512_t lba512; /* number of blocks if 512bytes block size */
  103. if (dev_desc->type == DEV_TYPE_UNKNOWN) {
  104. puts ("not available\n");
  105. return;
  106. }
  107. switch (dev_desc->if_type) {
  108. case IF_TYPE_SCSI:
  109. printf ("(%d:%d) Vendor: %s Prod.: %s Rev: %s\n",
  110. dev_desc->target,dev_desc->lun,
  111. dev_desc->vendor,
  112. dev_desc->product,
  113. dev_desc->revision);
  114. break;
  115. case IF_TYPE_ATAPI:
  116. case IF_TYPE_IDE:
  117. case IF_TYPE_SATA:
  118. printf ("Model: %s Firm: %s Ser#: %s\n",
  119. dev_desc->vendor,
  120. dev_desc->revision,
  121. dev_desc->product);
  122. break;
  123. case IF_TYPE_SD:
  124. case IF_TYPE_MMC:
  125. case IF_TYPE_USB:
  126. case IF_TYPE_NVME:
  127. printf ("Vendor: %s Rev: %s Prod: %s\n",
  128. dev_desc->vendor,
  129. dev_desc->revision,
  130. dev_desc->product);
  131. break;
  132. case IF_TYPE_VIRTIO:
  133. printf("%s VirtIO Block Device\n", dev_desc->vendor);
  134. break;
  135. case IF_TYPE_DOC:
  136. puts("device type DOC\n");
  137. return;
  138. case IF_TYPE_UNKNOWN:
  139. puts("device type unknown\n");
  140. return;
  141. default:
  142. printf("Unhandled device type: %i\n", dev_desc->if_type);
  143. return;
  144. }
  145. puts (" Type: ");
  146. if (dev_desc->removable)
  147. puts ("Removable ");
  148. switch (dev_desc->type & 0x1F) {
  149. case DEV_TYPE_HARDDISK:
  150. puts ("Hard Disk");
  151. break;
  152. case DEV_TYPE_CDROM:
  153. puts ("CD ROM");
  154. break;
  155. case DEV_TYPE_OPDISK:
  156. puts ("Optical Device");
  157. break;
  158. case DEV_TYPE_TAPE:
  159. puts ("Tape");
  160. break;
  161. default:
  162. printf ("# %02X #", dev_desc->type & 0x1F);
  163. break;
  164. }
  165. puts ("\n");
  166. if (dev_desc->lba > 0L && dev_desc->blksz > 0L) {
  167. ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
  168. lbaint_t lba;
  169. lba = dev_desc->lba;
  170. lba512 = (lba * (dev_desc->blksz/512));
  171. /* round to 1 digit */
  172. /* 2048 = (1024 * 1024) / 512 MB */
  173. mb = lba512_muldiv(lba512, 10, 2048);
  174. mb_quot = mb / 10;
  175. mb_rem = mb - (10 * mb_quot);
  176. gb = mb / 1024;
  177. gb_quot = gb / 10;
  178. gb_rem = gb - (10 * gb_quot);
  179. #ifdef CONFIG_LBA48
  180. if (dev_desc->lba48)
  181. printf (" Supports 48-bit addressing\n");
  182. #endif
  183. #if defined(CONFIG_SYS_64BIT_LBA)
  184. printf (" Capacity: %lu.%lu MB = %lu.%lu GB (%llu x %lu)\n",
  185. mb_quot, mb_rem,
  186. gb_quot, gb_rem,
  187. lba,
  188. dev_desc->blksz);
  189. #else
  190. printf (" Capacity: %lu.%lu MB = %lu.%lu GB (%lu x %lu)\n",
  191. mb_quot, mb_rem,
  192. gb_quot, gb_rem,
  193. (ulong)lba,
  194. dev_desc->blksz);
  195. #endif
  196. } else {
  197. puts (" Capacity: not available\n");
  198. }
  199. }
  200. #endif
  201. #ifdef CONFIG_HAVE_BLOCK_DEVICE
  202. void part_init(struct blk_desc *dev_desc)
  203. {
  204. struct part_driver *drv =
  205. ll_entry_start(struct part_driver, part_driver);
  206. const int n_ents = ll_entry_count(struct part_driver, part_driver);
  207. struct part_driver *entry;
  208. blkcache_invalidate(dev_desc->if_type, dev_desc->devnum);
  209. dev_desc->part_type = PART_TYPE_UNKNOWN;
  210. for (entry = drv; entry != drv + n_ents; entry++) {
  211. int ret;
  212. ret = entry->test(dev_desc);
  213. debug("%s: try '%s': ret=%d\n", __func__, entry->name, ret);
  214. if (!ret) {
  215. dev_desc->part_type = entry->part_type;
  216. break;
  217. }
  218. }
  219. }
  220. static void print_part_header(const char *type, struct blk_desc *dev_desc)
  221. {
  222. #if CONFIG_IS_ENABLED(MAC_PARTITION) || \
  223. CONFIG_IS_ENABLED(DOS_PARTITION) || \
  224. CONFIG_IS_ENABLED(ISO_PARTITION) || \
  225. CONFIG_IS_ENABLED(AMIGA_PARTITION) || \
  226. CONFIG_IS_ENABLED(EFI_PARTITION)
  227. puts ("\nPartition Map for ");
  228. switch (dev_desc->if_type) {
  229. case IF_TYPE_IDE:
  230. puts ("IDE");
  231. break;
  232. case IF_TYPE_SATA:
  233. puts ("SATA");
  234. break;
  235. case IF_TYPE_SCSI:
  236. puts ("SCSI");
  237. break;
  238. case IF_TYPE_ATAPI:
  239. puts ("ATAPI");
  240. break;
  241. case IF_TYPE_USB:
  242. puts ("USB");
  243. break;
  244. case IF_TYPE_DOC:
  245. puts ("DOC");
  246. break;
  247. case IF_TYPE_MMC:
  248. puts ("MMC");
  249. break;
  250. case IF_TYPE_HOST:
  251. puts ("HOST");
  252. break;
  253. case IF_TYPE_NVME:
  254. puts ("NVMe");
  255. break;
  256. case IF_TYPE_VIRTIO:
  257. puts("VirtIO");
  258. break;
  259. default:
  260. puts ("UNKNOWN");
  261. break;
  262. }
  263. printf (" device %d -- Partition Type: %s\n\n",
  264. dev_desc->devnum, type);
  265. #endif /* any CONFIG_..._PARTITION */
  266. }
  267. void part_print(struct blk_desc *dev_desc)
  268. {
  269. struct part_driver *drv;
  270. drv = part_driver_lookup_type(dev_desc);
  271. if (!drv) {
  272. printf("## Unknown partition table type %x\n",
  273. dev_desc->part_type);
  274. return;
  275. }
  276. PRINTF("## Testing for valid %s partition ##\n", drv->name);
  277. print_part_header(drv->name, dev_desc);
  278. if (drv->print)
  279. drv->print(dev_desc);
  280. }
  281. #endif /* CONFIG_HAVE_BLOCK_DEVICE */
  282. int part_get_info(struct blk_desc *dev_desc, int part,
  283. disk_partition_t *info)
  284. {
  285. #ifdef CONFIG_HAVE_BLOCK_DEVICE
  286. struct part_driver *drv;
  287. #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
  288. /* The common case is no UUID support */
  289. info->uuid[0] = 0;
  290. #endif
  291. #ifdef CONFIG_PARTITION_TYPE_GUID
  292. info->type_guid[0] = 0;
  293. #endif
  294. drv = part_driver_lookup_type(dev_desc);
  295. if (!drv) {
  296. debug("## Unknown partition table type %x\n",
  297. dev_desc->part_type);
  298. return -EPROTONOSUPPORT;
  299. }
  300. if (!drv->get_info) {
  301. PRINTF("## Driver %s does not have the get_info() method\n",
  302. drv->name);
  303. return -ENOSYS;
  304. }
  305. if (drv->get_info(dev_desc, part, info) == 0) {
  306. PRINTF("## Valid %s partition found ##\n", drv->name);
  307. return 0;
  308. }
  309. #endif /* CONFIG_HAVE_BLOCK_DEVICE */
  310. return -1;
  311. }
  312. int part_get_info_whole_disk(struct blk_desc *dev_desc, disk_partition_t *info)
  313. {
  314. info->start = 0;
  315. info->size = dev_desc->lba;
  316. info->blksz = dev_desc->blksz;
  317. info->bootable = 0;
  318. strcpy((char *)info->type, BOOT_PART_TYPE);
  319. strcpy((char *)info->name, "Whole Disk");
  320. #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
  321. info->uuid[0] = 0;
  322. #endif
  323. #ifdef CONFIG_PARTITION_TYPE_GUID
  324. info->type_guid[0] = 0;
  325. #endif
  326. return 0;
  327. }
  328. int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,
  329. struct blk_desc **dev_desc)
  330. {
  331. char *ep;
  332. char *dup_str = NULL;
  333. const char *dev_str, *hwpart_str;
  334. int dev, hwpart;
  335. hwpart_str = strchr(dev_hwpart_str, '.');
  336. if (hwpart_str) {
  337. dup_str = strdup(dev_hwpart_str);
  338. dup_str[hwpart_str - dev_hwpart_str] = 0;
  339. dev_str = dup_str;
  340. hwpart_str++;
  341. } else {
  342. dev_str = dev_hwpart_str;
  343. hwpart = 0;
  344. }
  345. dev = simple_strtoul(dev_str, &ep, 16);
  346. if (*ep) {
  347. printf("** Bad device specification %s %s **\n",
  348. ifname, dev_str);
  349. dev = -EINVAL;
  350. goto cleanup;
  351. }
  352. if (hwpart_str) {
  353. hwpart = simple_strtoul(hwpart_str, &ep, 16);
  354. if (*ep) {
  355. printf("** Bad HW partition specification %s %s **\n",
  356. ifname, hwpart_str);
  357. dev = -EINVAL;
  358. goto cleanup;
  359. }
  360. }
  361. *dev_desc = get_dev_hwpart(ifname, dev, hwpart);
  362. if (!(*dev_desc) || ((*dev_desc)->type == DEV_TYPE_UNKNOWN)) {
  363. debug("** Bad device %s %s **\n", ifname, dev_hwpart_str);
  364. dev = -ENOENT;
  365. goto cleanup;
  366. }
  367. #ifdef CONFIG_HAVE_BLOCK_DEVICE
  368. /*
  369. * Updates the partition table for the specified hw partition.
  370. * Does not need to be done for hwpart 0 since it is default and
  371. * already loaded.
  372. */
  373. if(hwpart != 0)
  374. part_init(*dev_desc);
  375. #endif
  376. cleanup:
  377. free(dup_str);
  378. return dev;
  379. }
  380. #define PART_UNSPECIFIED -2
  381. #define PART_AUTO -1
  382. int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
  383. struct blk_desc **dev_desc,
  384. disk_partition_t *info, int allow_whole_dev)
  385. {
  386. int ret = -1;
  387. const char *part_str;
  388. char *dup_str = NULL;
  389. const char *dev_str;
  390. int dev;
  391. char *ep;
  392. int p;
  393. int part;
  394. disk_partition_t tmpinfo;
  395. #ifdef CONFIG_SANDBOX
  396. /*
  397. * Special-case a pseudo block device "hostfs", to allow access to the
  398. * host's own filesystem.
  399. */
  400. if (0 == strcmp(ifname, "hostfs")) {
  401. *dev_desc = NULL;
  402. info->start = 0;
  403. info->size = 0;
  404. info->blksz = 0;
  405. info->bootable = 0;
  406. strcpy((char *)info->type, BOOT_PART_TYPE);
  407. strcpy((char *)info->name, "Sandbox host");
  408. #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
  409. info->uuid[0] = 0;
  410. #endif
  411. #ifdef CONFIG_PARTITION_TYPE_GUID
  412. info->type_guid[0] = 0;
  413. #endif
  414. return 0;
  415. }
  416. #endif
  417. #ifdef CONFIG_CMD_UBIFS
  418. /*
  419. * Special-case ubi, ubi goes through a mtd, rathen then through
  420. * a regular block device.
  421. */
  422. if (0 == strcmp(ifname, "ubi")) {
  423. if (!ubifs_is_mounted()) {
  424. printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
  425. return -1;
  426. }
  427. *dev_desc = NULL;
  428. memset(info, 0, sizeof(*info));
  429. strcpy((char *)info->type, BOOT_PART_TYPE);
  430. strcpy((char *)info->name, "UBI");
  431. #if CONFIG_IS_ENABLED(PARTITION_UUIDS)
  432. info->uuid[0] = 0;
  433. #endif
  434. return 0;
  435. }
  436. #endif
  437. /* If no dev_part_str, use bootdevice environment variable */
  438. if (!dev_part_str || !strlen(dev_part_str) ||
  439. !strcmp(dev_part_str, "-"))
  440. dev_part_str = env_get("bootdevice");
  441. /* If still no dev_part_str, it's an error */
  442. if (!dev_part_str) {
  443. printf("** No device specified **\n");
  444. goto cleanup;
  445. }
  446. /* Separate device and partition ID specification */
  447. part_str = strchr(dev_part_str, ':');
  448. if (part_str) {
  449. dup_str = strdup(dev_part_str);
  450. dup_str[part_str - dev_part_str] = 0;
  451. dev_str = dup_str;
  452. part_str++;
  453. } else {
  454. dev_str = dev_part_str;
  455. }
  456. /* Look up the device */
  457. dev = blk_get_device_by_str(ifname, dev_str, dev_desc);
  458. if (dev < 0)
  459. goto cleanup;
  460. /* Convert partition ID string to number */
  461. if (!part_str || !*part_str) {
  462. part = PART_UNSPECIFIED;
  463. } else if (!strcmp(part_str, "auto")) {
  464. part = PART_AUTO;
  465. } else {
  466. /* Something specified -> use exactly that */
  467. part = (int)simple_strtoul(part_str, &ep, 16);
  468. /*
  469. * Less than whole string converted,
  470. * or request for whole device, but caller requires partition.
  471. */
  472. if (*ep || (part == 0 && !allow_whole_dev)) {
  473. printf("** Bad partition specification %s %s **\n",
  474. ifname, dev_part_str);
  475. goto cleanup;
  476. }
  477. }
  478. /*
  479. * No partition table on device,
  480. * or user requested partition 0 (entire device).
  481. */
  482. if (((*dev_desc)->part_type == PART_TYPE_UNKNOWN) ||
  483. (part == 0)) {
  484. if (!(*dev_desc)->lba) {
  485. printf("** Bad device size - %s %s **\n", ifname,
  486. dev_str);
  487. goto cleanup;
  488. }
  489. /*
  490. * If user specified a partition ID other than 0,
  491. * or the calling command only accepts partitions,
  492. * it's an error.
  493. */
  494. if ((part > 0) || (!allow_whole_dev)) {
  495. printf("** No partition table - %s %s **\n", ifname,
  496. dev_str);
  497. goto cleanup;
  498. }
  499. (*dev_desc)->log2blksz = LOG2((*dev_desc)->blksz);
  500. part_get_info_whole_disk(*dev_desc, info);
  501. ret = 0;
  502. goto cleanup;
  503. }
  504. /*
  505. * Now there's known to be a partition table,
  506. * not specifying a partition means to pick partition 1.
  507. */
  508. if (part == PART_UNSPECIFIED)
  509. part = 1;
  510. /*
  511. * If user didn't specify a partition number, or did specify something
  512. * other than "auto", use that partition number directly.
  513. */
  514. if (part != PART_AUTO) {
  515. ret = part_get_info(*dev_desc, part, info);
  516. if (ret) {
  517. printf("** Invalid partition %d **\n", part);
  518. goto cleanup;
  519. }
  520. } else {
  521. /*
  522. * Find the first bootable partition.
  523. * If none are bootable, fall back to the first valid partition.
  524. */
  525. part = 0;
  526. for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
  527. ret = part_get_info(*dev_desc, p, info);
  528. if (ret)
  529. continue;
  530. /*
  531. * First valid partition, or new better partition?
  532. * If so, save partition ID.
  533. */
  534. if (!part || info->bootable)
  535. part = p;
  536. /* Best possible partition? Stop searching. */
  537. if (info->bootable)
  538. break;
  539. /*
  540. * We now need to search further for best possible.
  541. * If we what we just queried was the best so far,
  542. * save the info since we over-write it next loop.
  543. */
  544. if (part == p)
  545. tmpinfo = *info;
  546. }
  547. /* If we found any acceptable partition */
  548. if (part) {
  549. /*
  550. * If we searched all possible partition IDs,
  551. * return the first valid partition we found.
  552. */
  553. if (p == MAX_SEARCH_PARTITIONS + 1)
  554. *info = tmpinfo;
  555. } else {
  556. printf("** No valid partitions found **\n");
  557. ret = -1;
  558. goto cleanup;
  559. }
  560. }
  561. if (strncmp((char *)info->type, BOOT_PART_TYPE, sizeof(info->type)) != 0) {
  562. printf("** Invalid partition type \"%.32s\""
  563. " (expect \"" BOOT_PART_TYPE "\")\n",
  564. info->type);
  565. ret = -1;
  566. goto cleanup;
  567. }
  568. (*dev_desc)->log2blksz = LOG2((*dev_desc)->blksz);
  569. ret = part;
  570. goto cleanup;
  571. cleanup:
  572. free(dup_str);
  573. return ret;
  574. }
  575. int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
  576. disk_partition_t *info, int part_type)
  577. {
  578. struct part_driver *part_drv;
  579. int ret;
  580. int i;
  581. part_drv = part_driver_lookup_type(dev_desc);
  582. if (!part_drv)
  583. return -1;
  584. for (i = 1; i < part_drv->max_entries; i++) {
  585. ret = part_drv->get_info(dev_desc, i, info);
  586. if (ret != 0) {
  587. /* no more entries in table */
  588. break;
  589. }
  590. if (strcmp(name, (const char *)info->name) == 0) {
  591. /* matched */
  592. return i;
  593. }
  594. }
  595. return -1;
  596. }
  597. int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
  598. disk_partition_t *info)
  599. {
  600. return part_get_info_by_name_type(dev_desc, name, info, PART_TYPE_ALL);
  601. }
  602. void part_set_generic_name(const struct blk_desc *dev_desc,
  603. int part_num, char *name)
  604. {
  605. char *devtype;
  606. switch (dev_desc->if_type) {
  607. case IF_TYPE_IDE:
  608. case IF_TYPE_SATA:
  609. case IF_TYPE_ATAPI:
  610. devtype = "hd";
  611. break;
  612. case IF_TYPE_SCSI:
  613. devtype = "sd";
  614. break;
  615. case IF_TYPE_USB:
  616. devtype = "usbd";
  617. break;
  618. case IF_TYPE_DOC:
  619. devtype = "docd";
  620. break;
  621. case IF_TYPE_MMC:
  622. case IF_TYPE_SD:
  623. devtype = "mmcsd";
  624. break;
  625. default:
  626. devtype = "xx";
  627. break;
  628. }
  629. sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num);
  630. }