VOP_OPEN (9)
Leading comments
Copyright (c) 1996 Doug Rabson All rights reserved. This program is free software. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in...
NAME
VOP_OPEN VOP_CLOSE - open or close a fileSYNOPSIS
In sys/param.h In sys/vnode.h Ft int Fn VOP_OPEN struct vnode *vp int mode struct ucred *cred struct thread *td struct file *fp Ft int Fn VOP_CLOSE struct vnode *vp int mode struct ucred *cred struct thread *tdDESCRIPTION
The Fn VOP_OPEN entry point is called before a file is accessed by a process and the Fn VOP_CLOSE entry point is called after a file is finished with by the process.The arguments are:
- Fa vp
- The vnode of the file.
- Fa mode
- The access mode required by the calling process.
- Fa cred
- The caller's credentials.
- Fa td
- The thread which is accessing the file.
- Fa fp
- The file being opened.
Pointer to the file Fa fp is useful for file systems which require such information, e.g., fdescfs(5). Use `NULL' as Fa fp argument to Fn VOP_OPEN for in-kernel opens.
The access mode is a set of flags, including FREAD FWRITE O_NONBLOCK O_APPEND
LOCKS
Fn VOP_OPEN expects Fa vp to be locked on entry and will leave it locked on return.Fn VOP_CLOSE expects at least a reference to be associated with the vnode and does not care whether the vnode is locked or not. The lock and reference state is left unchanged on return. Note that Fa vn_close expects an unlocked, referenced vnode and will dereference the vnode prior to returning.