part.c 15 KB

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