lkml.org 
[lkml]   [2013]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 10/13] make dump_emit() use vfs_write() instead of banging at ->f_op->write directly
On Tue, Oct 08, 2013 at 05:52:42PM -0700, Linus Torvalds wrote:
> On Tue, Oct 8, 2013 at 5:15 PM, Al Viro <viro@ftp.linux.org.uk> wrote:
> >
> > ... and deal with short writes properly
>
> .. except you don't.
>
> > + while (nr) {
> > + if (dump_interrupted())
> > + return 0;
> > + n = vfs_write(file, addr, nr, &pos);
> > + if (n < 0)
> > + return 0;
> > + file->f_pos = pos;
> > + cprm->written += n;
> > + nr -= n;
> > + }
>
> Please handle 'n == 0' too. Maybe it never happens (ie you get EPIPE
> or ENOSPC), but write returning zero is actually possible and a valid
> return value and traditional for "end of media". Looping forever is
> not a good idea.

Point, but I would argue that we should yell very loud if we get 0 from
vfs_write() for non-zero size. I'm not sure if POSIX allows write(2)
to return that, but a lot of userland code won't be expecting that and
won't be able to cope...


\
 
 \ /
  Last update: 2013-10-09 04:01    [W:0.065 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site