posix: Support EOF for file reading

This is a small hack to notify higher translators that an end-of-file
was encountered at the end of the readv operation. This is helpful
in determining end-of-file without sending another readv fop.

Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>

BUG: 597 (miscellaneous fixes for xlators to work well with NFS xlator)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=597
This commit is contained in:
Shehjar Tikoo 2010-02-25 15:37:47 +00:00 committed by Anand V. Avati
parent 1262b1e4fe
commit 9fe5c6d391

View File

@ -2530,7 +2530,13 @@ posix_readv (call_frame_t *frame, xlator_t *this,
goto out;
}
op_ret = vec.iov_len;
/* Hack to notify higher layers of EOF. */
if (stbuf.st_size == 0)
op_errno = ENOENT;
else if ((offset + vec.iov_len) == stbuf.st_size)
op_errno = ENOENT;
op_ret = vec.iov_len;
out:
STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno,