⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fs_name.c

📁 linux下开发的针对所有磁盘的数据恢复的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
            tzname[(tmTime->tm_isdst == 0) ? 0 : 1]);    }}/** * The only difference with this one is that the time is always * 00:00:00, which is applicable for the A-Time in FAT, which does * not have a time and if we do it normally it gets messed up because * of the timezone conversion */static voidtsk_fs_print_day(FILE * hFile, time_t time){    if (time <= 0) {        tsk_fprintf(hFile, "0000-00-00 00:00:00 (UTC)");    }    else {        struct tm *tmTime = localtime(&time);        tsk_fprintf(hFile, "%.4d-%.2d-%.2d 00:00:00 (%s)",            (int) tmTime->tm_year + 1900,            (int) tmTime->tm_mon + 1, (int) tmTime->tm_mday,            tzname[(tmTime->tm_isdst == 0) ? 0 : 1]);    }}/*** \internal * Simple print of dentry type / inode type, deleted, inode, and * name * * fs_attr is used for alternate data streams in NTFS, set to NULL * for all other file systems * * A newline is not printed at the end * * If path is NULL, then skip else use. it has the full directory name *  It needs to end with "/" */voidtsk_fs_name_print(FILE * hFile, const TSK_FS_FILE * fs_file,    const char *a_path, TSK_FS_INFO * fs, const TSK_FS_ATTR * fs_attr,    uint8_t print_path){    /* type of file - based on dentry type */    if (fs_file->name->type < TSK_FS_NAME_TYPE_STR_MAX)        tsk_fprintf(hFile, "%s/",            tsk_fs_name_type_str[fs_file->name->type]);    else        tsk_fprintf(hFile, "-/");    /* type of file - based on inode type: we want letters though for     * regular files so we use the dent_str though */    if (fs_file->meta) {        /*          * An NTFS directory can have a Data stream, in which         * case it would be printed with modes of a         * directory, although it is really a file         * So, to avoid confusion we will set the modes         * to a file so it is printed that way.  The         * entry for the directory itself will still be         * printed as a directory         */        if ((fs_attr) && (fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_DATA) &&            (fs_file->meta->type == TSK_FS_META_TYPE_DIR)) {            tsk_fprintf(hFile, "r ");        }        else {            if (fs_file->meta->type < TSK_FS_META_TYPE_STR_MAX)                tsk_fprintf(hFile, "%s ",                    tsk_fs_meta_type_str[fs_file->meta->type]);            else                tsk_fprintf(hFile, "- ");        }    }    else {        tsk_fprintf(hFile, "- ");    }    /* print a * if it is deleted */    if (fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC)        tsk_fprintf(hFile, "* ");    tsk_fprintf(hFile, "%" PRIuINUM "", fs_file->name->meta_addr);    /* print the id and type if we have fs_attr (NTFS) */    if (fs_attr)        tsk_fprintf(hFile, "-%" PRIu32 "-%" PRIu16 "", fs_attr->type,            fs_attr->id);    tsk_fprintf(hFile, "%s:\t",        ((fs_file->meta) && (fs_file->meta->flags & TSK_FS_META_FLAG_ALLOC)            && (fs_file->name->                flags & TSK_FS_NAME_FLAG_UNALLOC)) ? "(realloc)" : "");    if ((print_path) && (a_path != NULL))        tsk_fprintf(hFile, "%s", a_path);    tsk_fprintf(hFile, "%s", fs_file->name->name);/*  This will add the short name in parentheses    if (fs_file->name->shrt_name != NULL && fs_file->name->shrt_name[0] != '\0')	tsk_fprintf(hFile, " (%s)", fs_file->name->shrt_name);*/    /* print the data stream name if we the non-data NTFS stream */    if (fs_attr) {        if (((fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_DATA) &&                (strcmp(fs_attr->name, "$Data") != 0)) ||            ((fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_IDXROOT) &&                (strcmp(fs_attr->name, "$I30") != 0)))            tsk_fprintf(hFile, ":%s", fs_attr->name);    }    return;}/** * \internal * Print contents of  fs_name entry format like ls -l**** All elements are tab delimited **** If path is NULL, then skip else use. it has the full directory name**  It needs to end with "/"*/voidtsk_fs_name_print_long(FILE * hFile, const TSK_FS_FILE * fs_file,    const char *a_path, TSK_FS_INFO * fs, const TSK_FS_ATTR * fs_attr,    uint8_t print_path){    tsk_fs_name_print(hFile, fs_file, a_path, fs, fs_attr, print_path);    if ((fs == NULL) || (fs_file->meta == NULL)) {        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, 0);    // mtime        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, 0);    // atime        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, 0);    // ctime        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, 0);    // crtime        // size, uid, gid        tsk_fprintf(hFile, "\t0\t0\t0\n");    }    else {        /* MAC times */        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, fs_file->meta->mtime);        tsk_fprintf(hFile, "\t");        /* FAT only gives the day of last access */        if (TSK_FS_TYPE_ISFAT(fs->ftype))            tsk_fs_print_day(hFile, fs_file->meta->atime);        else            tsk_fs_print_time(hFile, fs_file->meta->atime);        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, fs_file->meta->ctime);        tsk_fprintf(hFile, "\t");        tsk_fs_print_time(hFile, fs_file->meta->crtime);        /* use the stream size if one was given */        if (fs_attr)            tsk_fprintf(hFile, "\t%" PRIuOFF, fs_attr->size);        else            tsk_fprintf(hFile, "\t%" PRIuOFF, fs_file->meta->size);        tsk_fprintf(hFile, "\t%" PRIuGID "\t%" PRIuUID "\n",            fs_file->meta->gid, fs_file->meta->uid);    }    return;}/** * \internal *** Print output in the format that mactime reads.** This allows the deleted files to be inserted to get a better** picture of what happened**** Prepend a_path when printing full file name**  dir needs to end with "/" **** prepend *prefix to path as the mounting point that the original** grave-robber was run on**** If the flags in the fs_file->meta structure are set to FS_FLAG_ALLOC** then it is assumed that the inode has been reallocated and the** contents are not displayed**** fs is not required (only used for block size).  */voidtsk_fs_name_print_mac(FILE * hFile, const TSK_FS_FILE * fs_file,    const char *a_path, TSK_FS_INFO * fs, const TSK_FS_ATTR * fs_attr,    const char *prefix){    char ls[12];    if ((!hFile) || (!fs_file))        return;    /* md5 */    tsk_fprintf(hFile, "0|");    /* file name */    tsk_fprintf(hFile, "%s%s%s", prefix, a_path, fs_file->name->name);    /* print the data stream name if it exists and is not the default NTFS */    if ((fs_attr) && (((fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_DATA) &&                (strcmp(fs_attr->name, "$Data") != 0)) ||            ((fs_attr->type == TSK_FS_ATTR_TYPE_NTFS_IDXROOT) &&                (strcmp(fs_attr->name, "$I30") != 0))))        tsk_fprintf(hFile, ":%s", fs_attr->name);    if ((fs_file->meta)        && (fs_file->meta->type == TSK_FS_META_TYPE_LNK)        && (fs_file->meta->link)) {        tsk_fprintf(hFile, " -> %s", fs_file->meta->link);    }    /* if filename is deleted add a comment and if the inode is now     * allocated, then add realloc comment */    if (fs_file->name->flags & TSK_FS_NAME_FLAG_UNALLOC)        tsk_fprintf(hFile, " (deleted%s)", ((fs_file->meta)                && (fs_file->meta->                    flags & TSK_FS_META_FLAG_ALLOC)) ? "-realloc" : "");    /* inode */    tsk_fprintf(hFile, "|%" PRIuINUM, fs_file->name->meta_addr);    if (fs_attr)        tsk_fprintf(hFile, "-%" PRIu32 "-%" PRIu16 "", fs_attr->type,            fs_attr->id);    tsk_fprintf(hFile, "|");    /* TYPE as specified in the directory entry      */    if (fs_file->name->type < TSK_FS_NAME_TYPE_STR_MAX)        tsk_fprintf(hFile, "%s/",            tsk_fs_name_type_str[fs_file->name->type]);    else        tsk_fprintf(hFile, "-/");    if (!fs_file->meta) {        tsk_fprintf(hFile, "----------|0|0|0|0|0|0\n");    }    else {        /* mode as string */        tsk_fs_make_ls(fs_file->meta, ls);        tsk_fprintf(hFile, "%s|", ls);        /* uid, gid */        tsk_fprintf(hFile, "%" PRIuUID "|%" PRIuGID "|",            fs_file->meta->uid, fs_file->meta->gid);        /* size - use data stream if we have it */        if (fs_attr)            tsk_fprintf(hFile, "%" PRIuOFF "|", fs_attr->size);        else            tsk_fprintf(hFile, "%" PRIuOFF "|", fs_file->meta->size);        /* atime, mtime, ctime, crtime */        tsk_fprintf(hFile,            "%" PRIu32 "|%" PRIu32 "|%" PRIu32 "|%" PRIu32 "\n",            (uint32_t) fs_file->meta->atime,            (uint32_t) fs_file->meta->mtime,            (uint32_t) fs_file->meta->ctime,            (uint32_t) fs_file->meta->crtime);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -