Lines Matching refs:ctx

448  * @ctx:   A search context, created using ntfs_get_attr_search_ctx
459 ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
461 if (!ctx) {
466 if (ntfs_attr_lookup(type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) {
472 return ctx->attr;
491 ntfs_attr_search_ctx *ctx;
499 ctx = ntfs_attr_get_search_ctx(NULL, mft);
500 if (!ctx) {
505 rec = find_attribute(type, ctx);
506 ntfs_attr_put_search_ctx(ctx);
532 ntfs_attr_search_ctx *ctx;
552 ctx = ntfs_attr_get_search_ctx(inode, NULL);
553 if (!ctx) {
561 while ((rec = find_attribute(AT_FILE_NAME, ctx))) {
593 ntfs_attr_put_search_ctx(ctx);
970 struct mft_search_ctx *ctx;
977 ctx = (struct mft_search_ctx*)calloc(1, sizeof *ctx);
979 ctx->mft_num = -1;
980 ctx->vol = vol;
982 return ctx;
988 void mft_put_search_ctx(struct mft_search_ctx *ctx)
990 if (!ctx)
992 if (ctx->inode)
993 ntfs_inode_close(ctx->inode);
994 free(ctx);
1000 int mft_next_record(struct mft_search_ctx *ctx)
1008 if (!ctx) {
1013 if (ctx->inode) {
1014 ntfs_inode_close(ctx->inode);
1015 ctx->inode = NULL;
1018 nr_mft_records = ctx->vol->mft_na->initialized_size >>
1019 ctx->vol->mft_record_size_bits;
1021 for (ctx->mft_num++; (s64)ctx->mft_num < nr_mft_records; ctx->mft_num++) {
1024 ctx->flags_match = 0;
1025 in_use = utils_mftrec_in_use(ctx->vol, (MFT_REF) ctx->mft_num);
1028 (unsigned long long)ctx->mft_num);
1033 ctx->flags_match |= FEMR_IN_USE;
1035 ctx->inode = ntfs_inode_open(ctx->vol, (MFT_REF) ctx->mft_num);
1036 if (ctx->inode == NULL) {
1042 r = ntfs_file_record_read(ctx->vol,
1043 (MFT_REF) ctx->mft_num, &mrec, NULL);
1047 (long long)ctx->mft_num);
1053 (long long)ctx->mft_num,
1060 attr10 = find_first_attribute(AT_STANDARD_INFORMATION, ctx->inode->mrec);
1061 attr20 = find_first_attribute(AT_ATTRIBUTE_LIST, ctx->inode->mrec);
1062 attr80 = find_first_attribute(AT_DATA, ctx->inode->mrec);
1065 ctx->flags_match |= FEMR_BASE_RECORD;
1067 ctx->flags_match |= FEMR_NOT_BASE_RECORD;
1070 ctx->flags_match |= FEMR_BASE_RECORD;
1073 ctx->flags_match |= FEMR_FILE;
1075 if (ctx->flags_search & FEMR_DIR) {
1076 attr_ctx = ntfs_attr_get_search_ctx(ctx->inode, NULL);
1079 ctx->flags_match |= FEMR_DIR;
1088 switch (utils_is_metadata(ctx->inode)) {
1089 case 1: ctx->flags_match |= FEMR_METADATA; break;
1090 case 0: ctx->flags_match |= FEMR_NOT_METADATA; break;
1092 ctx->flags_match |= FEMR_NOT_METADATA; break;
1093 //ntfs_log_error("Error reading inode %lld.\n", ctx->mft_num);
1100 ctx->flags_match |= FEMR_NOT_IN_USE;
1102 ctx->inode = (ntfs_inode*)calloc(1, sizeof(*ctx->inode));
1103 if (!ctx->inode) {
1108 ctx->inode->mft_no = ctx->mft_num;
1109 ctx->inode->vol = ctx->vol;
1110 ctx->inode->mrec = ntfs_malloc(ctx->vol->mft_record_size);
1111 if (!ctx->inode->mrec) {
1112 free(ctx->inode); // == ntfs_inode_close
1116 mft = ntfs_attr_open(ctx->vol->mft_ni, AT_DATA,
1124 if (ntfs_attr_pread(mft, ctx->vol->mft_record_size * ctx->mft_num, ctx->vol->mft_record_size, ctx->inode->mrec) < ctx->vol->mft_record_size) {
1126 (unsigned long long) ctx->mft_num);
1135 if (ctx->flags_match & ctx->flags_search) {
1139 if (ntfs_inode_close(ctx->inode)) {
1141 (unsigned long long)ctx->mft_num);
1145 ctx->inode = NULL;
1148 return (ctx->inode == NULL);