diff options
author | Markus Pargmann <mpa@pengutronix.de> | 2016-02-17 12:28:19 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-02-18 16:10:11 +0100 |
commit | 24ff0ab0fa0354d74c03c6a1cfddb05c52d9d113 (patch) | |
tree | 99bceacbbcd52441e962c5cf6c52b44eb5093139 /drivers/usb | |
parent | 7290110f1a6f4643beb7695ba7d26e472f8290c6 (diff) | |
download | barebox-24ff0ab0fa0354d74c03c6a1cfddb05c52d9d113.tar.gz barebox-24ff0ab0fa0354d74c03c6a1cfddb05c52d9d113.tar.xz |
fastboot: Fix usage of ubiformat for UBI image transfers
Currently all fastboot flash commands with UBI images are handled by a
final call to 'ubiformat'. This only makes sense for flash commands
where the target file is a mtd device. If we just want to transfer a UBI
image we would expect a simple copy to the correct location.
This patch checks if the destination file is a MTD device by opening it
and calling an ioctl MEMGETINFO. Only for MTD devices, ubiformat is
called.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index bf28f7c22a..bc06c58d8d 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -686,7 +686,21 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd } if (filetype == filetype_ubi) { - char *cmd = asprintf("ubiformat -y -f %s %s", FASTBOOT_TMPFILE, filename); + char *cmd; + int fd; + struct mtd_info_user meminfo; + + fd = open(filename, O_RDONLY); + if (fd < 0) + goto copy; + + ret = ioctl(fd, MEMGETINFO, &meminfo); + close(fd); + /* Not a MTD device, ubiformat is not a valid operation */ + if (ret) + goto copy; + + cmd = asprintf("ubiformat -y -f %s %s", FASTBOOT_TMPFILE, filename); fastboot_tx_print(f_fb, "INFOThis is an UBI image..."); @@ -702,6 +716,7 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd goto out; } +copy: ret = copy_file(FASTBOOT_TMPFILE, filename, 1); if (ret) { fastboot_tx_print(f_fb, "FAILwrite partition: %s", strerror(-ret)); |