PRIVATE void hd_open(int device) { int drive = DRV_OF_DEV(device); hd_identify(drive); if (hd_info[drive].open_cnt++ == 0) { partition(drive * (NR_PART_PER_DRIVE + 1), P_PRIMARY); print_hdinfo(&hd_info[drive]); } }
/* 功能: 硬盘打开命令 参数: index:完整的设备编号,由设备驱动程序编号和设备编号构成,具体含义参考fs.h,hd.h 返回值: (无) */ static void hd_device_info(MESSAGE *message){ int index=message->device; int hd_index=HD_INDEX(index); assert(hd_index==0,""); hd_identify(hd_index);/*驱动器号,目前只可能是0*/ if((hd_info[hd_index].open_count++)==0){ partition(index); #ifdef DEBUG print_hdinfo(&hd_info[hd_index]); #endif } }
/** * <Ring 1> This routine handles DEV_OPEN message. It identify the drive * of the given device and read the partition table of the drive if it * has not been read. * * @param device The device to be opened. *****************************************************************************/ PRIVATE void hd_open(int device) { int drive = DRV_OF_DEV(device); ERIC_HD("\nHD_open=%x",drive); assert(drive == 0); /* only one drive */ hd_identify(drive); // ++的優先權很高, 而 == 號優先權約在中間,所以要小心 if (hd_info[drive].open_cnt++ == 0) { //列印主分區,每個hd都只有4個主分區 partition(drive * (NR_PART_PER_DRIVE + 1), P_PRIMARY); print_hdinfo(&hd_info[drive]); } }