/* kern_descrip.c 6.3 83/11/18 */
#include "../h/socketvar.h"
* eliminate u.u_error side effects
* 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
]);
} *uap
= (struct a
*) u
.u_ap
;
register struct file
*fp
;
if (uap
->j
< 0 || uap
->j
>= NOFILE
) {
if (u
.u_pofile
[uap
->j
] & UF_MAPPED
)
closef(u
.u_ofile
[uap
->j
]);
dupit(uap
->j
, fp
, u
.u_pofile
[uap
->i
]);
register struct file
*fp
;
* The file control system call.
register struct file
*fp
;
uap
= (struct a
*)u
.u_ap
;
pop
= &u
.u_pofile
[uap
->fdes
];
if (i
< 0 || i
> NOFILE
) {
if ((i
= ufalloc(i
)) < 0)
*pop
= (*pop
&~ 1) | (uap
->arg
& 1);
u
.u_r
.r_val1
= fp
->f_flag
+FOPEN
;
fp
->f_flag
|= (uap
->arg
-FOPEN
) &~ FCNTLCANT
;
u
.u_error
= fset(fp
, FNDELAY
, fp
->f_flag
& FNDELAY
);
u
.u_error
= fset(fp
, FASYNC
, fp
->f_flag
& FASYNC
);
(void) fset(fp
, FNDELAY
, 0);
u
.u_error
= fgetown(fp
, &u
.u_r
.r_val1
);
u
.u_error
= fsetown(fp
, uap
->arg
);
return (fioctl(fp
, (int)(bit
== FNDELAY
? FIONBIO
: FIOASYNC
),
*valuep
= ((struct socket
*)fp
->f_data
)->so_pgrp
;
error
= fioctl(fp
, (int)TIOCGPGRP
, (caddr_t
)valuep
);
if (fp
->f_type
== DTYPE_SOCKET
) {
((struct socket
*)fp
->f_data
)->so_pgrp
= value
;
struct proc
*p
= pfind(value
);
return (fioctl(fp
, (int)TIOCSPGRP
, (caddr_t
)&value
));
return ((*fp
->f_ops
->fo_ioctl
)(fp
, cmd
, value
));
} *uap
= (struct a
*)u
.u_ap
;
register struct file
*fp
;
pf
= (u_char
*)&u
.u_pofile
[uap
->i
];
u
.u_ofile
[uap
->i
] = NULL
;
/* WHAT IF u.u_error ? */
register struct file
*fp
;
uap
= (struct a
*)u
.u_ap
;
u
.u_error
= ino_stat((struct inode
*)fp
->f_data
, &ub
);
u
.u_error
= soo_stat((struct socket
*)fp
->f_data
, &ub
);
u
.u_error
= copyout((caddr_t
)&ub
, (caddr_t
)uap
->sb
,
* Allocate a user file descriptor.
if (u
.u_ofile
[i
] == NULL
) {
register int i
, avail
= 0;
for (i
= 0; i
< NOFILE
; i
++)
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.
register struct file
*fp
;
if ((unsigned)f
>= NOFILE
|| (fp
= u
.u_ofile
[f
]) == NULL
) {
* Internal form of close.
* Decrement reference count on file structure.
* If last reference not going away, but no more
* references except in message queues, run a
* garbage collect. This would better be done by
* forcing a gc() to happen sometime soon, rather
* than running one each time.
register struct file
*fp
;
if (fp
->f_count
== fp
->f_msgcount
)
(*fp
->f_ops
->fo_close
)(fp
);
* Apply an advisory lock on a file descriptor.
} *uap
= (struct a
*)u
.u_ap
;
register struct file
*fp
;
if (fp
->f_type
!= DTYPE_INODE
) {
if (uap
->how
& LOCK_UN
) {
ino_unlock(fp
, FSHLOCK
|FEXLOCK
);
if ((fp
->f_flag
& FEXLOCK
) && (uap
->how
& LOCK_EX
) ||
(fp
->f_flag
& FSHLOCK
) && (uap
->how
& LOCK_SH
))
u
.u_error
= ino_lock(fp
, uap
->how
);