/* vfs_vnops.c 4.6 %G% */
* Convert a user supplied
* file descriptor into a pointer
* Only task is to check range
register struct file
*fp
;
if ((unsigned)f
>= NOFILE
|| (fp
= u
.u_ofile
[f
]) == NULL
) {
if (u
.u_pofile
[f
] & ISPORT
) {
* 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
;
register struct mount
*mp
;
dev
= (dev_t
)ip
->i_un
.i_rdev
;
mode
= ip
->i_mode
& IFMT
;
ip
->i_mode
&= ~(IREAD
|IWRITE
);
cfunc
= cdevsw
[major(dev
)].d_close
;
* We don't want to really close the device if it is mounted
for (mp
= mount
; mp
< &mount
[NMOUNT
]; mp
++)
if (mp
->m_bufp
!= NULL
&& mp
->m_dev
== dev
)
cfunc
= bdevsw
[major(dev
)].d_close
;
for(fp
=file
; fp
< fileNFILE
; fp
++)
if (fp
->f_count
&& (ip
=fp
->f_inode
)->i_un
.i_rdev
==dev
&&
(ip
->i_mode
&IFMT
) == mode
)
* on last close of a block device (that isn't mounted)
* we must invalidate any in core blocks
* 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
= lastf
; fp
< fileNFILE
; fp
++)
for (fp
= file
; fp
< lastf
; fp
++)