From 9fe5c6d391fd159fe27022ab806408831ed5b27f Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Thu, 25 Feb 2010 15:37:47 +0000 Subject: 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 Signed-off-by: Anand V. Avati 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 --- xlators/storage/posix/src/posix.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xlators/storage/posix/src/posix.c') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index dcff1dbe29e..f1541a2da36 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -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, -- cgit