On Wed, 24 May 2006, Matthias Lederhofer wrote: > > checking for partial writes > > Just out of interest: is this to be safe on any OS or should this > be checked always? Any POSIX-conformant OS/filesystem should always do a full write for a regular file, unless a serious error happens. HOWEVER. In practice, you can get partial writes at least over NFS (hey, it may not be posix, but it's _common_) when the filesystem has been mounted soft (and/or interruptible). And obviously if your file descriptor isn't a regular file, you can easily get partial writes. Doing the loop is always safe, so it's worth doing it that way. > > + size = write(fd, buf, len); > > + if (!size) > > + return error("file write: disk full"); > > Shouldn't write to a full disk return -1 with ENOSPC? In that case, the "size < 0" check will catch it. The "return zero for full" case is an alternate error return (it happens for block device files at the end, it could happen for other things too). So the "returns zero means full" is the portable/safe thing to do. Linus - : send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html