]> git.proxmox.com Git - mirror_spl.git/commitdiff
kobj_read_file: Return -1 on vn_rdwr() error
authorRichard Yao <richard.yao@clusterhq.com>
Tue, 15 Dec 2015 16:48:19 +0000 (11:48 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 23 Jan 2016 18:10:44 +0000 (10:10 -0800)
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 <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #513

include/sys/kobj.h
module/spl/spl-kobj.c

index f95fa8039762d5feb86b685c6e8d0f2d86a3c2d9..334449a8e234b0e3193e98abecbe018f7d61ed0c 100644 (file)
@@ -35,8 +35,8 @@ typedef struct _buf buf_t;
 
 extern struct _buf *kobj_open_file(const char *name);
 extern void kobj_close_file(struct _buf *file);
-extern int kobj_read_file(struct _buf *file, char *buf,
-                         ssize_t size, offset_t off);
+extern int kobj_read_file(struct _buf *file, char *buf, unsigned size,
+    unsigned off);
 extern int kobj_get_filesize(struct _buf *file, uint64_t *size);
 
 #endif /* SPL_KOBJ_H */
index 4dd14ba41760e123a82dda7241c5e878122bd83b..b79fcb82836c83bba4d448fa49e14882848134dc 100644 (file)
@@ -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);