/* kern_descrip.c 5.4 82/08/10 */
#include "../h/socketvar.h"
#include "../h/descrip.h"
* ufalloc side effects are gross
* System calls on descriptors.
} *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
;
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
;
register struct file
*fp
;
if (copyin((caddr_t
)uap
->dtypeb
, (caddr_t
)&adtype
,
sizeof (struct dtype
)) < 0) {
} *uap
= (struct a
*)u
.u_ap
;
} *uap
= (struct a
*)u
.u_ap
;
} *ap
= (struct uap
*)u
.u_ap
;
int nfds
= 0, readable
= 0, writeable
= 0;
if (ap
->rp
&& copyin((caddr_t
)ap
->rp
,(caddr_t
)&rd
,sizeof(fd_set
)))
if (ap
->wp
&& copyin((caddr_t
)ap
->wp
,(caddr_t
)&wr
,sizeof(fd_set
)))
u
.u_procp
->p_flag
|= SSEL
;
readable
= selscan(ap
->nfd
, rd
, &nfds
, FREAD
);
writeable
= selscan(ap
->nfd
, wr
, &nfds
, FWRITE
);
if (readable
|| writeable
)
rem
= (ap
->timo
+999)/1000 - (time
- t
);
if (ap
->timo
== 0 || rem
<= 0)
if ((u
.u_procp
->p_flag
& SSEL
) == 0 || nselcoll
!= ncoll
) {
u
.u_procp
->p_flag
&= ~SSEL
;
u
.u_procp
->p_flag
&= ~SSEL
;
tsel
= tsleep((caddr_t
)&selwait
, PZERO
+1, rem
);
rd
.fds_bits
[0] = readable
;
wr
.fds_bits
[0] = writeable
;
s
= (ap
->nfd
+ NBBY
- 1) / NBBY
;
(void) copyout((caddr_t
)&rd
, (caddr_t
)ap
->rp
, sizeof(fd_set
));
(void) copyout((caddr_t
)&wr
, (caddr_t
)ap
->wp
, sizeof(fd_set
));
selscan(nfd
, fds
, nfdp
, flag
)
if (fp
->f_type
== DTYPE_SOCKET
)
able
= soselect(fp
->f_socket
, flag
);
switch (ip
->i_mode
& IFMT
) {
(*cdevsw
[major(ip
->i_rdev
)].d_select
)
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