int get_file_inode(int device, char* pathname) { char** name = parse(pathname, "/"); // Follow user provided pathname int i = 0; while(name[i]) { ino = search(ip, name[i]); if (ino == 0) { printf("\n Failure: '%s' does not exist!\n\n", pathname); exit(1); } ip = iget(ino); if (S_ISDIR(ip->i_mode) && name[i + 1]) { printDivider('='); print(ip); } else fprintf(stderr, "%s is not a directory\n", name[i + 1]); i++ } printDivider('-'); printf(" Success: '%s' has been found!\n", name[n-1]); }
int main(int argc, char** argv){ if(argc != 2){ printf("Invalid Arguments. Usage: raw_image_reader <path_to_file>\n"); return -1; } struct stat fstats; int file = open(argv[1], O_RDONLY); MBR mbr; VBR vbr[NUM_OF_PARTITIONS]; if(file<0){ printf("Unable to open file"); return -1; } printDivider(); fstat(file, &fstats); calcMD5(file, fstats.st_size, argv[1]); calcSHA1(file, fstats.st_size, argv[1]); readMBR(file, (char*)&mbr); readVBR(file, &mbr, vbr); printDivider(); printPartitions(&mbr); printDivider(); printVBR(&mbr,vbr); close(file); return 1; }
void gameBoardPrint(GameBoard board) { printf(" 1 2 3 4 5 6 7 8 9\n"); printDivider(); for (int i = 0; i < GROUP_SIZE; ++i) { gameBoardPrintRowGroup(board, i); printDivider(); } }
void printVBR(MBR *mbr, VBR *vbr){ int fatSize, endingSec, firstSecCluster2; for(int i =0; i < NUM_OF_PARTITIONS; i++){ fatSize = vbr[i].sizeOfFAT; endingSec = 0; firstSecCluster2 = FAT16Offset; switch(mbr->entries[i].type){ FAT32Switch fatSize = vbr[i].sizeOfFAT32; firstSecCluster2-= FAT16Offset; FAT16Switch endingSec = vbr[i].sizeOfReserved-1 + vbr[i].numFATs * fatSize; firstSecCluster2 += mbr->entries[i].sectorDistance + endingSec + 1; printf("Partition %i(%s):\n", i, partition_type[mbr->entries[i].type]); printf("Reserved Area: Start Sector: %i Ending Sector: %i Size: %i sectors\n", 0, vbr[i].sizeOfReserved-1, vbr[i].sizeOfReserved); printf("Sectors per cluster: %i sectors\n", vbr[i].sectorsPerCluster); printf("FAT ares: Start Sector: %i Ending Sector: %i\n", vbr[i].sizeOfReserved, endingSec); printf("# of FATs: %i\n", vbr[i].numFATs); printf("The size of each FAT: %i sectors\n", fatSize); printf("The first sector of cluster %i: %i sectors\n", 2, firstSecCluster2); printDivider(); break; default: printf("Partition %i(%s) is not a FAT16/32 Partition\n", i, partition_type[mbr->entries[i].type]); printDivider(); } } }