From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible
Date: Fri, 10 Aug 2018 09:14:01 +0200 [thread overview]
Message-ID: <20180810071401.i2wqpnwpegdidhzh@pengutronix.de> (raw)
In-Reply-To: <20180810062247.jlgodzci7xvbtqip@pengutronix.de>
On Fri, Aug 10, 2018 at 08:22:47AM +0200, Sascha Hauer wrote:
> On Thu, Aug 09, 2018 at 10:33:12AM +0200, Uwe Kleine-König wrote:
> > This makes the following do the expected thing:
> >
> > barebox@barebox sandbox:/ ls -l lala
> > -rwxrwxrwx 4 lala
> > barebox@barebox sandbox:/ mw -d lala 72 0
> >
> > Without this patch mw dies with
> >
> > lseek: Invalid argument
> >
> > memset, memcpy and probably others benefit in the same way.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> > lib/libfile.c | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > diff --git a/lib/libfile.c b/lib/libfile.c
> > index 83c6399a5b39..01c59cdb80fe 100644
> > --- a/lib/libfile.c
> > +++ b/lib/libfile.c
> > @@ -510,6 +510,24 @@ int open_and_lseek(const char *filename, int mode, loff_t pos)
> > if (!pos)
> > return fd;
> >
> > + if (mode & (O_WRONLY | O_RDWR)) {
> > + struct stat s;
> > +
> > + ret = fstat(fd, &s);
> > + if (ret) {
> > + perror("ftruncate");
>
> I assume this "ftruncate" did not happen on purpose, right? Replaced
> with "fstat" and applied.
Right, thanks
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-10 7:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 8:33 [PATCH 1/3] libfile: open_and_lseek: don't imply O_RDONLY Uwe Kleine-König
2018-08-09 8:33 ` [PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible Uwe Kleine-König
2018-08-10 6:22 ` Sascha Hauer
2018-08-10 7:14 ` Uwe Kleine-König [this message]
2018-08-09 8:33 ` [PATCH 3/3] commands: teach commands that write to files to also create them Uwe Kleine-König
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=20180810071401.i2wqpnwpegdidhzh@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.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