Lines Matching refs:ctx

443  * @ctx:   A search context, created using ntfs_get_attr_search_ctx
454 ATTR_RECORD * find_attribute(const ATTR_TYPES type, ntfs_attr_search_ctx *ctx)
456 if (!ctx) {
461 if (ntfs_attr_lookup(type, NULL, 0, 0, 0, NULL, 0, ctx) != 0) {
467 return ctx->attr;
486 ntfs_attr_search_ctx *ctx;
494 ctx = ntfs_attr_get_search_ctx(NULL, mft);
495 if (!ctx) {
500 rec = find_attribute(type, ctx);
501 ntfs_attr_put_search_ctx(ctx);
527 ntfs_attr_search_ctx *ctx;
547 ctx = ntfs_attr_get_search_ctx(inode, NULL);
548 if (!ctx) {
556 while ((rec = find_attribute(AT_FILE_NAME, ctx))) {
588 ntfs_attr_put_search_ctx(ctx);
962 struct mft_search_ctx *ctx;
969 ctx = (struct mft_search_ctx*)calloc(1, sizeof *ctx);
971 ctx->mft_num = -1;
972 ctx->vol = vol;
974 return ctx;
980 void mft_put_search_ctx(struct mft_search_ctx *ctx)
982 if (!ctx)
984 if (ctx->inode)
985 ntfs_inode_close(ctx->inode);
986 free(ctx);
992 int mft_next_record(struct mft_search_ctx *ctx)
1000 if (!ctx) {
1005 if (ctx->inode) {
1006 ntfs_inode_close(ctx->inode);
1007 ctx->inode = NULL;
1010 nr_mft_records = ctx->vol->mft_na->initialized_size >>
1011 ctx->vol->mft_record_size_bits;
1013 for (ctx->mft_num++; (s64)ctx->mft_num < nr_mft_records; ctx->mft_num++) {
1016 ctx->flags_match = 0;
1017 in_use = utils_mftrec_in_use(ctx->vol, (MFT_REF) ctx->mft_num);
1020 (unsigned long long)ctx->mft_num);
1025 ctx->flags_match |= FEMR_IN_USE;
1027 ctx->inode = ntfs_inode_open(ctx->vol, (MFT_REF) ctx->mft_num);
1028 if (ctx->inode == NULL) {
1030 long long) ctx->mft_num);
1034 attr10 = find_first_attribute(AT_STANDARD_INFORMATION, ctx->inode->mrec);
1035 attr20 = find_first_attribute(AT_ATTRIBUTE_LIST, ctx->inode->mrec);
1036 attr80 = find_first_attribute(AT_DATA, ctx->inode->mrec);
1039 ctx->flags_match |= FEMR_BASE_RECORD;
1041 ctx->flags_match |= FEMR_NOT_BASE_RECORD;
1044 ctx->flags_match |= FEMR_BASE_RECORD;
1047 ctx->flags_match |= FEMR_FILE;
1049 if (ctx->flags_search & FEMR_DIR) {
1050 attr_ctx = ntfs_attr_get_search_ctx(ctx->inode, NULL);
1053 ctx->flags_match |= FEMR_DIR;
1062 switch (utils_is_metadata(ctx->inode)) {
1063 case 1: ctx->flags_match |= FEMR_METADATA; break;
1064 case 0: ctx->flags_match |= FEMR_NOT_METADATA; break;
1066 ctx->flags_match |= FEMR_NOT_METADATA; break;
1067 //ntfs_log_error("Error reading inode %lld.\n", ctx->mft_num);
1074 ctx->flags_match |= FEMR_NOT_IN_USE;
1076 ctx->inode = (ntfs_inode*)calloc(1, sizeof(*ctx->inode));
1077 if (!ctx->inode) {
1082 ctx->inode->mft_no = ctx->mft_num;
1083 ctx->inode->vol = ctx->vol;
1084 ctx->inode->mrec = ntfs_malloc(ctx->vol->mft_record_size);
1085 if (!ctx->inode->mrec) {
1086 free(ctx->inode); // == ntfs_inode_close
1090 mft = ntfs_attr_open(ctx->vol->mft_ni, AT_DATA,
1098 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) {
1100 (unsigned long long) ctx->mft_num);
1109 if (ctx->flags_match & ctx->flags_search) {
1113 if (ntfs_inode_close(ctx->inode)) {
1115 (unsigned long long)ctx->mft_num);
1119 ctx->inode = NULL;
1122 return (ctx->inode == NULL);
1146 ntfs_attr_search_ctx *ctx;
1157 ctx = ntfs_attr_get_search_ctx(ni, NULL);
1158 if (!ctx)
1160 if (ntfs_attr_lookup(AT_FILE_NAME, AT_UNNAMED, 0, 0, 0, NULL, 0, ctx)) {
1165 if (ctx->attr->non_resident) {
1170 fn = (FILE_NAME_ATTR*)((u8*)ctx->attr +
1171 le16_to_cpu(ctx->attr->value_offset));
1172 if ((u8*)fn + le32_to_cpu(ctx->attr->value_length) >
1173 (u8*)ctx->attr + le32_to_cpu(ctx->attr->length)) {
1179 ntfs_attr_put_search_ctx(ctx);
1185 ntfs_attr_put_search_ctx(ctx);