From: Brian Behlendorf Date: Fri, 9 Jan 2009 21:59:39 +0000 (-0800) Subject: Add VOP_SEEK X-Git-Tag: spl-0.4.1~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97735c39e37f1b644ba09755173dd2b3de95ab47;p=spl Add VOP_SEEK --- diff --git a/include/sys/vnode.h b/include/sys/vnode.h index 8b7aefe..7972f65 100644 --- a/include/sys/vnode.h +++ b/include/sys/vnode.h @@ -207,6 +207,8 @@ extern int vn_rdwr(uio_rw_t uio, vnode_t *vp, void *addr, ssize_t len, offset_t off, uio_seg_t seg, int x1, rlim64_t x2, void *x3, ssize_t *residp); extern int vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4); +extern int vn_seek(vnode_t *vp, offset_t o, offset_t *op, caller_context_t *ct); + extern int vn_remove(const char *path, uio_seg_t seg, int flags); extern int vn_rename(const char *path1, const char *path2, int x1); extern int vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4); @@ -230,6 +232,7 @@ vn_putpage(vnode_t *vp, offset_t off, ssize_t size, } /* vn_putpage() */ #define VOP_CLOSE vn_close +#define VOP_SEEK vn_seek #define VN_RELE vn_rele #define VOP_GETATTR vn_getattr #define VOP_FSYNC vn_fsync diff --git a/modules/spl/spl-vnode.c b/modules/spl/spl-vnode.c index fef74f3..b19d9f1 100644 --- a/modules/spl/spl-vnode.c +++ b/modules/spl/spl-vnode.c @@ -235,19 +235,31 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4) ASSERT(vp); ASSERT(vp->v_file); - rc = filp_close(vp->v_file, 0); - vn_free(vp); + rc = filp_close(vp->v_file, 0); + vn_free(vp); RETURN(-rc); } /* vn_close() */ EXPORT_SYMBOL(vn_close); -static struct dentry *vn_lookup_hash(struct nameidata *nd) +/* vn_seek() does not actually seek it only performs bounds checking on the + * proposed seek. We perform minimal checking and allow vn_rdwr() to catch + * anything more serious. */ +int +vn_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, caller_context_t *ct) +{ + return ((*noffp < 0 || *noffp > MAXOFFSET_T) ? EINVAL : 0); +} +EXPORT_SYMBOL(vn_seek); + +static struct dentry * +vn_lookup_hash(struct nameidata *nd) { return lookup_one_len(nd->last.name, nd->nd_dentry, nd->last.len); } /* lookup_hash() */ -static void vn_path_release(struct nameidata *nd) +static void +vn_path_release(struct nameidata *nd) { dput(nd->nd_dentry); mntput(nd->nd_mnt);