From: Markus Pargmann <mpa@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] fastboot: Umount filesystems of target devices before flashing
Date: Wed, 9 Mar 2016 10:10:20 +0100 [thread overview]
Message-ID: <1457514620-14689-1-git-send-email-mpa@pengutronix.de> (raw)
Before flashing data to some device, we should check whether this device
is in use. If it is mounted it is umounted and flashed afterwards.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
Hi,
This patch requires the for_each_fs_device_safe() macro which was sent as a
patch yesterday.
Best Regards,
Markus
drivers/usb/gadget/f_fastboot.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 9a1058a9670b..e81392f38ae9 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -664,6 +664,37 @@ static void __maybe_unused cb_boot(struct usb_ep *ep, struct usb_request *req,
fastboot_tx_print(f_fb, "OKAY");
}
+/**
+ * fastboot_flash_umount_target checks whether the target file is a device and
+ * umounts mounted filesystems
+ * @param filename Target file name
+ * @return 0 on success, < 0 otherwise
+ */
+static int fastboot_flash_umount_target(const char *filename)
+{
+ struct cdev *tgt_cdev;
+ struct fs_device_d *fs;
+ struct fs_device_d *fs_tmp;
+
+ tgt_cdev = cdev_by_path(filename);
+ if (!tgt_cdev)
+ return 0;
+
+ for_each_fs_device_safe(fs_tmp, fs) {
+ int ret;
+
+ if (fs->cdev == tgt_cdev) {
+ ret = umount(fs->path);
+ if (ret) {
+ pr_err("Failed umounting %s, %d, continuing anyway\n",
+ fs->path, ret);
+ }
+ }
+ }
+
+ return 0;
+}
+
static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd)
{
struct f_fastboot *f_fb = req->context;
@@ -745,6 +776,8 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
goto out;
}
+ fastboot_flash_umount_target(filename);
+
copy:
ret = copy_file(FASTBOOT_TMPFILE, filename, 1);
if (ret) {
--
2.7.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2016-03-09 9:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1457514620-14689-1-git-send-email-mpa@pengutronix.de \
--to=mpa@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