[PATCH 5/8] mtd: ubi: umount mounted volumes before detaching a ubi device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/mtd/ubi/barebox.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/mtd/ubi/barebox.c b/drivers/mtd/ubi/barebox.c
index 1643f7c..f81705e 100644
--- a/drivers/mtd/ubi/barebox.c
+++ b/drivers/mtd/ubi/barebox.c
@@ -261,10 +261,25 @@ void ubi_cdev_remove(struct ubi_device *ubi)
 	kfree(cdev->name);
 }
 
+static void ubi_umount_volumes(struct ubi_device *ubi)
+{
+	int i;
+
+	for (i = 0; i < ubi->vtbl_slots; i++) {
+		struct ubi_volume *vol = ubi->volumes[i];
+		if (!vol)
+			continue;
+		umount_by_cdev(&vol->cdev);
+	}
+}
+
 /**
  * ubi_detach - detach an UBI device
  * @ubi_num: The UBI device number
  *
+ * UBI volumes used by UBIFS will be unmounted before detaching the
+ * UBI device.
+ *
  * @return: 0 for success, negative error code otherwise
  */
 int ubi_detach(int ubi_num)
@@ -278,5 +293,7 @@ int ubi_detach(int ubi_num)
 	if (!ubi)
 		return -ENOENT;
 
+	ubi_umount_volumes(ubi);
+
 	return ubi_detach_mtd_dev(ubi_num, 1);
 }
-- 
2.7.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux