/* sys_generic.c 5.10 82/08/14 */
#include "../h/socketvar.h"
#include "../h/descrip.h"
register struct file
*fp
;
register struct inode
*ip
;
uap
= (struct a
*)u
.u_ap
;
if ((int)uap
->count
< 0) {
if ((fp
->f_flag
&FREAD
) == 0) {
aiov
.iov_base
= (caddr_t
)uap
->cbuf
;
aiov
.iov_len
= uap
->count
;
auio
.uio_resid
= uap
->count
;
u
.u_base
= (caddr_t
)0xc0000000;
if ((u
.u_procp
->p_flag
&SNUSIG
) && setjmp(u
.u_qsav
)) {
if (auio
.uio_resid
== uap
->count
)
} else if (fp
->f_type
== DTYPE_SOCKET
)
u
.u_error
= soreceive(fp
->f_socket
, (struct sockaddr
*)0, &auio
);
auio
.uio_offset
= fp
->f_offset
;
if ((ip
->i_mode
&IFMT
) == IFREG
) {
u
.u_error
= readip(ip
, &auio
);
u
.u_error
= readip(ip
, &auio
);
fp
->f_offset
+= uap
->count
- auio
.uio_resid
;
u
.u_r
.r_val1
= uap
->count
- auio
.uio_resid
;
register struct file
*fp
;
register struct inode
*ip
;
uap
= (struct a
*)u
.u_ap
;
if ((int)uap
->count
< 0) {
if ((fp
->f_flag
&FWRITE
) == 0) {
u
.u_base
= (caddr_t
)uap
->cbuf
;
if ((u
.u_procp
->p_flag
&SNUSIG
) && setjmp(u
.u_qsav
)) {
if (u
.u_count
== uap
->count
)
} else if (fp
->f_type
== DTYPE_SOCKET
)
u
.u_error
= sosend(fp
->f_socket
, (struct sockaddr
*)0);
fp
->f_offset
= ip
->i_size
;
u
.u_offset
= fp
->f_offset
;
if ((ip
->i_mode
&IFMT
) == IFREG
) {
fp
->f_offset
+= uap
->count
- u
.u_count
;
u
.u_r
.r_val1
= uap
->count
- u
.u_count
;
* Check legality, execute common code,
* and switch out to individual device routine.
register struct file
*fp
;
char data
[IOCPARM_MASK
+1];
uap
= (struct a
*)u
.u_ap
;
if ((fp
= getf(uap
->fdes
)) == NULL
)
if ((fp
->f_flag
& (FREAD
|FWRITE
)) == 0) {
* Map old style ioctl's into new for the
* sake of backwards compatibility (sigh).
if ((com
&~0xffff) == 0) {
u
.u_pofile
[uap
->fdes
] |= EXCLOSE
;
u
.u_pofile
[uap
->fdes
] &= ~EXCLOSE
;
* Interpret high order word to find
* amount of data to be copied to/from the
* (this'll have to change if we have in+out ioctls)
size
= (com
&~ (IOC_INOUT
|IOC_VOID
)) >> 16;
if (size
> sizeof (data
)) {
if (com
&IOC_IN
&& size
) {
if (copyin(uap
->cmarg
, (caddr_t
)data
, size
)) {
*(caddr_t
*)data
= uap
->cmarg
;
* Zero the buffer on the stack so the user
* always gets back something deterministic.
if ((com
&IOC_OUT
) && size
)
bzero((caddr_t
)data
, size
);
if (fp
->f_type
== DTYPE_SOCKET
)
soioctl(fp
->f_socket
, com
, data
);
register struct inode
*ip
= fp
->f_inode
;
int fmt
= ip
->i_mode
& IFMT
;
if (com
== FIONREAD
&& (fmt
== IFREG
|| fmt
== IFDIR
)) {
*(off_t
*)data
= ip
->i_size
- fp
->f_offset
;
if (com
!= FIONBIO
&& com
!= FIOASYNC
)
if ((u
.u_procp
->p_flag
&SNUSIG
) && setjmp(u
.u_qsav
)) {
(*cdevsw
[major(dev
)].d_ioctl
)(dev
, com
, data
, 0);
* Copy any data to user, size was
* already set and checked above.
if (u
.u_error
== 0 && com
&IOC_OUT
)
if (size
&& copyout(data
, uap
->cmarg
, size
))
* Do nothing specific version of line
* discipline specific ioctl command.
nullioctl(tp
, cmd
, data
, flags
)
tp
= tp
; data
= data
; flags
= flags
;
* Write the file corresponding to
* the inode pointed at by the argument.
* The actual write arguments are found
* u_base core address for source
* u_offset byte offset in file
* u_count number of bytes to write
* u_segflg write to kernel/user/user I
register struct inode
*ip
;
if (u
.u_offset
< 0 && ((ip
->i_mode
&IFMT
) != IFCHR
||
mem_no
!= major(dev
)) ) {
type
= ip
->i_mode
& IFMT
;
CHARGE(sc_tio
* u
.u_count
);
(*cdevsw
[major(dev
)].d_write
)(dev
);
if ((ip
->i_mode
& IFMT
) == IFREG
&&
u
.u_offset
+ u
.u_count
> u
.u_limit
[LIM_FSIZE
]) {
psignal(u
.u_procp
, SIGXFSZ
);
lbn
= u
.u_offset
/ bsize
;
n
= MIN((unsigned)(bsize
- on
), u
.u_count
);
bn
= fsbtodb(fs
, bmap(ip
, lbn
, B_WRITE
, (int)(on
+ n
)));
if (u
.u_error
|| (long)bn
<0)
if(u
.u_offset
+ n
> ip
->i_size
&&
(type
== IFDIR
|| type
== IFREG
|| type
== IFLNK
))
ip
->i_size
= u
.u_offset
+ n
;
size
= blksize(fs
, ip
, lbn
);
bn
= lbn
* (BLKDEV_IOSIZE
/DEV_BSIZE
);
count
= howmany(size
, DEV_BSIZE
);
for (i
= 0; i
< count
; i
+= CLSIZE
)
bp
= getblk(dev
, bn
, size
);
bp
= bread(dev
, bn
, size
);
if (copyin(u
.u_base
, bp
->b_un
.b_addr
+ on
, n
)) {
bcopy(u
.u_base
, bp
->b_un
.b_addr
+ on
, n
);
if ((ip
->i_mode
&IFMT
) == IFDIR
)
* Writing to clear a directory entry.
* Must insure the write occurs before
* the inode is freed, or may end up
* pointing at a new (different) file
* if inode is quickly allocated again
else if (n
+ on
== bsize
) {
ip
->i_mode
&= ~(ISUID
|ISGID
);
} while (u
.u_error
== 0 && u
.u_count
!= 0);
* Move n bytes at byte location
* &bp->b_un.b_addr[o] to/from (flag) the
* user/kernel (u.segflg) area starting at u.base.
* Update all the arguments by the number
t
= copyin(u
.u_base
, (caddr_t
)cp
, n
);
t
= copyout((caddr_t
)cp
, u
.u_base
, n
);
bcopy(u
.u_base
, (caddr_t
)cp
, n
);
bcopy((caddr_t
)cp
, u
.u_base
, n
);
readip1(ip
, base
, len
, offset
, segflg
, aresid
)
auio
.uio_offset
= offset
;
auio
.uio_segflg
= segflg
;
error
= readip(ip
, &auio
);
*aresid
= auio
.uio_resid
;
register struct inode
*ip
;
register struct uio
*uio
;
register struct iovec
*iov
;
if (uio
->uio_offset
< 0 &&
((ip
->i_mode
&IFMT
) != IFCHR
|| mem_no
!= major(dev
)))
(*cdevsw
[major(dev
)].d_read
)(dev
, uio
);
CHARGE(sc_tio
* (c
- uio
->uio_resid
));
if (uio
->uio_iovcnt
== 0)
lbn
= uio
->uio_offset
/ bsize
;
on
= uio
->uio_offset
% bsize
;
n
= MIN((unsigned)(bsize
- on
), iov
->iov_len
);
diff
= ip
->i_size
- uio
->uio_offset
;
bn
= fsbtodb(fs
, bmap(ip
, lbn
, B_READ
));
size
= blksize(fs
, ip
, lbn
);
bn
= lbn
* (BLKDEV_IOSIZE
/DEV_BSIZE
);
rablock
= bn
+ (BLKDEV_IOSIZE
/DEV_BSIZE
);
} else if (ip
->i_lastr
+ 1 == lbn
)
bp
= breada(dev
, bn
, size
, rablock
, rasize
);
bp
= bread(dev
, bn
, size
);
n
= MIN(n
, size
- bp
->b_resid
);
if (uio
->uio_segflg
!= 1) {
if (copyout(bp
->b_un
.b_addr
+on
, iov
->iov_base
, n
)) {
bcopy(bp
->b_un
.b_addr
+ on
, iov
->iov_base
, n
);
if (n
+ on
== bsize
|| uio
->uio_offset
== ip
->i_size
)
} while (u
.u_error
== 0 && iov
->iov_len
!= 0 && n
!= 0);
if (u
.u_error
== 0 && iov
->iov_len
== 0) {
register struct iovec
*iov
;
if (uio
->uio_segflg
!= 1) {
bad
= copyuin(uio
, (caddr_t
)cp
, n
);
bad
= copyuout((caddr_t
)cp
, n
, uio
);
while (n
> 0 && uio
->uio_iovcnt
) {
bcopy(iov
->iov_base
, (caddr_t
)cp
, cnt
);
bcopy((caddr_t
)cp
, iov
->iov_base
, cnt
);