summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r--usr/src/uts/common/sys/Makefile3
-rw-r--r--usr/src/uts/common/sys/fem.h218
-rw-r--r--usr/src/uts/common/sys/fs/sdev_impl.h1
-rw-r--r--usr/src/uts/common/sys/gfs.h8
-rw-r--r--usr/src/uts/common/sys/vfs.h39
-rw-r--r--usr/src/uts/common/sys/vfs_opreg.h116
-rw-r--r--usr/src/uts/common/sys/vnode.h184
7 files changed, 345 insertions, 224 deletions
diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile
index 2cab0fbac7..a8e545a6cc 100644
--- a/usr/src/uts/common/sys/Makefile
+++ b/usr/src/uts/common/sys/Makefile
@@ -479,7 +479,7 @@ CHKHDRS= \
syscall.h \
sysconf.h \
sysconfig.h \
- sysevent.h \
+ sysevent.h \
sysevent_impl.h \
sysinfo.h \
syslog.h \
@@ -546,6 +546,7 @@ CHKHDRS= \
var.h \
varargs.h \
vfs.h \
+ vfs_opreg.h \
vfstab.h \
vgareg.h \
videodev2.h \
diff --git a/usr/src/uts/common/sys/fem.h b/usr/src/uts/common/sys/fem.h
index 7e2a133948..04afc1466d 100644
--- a/usr/src/uts/common/sys/fem.h
+++ b/usr/src/uts/common/sys/fem.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -43,6 +42,8 @@
extern "C" {
#endif
+#ifdef _KERNEL
+
struct fs_operation_def; /* from vfs.h */
/*
@@ -90,7 +91,6 @@ typedef struct fem fem_t;
typedef struct fsem fsem_t;
typedef int femop_t();
-typedef int vop_t();
/*
* The following enumerations specify the conditions
@@ -141,107 +141,128 @@ struct fem_head {
struct fem_list *femh_list;
};
+/*
+ * FEM_OPS defines all the FEM operations. It is used to define
+ * the fem structure (below) and the fs_func_p union (vfs_opreg.h).
+ */
+#define FEM_OPS \
+ int (*femop_open)(femarg_t *vf, int mode, cred_t *cr); \
+ int (*femop_close)(femarg_t *vf, int flag, int count, \
+ offset_t offset, cred_t *cr); \
+ int (*femop_read)(femarg_t *vf, uio_t *uiop, int ioflag, \
+ cred_t *cr, struct caller_context *ct); \
+ int (*femop_write)(femarg_t *vf, uio_t *uiop, int ioflag, \
+ cred_t *cr, struct caller_context *ct); \
+ int (*femop_ioctl)(femarg_t *vf, int cmd, intptr_t arg, \
+ int flag, cred_t *cr, int *rvalp); \
+ int (*femop_setfl)(femarg_t *vf, int oflags, int nflags, \
+ cred_t *cr); \
+ int (*femop_getattr)(femarg_t *vf, vattr_t *vap, int flags, \
+ cred_t *cr); \
+ int (*femop_setattr)(femarg_t *vf, vattr_t *vap, int flags, \
+ cred_t *cr, caller_context_t *ct); \
+ int (*femop_access)(femarg_t *vf, int mode, int flags, \
+ cred_t *cr); \
+ int (*femop_lookup)(femarg_t *vf, char *nm, vnode_t **vpp, \
+ pathname_t *pnp, int flags, vnode_t *rdir, \
+ cred_t *cr); \
+ int (*femop_create)(femarg_t *vf, char *name, vattr_t *vap, \
+ vcexcl_t excl, int mode, vnode_t **vpp, \
+ cred_t *cr, int flag); \
+ int (*femop_remove)(femarg_t *vf, char *nm, cred_t *cr); \
+ int (*femop_link)(femarg_t *vf, vnode_t *svp, char *tnm, \
+ cred_t *cr); \
+ int (*femop_rename)(femarg_t *vf, char *snm, vnode_t *tdvp, \
+ char *tnm, cred_t *cr); \
+ int (*femop_mkdir)(femarg_t *vf, char *dirname, vattr_t *vap, \
+ vnode_t **vpp, cred_t *cr); \
+ int (*femop_rmdir)(femarg_t *vf, char *nm, vnode_t *cdir, \
+ cred_t *cr); \
+ int (*femop_readdir)(femarg_t *vf, uio_t *uiop, cred_t *cr, \
+ int *eofp); \
+ int (*femop_symlink)(femarg_t *vf, char *linkname, \
+ vattr_t *vap, char *target, cred_t *cr); \
+ int (*femop_readlink)(femarg_t *vf, uio_t *uiop, cred_t *cr); \
+ int (*femop_fsync)(femarg_t *vf, int syncflag, cred_t *cr); \
+ void (*femop_inactive)(femarg_t *vf, cred_t *cr); \
+ int (*femop_fid)(femarg_t *vf, fid_t *fidp); \
+ int (*femop_rwlock)(femarg_t *vf, int write_lock, \
+ caller_context_t *ct); \
+ void (*femop_rwunlock)(femarg_t *vf, int write_lock, \
+ caller_context_t *ct); \
+ int (*femop_seek)(femarg_t *vf, offset_t ooff, \
+ offset_t *noffp); \
+ int (*femop_cmp)(femarg_t *vf, vnode_t *vp2); \
+ int (*femop_frlock)(femarg_t *vf, int cmd, struct flock64 *bfp, \
+ int flag, offset_t offset, \
+ struct flk_callback *flk_cbp, cred_t *cr); \
+ int (*femop_space)(femarg_t *vf, int cmd, struct flock64 *bfp, \
+ int flag, offset_t offset, cred_t *cr, \
+ caller_context_t *ct); \
+ int (*femop_realvp)(femarg_t *vf, vnode_t **vpp); \
+ int (*femop_getpage)(femarg_t *vf, offset_t off, size_t len, \
+ uint_t *protp, struct page **plarr, \
+ size_t plsz, struct seg *seg, caddr_t addr, \
+ enum seg_rw rw, cred_t *cr); \
+ int (*femop_putpage)(femarg_t *vf, offset_t off, size_t len, \
+ int flags, cred_t *cr); \
+ int (*femop_map)(femarg_t *vf, offset_t off, struct as *as, \
+ caddr_t *addrp, size_t len, uchar_t prot, \
+ uchar_t maxprot, uint_t flags, cred_t *cr); \
+ int (*femop_addmap)(femarg_t *vf, offset_t off, struct as *as, \
+ caddr_t addr, size_t len, uchar_t prot, \
+ uchar_t maxprot, uint_t flags, cred_t *cr); \
+ int (*femop_delmap)(femarg_t *vf, offset_t off, struct as *as, \
+ caddr_t addr, size_t len, uint_t prot, \
+ uint_t maxprot, uint_t flags, cred_t *cr); \
+ int (*femop_poll)(femarg_t *vf, short events, int anyyet, \
+ short *reventsp, struct pollhead **phpp); \
+ int (*femop_dump)(femarg_t *vf, caddr_t addr, int lbdn, \
+ int dblks); \
+ int (*femop_pathconf)(femarg_t *vf, int cmd, ulong_t *valp, \
+ cred_t *cr); \
+ int (*femop_pageio)(femarg_t *vf, struct page *pp, \
+ u_offset_t io_off, size_t io_len, int flags, \
+ cred_t *cr); \
+ int (*femop_dumpctl)(femarg_t *vf, int action, int *blkp); \
+ void (*femop_dispose)(femarg_t *vf, struct page *pp, int flag, \
+ int dn, cred_t *cr); \
+ int (*femop_setsecattr)(femarg_t *vf, vsecattr_t *vsap, \
+ int flag, cred_t *cr); \
+ int (*femop_getsecattr)(femarg_t *vf, vsecattr_t *vsap, \
+ int flag, cred_t *cr); \
+ int (*femop_shrlock)(femarg_t *vf, int cmd, \
+ struct shrlock *shr, int flag, cred_t *cr); \
+ int (*femop_vnevent)(femarg_t *vf, vnevent_t vnevent) /* NB: No ";" */
+
struct fem {
const char *name;
const struct fs_operation_def *templ;
- int (*vsop_open)(femarg_t *vf, int mode, cred_t *cr);
- int (*vsop_close)(femarg_t *vf, int flag, int count,
- offset_t offset, cred_t *cr);
- int (*vsop_read)(femarg_t *vf, uio_t *uiop, int ioflag, cred_t *cr,
- struct caller_context *ct);
- int (*vsop_write)(femarg_t *vf, uio_t *uiop, int ioflag,
- cred_t *cr, struct caller_context *ct);
- int (*vsop_ioctl)(femarg_t *vf, int cmd, intptr_t arg, int flag,
- cred_t *cr, int *rvalp);
- int (*vsop_setfl)(femarg_t *vf, int oflags, int nflags, cred_t *cr);
- int (*vsop_getattr)(femarg_t *vf, vattr_t *vap, int flags,
- cred_t *cr);
- int (*vsop_setattr)(femarg_t *vf, vattr_t *vap, int flags,
- cred_t *cr, caller_context_t *ct);
- int (*vsop_access)(femarg_t *vf, int mode, int flags, cred_t *cr);
- int (*vsop_lookup)(femarg_t *vf, char *nm, vnode_t **vpp,
- pathname_t *pnp, int flags, vnode_t *rdir,
- cred_t *cr);
- int (*vsop_create)(femarg_t *vf, char *name, vattr_t *vap,
- vcexcl_t excl, int mode, vnode_t **vpp, cred_t *cr,
- int flag);
- int (*vsop_remove)(femarg_t *vf, char *nm, cred_t *cr);
- int (*vsop_link)(femarg_t *vf, vnode_t *svp, char *tnm, cred_t *cr);
- int (*vsop_rename)(femarg_t *vf, char *snm, vnode_t *tdvp,
- char *tnm, cred_t *cr);
- int (*vsop_mkdir)(femarg_t *vf, char *dirname, vattr_t *vap,
- vnode_t **vpp, cred_t *cr);
- int (*vsop_rmdir)(femarg_t *vf, char *nm, vnode_t *cdir,
- cred_t *cr);
- int (*vsop_readdir)(femarg_t *vf, uio_t *uiop, cred_t *cr,
- int *eofp);
- int (*vsop_symlink)(femarg_t *vf, char *linkname, vattr_t *vap,
- char *target, cred_t *cr);
- int (*vsop_readlink)(femarg_t *vf, uio_t *uiop, cred_t *cr);
- int (*vsop_fsync)(femarg_t *vf, int syncflag, cred_t *cr);
- void (*vsop_inactive)(femarg_t *vf, cred_t *cr);
- int (*vsop_fid)(femarg_t *vf, fid_t *fidp);
- int (*vsop_rwlock)(femarg_t *vf, int write_lock,
- caller_context_t *ct);
- void (*vsop_rwunlock)(femarg_t *vf, int write_lock,
- caller_context_t *ct);
- int (*vsop_seek)(femarg_t *vf, offset_t ooff, offset_t *noffp);
- int (*vsop_cmp)(femarg_t *vf, vnode_t *vp2);
- int (*vsop_frlock)(femarg_t *vf, int cmd, struct flock64 *bfp,
- int flag, offset_t offset,
- struct flk_callback *flk_cbp, cred_t *cr);
- int (*vsop_space)(femarg_t *vf, int cmd, struct flock64 *bfp,
- int flag, offset_t offset, cred_t *cr,
- caller_context_t *ct);
- int (*vsop_realvp)(femarg_t *vf, vnode_t **vpp);
- int (*vsop_getpage)(femarg_t *vf, offset_t off, size_t len,
- uint_t *protp, struct page **plarr, size_t plsz,
- struct seg *seg, caddr_t addr, enum seg_rw rw,
- cred_t *cr);
- int (*vsop_putpage)(femarg_t *vf, offset_t off, size_t len,
- int flags, cred_t *cr);
- int (*vsop_map)(femarg_t *vf, offset_t off, struct as *as,
- caddr_t *addrp, size_t len, uchar_t prot,
- uchar_t maxprot, uint_t flags, cred_t *cr);
- int (*vsop_addmap)(femarg_t *vf, offset_t off, struct as *as,
- caddr_t addr, size_t len, uchar_t prot,
- uchar_t maxprot, uint_t flags, cred_t *cr);
- int (*vsop_delmap)(femarg_t *vf, offset_t off, struct as *as,
- caddr_t addr, size_t len, uint_t prot,
- uint_t maxprot, uint_t flags, cred_t *cr);
- int (*vsop_poll)(femarg_t *vf, short events, int anyyet,
- short *reventsp, struct pollhead **phpp);
- int (*vsop_dump)(femarg_t *vf, caddr_t addr, int lbdn, int dblks);
- int (*vsop_pathconf)(femarg_t *vf, int cmd, ulong_t *valp,
- cred_t *cr);
- int (*vsop_pageio)(femarg_t *vf, struct page *pp,
- u_offset_t io_off, size_t io_len, int flags,
- cred_t *cr);
- int (*vsop_dumpctl)(femarg_t *vf, int action, int *blkp);
- void (*vsop_dispose)(femarg_t *vf, struct page *pp, int flag,
- int dn, cred_t *cr);
- int (*vsop_setsecattr)(femarg_t *vf, vsecattr_t *vsap, int flag,
- cred_t *cr);
- int (*vsop_getsecattr)(femarg_t *vf, vsecattr_t *vsap, int flag,
- cred_t *cr);
- int (*vsop_shrlock)(femarg_t *vf, int cmd, struct shrlock *shr,
- int flag, cred_t *cr);
- int (*vsop_vnevent)(femarg_t *vf, vnevent_t vnevent);
+ FEM_OPS; /* Signatures of all FEM operations (femops) */
};
+/*
+ * FSEM_OPS defines all the FSEM operations. It is used to define
+ * the fsem structure (below) and the fs_func_p union (vfs_opreg.h).
+ */
+#define FSEM_OPS \
+ int (*fsemop_mount)(fsemarg_t *vf, vnode_t *mvp, \
+ struct mounta *uap, cred_t *cr); \
+ int (*fsemop_unmount)(fsemarg_t *vf, int flag, cred_t *cr); \
+ int (*fsemop_root)(fsemarg_t *vf, vnode_t **vpp); \
+ int (*fsemop_statvfs)(fsemarg_t *vf, statvfs64_t *sp); \
+ int (*fsemop_sync)(fsemarg_t *vf, short flag, cred_t *cr); \
+ int (*fsemop_vget)(fsemarg_t *vf, vnode_t **vpp, fid_t *fidp); \
+ int (*fsemop_mountroot)(fsemarg_t *vf, \
+ enum whymountroot reason); \
+ void (*fsemop_freevfs)(fsemarg_t *vf); \
+ int (*fsemop_vnstate)(fsemarg_t *vf, vnode_t *vp, \
+ vntrans_t nstate) /* NB: No ";" */
+
struct fsem {
const char *name;
const struct fs_operation_def *templ;
- int (*vfsop_mount)(fsemarg_t *vf, vnode_t *mvp, struct mounta *uap,
- cred_t *cr);
- int (*vfsop_unmount)(fsemarg_t *vf, int flag, cred_t *cr);
- int (*vfsop_root)(fsemarg_t *vf, vnode_t **vpp);
- int (*vfsop_statvfs)(fsemarg_t *vf, statvfs64_t *sp);
- int (*vfsop_sync)(fsemarg_t *vf, short flag, cred_t *cr);
- int (*vfsop_vget)(fsemarg_t *vf, vnode_t **vpp, fid_t *fidp);
- int (*vfsop_mountroot)(fsemarg_t *vf, enum whymountroot reason);
- void (*vfsop_freevfs)(fsemarg_t *vf);
- int (*vfsop_vnstate)(fsemarg_t *vf, vnode_t *vp, vntrans_t nstate);
+ FSEM_OPS; /* Signatures of all FSEM operations (fsemops) */
};
extern int vnext_open(femarg_t *vf, int mode, cred_t *cr);
@@ -357,6 +378,7 @@ extern int fsem_uninstall(struct vfs *v, fsem_t *mon, void *arg);
extern vfsops_t *fsem_getvfsops(struct vfs *v);
extern void fsem_setvfsops(struct vfs *v, struct vfsops *nops);
+#endif /* _KERNEL */
#ifdef __cplusplus
}
diff --git a/usr/src/uts/common/sys/fs/sdev_impl.h b/usr/src/uts/common/sys/fs/sdev_impl.h
index 4083fd382d..281bc2faf7 100644
--- a/usr/src/uts/common/sys/fs/sdev_impl.h
+++ b/usr/src/uts/common/sys/fs/sdev_impl.h
@@ -35,6 +35,7 @@ extern "C" {
#include <rpc/rpc.h>
#include <sys/dirent.h>
#include <sys/vfs.h>
+#include <sys/vfs_opreg.h>
#include <sys/list.h>
#include <sys/nvpair.h>
diff --git a/usr/src/uts/common/sys/gfs.h b/usr/src/uts/common/sys/gfs.h
index 65a379eeb9..fd2abc1326 100644
--- a/usr/src/uts/common/sys/gfs.h
+++ b/usr/src/uts/common/sys/gfs.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -31,6 +30,7 @@
#include <sys/types.h>
#include <sys/vnode.h>
+#include <sys/vfs_opreg.h>
#include <sys/mutex.h>
#include <sys/dirent.h>
#include <sys/uio.h>
diff --git a/usr/src/uts/common/sys/vfs.h b/usr/src/uts/common/sys/vfs.h
index 66fc2f2c2a..0834cf1f84 100644
--- a/usr/src/uts/common/sys/vfs.h
+++ b/usr/src/uts/common/sys/vfs.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -310,20 +310,26 @@ enum vntrans {
};
typedef enum vntrans vntrans_t;
+/*
+ * VFS_OPS defines all the vfs operations. It is used to define
+ * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h).
+ */
+#define VFS_OPS \
+ int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \
+ int (*vfs_unmount)(vfs_t *, int, cred_t *); \
+ int (*vfs_root)(vfs_t *, vnode_t **); \
+ int (*vfs_statvfs)(vfs_t *, statvfs64_t *); \
+ int (*vfs_sync)(vfs_t *, short, cred_t *); \
+ int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *); \
+ int (*vfs_mountroot)(vfs_t *, enum whymountroot); \
+ void (*vfs_freevfs)(vfs_t *); \
+ int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t) /* NB: No ";" */
/*
* Operations supported on virtual file system.
*/
struct vfsops {
- int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *);
- int (*vfs_unmount)(vfs_t *, int, cred_t *);
- int (*vfs_root)(vfs_t *, vnode_t **);
- int (*vfs_statvfs)(vfs_t *, statvfs64_t *);
- int (*vfs_sync)(vfs_t *, short, cred_t *);
- int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *);
- int (*vfs_mountroot)(vfs_t *, enum whymountroot);
- int (*vfs_freevfs)(vfs_t *);
- int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t);
+ VFS_OPS; /* Signature of all vfs operations (vfsops) */
};
extern int fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *);
@@ -391,17 +397,6 @@ enum {
};
/*
- * Generic operations vector types (used for vfs/vnode ops registration).
- */
-
-extern int fs_default(); /* "default" function placeholder */
-extern int fs_error(); /* "error" function placeholder */
-
-int fs_build_vector(void *vector, int *unused_ops,
- const fs_operation_trans_def_t *translation,
- const fs_operation_def_t *operations);
-
-/*
* flags for vfssw and vfsdef
*/
#define VSW_HASPROTO 0x01 /* struct has a mount options prototype */
@@ -421,8 +416,6 @@ struct umounta;
struct statvfsa;
struct fstatvfsa;
-int vfs_setfsops(int, const fs_operation_def_t *, vfsops_t **);
-int vfs_makefsops(const fs_operation_def_t *, vfsops_t **);
void vfs_freevfsops(vfsops_t *);
int vfs_freevfsops_by_type(int);
void vfs_setops(vfs_t *, vfsops_t *);
diff --git a/usr/src/uts/common/sys/vfs_opreg.h b/usr/src/uts/common/sys/vfs_opreg.h
new file mode 100644
index 0000000000..c9d4d9f699
--- /dev/null
+++ b/usr/src/uts/common/sys/vfs_opreg.h
@@ -0,0 +1,116 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+#ifndef _SYS_VFS_OPREG_H
+#define _SYS_VFS_OPREG_H
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#include <sys/vfs.h>
+#include <sys/fem.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _KERNEL
+
+/*
+ * The following union allows us to use C99's "designated initializer"
+ * feature so that we can have strong typechecking for the operations
+ * used in the the fs_operation_def structures.
+ */
+
+typedef union fs_func {
+ fs_generic_func_p fs_generic; /* Generic function signature */
+ int (*error)(); /* Signature of error function */
+ VFS_OPS; /* Signatures of all vfs operations (vfsops) */
+ VNODE_OPS; /* Signatures of all vnode operations (vops) */
+ FEM_OPS; /* Signatures of all FEM operations (femops) */
+ FSEM_OPS; /* Signatures of all FSEM ops (fsemops) */
+} fs_func_p;
+
+/*
+ * File systems use arrays of fs_operation_def structures to form
+ * name/value pairs of operations. These arrays get passed to:
+ *
+ * - vn_make_ops() to create vnodeops
+ * - vfs_makefsops()/vfs_setfsops() to create vfsops.
+ */
+typedef struct fs_operation_def {
+ char *name; /* name of operation (NULL at end) */
+ fs_func_p func; /* function implementing operation */
+} fs_operation_def_t;
+
+/*
+ * The operation registration mechanism uses two master tables of operations:
+ * one for vnode operations (vn_ops_table[]) and one for vfs operations
+ * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def
+ * structures. They contain all of the information necessary for the system
+ * to populate an operations structure (e.g., vnodeops, vfsops).
+ *
+ * File systems call registration routines (vfs_setfsops(), vfs_makefsops(),
+ * and vn_make_ops()) and pass in their operations specification tables
+ * (arrays of fs_operation_def structures). These routines use the master
+ * table(s) of operations to build a vnodeops or vfsops structure.
+ */
+typedef struct fs_operation_trans_def {
+ char *name; /* name of operation (NULL at end) */
+ int offset; /* byte offset within ops vector */
+ fs_generic_func_p defaultFunc; /* default function */
+ fs_generic_func_p errorFunc; /* error function */
+} fs_operation_trans_def_t;
+
+/*
+ * Generic operations vector types (used for vfs/vnode ops registration).
+ */
+
+extern int fs_default(); /* "default" function placeholder */
+extern int fs_error(); /* "error" function placeholder */
+
+int fs_build_vector(void *vector, int *unused_ops,
+ const fs_operation_trans_def_t *translation,
+ const fs_operation_def_t *operations);
+
+/*
+ * Public operations.
+ */
+
+int vn_make_ops(const char *, const struct fs_operation_def *,
+ vnodeops_t **);
+void vn_freevnodeops(vnodeops_t *);
+
+int vfs_setfsops(int, const fs_operation_def_t *, vfsops_t **);
+int vfs_makefsops(const fs_operation_def_t *, vfsops_t **);
+void vfs_freevfsops(vfsops_t *);
+int vfs_freevfsops_by_type(int);
+
+#endif /* _KERNEL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_VFS_OPREG_H */
diff --git a/usr/src/uts/common/sys/vnode.h b/usr/src/uts/common/sys/vnode.h
index 0e69840c1a..d2494e013e 100644
--- a/usr/src/uts/common/sys/vnode.h
+++ b/usr/src/uts/common/sys/vnode.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -59,41 +59,6 @@
extern "C" {
#endif
-
-typedef int (*fs_generic_func_p) ();
-
-/*
- * File systems use arrays of fs_operation_def structures to form
- * name/value pairs of operations. These arrays get passed to:
- *
- * - vn_make_ops() to create vnodeops
- * - vfs_makefsops()/vfs_setfsops() to create vfsops.
- */
-typedef struct fs_operation_def {
- char *name; /* name of operation (NULL at end) */
- fs_generic_func_p func; /* function implementing operation */
-} fs_operation_def_t;
-
-/*
- * The operation registration mechanism uses two master tables of operations:
- * one for vnode operations (vn_ops_table[]) and one for vfs operations
- * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def
- * structures. They contain all of the information necessary for the system
- * to populate an operations structure (e.g., vnodeops, vfsops).
- *
- * File systems call registration routines (vfs_setfsops(), vfs_makefsops(),
- * and vn_make_ops()) and pass in their operations specification tables
- * (arrays of fs_operation_def structures). These routines use the master
- * table(s) of operations to build a vnodeops or vfsops structure.
- */
-typedef struct fs_operation_trans_def {
- char *name; /* name of operation (NULL at end) */
- int offset; /* byte offset within ops vector */
- fs_generic_func_p defaultFunc; /* default function */
- fs_generic_func_p errorFunc; /* error function */
-} fs_operation_trans_def_t;
-
-
/*
* Statistics for all vnode operations.
* All operations record number of ops (since boot/mount/zero'ed).
@@ -562,74 +527,98 @@ struct seg;
struct as;
struct pollhead;
+#ifdef _KERNEL
+
/*
- * Operations on vnodes. Note: File systems should never operate directly
+ * VNODE_OPS defines all the vnode operations. It is used to define
+ * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h).
+ */
+#define VNODE_OPS \
+ int (*vop_open)(vnode_t **, int, cred_t *); \
+ int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *); \
+ int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, \
+ caller_context_t *); \
+ int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, \
+ caller_context_t *); \
+ int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, \
+ int *); \
+ int (*vop_setfl)(vnode_t *, int, int, cred_t *); \
+ int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *); \
+ int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, \
+ caller_context_t *); \
+ int (*vop_access)(vnode_t *, int, int, cred_t *); \
+ int (*vop_lookup)(vnode_t *, char *, vnode_t **, \
+ struct pathname *, \
+ int, vnode_t *, cred_t *); \
+ int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, \
+ int, vnode_t **, cred_t *, int); \
+ int (*vop_remove)(vnode_t *, char *, cred_t *); \
+ int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *); \
+ int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, \
+ cred_t *); \
+ int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, \
+ cred_t *); \
+ int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *); \
+ int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *); \
+ int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, \
+ cred_t *); \
+ int (*vop_readlink)(vnode_t *, uio_t *, cred_t *); \
+ int (*vop_fsync)(vnode_t *, int, cred_t *); \
+ void (*vop_inactive)(vnode_t *, cred_t *); \
+ int (*vop_fid)(vnode_t *, struct fid *); \
+ int (*vop_rwlock)(vnode_t *, int, caller_context_t *); \
+ void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); \
+ int (*vop_seek)(vnode_t *, offset_t, offset_t *); \
+ int (*vop_cmp)(vnode_t *, vnode_t *); \
+ int (*vop_frlock)(vnode_t *, int, struct flock64 *, \
+ int, offset_t, \
+ struct flk_callback *, cred_t *); \
+ int (*vop_space)(vnode_t *, int, struct flock64 *, \
+ int, offset_t, \
+ cred_t *, caller_context_t *); \
+ int (*vop_realvp)(vnode_t *, vnode_t **); \
+ int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, \
+ struct page **, size_t, struct seg *, \
+ caddr_t, enum seg_rw, cred_t *); \
+ int (*vop_putpage)(vnode_t *, offset_t, size_t, \
+ int, cred_t *); \
+ int (*vop_map)(vnode_t *, offset_t, struct as *, \
+ caddr_t *, size_t, \
+ uchar_t, uchar_t, uint_t, cred_t *); \
+ int (*vop_addmap)(vnode_t *, offset_t, struct as *, \
+ caddr_t, size_t, \
+ uchar_t, uchar_t, uint_t, cred_t *); \
+ int (*vop_delmap)(vnode_t *, offset_t, struct as *, \
+ caddr_t, size_t, \
+ uint_t, uint_t, uint_t, cred_t *); \
+ int (*vop_poll)(vnode_t *, short, int, short *, \
+ struct pollhead **); \
+ int (*vop_dump)(vnode_t *, caddr_t, int, int); \
+ int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *); \
+ int (*vop_pageio)(vnode_t *, struct page *, \
+ u_offset_t, size_t, int, cred_t *); \
+ int (*vop_dumpctl)(vnode_t *, int, int *); \
+ void (*vop_dispose)(vnode_t *, struct page *, \
+ int, int, cred_t *); \
+ int (*vop_setsecattr)(vnode_t *, vsecattr_t *, \
+ int, cred_t *); \
+ int (*vop_getsecattr)(vnode_t *, vsecattr_t *, \
+ int, cred_t *); \
+ int (*vop_shrlock)(vnode_t *, int, struct shrlock *, \
+ int, cred_t *); \
+ int (*vop_vnevent)(vnode_t *, vnevent_t) /* NB: No ";" */
+
+/*
+ * Operations on vnodes. Note: File systems must never operate directly
* on a 'vnodeops' structure -- it WILL change in future releases! They
- * should use vn_make_ops() to create the structure.
+ * must use vn_make_ops() to create the structure.
*/
typedef struct vnodeops {
const char *vnop_name;
- int (*vop_open)(vnode_t **, int, cred_t *);
- int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *);
- int (*vop_read)(vnode_t *, uio_t *, int, cred_t *,
- caller_context_t *);
- int (*vop_write)(vnode_t *, uio_t *, int, cred_t *,
- caller_context_t *);
- int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, int *);
- int (*vop_setfl)(vnode_t *, int, int, cred_t *);
- int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *);
- int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *,
- caller_context_t *);
- int (*vop_access)(vnode_t *, int, int, cred_t *);
- int (*vop_lookup)(vnode_t *, char *, vnode_t **, struct pathname *,
- int, vnode_t *, cred_t *);
- int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, int,
- vnode_t **, cred_t *, int);
- int (*vop_remove)(vnode_t *, char *, cred_t *);
- int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *);
- int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, cred_t *);
- int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **,
- cred_t *);
- int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *);
- int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *);
- int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, cred_t *);
- int (*vop_readlink)(vnode_t *, uio_t *, cred_t *);
- int (*vop_fsync)(vnode_t *, int, cred_t *);
- void (*vop_inactive)(vnode_t *, cred_t *);
- int (*vop_fid)(vnode_t *, struct fid *);
- int (*vop_rwlock)(vnode_t *, int, caller_context_t *);
- void (*vop_rwunlock)(vnode_t *, int, caller_context_t *);
- int (*vop_seek)(vnode_t *, offset_t, offset_t *);
- int (*vop_cmp)(vnode_t *, vnode_t *);
- int (*vop_frlock)(vnode_t *, int, struct flock64 *, int, offset_t,
- struct flk_callback *, cred_t *);
- int (*vop_space)(vnode_t *, int, struct flock64 *, int, offset_t,
- cred_t *, caller_context_t *);
- int (*vop_realvp)(vnode_t *, vnode_t **);
- int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *,
- struct page **, size_t, struct seg *,
- caddr_t, enum seg_rw, cred_t *);
- int (*vop_putpage)(vnode_t *, offset_t, size_t, int, cred_t *);
- int (*vop_map)(vnode_t *, offset_t, struct as *, caddr_t *, size_t,
- uchar_t, uchar_t, uint_t, cred_t *);
- int (*vop_addmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t,
- uchar_t, uchar_t, uint_t, cred_t *);
- int (*vop_delmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t,
- uint_t, uint_t, uint_t, cred_t *);
- int (*vop_poll)(vnode_t *, short, int, short *, struct pollhead **);
- int (*vop_dump)(vnode_t *, caddr_t, int, int);
- int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *);
- int (*vop_pageio)(vnode_t *, struct page *, u_offset_t, size_t,
- int, cred_t *);
- int (*vop_dumpctl)(vnode_t *, int, int *);
- void (*vop_dispose)(vnode_t *, struct page *, int, int, cred_t *);
- int (*vop_setsecattr)(vnode_t *, vsecattr_t *, int, cred_t *);
- int (*vop_getsecattr)(vnode_t *, vsecattr_t *, int, cred_t *);
- int (*vop_shrlock)(vnode_t *, int, struct shrlock *, int, cred_t *);
- int (*vop_vnevent)(vnode_t *, vnevent_t);
+ VNODE_OPS; /* Signatures of all vnode operations (vops) */
} vnodeops_t;
-#ifdef _KERNEL
+typedef int (*fs_generic_func_p) (); /* Generic vop/vfsop/femop/fsemop ptr */
extern int fop_open(vnode_t **, int, cred_t *);
extern int fop_close(vnode_t *, int, int, offset_t, cred_t *);
@@ -876,7 +865,6 @@ struct vfs *vn_mountedvfs(vnode_t *);
void vn_create_cache(void);
void vn_destroy_cache(void);
-int vn_make_ops(const char *, const fs_operation_def_t *, vnodeops_t **);
void vn_freevnodeops(vnodeops_t *);
int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,