diff options
author | Richard Yao <[email protected]> | 2015-12-15 11:48:19 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-01-23 10:10:44 -0800 |
commit | be29e6a6e682123a009d20b2c5ab0b5393f43a8b (patch) | |
tree | 3ec79249c27855e74598fe9156623dfeb9b921a1 /module/spl | |
parent | 7323da1b2f337f5dab52452e7b765f4a0bc99b78 (diff) |
kobj_read_file: Return -1 on vn_rdwr() error
I noticed that the SPL implementation of kobj_read_file is not correct
after comparing it with the userland implementation of kobj_read_file()
in zfsonlinux/zfs#4104.
Note that we no longer pass RLIM64_INFINITY with this, but our vn_rdwr
implementation did not support it anyway, so there is no difference.
Signed-off-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #513
Diffstat (limited to 'module/spl')
-rw-r--r-- | module/spl/spl-kobj.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/module/spl/spl-kobj.c b/module/spl/spl-kobj.c index 4dd14ba41..b79fcb828 100644 --- a/module/spl/spl-kobj.c +++ b/module/spl/spl-kobj.c @@ -57,10 +57,15 @@ kobj_close_file(struct _buf *file) EXPORT_SYMBOL(kobj_close_file); int -kobj_read_file(struct _buf *file, char *buf, ssize_t size, offset_t off) +kobj_read_file(struct _buf *file, char *buf, unsigned size, unsigned off) { - return (vn_rdwr(UIO_READ, file->vp, buf, size, off, - UIO_SYSSPACE, 0, RLIM64_INFINITY, 0, NULL)); + ssize_t resid; + + if (vn_rdwr(UIO_READ, file->vp, buf, size, (offset_t)off, + UIO_SYSSPACE, 0, 0, 0, &resid) != 0) + return (-1); + + return (size - resid); } /* kobj_read_file() */ EXPORT_SYMBOL(kobj_read_file); |