code:getmdev - ikarishinjieva/unixV6-code-analyze-chs GitHub Wiki
6175
6176 /*
6177 * Common code for mount and umount.
6178 * Check that the user’s argument is a reasonable thing
6179 * on which to mount, and return the device number if so.
6180 */
6181 getmdev()
6182 {
6183 register d, *ip;
6184 extern uchar;
6185
6187 if(ip == NULL)
- ip ← 文件路径对应的INODE
6188 return;
6189 if((ip->i_mode&IFMT) != IFBLK)
6190 u.u_error = ENOTBLK;
6191 d = ip->i_addr[0];
6192 if(ip->i_addr[0].d_major >= nblkdev)
- d ← 从ip抽取 设备号
- 关于ip->i_addr[0] 为什么是设备号,参看装载文件系统
6193 u.u_error = ENXIO;
6194 iput(ip);
- 若 主设备号越界,抛出错误,错误代码 : ENXIO
6195 return(d);
6196 }
6197 /* ------------------------- */
6198
6199