|
|
1.1 root 1: #include "sys/param.h"
2: #include "sys/inode.h"
3: #include "sys/user.h"
4: #include "sys/conf.h"
5: #include "sys/buf.h"
6:
7: /*
8: * Read the file corresponding to
9: * the inode pointed at by the argument.
10: * The actual read arguments are found
11: * in the variables:
12: * u_base core address for destination
13: * u_offset byte offset in file
14: * u_count number of bytes to read
15: * u_segflg read to kernel/user
16: */
17: readi(ip)
18: register struct inode *ip;
19: {
20:
21: if(u.u_count == 0)
22: return;
23: ip->i_flag |= IACC;
24: if (ip->i_sptr) {
25: u.u_nbadio = 0; /* approximates a bad-count per stream */
26: stread(ip);
27: return;
28: }
29: (*fstypsw[ip->i_fstyp]->t_read)(ip);
30: }
31:
32: /*
33: * Write the file corresponding to
34: * the inode pointed at by the argument.
35: * The actual write arguments are found
36: * in the variables:
37: * u_base core address for source
38: * u_offset byte offset in file
39: * u_count number of bytes to write
40: * u_segflg write to kernel/user/user I
41: */
42:
43: writei(ip)
44: register struct inode *ip;
45: {
46:
47: if (ip->i_sptr) {
48: ip->i_flag |= IUPD|ICHG;
49: stwrite(ip);
50: return;
51: }
52: (*fstypsw[ip->i_fstyp]->t_write)(ip);
53: }
54:
55: /*
56: * Return the logical maximum
57: * of the 2 arguments.
58: */
59: unsigned
60: max(a, b)
61: unsigned a, b;
62: {
63:
64: if(a > b)
65: return(a);
66: return(b);
67: }
68:
69: /*
70: * Return the logical minimum
71: * of the 2 arguments.
72: */
73: unsigned
74: min(a, b)
75: unsigned a, b;
76: {
77:
78: if(a < b)
79: return(a);
80: return(b);
81: }
82:
83: /*
84: * Move n bytes at byte location
85: * &bp->b_un.b_addr[o] to/from (flag) the
86: * user/kernel (u.segflg) area starting at u.base.
87: * Update all the arguments by the number
88: * of bytes moved.
89: *
90: * Botchy VAX-ism: believes user I and user D are the same
91: */
92: iomove(cp, n, flag)
93: register caddr_t cp;
94: register unsigned n;
95: {
96: register int t;
97:
98: if (n==0)
99: return;
100: if (u.u_segflg != SEGSYS) {
101: if (flag==B_WRITE)
102: t = copyin(u.u_base, (caddr_t)cp, n);
103: else
104: t = copyout((caddr_t)cp, u.u_base, n);
105: if (t) {
106: u.u_error = EFAULT;
107: return;
108: }
109: } else
110: if (flag == B_WRITE)
111: bcopy(u.u_base, (caddr_t)cp, n);
112: else
113: bcopy((caddr_t)cp, u.u_base, n);
114: u.u_base += n;
115: u.u_offset = Lladd(u.u_offset, n);
116: u.u_count -= n;
117: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.