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

Source

  • 判断 指定盘块 是否为 指定设备的一般盘块
  • 共传入三个参数 afp,abn,dev
    • afp : 指定设备的超级块结构,类型为struct filsys
    • abn : 指定块号
    • dev : 指定设备的设备号
  • 返回值
    • 若指定盘块是一般盘块,则返回0
    • 若指定盘块不是一般盘块,例如是超级块或INODE块,则返回1

7030

7031 /*

7032  * Check that a block number is in the

7033  * range between the I list and the size

7034  * of the device.

7035  * This is used mainly to check that a

7036  * garbage file system has not been mounted.

7037  *

7038  * bad block on dev x/y -- not in range

7039  */

7040 badblock(afp, abn, dev)

7041 {

7042     register struct filsys *fp;

7043     register char *bn;

7044

7045     fp = afp;

7046     bn = abn;

7047     if (bn < fp->s_isize+2 || bn >= fp->s_fsize) {

7048          prdev("bad block", dev);

7049          return(1);

7050     }

  • 若指定盘块不是一般盘块,例如是超级块或INODE块或越界,则
    • 输出错误信息
    • 函数返回1
7051     return(0);

7052 }

7053 /* ------------------------- */

7054 /* ------------------------- */

Ref

Caller

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