이 코드는 프로젝트 소스의 일부입니다. 이 코드는 MBR 유형 (GRUB 또는 LILO)을 찾고 그에 따라 플래그를 설정합니다.MBR 유형을 찾을 수 없습니다.
놀랍게도 SLES 10-SP1 (SUSE Linux Enterprise Server)에서 확인할 수 없습니다. /dev/sda1
은 제 스왑입니다. /dev/sda2
은 MBR을 포함하여 전체가 /
인 곳입니다.
동일한 코드가 SLES11 및 다른 제품에서 작동합니다. 여기에서 MBR_SIZE
은 #defined
에서 0x1be
입니다.
int lnxfsGetBootType(int pNumber)
{
int i, retval = -1, ccode;
PartInfo *p = &cpuParts[pNumber];
char buffer[SECTOR_SIZE];
var64 offset = 0;
isdLogFileOut(ZISD_LOG_DEVELOPER,"[lnxGBT]\n");
if (getenv("ZENDEVICE") || gUtilPart == 1) {
offset = p->pOffset; // look at the partition BPB
}
//Now try to find the installed boot loader...
lseek64(p->handle, (var64)offset, SEEK_SET); // either MBR or BPB
ccode = read(p->handle, buffer, SECTOR_SIZE);
for (i=0; i<MBR_SIZE-4;i++) {
if (strncmp(&buffer[i], "LILO", 4) == 0) {
if (offset == 0){
retval = FLAG_LNXFS_LILO;
isdLogFileOut(ZISD_LOG_WARNING,"\tLILO MBR found on %s\n",p->header.deviceName);
} else {
retval = FLAG_LNXFS_LILO; // 10.31.06 _BPB;
isdLogFileOut(ZISD_LOG_WARNING,"\tLILO BPB found on %s\n",p->header.deviceName);
}
}
if (strncmp(&buffer[i], "GRUB", 4) == 0) {
if (offset == 0){
retval = FLAG_LNXFS_GRUB;
isdLogFileOut(ZISD_LOG_WARNING,"\tGRUB MBR found on %s\n",p->header.deviceName);
} else {
retval = FLAG_LNXFS_GRUB; // 10.31.06 _BPB;
isdLogFileOut(ZISD_LOG_WARNING,"\tGRUB BPB found on %s\n",p->header.deviceName);
}
}
}
if (retval == -1) {
isdLogFileOut(ZISD_LOG_WARNING,"\tLILO or GRUB mbr/bpb not found on %s\n",p->header.deviceName);
}
return retval;
} // lnxfsGetBootType
Here partinfo, is a struct of partition type:
//Data structure used internally by the image engine to store information about the
//partitions. It encapsulates the PartHeader struct, whcih is used to store partition
//information in image archives
typedef struct _PartInfo
{
PartHeader header;
int handle; //file handle for reading/writing physical device
var32 flags; //Various flags as needed. Defined above.
var64 pOffset; //offset to partition from start of physical device
int deviceNumber; //index into 'devices' where this partition's
// physical device is located
int archIndex; //for restoring only. Index into imgParts of the
// archive partition this physical partition is
// mapped to
int bytesWritten; //track number of sectors written so the device-level
// cache can be flushed
void *info; //partition-type-specific info struct
/* snip */
테스트는 VMWare에서 다른 가상 디스크 이미지로 수행됩니다. 디스크가 GPR이 아닌 MBR로 포맷되었는지 확인했습니다.
@sarnold : 아니오, VMware 및 개별 가상 디스크에서 테스트 중입니다. – kingsmasher1
@sarnold : 아니요, GPT는 사용하지 않습니다. MBR입니다. 팀에서 확인했습니다. – kingsmasher1
@sarnold : vmware4 디스크 이미지 :) – kingsmasher1