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

Source

  • 用来调用指定设备对应的d_sgtty函数
  • 传入一个参数:
    • t:一个缓存区,用来交换tty状态
  • 隐式参数:
    • 通过R0传入指定设备的字符设备装载文件的文件描述号

8194 /* Stuff common to stty and gtty.

8196  * device routine.

8197  * v is 0 for stty; the parameters are taken from u.u_arg\[].

8198  * c is non-zero for gtty and is the place in which the

8199  * device routines place their information.

8200  */

8201 sgtty(v)

8202 int *v;

8203 {

8204     register struct file *fp;

8205     register struct inode *ip;

8206     if ((fp = getf(u.u_ar0[R0])) == NULL)

8207           return;

  • 根据传入的文件描述号找到其对应的file结构
    • 若不能找到便直接返回
8208     ip = fp->f_inode;

8209     if ((ip->i_mode&IFMT) != IFCHR) {

8210           u.u_error = ENOTTY;

8211           return;

8212 }

8213     (*cdevsw[ip->i_addr[0].d_major].d_sgtty)(ip->i_addr[0],v);

8214 }

8215 /* ------------------------- */

Caller

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