code:passc - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki

Source

  • 向 指定地址空间 的 指定地址 写入字节
  • 修改 u_base,u_count,u_offset ,参看user
  • 输入参数
  • 返回值
    • 若出错,则返回-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          }

  • 若 目标地址空间 为 核心态地址空间,则直接向目标地址写入字节
  • 若 目标地址空间 为 用户态地址空间,则调用subyte 向目标地址写入字节
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);
  • 若u.u_count==0(写入任务完成),则返回-1
  • 否则,返回0
6532 }

6533 /* ------------------------- */

Caller

⚠️ **GitHub.com Fallback** ⚠️