Lines Matching refs:ctx

450  * @ctx:   A search context, created using ntfs_get_attr_search_ctx
461 ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
463 if (!ctx) {
468 if (ntfs_attr_lookup(type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) {
474 return ctx->attr;
493 ntfs_attr_search_ctx *ctx;
501 ctx = ntfs_attr_get_search_ctx(NULL, mft);
502 if (!ctx) {
507 rec = find_attribute(type, ctx);
508 ntfs_attr_put_search_ctx(ctx);
534 ntfs_attr_search_ctx *ctx;
554 ctx = ntfs_attr_get_search_ctx(inode, NULL);
555 if (!ctx) {
563 while ((rec = find_attribute(AT_FILE_NAME, ctx))) {
595 ntfs_attr_put_search_ctx(ctx);
978 struct mft_search_ctx *ctx;
985 ctx = (struct mft_search_ctx*)calloc(1, sizeof *ctx);
987 ctx->mft_num = -1;
988 ctx->vol = vol;
990 return ctx;
996 void mft_put_search_ctx(struct mft_search_ctx *ctx)
998 if (!ctx)
1000 if (ctx->inode)
1001 ntfs_inode_close(ctx->inode);
1002 free(ctx);
1008 int mft_next_record(struct mft_search_ctx *ctx)
1016 if (!ctx) {
1021 if (ctx->inode) {
1022 ntfs_inode_close(ctx->inode);
1023 ctx->inode = NULL;
1026 nr_mft_records = ctx->vol->mft_na->initialized_size >>
1027 ctx->vol->mft_record_size_bits;
1029 for (ctx->mft_num++; (s64)ctx->mft_num < nr_mft_records; ctx->mft_num++) {
1032 ctx->flags_match = 0;
1033 in_use = utils_mftrec_in_use(ctx->vol, (MFT_REF) ctx->mft_num);
1036 (unsigned long long)ctx->mft_num);
1041 ctx->flags_match |= FEMR_IN_USE;
1043 ctx->inode = ntfs_inode_open(ctx->vol, (MFT_REF) ctx->mft_num);
1044 if (ctx->inode == NULL) {
1050 r = ntfs_file_record_read(ctx->vol,
1051 (MFT_REF) ctx->mft_num, &mrec, NULL);
1055 (long long)ctx->mft_num);
1061 (long long)ctx->mft_num,
1068 attr10 = find_first_attribute(AT_STANDARD_INFORMATION, ctx->inode->mrec);
1069 attr20 = find_first_attribute(AT_ATTRIBUTE_LIST, ctx->inode->mrec);
1070 attr80 = find_first_attribute(AT_DATA, ctx->inode->mrec);
1073 ctx->flags_match |= FEMR_BASE_RECORD;
1075 ctx->flags_match |= FEMR_NOT_BASE_RECORD;
1078 ctx->flags_match |= FEMR_BASE_RECORD;
1081 ctx->flags_match |= FEMR_FILE;
1083 if (ctx->flags_search & FEMR_DIR) {
1084 attr_ctx = ntfs_attr_get_search_ctx(ctx->inode, NULL);
1087 ctx->flags_match |= FEMR_DIR;
1096 switch (utils_is_metadata(ctx->inode)) {
1097 case 1: ctx->flags_match |= FEMR_METADATA; break;
1098 case 0: ctx->flags_match |= FEMR_NOT_METADATA; break;
1100 ctx->flags_match |= FEMR_NOT_METADATA; break;
1101 //ntfs_log_error("Error reading inode %lld.\n", ctx->mft_num);
1108 ctx->flags_match |= FEMR_NOT_IN_USE;
1110 ctx->inode = (ntfs_inode*)calloc(1, sizeof(*ctx->inode));
1111 if (!ctx->inode) {
1116 ctx->inode->mft_no = ctx->mft_num;
1117 ctx->inode->vol = ctx->vol;
1118 ctx->inode->mrec = ntfs_malloc(ctx->vol->mft_record_size);
1119 if (!ctx->inode->mrec) {
1120 free(ctx->inode); // == ntfs_inode_close
1124 mft = ntfs_attr_open(ctx->vol->mft_ni, AT_DATA,
1132 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) {
1134 (unsigned long long) ctx->mft_num);
1143 if (ctx->flags_match & ctx->flags_search) {
1147 if (ntfs_inode_close(ctx->inode)) {
1149 (unsigned long long)ctx->mft_num);
1153 ctx->inode = NULL;
1156 return (ctx->inode == NULL);