From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/6] fat: write: fix broken write to fragmented files
Date: Wed, 27 Nov 2019 11:26:07 +0900 [thread overview]
Message-ID: <20191127022606.GK22427@linaro.org> (raw)
In-Reply-To: <20191126165729.GA15966@bill-the-cat>
Thank you for the heads-up.
On Tue, Nov 26, 2019 at 11:57:29AM -0500, Tom Rini wrote:
> On Tue, Nov 26, 2019 at 09:15:07AM +0100, Marek Szyprowski wrote:
>
> > The code for handing file overwrite incorrectly assumed that the file on
> > disk is always contiguous. This resulted in corrupting disk structure
> > every time when write to existing fragmented file happened. Fix this
> > by adding proper check for cluster discontinuity and adjust chunk size
> > on each partial write.
> >
> > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > Reviewed-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
> > Reviewed-by: Lukasz Majewski <lukma@denx.de>
> > ---
> > fs/fat/fat_write.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
> > index 729cf39630..6cfa5b4565 100644
> > --- a/fs/fat/fat_write.c
> > +++ b/fs/fat/fat_write.c
> > @@ -794,6 +794,8 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
> >
> > newclust = get_fatent(mydata, endclust);
> >
> > + if ((newclust - 1) != endclust)
"newclust != (endclust + 1)" would be more intuitive?
But it's just my preference.
> > + break;
> > if (IS_LAST_CLUST(newclust, mydata->fatsize))
> > break;
> > if (CHECK_CLUST(newclust, mydata->fatsize)) {
> > @@ -811,7 +813,7 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
> > offset = 0;
> > else
> > offset = pos - cur_pos;
> > - wsize = min(cur_pos + actsize, filesize) - pos;
> > + wsize = min_t(unsigned long long, actsize, filesize - cur_pos);
This hunk is not directly related to the issue, is it?
> > if (get_set_cluster(mydata, curclust, offset,
> > buffer, wsize, &actsize)) {
> > printf("Error get-and-setting cluster\n");
> > @@ -824,8 +826,6 @@ set_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, __u8 *buffer,
> > if (filesize <= cur_pos)
> > break;
> >
> > - /* CHECK: newclust = get_fatent(mydata, endclust); */
> > -
> > if (IS_LAST_CLUST(newclust, mydata->fatsize))
> > /* no more clusters */
> > break;
>
> Adding in Heinrich and Akashi-san for more review on this, thanks!
Otherwise, it looks good.
Reviewed-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> --
> Tom
next prev parent reply other threads:[~2019-11-27 2:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20191126081543eucas1p2a86f5aecbfd7bdf740574fec2671bb4b@eucas1p2.samsung.com>
2019-11-26 8:15 ` [U-Boot] [PATCH v3 0/6] Raspberry Pi4: add support for DFU over USB Marek Szyprowski
2019-11-26 8:15 ` [U-Boot] [PATCH v3 1/6] fat: write: fix broken write to fragmented files Marek Szyprowski
2019-11-26 16:57 ` Tom Rini
2019-11-27 2:26 ` AKASHI Takahiro [this message]
2019-11-27 12:01 ` Marek Szyprowski
2019-11-26 8:15 ` [U-Boot] [PATCH v3 2/6] fat: write: fix broken write at non-zero file offset Marek Szyprowski
2019-11-26 16:57 ` Tom Rini
2019-11-27 3:13 ` AKASHI Takahiro
2019-11-27 13:34 ` Marek Szyprowski
2019-11-26 8:15 ` [U-Boot] [PATCH v3 3/6] dfu: mmc: rearrange the code Marek Szyprowski
2019-11-26 8:15 ` [U-Boot] [PATCH v3 4/6] dfu: mmc: remove file size limit for io operations Marek Szyprowski
2019-11-26 8:15 ` [U-Boot] [PATCH v3 5/6] usb: dwc2_udc_otg: add bcm2835 SoC (Raspberry Pi4) support Marek Szyprowski
2019-11-26 8:15 ` [U-Boot] [PATCH v3 6/6] config: enable DFU over USB on Raspberry Pi4 boards Marek Szyprowski
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=20191127022606.GK22427@linaro.org \
--to=takahiro.akashi@linaro.org \
--cc=u-boot@lists.denx.de \
/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