Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_default.c
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | static int get_next_dirent(struct vnode *vp, struct dirent **dpp, | ||||
char **cpos, int *len, int *eofflag, | char **cpos, int *len, int *eofflag, | ||||
struct thread *td); | struct thread *td); | ||||
static int dirent_exists(struct vnode *vp, const char *dirname, | static int dirent_exists(struct vnode *vp, const char *dirname, | ||||
struct thread *td); | struct thread *td); | ||||
#define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4) | #define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4) | ||||
static int vop_stdis_text(struct vop_is_text_args *ap); | static int vop_stdis_text(struct vop_is_text_args *ap); | ||||
static int vop_stdset_text(struct vop_set_text_args *ap); | |||||
static int vop_stdunset_text(struct vop_unset_text_args *ap); | static int vop_stdunset_text(struct vop_unset_text_args *ap); | ||||
static int vop_stdget_writecount(struct vop_get_writecount_args *ap); | |||||
static int vop_stdadd_writecount(struct vop_add_writecount_args *ap); | static int vop_stdadd_writecount(struct vop_add_writecount_args *ap); | ||||
static int vop_stdfdatasync(struct vop_fdatasync_args *ap); | static int vop_stdfdatasync(struct vop_fdatasync_args *ap); | ||||
static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); | static int vop_stdgetpages_async(struct vop_getpages_async_args *ap); | ||||
/* | /* | ||||
* This vnode table stores what we want to do if the filesystem doesn't | * This vnode table stores what we want to do if the filesystem doesn't | ||||
* implement a particular VOP. | * implement a particular VOP. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | struct vop_vector default_vnodeops = { | ||||
.vop_vptocnp = vop_stdvptocnp, | .vop_vptocnp = vop_stdvptocnp, | ||||
.vop_vptofh = vop_stdvptofh, | .vop_vptofh = vop_stdvptofh, | ||||
.vop_unp_bind = vop_stdunp_bind, | .vop_unp_bind = vop_stdunp_bind, | ||||
.vop_unp_connect = vop_stdunp_connect, | .vop_unp_connect = vop_stdunp_connect, | ||||
.vop_unp_detach = vop_stdunp_detach, | .vop_unp_detach = vop_stdunp_detach, | ||||
.vop_is_text = vop_stdis_text, | .vop_is_text = vop_stdis_text, | ||||
.vop_set_text = vop_stdset_text, | .vop_set_text = vop_stdset_text, | ||||
.vop_unset_text = vop_stdunset_text, | .vop_unset_text = vop_stdunset_text, | ||||
.vop_get_writecount = vop_stdget_writecount, | |||||
.vop_add_writecount = vop_stdadd_writecount, | .vop_add_writecount = vop_stdadd_writecount, | ||||
}; | }; | ||||
/* | /* | ||||
* Series of placeholder functions for various error returns for | * Series of placeholder functions for various error returns for | ||||
* VOPs. | * VOPs. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 912 Lines • ▼ Show 20 Lines | vop_stdunp_detach(struct vop_unp_detach_args *ap) | ||||
ap->a_vp->v_unpcb = NULL; | ap->a_vp->v_unpcb = NULL; | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
vop_stdis_text(struct vop_is_text_args *ap) | vop_stdis_text(struct vop_is_text_args *ap) | ||||
{ | { | ||||
return ((ap->a_vp->v_vflag & VV_TEXT) != 0); | return (ap->a_vp->v_writecount < 0); | ||||
} | } | ||||
static int | int | ||||
vop_stdset_text(struct vop_set_text_args *ap) | vop_stdset_text(struct vop_set_text_args *ap) | ||||
{ | { | ||||
struct vnode *vp; | |||||
int error; | |||||
ap->a_vp->v_vflag |= VV_TEXT; | vp = ap->a_vp; | ||||
return (0); | VI_LOCK(vp); | ||||
if (vp->v_writecount > 0) { | |||||
error = ETXTBSY; | |||||
} else { | |||||
vp->v_writecount--; | |||||
error = 0; | |||||
} | } | ||||
VI_UNLOCK(vp); | |||||
return (error); | |||||
} | |||||
static int | static int | ||||
vop_stdunset_text(struct vop_unset_text_args *ap) | vop_stdunset_text(struct vop_unset_text_args *ap) | ||||
{ | { | ||||
struct vnode *vp; | |||||
int error; | |||||
ap->a_vp->v_vflag &= ~VV_TEXT; | vp = ap->a_vp; | ||||
return (0); | VI_LOCK(vp); | ||||
if (vp->v_writecount < 0) { | |||||
vp->v_writecount++; | |||||
error = 0; | |||||
} else { | |||||
error = EINVAL; | |||||
} | } | ||||
VI_UNLOCK(vp); | |||||
static int | return (error); | ||||
vop_stdget_writecount(struct vop_get_writecount_args *ap) | |||||
{ | |||||
*ap->a_writecount = ap->a_vp->v_writecount; | |||||
return (0); | |||||
} | } | ||||
static int | static int | ||||
vop_stdadd_writecount(struct vop_add_writecount_args *ap) | vop_stdadd_writecount(struct vop_add_writecount_args *ap) | ||||
{ | { | ||||
struct vnode *vp; | |||||
int error; | |||||
ap->a_vp->v_writecount += ap->a_inc; | vp = ap->a_vp; | ||||
return (0); | VI_LOCK(vp); | ||||
if (vp->v_writecount < 0) { | |||||
error = ETXTBSY; | |||||
} else { | |||||
VNASSERT(vp->v_writecount + ap->a_inc >= 0, vp, | |||||
("neg writecount increment %d", ap->a_inc)); | |||||
vp->v_writecount += ap->a_inc; | |||||
error = 0; | |||||
} | |||||
VI_UNLOCK(vp); | |||||
return (error); | |||||
} | } | ||||
/* | /* | ||||
* vfs default ops | * vfs default ops | ||||
* used to fill the vfs function table to get reasonable default return values. | * used to fill the vfs function table to get reasonable default return values. | ||||
*/ | */ | ||||
int | int | ||||
vfs_stdroot (mp, flags, vpp) | vfs_stdroot (mp, flags, vpp) | ||||
▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines |