code:passc - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
- 向 指定地址空间 的 指定地址 写入字节
- 修改 u_base,u_count,u_offset ,参看user
- 输入参数
- 地址空间 由 u.u_segflg指明
- 指定地址 由 u.u_base 提供
- c : 欲写入字节
- 返回值
- 若出错,则返回-1
- 若u.u_count==0(写入任务完成),则返回-1
- 否则,返回0
6510
6511 /* Pass back c to the user at his location u_base;
6512 * update u_base, u_count, and u_offset. Return -1
6513 * on the last character of the user’s read.
6514 * u_base is in the user address space unless u_segflg
6515 * is set.
6516 */
6517 passc(c)
6518 char c;
6519 {
6520
6521 if(u.u_segflg)
6522 *u.u_base =c; else
6523 if(subyte(u.u_base, c) < 0) {
6524 u.u_error = EFAULT;
6525 return(-1);
6526 }
6527 u.u_count--;
6528 if(++u.u_offset[1] == 0)
6529 u.u_offset[0]++;
6530 u.u_base++;
6531 return(u.u_count == 0? -1: 0);
- 修改相应参数
- 参看user
6532 }
- 若u.u_count==0(写入任务完成),则返回-1
- 否则,返回0
6533 /* ------------------------- */