00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00047 #include <errno.h>
00048
00049 #include <fs/fs.h>
00050
00051 #include <fs/phatfs.h>
00052 #include <fs/phatvol.h>
00053 #include <dev/blockdev.h>
00054 #include <fs/phatio.h>
00055
00056 #include <stdio.h>
00057
00058 #include <fs/phatdbg.h>
00059
00064
00065 void PhatDbgAttrList(FILE * fp, u_char attr)
00066 {
00067 if (attr & PHAT_FATTR_RDONLY) {
00068 fputc('R', fp);
00069 } else if (attr & PHAT_FATTR_HIDDEN) {
00070 fputc('H', fp);
00071 } else if (attr & PHAT_FATTR_SYSTEM) {
00072 fputc('S', fp);
00073 } else if (attr & PHAT_FATTR_VOLID) {
00074 fputc('V', fp);
00075 } else if (attr & PHAT_FATTR_DIR) {
00076 fputc('D', fp);
00077 } else if (attr & PHAT_FATTR_ARCHIV) {
00078 fputc('A', fp);
00079 }
00080 }
00081
00082 void PhatDbgDirEntry(FILE * fp, CONST char *title, PHATDIRENT * dent)
00083 {
00084 if (title) {
00085 fprintf(fp, "--- %s ---\n", title);
00086 }
00087 fprintf(fp, "DentFName: '%.11s'\n", dent->dent_name);
00088 fputs("DentFAttr: ", fp);
00089 PhatDbgAttrList(fp, dent->dent_attr);
00090 fputc('\n', fp);
00091 fprintf(fp, "DentRsrvd: 0x%02X\n", dent->dent_rsvdnt);
00092 fprintf(fp, "DentCTime: 0x%04X 0x%04X 0x%02X\n", dent->dent_cdate, dent->dent_ctime, dent->dent_ctsecs);
00093 fprintf(fp, "DentADate: 0x%04X\n", dent->dent_adate);
00094 fprintf(fp, "DentMTime: 0x%04X 0x%04X\n", dent->dent_mdate, dent->dent_mtime);
00095 fprintf(fp, "DentClust: %lu\n", (u_long) dent->dent_clust + ((u_long) dent->dent_clusthi << 16));
00096 fprintf(fp, "DentFSize: %lu\n", dent->dent_fsize);
00097 }
00098
00099 void PhatDbgFileInfo(FILE * fp, CONST char *title, PHATFILE * nfp)
00100 {
00101 if (title) {
00102 fprintf(fp, "--- %s ---\n", title);
00103 }
00104 fprintf(fp, "File Pos : %lu\n", nfp->f_pos);
00105 fprintf(fp, "Cluster : %lu Prev %lu\n", nfp->f_clust, nfp->f_clust_prv);
00106 fprintf(fp, "Cluster Pos: %lu\n", nfp->f_clust_pos);
00107 fprintf(fp, "Sector Pos : %lu\n", nfp->f_sect_pos);
00108 PhatDbgDirEntry(fp, NULL, &nfp->f_dirent);
00109 fprintf(fp, "Parent Clust: %lu\n", (u_long) nfp->f_pde_clust + ((u_long) nfp->f_pde_clusthi << 16));
00110 fprintf(fp, "DirEnt Sect : %lu\n", nfp->f_de_sect);
00111 fprintf(fp, "DirEnt Offs : %lu\n", nfp->f_de_offs);
00112 fprintf(fp, "DirEnt Dirty: %u\n", nfp->f_de_dirty);
00113 }
00114
00115 void PhatDbgVbr(FILE * fp, CONST char *title, PHATVBR * vbr)
00116 {
00117 if (title) {
00118 fprintf(fp, "--- %s ---\n", title);
00119 }
00120 fprintf(fp, "Boot jump : %02X %02X %02X\n", vbr->boot_jump[0], vbr->boot_jump[1], vbr->boot_jump[2]);
00121 fprintf(fp, "OEM name : %.8s\n", vbr->boot_oem);
00122 fprintf(fp, "Bytes/sector : %u\n", vbr->bios_sectsz);
00123 fprintf(fp, "Sectors/cluster: %u\n", vbr->bios_clustsz);
00124 fprintf(fp, "Rsvd. sectors : %u\n", vbr->bios_rsvd_sects);
00125 fprintf(fp, "Alloc. tables : %u\n", vbr->bios_ntabs);
00126 fprintf(fp, "Root entries : %u\n", vbr->bios_rootsz);
00127 fprintf(fp, "Total sectors : %lu\n", vbr->bios_volsz ? (u_long) vbr->bios_volsz : vbr->bios_volsz_big);
00128 fprintf(fp, "Media type : 0x%02X\n", vbr->bios_media);
00129 fprintf(fp, "Sectors/table : %u %lu\n", vbr->bios_tabsz, vbr->bios_tabsz_big);
00130 fprintf(fp, "Sectors/track : %u\n", vbr->bios_sects_p_trk);
00131 fprintf(fp, "Heads : %u\n", vbr->bios_heads);
00132 fprintf(fp, "Hidden sectors : %lu\n", vbr->bios_sects_hidd);
00133 fprintf(fp, "Mirror flags : 0x%04u\n", vbr->bios_xflags);
00134 fprintf(fp, "File system ver: %u\n", vbr->bios_fsver);
00135 fprintf(fp, "Root dir clust : %lu\n", vbr->bios_root_clust);
00136 fprintf(fp, "FSInfo sector : %u\n", vbr->bios_fsinfo);
00137 fprintf(fp, "Boot back sect : %u\n", vbr->bios_boot_bak);
00138 fprintf(fp, "Logical drive : %u\n", vbr->boot_drive);
00139 fprintf(fp, "Rsvd NT(head) : %u\n", vbr->boot_rsvd_nt);
00140 fprintf(fp, "Ext. signature : 0x%02X\n", vbr->boot_xsig);
00141 if (vbr->boot_xsig == 0x28 || vbr->boot_xsig == 0x29) {
00142 fprintf(fp, "Volume ID : 0x%08lX\n", vbr->boot_vol_id);
00143 fprintf(fp, "Volume label : %.11s\n", vbr->boot_vol_lbl);
00144 fprintf(fp, "Filesystem : %.8s\n", vbr->boot_vol_fs);
00145 }
00146 }
00147