/* vfs_vnops.c 4.17 81/11/18 */
#include "../h/socketvar.h"
* Convert a user supplied file descriptor into a pointer
* to a file structure. Only task is to check range of the descriptor.
* Critical paths should use the GETF macro, defined in inline.h.
register struct file
*fp
;
if ((unsigned)f
>= NOFILE
|| (fp
= u
.u_ofile
[f
]) == NULL
) {
* 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
;
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_flag
& FSOCKET
)
if (fp
->f_count
&& (ip
= fp
->f_inode
) &&
ip
->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 (ip
->i_flag
& ITEXT
) {
if (u
.u_uid
!= ip
->i_uid
) {
if (u
.u_gid
!= ip
->i_gid
)
* 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
;
if (u
.u_uid
== ip
->i_uid
)
* 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.
register struct file
*fp
;
for (fp
= lastf
; fp
< fileNFILE
; fp
++)
for (fp
= file
; fp
< lastf
; fp
++)