e980f886e5797915cca08712236348fc9e8211f7
/* kern_descrip.c 5.8 82/09/08 */
#include "../h/socketvar.h"
#include "../h/descrip.h"
* ufalloc side effects are gross
* System calls on descriptors.
} *uap
= (struct a
*)u
.u_ap
;
register struct file
*fp
;
adtype
.dt_type
= 0; /* XXX */
adtype
.dt_protocol
= 0; /* XXX */
if (copyout((caddr_t
)&adtype
, (caddr_t
)uap
->dtypeb
,
sizeof (struct dtype
)) < 0) {
} *uap
= (struct a
*) u
.u_ap
;
if (uap
->i
&~ 077) { uap
->i
&= 077; dup2(); return; } /* XXX */
dupit(j
, fp
, u
.u_pofile
[uap
->i
] & (RDLOCK
|WRLOCK
));
} *uap
= (struct a
*) u
.u_ap
;
register struct file
*fp
;
if (uap
->j
< 0 || uap
->j
>= NOFILE
) {
closef(u
.u_ofile
[uap
->j
], 0, u
.u_pofile
[uap
->j
]);
/* u.u_ofile[uap->j] = 0; */
/* u.u_pofile[uap->j] = 0; */
dupit(uap
->j
, fp
, u
.u_pofile
[uap
->i
] & (RDLOCK
|WRLOCK
));
register struct file
*fp
;
u
.u_pofile
[fd
] = lockflags
;
fp
->f_inode
->i_rdlockc
++;
fp
->f_inode
->i_wrlockc
++;
} *uap
= (struct a
*)u
.u_ap
;
register struct file
*fp
;
closef(fp
, 0, u
.u_pofile
[uap
->i
]);
/* WHAT IF u.u_error ? */
u
.u_ofile
[uap
->i
] = NULL
;
} *uap
= (struct a
*)u
.u_ap
;
register struct file
*fp
;
if (copyin((caddr_t
)uap
->dtypeb
, (caddr_t
)&adtype
,
sizeof (struct dtype
)) < 0) {
} *uap
= (struct uap
*)u
.u_ap
;
if (copyin((caddr_t
)uap
->tv
, (caddr_t
)&atv
, sizeof (atv
))) {
s
= spl7(); timevaladd(&atv
, &time
); splx(s
);
if (copyin((caddr_t
)uap
->ibits
, (caddr_t
)ibits
, sizeof (ibits
))) {
u
.u_procp
->p_flag
|= SSEL
;
u
.u_r
.r_val1
= selscan(ibits
, obits
);
if (uap
->tv
&& timercmp(&atv
, &time
, >=)) {
if ((u
.u_procp
->p_flag
& SSEL
) == 0 || nselcoll
!= ncoll
) {
u
.u_procp
->p_flag
&= ~SSEL
;
u
.u_procp
->p_flag
&= ~SSEL
;
if (setjmp(&u
.u_qsave
)) {
untimeout(unselect
, u
.u_procp
);
timeout(unselect
, u
.u_procp
, hzto(&atv
));
sleep((caddr_t
)&selwait
, PZERO
+1);
untimeout(unselect
, u
.u_procp
);
if (copyout((caddr_t
)obits
, (caddr_t
)uap
->obits
, sizeof (obits
))) {
register int which
, bits
, i
;
for (which
= 0; which
< 3; which
++) {
if (fp
->f_type
== DTYPE_SOCKET
)
able
= soselect(fp
->f_socket
, flag
);
switch (ip
->i_mode
& IFMT
) {
(*cdevsw
[major(ip
->i_rdev
)].d_select
)
obits
[which
] |= (1<<(i
-1));
wakeup((caddr_t
)&selwait
);
if (p
->p_wchan
== (caddr_t
)&selwait
)
* 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
++)
* 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.
* Nouser indicates that the user isn't available to present
* Handling locking at this level is RIDICULOUS.
closef(fp
, nouser
, flags
)
register struct file
*fp
;
register struct inode
*ip
;
register struct mount
*mp
;
if (fp
->f_type
== DTYPE_SOCKET
) {
soclose(fp
->f_socket
, nouser
);
if (nouser
== 0 && u
.u_error
)
mode
= ip
->i_mode
& IFMT
;
flags
&= RDLOCK
|WRLOCK
; /* conservative */
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_type
== DTYPE_SOCKET
) /* XXX */
if (fp
->f_count
&& (ip
= fp
->f_inode
) &&
ip
->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