/* Note that unlike the "iget" stuff, this does NOT use ioctls. * This reads directly from the ***DISK DRIVE** */ #include #include #include #include #include extern void numtoOS(int ostype, char *buffer); int main(int argc, char *argv[]){ int fd; int fpart; char namebuff[25]; char buffer[1024]; struct ipart parts[10]; struct mboot *mbootptr,mboot; if(argc<2){ puts("Need name of file or device!"); exit(1); } fd=open(argv[1],O_RDONLY); if(fd <0){ perror("cannot open file"); exit(errno); } if(read(fd,buffer,512) !=512){ perror("err reading initial sector"); exit(errno); } close(fd); printf("Fdisk information for device %s\n",argv[1]); memcpy(&mboot,buffer,sizeof(struct mboot)); mbootptr=&mboot; if(mbootptr->signature!= MBB_MAGIC){ fprintf(stderr,"FDISK table NOT VALID\n"); fprintf(stderr,"Reminder: dont forget to use either 'p0' or 'D0' device\n"); exit(1); } /* See "NOTES.fdisk" */ memcpy(parts, mbootptr->parts, sizeof(struct ipart)*FD_NUMPART); puts("# start block end block startCylSecHd endCylSecHd OSType"); for(fpart=0;fpart