* Read the file corresponding to
* the inode pointed at by the argument.
* The actual read arguments are found
* u_base core address for destination
* u_offset byte offset in file
* u_count number of bytes to read
* u_segflg read to kernel/user
register struct inode
*ip
;
if((ip
->i_mode
&IFMT
) == IFCHR
) {
(*cdevsw
[ip
->i_addr
[0].d_major
].d_read
)(ip
->i_addr
[0]);
lbn
= bn
= lshift(u
.u_offset
, -9);
on
= u
.u_offset
[1] & 0777;
n
= min(512-on
, u
.u_count
);
if((ip
->i_mode
&IFMT
) != IFBLK
) {
dn
= dpcmp(ip
->i_size0
&0377, ip
->i_size1
,
u
.u_offset
[0], u
.u_offset
[1]);
if ((bn
= bmap(ip
, lbn
)) == 0)
if (ip
->i_lastr
+1 == lbn
)
bp
= breada(dn
, bn
, rablock
);
iomove(bp
, on
, n
, B_READ
);
} while(u
.u_error
==0 && u
.u_count
!=0);
* 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
register struct inode
*ip
;
if((ip
->i_mode
&IFMT
) == IFCHR
) {
(*cdevsw
[ip
->i_addr
[0].d_major
].d_write
)(ip
->i_addr
[0]);
bn
= lshift(u
.u_offset
, -9);
on
= u
.u_offset
[1] & 0777;
n
= min(512-on
, u
.u_count
);
if((ip
->i_mode
&IFMT
) != IFBLK
) {
if ((bn
= bmap(ip
, bn
)) == 0)
bp
= getblk(dn
, bn
); else
iomove(bp
, on
, n
, B_WRITE
);
if ((u
.u_offset
[1]&0777)==0)
if(dpcmp(ip
->i_size0
&0377, ip
->i_size1
,
u
.u_offset
[0], u
.u_offset
[1]) < 0 &&
(ip
->i_mode
&(IFBLK
&IFCHR
)) == 0) {
ip
->i_size0
= u
.u_offset
[0];
ip
->i_size1
= u
.u_offset
[1];
} while(u
.u_error
==0 && u
.u_count
!=0);
* Return the logical maximum
* Return the logical minimum
* Move 'an' bytes at byte location
* &bp->b_addr[o] to/from (flag) the
* user/kernel (u.segflg) area starting at u.base.
* Update all the arguments by the number
* There are 2 algorithms,
* if source address, dest address and count
* are all even in a user copy,
* then the machine language copyin/copyout
* If not, its done byte-by-byte with
if(u
.u_segflg
==0 && ((n
| cp
| u
.u_base
)&01)==0) {
cp
= copyin(u
.u_base
, cp
, n
);
cp
= copyout(cp
, u
.u_base
, n
);