065-rootfs_split.patch 15 KB

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