mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/8] mtd: ubi: umount mounted volumes before detaching a ubi device
Date: Tue, 15 Mar 2016 12:22:29 +0100	[thread overview]
Message-ID: <1458040952-6826-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1458040952-6826-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-03-15 11:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15 11:22 Let ubiformat umount / detach users Sascha Hauer
2016-03-15 11:22 ` [PATCH 1/8] fs: umount based on device path and mount path Sascha Hauer
2016-03-15 11:22 ` [PATCH 2/8] fs: Add for_each_fs_device_safe() Sascha Hauer
2016-03-15 11:22 ` [PATCH 3/8] mtd: ubi: rename cdev.c to barebox.c Sascha Hauer
2016-03-15 11:22 ` [PATCH 4/8] mtd: ubi: make ubi_detach_mtd_dev ubi internal Sascha Hauer
2016-03-15 11:22 ` Sascha Hauer [this message]
2016-03-15 11:22 ` [PATCH 6/8] mtd: ubi: Add function to get ubi number from mtd device Sascha Hauer
2016-03-15 11:22 ` [PATCH 7/8] commands: ubidetach: Allow mtd devices as argument Sascha Hauer
2016-03-15 11:22 ` [PATCH 8/8] ubiformat: Cleanly umount and detach the ubi before formating Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458040952-6826-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox