/* vfs_vnops.c 3.2 %G% */
* Convert a user supplied
* file descriptor into a pointer
* Only task is to check range
register struct file
*fp
;
if(0 <= f
&& f
< NOFILE
) {
* Internal form of close.
* Decrement reference count on
* Also make sure the pipe protocol
* Decrement reference count on the inode following
* removal to the referencing file structure.
* Call device handler on last close.
register struct file
*fp
;
register struct inode
*ip
;
dev
= (dev_t
)ip
->i_un
.i_rdev
;
ip
->i_mode
&= ~(IREAD
|IWRITE
);
cfunc
= cdevsw
[major(dev
)].d_close
;
cfunc
= bdevsw
[major(dev
)].d_close
;
for(fp
=file
; fp
< &file
[NFILE
]; fp
++)
if (fp
->f_count
&& fp
->f_inode
==ip
)
* openi called to allow handler
* of special files to initialize and
* validate before actual IO.
register struct inode
*ip
;
register unsigned int maj
;
dev
= (dev_t
)ip
->i_un
.i_rdev
;
switch(ip
->i_mode
&IFMT
) {
(*cdevsw
[maj
].d_open
)(dev
, rw
);
(*bdevsw
[maj
].d_open
)(dev
, rw
);
* Check mode permission on inode pointer.
* Mode is READ, WRITE or EXEC.
* In the case of WRITE, the
* read-only status of the file
* Also in WRITE, prototype text
* segments cannot be written.
* The mode is shifted to select
* the owner/group/other fields.
* The super user is granted all
register struct inode
*ip
;
if(getfs(ip
->i_dev
)->s_ronly
!= 0) {
if (ip
->i_flag
&ITEXT
) /* try to free text */
if(u
.u_uid
!= ip
->i_uid
) {
* Look up a pathname and test if
* the resultant inode is owned by the
* If not, try for super-user.
* If permission is granted,
register struct inode
*ip
;
* Test if the current user is the
* Allocate a user file descriptor.
if(u
.u_ofile
[i
] == NULL
) {
* Allocate a user file descriptor
* Initialize the descriptor
* to point at the file structure.
* no file -- if there are no available
register struct file
*fp
;
for(fp
= &file
[0]; fp
< &file
[NFILE
]; fp
++)