065-rootfs_split.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. --- a/drivers/mtd/Kconfig
  2. +++ b/drivers/mtd/Kconfig
  3. @@ -53,6 +53,16 @@ config MTD_PARTITIONS
  4. devices. Partitioning on NFTL 'devices' is a different - that's the
  5. 'normal' form of partitioning used on a block device.
  6. +config MTD_ROOTFS_ROOT_DEV
  7. + bool "Automatically set 'rootfs' partition to be root filesystem"
  8. + depends on MTD_PARTITIONS
  9. + default y
  10. +
  11. +config MTD_ROOTFS_SPLIT
  12. + bool "Automatically split 'rootfs' partition for squashfs"
  13. + depends on MTD_PARTITIONS
  14. + default y
  15. +
  16. config MTD_REDBOOT_PARTS
  17. tristate "RedBoot partition table parsing"
  18. depends on MTD_PARTITIONS
  19. --- a/drivers/mtd/mtdpart.c
  20. +++ b/drivers/mtd/mtdpart.c
  21. @@ -29,6 +29,8 @@
  22. #include <linux/kmod.h>
  23. #include <linux/mtd/mtd.h>
  24. #include <linux/mtd/partitions.h>
  25. +#include <linux/root_dev.h>
  26. +#include <linux/magic.h>
  27. #include <linux/err.h>
  28. /* Our partition linked list */
  29. @@ -48,7 +50,7 @@ struct mtd_part {
  30. * the pointer to that structure with this macro.
  31. */
  32. #define PART(x) ((struct mtd_part *)(x))
  33. -
  34. +#define IS_PART(mtd) (mtd->read == part_read)
  35. /*
  36. * MTD methods which simply translate the effective address and pass through
  37. @@ -618,6 +620,153 @@ int mtd_del_partition(struct mtd_info *m
  38. }
  39. EXPORT_SYMBOL_GPL(mtd_del_partition);
  40. +#ifdef CONFIG_MTD_ROOTFS_SPLIT
  41. +#define ROOTFS_SPLIT_NAME "rootfs_data"
  42. +#define ROOTFS_REMOVED_NAME "<removed>"
  43. +
  44. +struct squashfs_super_block {
  45. + __le32 s_magic;
  46. + __le32 pad0[9];
  47. + __le64 bytes_used;
  48. +};
  49. +
  50. +
  51. +static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
  52. +{
  53. + struct squashfs_super_block sb;
  54. + int len, ret;
  55. +
  56. + ret = master->read(master, offset, sizeof(sb), &len, (void *) &sb);
  57. + if (ret || (len != sizeof(sb))) {
  58. + printk(KERN_ALERT "split_squashfs: error occured while reading "
  59. + "from \"%s\"\n", master->name);
  60. + return -EINVAL;
  61. + }
  62. +
  63. + if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) {
  64. + printk(KERN_ALERT "split_squashfs: no squashfs found in \"%s\"\n",
  65. + master->name);
  66. + *split_offset = 0;
  67. + return 0;
  68. + }
  69. +
  70. + if (le64_to_cpu((sb.bytes_used)) <= 0) {
  71. + printk(KERN_ALERT "split_squashfs: squashfs is empty in \"%s\"\n",
  72. + master->name);
  73. + *split_offset = 0;
  74. + return 0;
  75. + }
  76. +
  77. + len = (u32) le64_to_cpu(sb.bytes_used);
  78. + len += (offset & 0x000fffff);
  79. + len += (master->erasesize - 1);
  80. + len &= ~(master->erasesize - 1);
  81. + len -= (offset & 0x000fffff);
  82. + *split_offset = offset + len;
  83. +
  84. + return 0;
  85. +}
  86. +
  87. +static int split_rootfs_data(struct mtd_info *master, struct mtd_info *rpart, const struct mtd_partition *part)
  88. +{
  89. + struct mtd_partition *dpart;
  90. + struct mtd_part *slave = NULL;
  91. + int ret, split_offset = 0;
  92. +
  93. + ret = split_squashfs(master, part->offset, &split_offset);
  94. + if (ret)
  95. + return ret;
  96. +
  97. + if (split_offset <= 0)
  98. + return 0;
  99. +
  100. + dpart = kmalloc(sizeof(*part)+sizeof(ROOTFS_SPLIT_NAME)+1, GFP_KERNEL);
  101. + if (dpart == NULL) {
  102. + printk(KERN_INFO "split_squashfs: no memory for partition \"%s\"\n",
  103. + ROOTFS_SPLIT_NAME);
  104. + return -ENOMEM;
  105. + }
  106. +
  107. + memcpy(dpart, part, sizeof(*part));
  108. + dpart->name = (unsigned char *)&dpart[1];
  109. + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
  110. +
  111. + dpart->size -= split_offset - dpart->offset;
  112. + dpart->offset = split_offset;
  113. +
  114. + if (dpart == NULL)
  115. + return 1;
  116. +
  117. + printk(KERN_INFO "mtd: partition \"%s\" created automatically, ofs=%llX, len=%llX \n",
  118. + ROOTFS_SPLIT_NAME, dpart->offset, dpart->size);
  119. +
  120. + slave = allocate_partition(master, dpart, 0, split_offset);
  121. + if (IS_ERR(slave))
  122. + return PTR_ERR(slave);
  123. + mutex_lock(&mtd_partitions_mutex);
  124. + list_add(&slave->list, &mtd_partitions);
  125. + mutex_unlock(&mtd_partitions_mutex);
  126. +
  127. + add_mtd_device(&slave->mtd);
  128. +
  129. + rpart->split = &slave->mtd;
  130. +
  131. + return 0;
  132. +}
  133. +
  134. +static int refresh_rootfs_split(struct mtd_info *mtd)
  135. +{
  136. + struct mtd_partition tpart;
  137. + struct mtd_part *part;
  138. + char *name;
  139. + //int index = 0;
  140. + int offset, size;
  141. + int ret;
  142. +
  143. + part = PART(mtd);
  144. +
  145. + /* check for the new squashfs offset first */
  146. + ret = split_squashfs(part->master, part->offset, &offset);
  147. + if (ret)
  148. + return ret;
  149. +
  150. + if ((offset > 0) && !mtd->split) {
  151. + printk(KERN_INFO "%s: creating new split partition for \"%s\"\n", __func__, mtd->name);
  152. + /* if we don't have a rootfs split partition, create a new one */
  153. + tpart.name = (char *) mtd->name;
  154. + tpart.size = mtd->size;
  155. + tpart.offset = part->offset;
  156. +
  157. + return split_rootfs_data(part->master, &part->mtd, &tpart);
  158. + } else if ((offset > 0) && mtd->split) {
  159. + /* update the offsets of the existing partition */
  160. + size = mtd->size + part->offset - offset;
  161. +
  162. + part = PART(mtd->split);
  163. + part->offset = offset;
  164. + part->mtd.size = size;
  165. + printk(KERN_INFO "%s: %s partition \"" ROOTFS_SPLIT_NAME "\", offset: 0x%06x (0x%06x)\n",
  166. + __func__, (!strcmp(part->mtd.name, ROOTFS_SPLIT_NAME) ? "updating" : "creating"),
  167. + (u32) part->offset, (u32) part->mtd.size);
  168. + name = kmalloc(sizeof(ROOTFS_SPLIT_NAME) + 1, GFP_KERNEL);
  169. + strcpy(name, ROOTFS_SPLIT_NAME);
  170. + part->mtd.name = name;
  171. + } else if ((offset <= 0) && mtd->split) {
  172. + printk(KERN_INFO "%s: removing partition \"%s\"\n", __func__, mtd->split->name);
  173. +
  174. + /* mark existing partition as removed */
  175. + part = PART(mtd->split);
  176. + name = kmalloc(sizeof(ROOTFS_SPLIT_NAME) + 1, GFP_KERNEL);
  177. + strcpy(name, ROOTFS_REMOVED_NAME);
  178. + part->mtd.name = name;
  179. + part->offset = 0;
  180. + part->mtd.size = 0;
  181. + }
  182. +
  183. + return 0;
  184. +}
  185. +#endif /* CONFIG_MTD_ROOTFS_SPLIT */
  186. +
  187. /*
  188. * This function, given a master MTD object and a partition table, creates
  189. * and registers slave MTD objects which are bound to the master according to
  190. @@ -633,7 +782,7 @@ int add_mtd_partitions(struct mtd_info *
  191. {
  192. struct mtd_part *slave;
  193. uint64_t cur_offset = 0;
  194. - int i;
  195. + int i, ret;
  196. printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
  197. @@ -648,6 +797,21 @@ int add_mtd_partitions(struct mtd_info *
  198. add_mtd_device(&slave->mtd);
  199. + if (!strcmp(parts[i].name, "rootfs")) {
  200. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  201. + if (ROOT_DEV == 0) {
  202. + printk(KERN_NOTICE "mtd: partition \"rootfs\" "
  203. + "set to be root filesystem\n");
  204. + ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, slave->mtd.index);
  205. + }
  206. +#endif
  207. +#ifdef CONFIG_MTD_ROOTFS_SPLIT
  208. + ret = split_rootfs_data(master, &slave->mtd, &parts[i]);
  209. + /* if (ret == 0)
  210. + * j++; */
  211. +#endif
  212. + }
  213. +
  214. cur_offset = slave->offset + slave->mtd.size;
  215. }
  216. @@ -655,6 +819,32 @@ int add_mtd_partitions(struct mtd_info *
  217. }
  218. EXPORT_SYMBOL(add_mtd_partitions);
  219. +int refresh_mtd_partitions(struct mtd_info *mtd)
  220. +{
  221. + int ret = 0;
  222. +
  223. + if (IS_PART(mtd)) {
  224. + struct mtd_part *part;
  225. + struct mtd_info *master;
  226. +
  227. + part = PART(mtd);
  228. + master = part->master;
  229. + if (master->refresh_device)
  230. + ret = master->refresh_device(master);
  231. + }
  232. +
  233. + if (!ret && mtd->refresh_device)
  234. + ret = mtd->refresh_device(mtd);
  235. +
  236. +#ifdef CONFIG_MTD_ROOTFS_SPLIT
  237. + if (!ret && IS_PART(mtd) && !strcmp(mtd->name, "rootfs"))
  238. + refresh_rootfs_split(mtd);
  239. +#endif
  240. +
  241. + return 0;
  242. +}
  243. +EXPORT_SYMBOL_GPL(refresh_mtd_partitions);
  244. +
  245. static DEFINE_SPINLOCK(part_parser_lock);
  246. static LIST_HEAD(part_parsers);
  247. --- a/drivers/mtd/devices/block2mtd.c
  248. +++ b/drivers/mtd/devices/block2mtd.c
  249. @@ -30,6 +30,8 @@ struct block2mtd_dev {
  250. struct block_device *blkdev;
  251. struct mtd_info mtd;
  252. struct mutex write_mutex;
  253. + rwlock_t bdev_mutex;
  254. + char devname[0];
  255. };
  256. @@ -82,6 +84,12 @@ static int block2mtd_erase(struct mtd_in
  257. size_t len = instr->len;
  258. int err;
  259. + read_lock(&dev->bdev_mutex);
  260. + if (!dev->blkdev) {
  261. + err = -EINVAL;
  262. + goto done;
  263. + }
  264. +
  265. instr->state = MTD_ERASING;
  266. mutex_lock(&dev->write_mutex);
  267. err = _block2mtd_erase(dev, from, len);
  268. @@ -93,6 +101,10 @@ static int block2mtd_erase(struct mtd_in
  269. instr->state = MTD_ERASE_DONE;
  270. mtd_erase_callback(instr);
  271. +
  272. +done:
  273. + read_unlock(&dev->bdev_mutex);
  274. +
  275. return err;
  276. }
  277. @@ -104,10 +116,14 @@ static int block2mtd_read(struct mtd_inf
  278. struct page *page;
  279. int index = from >> PAGE_SHIFT;
  280. int offset = from & (PAGE_SIZE-1);
  281. - int cpylen;
  282. + int cpylen, err = 0;
  283. +
  284. + read_lock(&dev->bdev_mutex);
  285. + if (!dev->blkdev || (from > mtd->size)) {
  286. + err = -EINVAL;
  287. + goto done;
  288. + }
  289. - if (from > mtd->size)
  290. - return -EINVAL;
  291. if (from + len > mtd->size)
  292. len = mtd->size - from;
  293. @@ -122,10 +138,14 @@ static int block2mtd_read(struct mtd_inf
  294. len = len - cpylen;
  295. page = page_read(dev->blkdev->bd_inode->i_mapping, index);
  296. - if (!page)
  297. - return -ENOMEM;
  298. - if (IS_ERR(page))
  299. - return PTR_ERR(page);
  300. + if (!page) {
  301. + err = -ENOMEM;
  302. + goto done;
  303. + }
  304. + if (IS_ERR(page)) {
  305. + err = PTR_ERR(page);
  306. + goto done;
  307. + }
  308. memcpy(buf, page_address(page) + offset, cpylen);
  309. page_cache_release(page);
  310. @@ -136,7 +156,10 @@ static int block2mtd_read(struct mtd_inf
  311. offset = 0;
  312. index++;
  313. }
  314. - return 0;
  315. +
  316. +done:
  317. + read_unlock(&dev->bdev_mutex);
  318. + return err;
  319. }
  320. @@ -188,12 +211,22 @@ static int block2mtd_write(struct mtd_in
  321. size_t *retlen, const u_char *buf)
  322. {
  323. struct block2mtd_dev *dev = mtd->priv;
  324. - int err;
  325. + int err = 0;
  326. +
  327. + read_lock(&dev->bdev_mutex);
  328. + if (!dev->blkdev) {
  329. + err = -EINVAL;
  330. + goto done;
  331. + }
  332. if (!len)
  333. - return 0;
  334. - if (to >= mtd->size)
  335. - return -ENOSPC;
  336. + goto done;
  337. +
  338. + if (to >= mtd->size) {
  339. + err = -ENOSPC;
  340. + goto done;
  341. + }
  342. +
  343. if (to + len > mtd->size)
  344. len = mtd->size - to;
  345. @@ -202,6 +235,9 @@ static int block2mtd_write(struct mtd_in
  346. mutex_unlock(&dev->write_mutex);
  347. if (err > 0)
  348. err = 0;
  349. +
  350. +done:
  351. + read_unlock(&dev->bdev_mutex);
  352. return err;
  353. }
  354. @@ -210,52 +246,29 @@ static int block2mtd_write(struct mtd_in
  355. static void block2mtd_sync(struct mtd_info *mtd)
  356. {
  357. struct block2mtd_dev *dev = mtd->priv;
  358. - sync_blockdev(dev->blkdev);
  359. - return;
  360. -}
  361. -
  362. -
  363. -static void block2mtd_free_device(struct block2mtd_dev *dev)
  364. -{
  365. - if (!dev)
  366. - return;
  367. -
  368. - kfree(dev->mtd.name);
  369. - if (dev->blkdev) {
  370. - invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping,
  371. - 0, -1);
  372. - close_bdev_exclusive(dev->blkdev, FMODE_READ|FMODE_WRITE);
  373. - }
  374. + read_lock(&dev->bdev_mutex);
  375. + if (dev->blkdev)
  376. + sync_blockdev(dev->blkdev);
  377. + read_unlock(&dev->bdev_mutex);
  378. - kfree(dev);
  379. + return;
  380. }
  381. -/* FIXME: ensure that mtd->size % erase_size == 0 */
  382. -static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
  383. +static int _open_bdev(struct block2mtd_dev *dev)
  384. {
  385. struct block_device *bdev;
  386. - struct block2mtd_dev *dev;
  387. - struct mtd_partition *part;
  388. - char *name;
  389. -
  390. - if (!devname)
  391. - return NULL;
  392. -
  393. - dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
  394. - if (!dev)
  395. - return NULL;
  396. /* Get a handle on the device */
  397. - bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, NULL);
  398. + bdev = open_bdev_exclusive(dev->devname, FMODE_READ|FMODE_WRITE, NULL);
  399. #ifndef MODULE
  400. if (IS_ERR(bdev)) {
  401. /* We might not have rootfs mounted at this point. Try
  402. to resolve the device name by other means. */
  403. - dev_t devt = name_to_dev_t(devname);
  404. + dev_t devt = name_to_dev_t(dev->devname);
  405. if (devt) {
  406. bdev = open_by_devnum(devt, FMODE_WRITE | FMODE_READ);
  407. }
  408. @@ -263,17 +276,98 @@ static struct block2mtd_dev *add_device(
  409. #endif
  410. if (IS_ERR(bdev)) {
  411. - ERROR("error: cannot open device %s", devname);
  412. - goto devinit_err;
  413. + ERROR("error: cannot open device %s", dev->devname);
  414. + return 1;
  415. }
  416. dev->blkdev = bdev;
  417. if (MAJOR(bdev->bd_dev) == MTD_BLOCK_MAJOR) {
  418. ERROR("attempting to use an MTD device as a block device");
  419. - goto devinit_err;
  420. + return 1;
  421. }
  422. + return 0;
  423. +}
  424. +
  425. +static void _close_bdev(struct block2mtd_dev *dev)
  426. +{
  427. + struct block_device *bdev;
  428. +
  429. + if (!dev->blkdev)
  430. + return;
  431. +
  432. + bdev = dev->blkdev;
  433. + invalidate_mapping_pages(dev->blkdev->bd_inode->i_mapping, 0, -1);
  434. + close_bdev_exclusive(dev->blkdev, FMODE_READ|FMODE_WRITE);
  435. + dev->blkdev = NULL;
  436. +}
  437. +
  438. +static void block2mtd_free_device(struct block2mtd_dev *dev)
  439. +{
  440. + if (!dev)
  441. + return;
  442. +
  443. + kfree(dev->mtd.name);
  444. + _close_bdev(dev);
  445. + kfree(dev);
  446. +}
  447. +
  448. +
  449. +static int block2mtd_refresh(struct mtd_info *mtd)
  450. +{
  451. + struct block2mtd_dev *dev = mtd->priv;
  452. + struct block_device *bdev;
  453. + dev_t devt;
  454. + int err = 0;
  455. +
  456. + /* no other mtd function can run at this point */
  457. + write_lock(&dev->bdev_mutex);
  458. +
  459. + /* get the device number for the whole disk */
  460. + devt = MKDEV(MAJOR(dev->blkdev->bd_dev), 0);
  461. +
  462. + /* close the old block device */
  463. + _close_bdev(dev);
  464. +
  465. + /* open the whole disk, issue a partition rescan, then */
  466. + bdev = open_by_devnum(devt, FMODE_WRITE | FMODE_READ);
  467. + if (!bdev || !bdev->bd_disk)
  468. + err = -EINVAL;
  469. +#ifndef CONFIG_MTD_BLOCK2MTD_MODULE
  470. + else
  471. + err = rescan_partitions(bdev->bd_disk, bdev);
  472. +#endif
  473. + if (bdev)
  474. + close_bdev_exclusive(bdev, FMODE_READ|FMODE_WRITE);
  475. +
  476. + /* try to open the partition block device again */
  477. + _open_bdev(dev);
  478. + write_unlock(&dev->bdev_mutex);
  479. +
  480. + return err;
  481. +}
  482. +
  483. +/* FIXME: ensure that mtd->size % erase_size == 0 */
  484. +static struct block2mtd_dev *add_device(char *devname, int erase_size, char *mtdname)
  485. +{
  486. + struct block2mtd_dev *dev;
  487. + struct mtd_partition *part;
  488. + char *name;
  489. +
  490. + if (!devname)
  491. + return NULL;
  492. +
  493. + dev = kzalloc(sizeof(struct block2mtd_dev) + strlen(devname) + 1, GFP_KERNEL);
  494. + if (!dev)
  495. + return NULL;
  496. +
  497. + strcpy(dev->devname, devname);
  498. +
  499. + if (_open_bdev(dev))
  500. + goto devinit_err;
  501. +
  502. mutex_init(&dev->write_mutex);
  503. + rwlock_init(&dev->bdev_mutex);
  504. /* Setup the MTD structure */
  505. /* make the name contain the block device in */
  506. @@ -298,6 +392,7 @@ static struct block2mtd_dev *add_device(
  507. dev->mtd.read = block2mtd_read;
  508. dev->mtd.priv = dev;
  509. dev->mtd.owner = THIS_MODULE;
  510. + dev->mtd.refresh_device = block2mtd_refresh;
  511. part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
  512. part->name = dev->mtd.name;
  513. --- a/drivers/mtd/mtdchar.c
  514. +++ b/drivers/mtd/mtdchar.c
  515. @@ -841,6 +841,13 @@ static int mtd_ioctl(struct file *file,
  516. file->f_pos = 0;
  517. break;
  518. }
  519. +#ifdef CONFIG_MTD_PARTITIONS
  520. + case MTDREFRESH:
  521. + {
  522. + ret = refresh_mtd_partitions(mtd);
  523. + break;
  524. + }
  525. +#endif
  526. case OTPGETREGIONCOUNT:
  527. case OTPGETREGIONINFO:
  528. --- a/include/linux/mtd/mtd.h
  529. +++ b/include/linux/mtd/mtd.h
  530. @@ -125,6 +125,7 @@ struct nand_ecclayout {
  531. struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
  532. };
  533. +struct mtd_info;
  534. struct mtd_info {
  535. u_char type;
  536. uint32_t flags;
  537. @@ -266,6 +267,9 @@ struct mtd_info {
  538. struct device dev;
  539. int usecount;
  540. + int (*refresh_device)(struct mtd_info *mtd);
  541. + struct mtd_info *split;
  542. +
  543. /* If the driver is something smart, like UBI, it may need to maintain
  544. * its own reference counting. The below functions are only for driver.
  545. * The driver may register its callbacks. These callbacks are not
  546. --- a/include/linux/mtd/partitions.h
  547. +++ b/include/linux/mtd/partitions.h
  548. @@ -34,12 +34,14 @@
  549. * erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK).
  550. */
  551. +struct mtd_partition;
  552. struct mtd_partition {
  553. char *name; /* identifier string */
  554. uint64_t size; /* partition size */
  555. uint64_t offset; /* offset within the master MTD space */
  556. uint32_t mask_flags; /* master MTD flags to mask out for this partition */
  557. struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */
  558. + int (*refresh_partition)(struct mtd_info *);
  559. };
  560. #define MTDPART_OFS_NXTBLK (-2)
  561. @@ -51,6 +53,7 @@ struct mtd_info;
  562. int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
  563. int del_mtd_partitions(struct mtd_info *);
  564. +int refresh_mtd_partitions(struct mtd_info *);
  565. /*
  566. * Functions dealing with the various ways of partitioning the space
  567. --- a/include/mtd/mtd-abi.h
  568. +++ b/include/mtd/mtd-abi.h
  569. @@ -127,6 +127,7 @@ struct otp_info {
  570. #define MEMWRITEOOB64 _IOWR('M', 21, struct mtd_oob_buf64)
  571. #define MEMREADOOB64 _IOWR('M', 22, struct mtd_oob_buf64)
  572. #define MEMISLOCKED _IOR('M', 23, struct erase_info_user)
  573. +#define MTDREFRESH _IO('M', 23)
  574. /*
  575. * Obsolete legacy interface. Keep it in order not to break userspace