Messages in this thread |  | | Date | Mon, 17 Dec 2001 19:53:12 +0000 | | From | Joel Becker <> | | Subject | Re: O_DIRECT wierd behavior.. |
| |
On Mon, Dec 17, 2001 at 07:26:05PM +0000, Linus Torvalds wrote: > Andrew Morton <akpm@zip.com.au> wrote: > >I take that to mean that if an error occurs, we return that > >error regardless of how much was written. > > I disagree. > > Note that writing 15 characters out of 30 is also a "successful write" - > it's just a _partial_ write. > > >Which makes sense. Consider this code: > > > > open(file) > > write(100k) > > close(fd) > > > >if the write gets an IO error halfway through, it looks like > >the caller never gets to hear about it at present.
IIRC, SUS states that if a fatal error occurred causing the partial write, that error will be returned on the next write or upon close(). Thus:
/* Smart program handles partial writes */ write(100k); = 50k write(remaining 50k); = -1/ENOSPC|EIO|etc
or:
/* Dumb program doesn't handle partial write */ write(100k); = 50k close(fd); = -1/EIO Joel
--
Life's Little Instruction Book #444
"Never underestimate the power of a kind word or deed."
http://www.jlbec.org/ jlbec@evilplan.org - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |