📄 iso9660.c
字号:
tsk_fs_block_free(fs_block); return 0;}static uint8_tiso9660_make_data_run(TSK_FS_FILE * a_fs_file){ ISO_INFO *iso; iso9660_dentry dd; TSK_FS_INFO *fs = NULL; TSK_FS_ATTR *fs_attr = NULL; TSK_FS_ATTR_RUN *data_run = NULL; // clean up any error messages that are lying around tsk_error_reset(); if ((a_fs_file == NULL) || (a_fs_file->meta == NULL) || (a_fs_file->fs_info == NULL)) { tsk_errno = TSK_ERR_FS_ARG; snprintf(tsk_errstr, TSK_ERRSTR_L, "iso9660_make_data_run: fs_file or meta is NULL"); return 1; } fs = a_fs_file->fs_info; iso = (ISO_INFO *) fs; // see if we have already loaded the runs if ((a_fs_file->meta->attr != NULL) && (a_fs_file->meta->attr_state == TSK_FS_META_ATTR_STUDIED)) { return 0; } else if (a_fs_file->meta->attr_state == TSK_FS_META_ATTR_ERROR) { return 1; } // not sure why this would ever happen, but... else if (a_fs_file->meta->attr != NULL) { tsk_fs_attrlist_markunused(a_fs_file->meta->attr); } else if (a_fs_file->meta->attr == NULL) { a_fs_file->meta->attr = tsk_fs_attrlist_alloc(); } // copy the raw data if (iso9660_dinode_load(iso, a_fs_file->meta->addr)) { snprintf(tsk_errstr2, TSK_ERRSTR_L, "iso9660_make_data_run"); a_fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; return 1; } memcpy(&dd, &iso->dinode->dr, sizeof(iso9660_dentry)); if (dd.gap_sz) { a_fs_file->meta->attr_state = TSK_FS_META_ATTR_ERROR; tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "file %" PRIuINUM " has an interleave gap -- not supported", a_fs_file->meta->addr); return 1; } if ((fs_attr = tsk_fs_attrlist_getnew(a_fs_file->meta->attr, TSK_FS_ATTR_NONRES)) == NULL) { return 1; } // make a non-resident run data_run = tsk_fs_attr_run_alloc(); if (data_run == NULL) return -1; data_run->addr = ((TSK_DADDR_T *) a_fs_file->meta->content_ptr)[0]; data_run->len = (a_fs_file->meta->size + fs->block_size - 1) / fs->block_size; data_run->offset = 0; // initialize the data run if (tsk_fs_attr_set_run(a_fs_file, fs_attr, data_run, NULL, TSK_FS_ATTR_TYPE_DEFAULT, TSK_FS_ATTR_ID_DEFAULT, a_fs_file->meta->size, roundup(a_fs_file->meta->size + dd.ext_len, fs->block_size) - dd.ext_len, 0, 0)) { return 1; } // the first bytes in the run could be allocated for the extended attribute. fs_attr->nrd.skiplen = dd.ext_len; a_fs_file->meta->attr_state = TSK_FS_META_ATTR_STUDIED; return 0;}static uint8_tiso9660_fscheck(TSK_FS_INFO * fs, FILE * hFile){ tsk_error_reset(); tsk_errno = TSK_ERR_FS_UNSUPFUNC; snprintf(tsk_errstr, TSK_ERRSTR_L, "fscheck not implemented for iso9660 yet"); return 1;}/** * Print details about the file system to a file handle. * * @param fs File system to print details on * @param hFile File handle to print text to * * @returns 1 on error and 0 on success */static uint8_tiso9660_fsstat(TSK_FS_INFO * fs, FILE * hFile){ char str[129]; /* store name of publisher/preparer/etc */ ISO_INFO *iso = (ISO_INFO *) fs; char *cp; int i; iso9660_pvd_node *p = iso->pvd; iso9660_svd_node *s; // clean up any error messages that are lying around tsk_error_reset(); if (tsk_verbose) tsk_fprintf(stderr, "iso9660_fsstat: fs: %lu \ hFile: %lu\n", (uintptr_t) fs, (uintptr_t) hFile); i = 0; for (p = iso->pvd; p != NULL; p = p->next) { i++; tsk_fprintf(hFile, "\nPRIMARY VOLUME DESCRIPTOR %d\n", i); tsk_fprintf(hFile, "\nFILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Read from Primary Volume Descriptor\n"); tsk_fprintf(hFile, "File System Type: ISO9660\n"); tsk_fprintf(hFile, "Volume Name: %s\n", p->pvd.vol_id); tsk_fprintf(hFile, "Volume Set Size: %d\n", tsk_getu16(fs->endian, p->pvd.vol_set_m)); tsk_fprintf(hFile, "Volume Set Sequence: %d\n", tsk_getu16(fs->endian, p->pvd.vol_seq_m)); /* print publisher */ if (p->pvd.pub_id[0] == 0x5f) /* publisher is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", p->pvd.pub_id); cp = &str[127]; /* find last printable non space character */ while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Publisher: %s\n", str); memset(str, ' ', 128); /* print data preparer */ if (p->pvd.prep_id[0] == 0x5f) /* preparer is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", p->pvd.prep_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Data Preparer: %s\n", str); memset(str, ' ', 128); /* print recording application */ if (p->pvd.app_id[0] == 0x5f) /* application is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", p->pvd.app_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Recording Application: %s\n", str); memset(str, ' ', 128); /* print copyright */ if (p->pvd.copy_id[0] == 0x5f) /* copyright is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 37, "%s", p->pvd.copy_id); cp = &str[36]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Copyright: %s\n", str); memset(str, ' ', 37); tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Path Table Location: %" PRIu32 "-%" PRIu32 "\n", tsk_getu32(fs->endian, p->pvd.pt_loc_m), tsk_getu32(fs->endian, p->pvd.pt_loc_m) + tsk_getu32(fs->endian, p->pvd.pt_size_m) / fs->block_size); tsk_fprintf(hFile, "Inode Range: %" PRIuINUM " - %" PRIuINUM "\n", fs->first_inum, fs->last_inum); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Sector Size: %d\n", ISO9660_SSIZE_B); tsk_fprintf(hFile, "Block Size: %d\n", tsk_getu16(fs->endian, p->pvd.blk_sz_m)); tsk_fprintf(hFile, "Total Sector Range: 0 - %d\n", (int) ((fs->block_size / ISO9660_SSIZE_B) * (fs->block_count - 1))); /* get image slack, ignore how big the image claims itself to be */ tsk_fprintf(hFile, "Total Block Range: 0 - %d\n", (int) fs->block_count - 1); } i = 0; for (s = iso->svd; s != NULL; s = s->next) { i++; tsk_fprintf(hFile, "\nSUPPLEMENTARY VOLUME DESCRIPTOR %d\n", i); tsk_fprintf(hFile, "\nFILE SYSTEM INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Read from Supplementary Volume Descriptor\n"); tsk_fprintf(hFile, "File System Type: ISO9660\n"); tsk_fprintf(hFile, "Volume Name: %s\n", s->svd.vol_id); tsk_fprintf(hFile, "Volume Set Size: %d\n", tsk_getu16(fs->endian, s->svd.vol_set_m)); tsk_fprintf(hFile, "Volume Set Sequence: %d\n", tsk_getu16(fs->endian, s->svd.vol_seq_m)); /* print publisher */ if (s->svd.pub_id[0] == 0x5f) /* publisher is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", s->svd.pub_id); cp = &str[127]; /* find last printable non space character */ while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Publisher: %s\n", str); memset(str, ' ', 128); /* print data preparer */ if (s->svd.prep_id[0] == 0x5f) /* preparer is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", s->svd.prep_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Data Preparer: %s\n", str); memset(str, ' ', 128); /* print recording application */ if (s->svd.app_id[0] == 0x5f) /* application is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 128, "%s", s->svd.app_id); cp = &str[127]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Recording Application: %s\n", str); memset(str, ' ', 128); /* print copyright */ if (s->svd.copy_id[0] == 0x5f) /* copyright is in a file. TODO: handle this properly */ snprintf(str, 8, "In file\n"); else snprintf(str, 37, "%s\n", s->svd.copy_id); cp = &str[36]; while ((!isprint(*cp) || isspace(*cp)) && (cp != str)) cp--; *++cp = '\0'; tsk_fprintf(hFile, "Copyright: %s\n", str); memset(str, ' ', 37); tsk_fprintf(hFile, "\nMETADATA INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Path Table Location: %" PRIu32 "-%" PRIu32 "\n", tsk_getu32(fs->endian, s->svd.pt_loc_m), tsk_getu32(fs->endian, s->svd.pt_loc_m) + tsk_getu32(fs->endian, s->svd.pt_size_m) / fs->block_size); /* learn joliet level (1-3) */ if (!strncmp((char *) s->svd.esc_seq, "%/E", 3)) tsk_fprintf(hFile, "Joliet Name Encoding: UCS-2 Level 3\n"); if (!strncmp((char *) s->svd.esc_seq, "%/C", 3)) tsk_fprintf(hFile, "Joliet Name Encoding: UCS-2 Level 2\n"); if (!strncmp((char *) s->svd.esc_seq, "%/@", 3)) tsk_fprintf(hFile, "Joliet Name Encoding: UCS-2 Level 1\n"); if (iso->rr_found) tsk_fprintf(hFile, "RockRidge Extensions present\n"); tsk_fprintf(hFile, "\nCONTENT INFORMATION\n"); tsk_fprintf(hFile, "--------------------------------------------\n"); tsk_fprintf(hFile, "Sector Size: %d\n", ISO9660_SSIZE_B); tsk_fprintf(hFile, "Block Size: %d\n", fs->block_size); tsk_fprintf(hFile, "Total Sector Range: 0 - %d\n", (int) ((fs->block_size / ISO9660_SSIZE_B) * (fs->block_count - 1))); /* get image slack, ignore how big the image claims itself to be */ tsk_fprintf(hFile, "Total Block Range: 0 - %d\n", (int) fs->block_count - 1); } return 0;}/** * Make a unix-style permissions string based the flags in dentry * and the cached inode in fs */char *make_unix_perm(TSK_FS_INFO * fs, iso9660_dentry * dd){ // @@@ we should change this design static char perm[11]; ISO_INFO *iso = (ISO_INFO *) fs; if (tsk_verbose) tsk_fprintf(stderr, "make_unix_perm: fs: %lu" " dd: %lu\n", (uintptr_t) fs, (uintptr_t) dd); perm[10] = '\0'; memset(perm, '-', 11); if (dd->flags & ISO9660_FLAG_DIR) perm[0] = 'd'; if (iso->dinode->ea) { if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_UR) perm[1] = 'r'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_UX) perm[3] = 'x'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_GR) perm[4] = 'r'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_GX) perm[6] = 'x'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_AR) perm[7] = 'r'; if (tsk_getu16(fs->endian, iso->dinode->ea->mode) & ISO9660_BIT_AX) perm[9] = 'x'; } else { strcpy(&perm[1], "r-xr-xr-x"); } return perm;}# if 0static voidiso9660_print_rockridge(FILE * hFile, rockridge_ext * rr){ char mode_buf[11]; tsk_fprintf(hFile, "\nROCKRIDGE EXTENSIONS\n"); tsk_fprintf(hFile, "Owner-ID: "); tsk_fprintf(hFile, "%d\t", (int) rr->uid); tsk_fprintf(hFile, "Group-ID: "); tsk_fprintf(hFile, "%d\n", (int) rr->gid);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -