Lines Matching refs:ino

66 ntfs_attribute *ntfs_find_attr(ntfs_inode *ino, int type, char *name)  in ntfs_find_attr()  argument
70 if (!ino) { in ntfs_find_attr()
74 for (i = 0; i < ino->attr_count; i++) { in ntfs_find_attr()
75 if (type < ino->attrs[i].type) in ntfs_find_attr()
77 if (type == ino->attrs[i].type) { in ntfs_find_attr()
79 if (!ino->attrs[i].name) in ntfs_find_attr()
80 return ino->attrs + i; in ntfs_find_attr()
81 } else if (ino->attrs[i].name && in ntfs_find_attr()
82 !ntfs_ua_strncmp(ino->attrs[i].name, name, in ntfs_find_attr()
84 return ino->attrs + i; in ntfs_find_attr()
98 static int ntfs_insert_mft_attributes(ntfs_inode* ino, char *mft, int mftno) in ntfs_insert_mft_attributes() argument
104 for(i = 0; i < ino->record_count; i++) in ntfs_insert_mft_attributes()
105 if (ino->records[i] == mftno) { in ntfs_insert_mft_attributes()
113 if (ino->record_count % 8 == 0) { in ntfs_insert_mft_attributes()
116 new = ntfs_malloc((ino->record_count + 8) * in ntfs_insert_mft_attributes()
120 if (ino->records) { in ntfs_insert_mft_attributes()
121 for (i = 0; i < ino->record_count; i++) in ntfs_insert_mft_attributes()
122 new[i] = ino->records[i]; in ntfs_insert_mft_attributes()
123 ntfs_free(ino->records); in ntfs_insert_mft_attributes()
125 ino->records = new; in ntfs_insert_mft_attributes()
127 ino->records[ino->record_count] = mftno; in ntfs_insert_mft_attributes()
128 ino->record_count++; in ntfs_insert_mft_attributes()
135 error = ntfs_insert_attribute(ino, it); in ntfs_insert_mft_attributes()
161 static int ntfs_insert_mft_attribute(ntfs_inode* ino, int mftno, in ntfs_insert_mft_attribute() argument
167 for(i = 0; i < ino->record_count; i++) in ntfs_insert_mft_attribute()
168 if (ino->records[i] == mftno) { in ntfs_insert_mft_attribute()
174 if (ino->record_count % 8 == 0) { in ntfs_insert_mft_attribute()
177 new = ntfs_malloc((ino->record_count + 8) * in ntfs_insert_mft_attribute()
181 if (ino->records) { in ntfs_insert_mft_attribute()
182 for (i = 0; i < ino->record_count; i++) in ntfs_insert_mft_attribute()
183 new[i] = ino->records[i]; in ntfs_insert_mft_attribute()
184 ntfs_free(ino->records); in ntfs_insert_mft_attribute()
186 ino->records = new; in ntfs_insert_mft_attribute()
188 ino->records[ino->record_count] = mftno; in ntfs_insert_mft_attribute()
189 ino->record_count++; in ntfs_insert_mft_attribute()
196 error = ntfs_insert_attribute(ino, attr); in ntfs_insert_mft_attribute()
204 static int parse_attributes(ntfs_inode *ino, ntfs_u8 *alist, int *plen) in parse_attributes() argument
212 if (!ino->attr) { in parse_attributes()
214 "loaded base mft record.\n", ino->i_number); in parse_attributes()
217 mft = ntfs_malloc(ino->vol->mft_record_size); in parse_attributes()
233 if (mftno != ino->i_number && mftno != last_mft) { in parse_attributes()
236 error = ntfs_read_mft_record(ino->vol, mftno, mft); in parse_attributes()
249 ino->vol, /* ntfs volume */ in parse_attributes()
250 mftno == ino->i_number ?/* mft record is: */ in parse_attributes()
251 ino->attr: /* base record */ in parse_attributes()
261 "0x%x corrupt!\n", ino->i_number, mftno); in parse_attributes()
265 error = ntfs_insert_mft_attribute(ino, mftno, attr); in parse_attributes()
303 mft2 = ntfs_malloc(ino->vol->mft_record_size); in parse_attributes()
308 ntfs_memcpy(mft2, mft, ino->vol->mft_record_size); in parse_attributes()
313 if (NTFS_GETU32(alist2 + 0x0) < ino->vol->at_data) { in parse_attributes()
318 if (NTFS_GETU32(alist2 + 0x0) > ino->vol->at_data) { in parse_attributes()
331 if (mftno2 != ino->i_number && mftno2 != last_mft2) { in parse_attributes()
333 error2 = ntfs_read_mft_record(ino->vol, mftno2, mft2); in parse_attributes()
343 ino->vol, /* ntfs volume */ in parse_attributes()
344 mftno2 == ino->i_number ?/* mft record is: */ in parse_attributes()
345 ino->attr: /* base record */ in parse_attributes()
355 "0x%x corrupt!\n", ino->i_number, in parse_attributes()
360 error2 = ntfs_insert_mft_attribute(ino, mftno2, attr2); in parse_attributes()
379 static void ntfs_load_attributes(ntfs_inode *ino) in ntfs_load_attributes() argument
385 ntfs_volume *vol = ino->vol; in ntfs_load_attributes()
387 ntfs_debug(DEBUG_FILE2, "load_attributes 0x%x 1\n", ino->i_number); in ntfs_load_attributes()
388 if (ntfs_insert_mft_attributes(ino, ino->attr, ino->i_number)) in ntfs_load_attributes()
390 ntfs_debug(DEBUG_FILE2, "load_attributes 0x%x 2\n", ino->i_number); in ntfs_load_attributes()
391 alist = ntfs_find_attr(ino, vol->at_attribute_list, 0); in ntfs_load_attributes()
392 ntfs_debug(DEBUG_FILE2, "load_attributes 0x%x 3\n", ino->i_number); in ntfs_load_attributes()
395 ntfs_debug(DEBUG_FILE2, "load_attributes 0x%x 4\n", ino->i_number); in ntfs_load_attributes()
398 ino->i_number, alist->size); in ntfs_load_attributes()
400 parse_attributes(ino, alist->d.data, &datasize); in ntfs_load_attributes()
403 ntfs_debug(DEBUG_FILE2, "load_attributes 0x%x 5\n", ino->i_number); in ntfs_load_attributes()
418 ino->i_number, len); in ntfs_load_attributes()
420 ino->i_number, delta); in ntfs_load_attributes()
422 if (ntfs_read_attr(ino, vol->at_attribute_list, 0, offset, in ntfs_load_attributes()
427 "delta = %i\n", ino->i_number, delta); in ntfs_load_attributes()
428 parse_attributes(ino, buf, &delta); in ntfs_load_attributes()
430 "parse_attr, delta = %i\n", ino->i_number, in ntfs_load_attributes()
436 ntfs_debug(DEBUG_FILE2, "load_attributes 0x%x 6\n", ino->i_number); in ntfs_load_attributes()
440 int ntfs_init_inode(ntfs_inode *ino, ntfs_volume *vol, int inum) in ntfs_init_inode() argument
446 ino->i_number = inum; in ntfs_init_inode()
447 ino->vol = vol; in ntfs_init_inode()
448 ino->attr = buf = ntfs_malloc(vol->mft_record_size); in ntfs_init_inode()
451 error = ntfs_read_mft_record(vol, inum, ino->attr); in ntfs_init_inode()
457 ino->sequence_number = NTFS_GETU16(buf + 0x10); in ntfs_init_inode()
458 ino->attr_count = 0; in ntfs_init_inode()
459 ino->record_count = 0; in ntfs_init_inode()
460 ino->records = 0; in ntfs_init_inode()
461 ino->attrs = 0; in ntfs_init_inode()
462 ntfs_load_attributes(ino); in ntfs_init_inode()
467 void ntfs_clear_inode(ntfs_inode *ino) in ntfs_clear_inode() argument
470 if (!ino->attr) { in ntfs_clear_inode()
474 ntfs_free(ino->attr); in ntfs_clear_inode()
475 ino->attr = 0; in ntfs_clear_inode()
476 ntfs_free(ino->records); in ntfs_clear_inode()
477 ino->records = 0; in ntfs_clear_inode()
478 for (i = 0; i < ino->attr_count; i++) { in ntfs_clear_inode()
479 if (ino->attrs[i].name) in ntfs_clear_inode()
480 ntfs_free(ino->attrs[i].name); in ntfs_clear_inode()
481 if (ino->attrs[i].resident) { in ntfs_clear_inode()
482 if (ino->attrs[i].d.data) in ntfs_clear_inode()
483 ntfs_free(ino->attrs[i].d.data); in ntfs_clear_inode()
485 if (ino->attrs[i].d.r.runlist) in ntfs_clear_inode()
486 ntfs_vfree(ino->attrs[i].d.r.runlist); in ntfs_clear_inode()
489 ntfs_free(ino->attrs); in ntfs_clear_inode()
490 ino->attrs = 0; in ntfs_clear_inode()
501 int ntfs_allocate_attr_number(ntfs_inode *ino, int *result) in ntfs_allocate_attr_number() argument
503 if (ino->record_count != 1) in ntfs_allocate_attr_number()
505 *result = NTFS_GETU16(ino->attr + 0x28); in ntfs_allocate_attr_number()
506 NTFS_PUTU16(ino->attr + 0x28, (*result) + 1); in ntfs_allocate_attr_number()
512 char *ntfs_get_attr(ntfs_inode *ino, int attr, char *name) in ntfs_get_attr() argument
515 char *it = ino->attr + NTFS_GETU16(ino->attr + 0x14); in ntfs_get_attr()
520 if (!IS_MFT_RECORD(ino->attr)) in ntfs_get_attr()
550 __s64 ntfs_get_attr_size(ntfs_inode *ino, int type, char *name) in ntfs_get_attr_size() argument
552 ntfs_attribute *attr = ntfs_find_attr(ino, type, name); in ntfs_get_attr_size()
559 int ntfs_attr_is_resident(ntfs_inode *ino, int type, char *name) in ntfs_attr_is_resident() argument
561 ntfs_attribute *attr = ntfs_find_attr(ino, type, name); in ntfs_attr_is_resident()
667 int ntfs_readwrite_attr(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, in ntfs_readwrite_attr() argument
677 dest->do_read ? "from" : "to", ino->i_number, in ntfs_readwrite_attr()
699 error = ntfs_resize_attr(ino, attr, offset + l); in ntfs_readwrite_attr()
730 error = ntfs_readwrite_attr(ino, attr, offset, dest); in ntfs_readwrite_attr()
737 return ntfs_read_compressed(ino, attr, offset, dest); in ntfs_readwrite_attr()
740 return ntfs_write_compressed(ino, attr, offset, dest); in ntfs_readwrite_attr()
743 clustersizebits = ino->vol->cluster_size_bits; in ntfs_readwrite_attr()
751 "s_vcn = 0x%x.\n", __FUNCTION__, ino->i_number, rnum, in ntfs_readwrite_attr()
767 error = ntfs_getput_clusters(ino->vol, s_cluster, offset - in ntfs_readwrite_attr()
788 int ntfs_read_attr(ntfs_inode *ino, int type, char *name, __s64 offset, in ntfs_read_attr() argument
794 attr = ntfs_find_attr(ino, type, name); in ntfs_read_attr()
797 "0x%x\n", __FUNCTION__, type, ino->i_number); in ntfs_read_attr()
800 return ntfs_readwrite_attr(ino, attr, offset, buf); in ntfs_read_attr()
803 int ntfs_write_attr(ntfs_inode *ino, int type, char *name, __s64 offset, in ntfs_write_attr() argument
809 attr = ntfs_find_attr(ino, type, name); in ntfs_write_attr()
812 "0x%x\n", __FUNCTION__, type, ino->i_number); in ntfs_write_attr()
815 return ntfs_readwrite_attr(ino, attr, offset, buf); in ntfs_write_attr()
819 int ntfs_vcn_to_lcn(ntfs_inode *ino, int vcn) in ntfs_vcn_to_lcn() argument
824 data = ntfs_find_attr(ino, ino->vol->at_data, 0); in ntfs_vcn_to_lcn()
828 if (data->size <= (__s64)vcn << ino->vol->cluster_size_bits) in ntfs_vcn_to_lcn()
830 if (data->initialized <= (__s64)vcn << ino->vol->cluster_size_bits) in ntfs_vcn_to_lcn()
1097 int layout_inode(ntfs_inode *ino, ntfs_disk_inode *store) in layout_inode() argument
1103 error = allocate_store(ino->vol, store, ino->record_count); in layout_inode()
1106 size = ino->vol->mft_record_size; in layout_inode()
1109 if (count < ino->record_count) { in layout_inode()
1110 recno = ino->records[count]; in layout_inode()
1112 error = allocate_store(ino->vol, store, count + 1); in layout_inode()
1126 offset = NTFS_GETU16(ino->attr + 0x14); /* attrs_offset */ in layout_inode()
1127 ntfs_memcpy(rec, ino->attr, offset); in layout_inode()
1129 while (i < ino->attr_count) { in layout_inode()
1130 attr = ino->attrs + i; in layout_inode()
1133 if (error == -E2BIG && offset != NTFS_GETU16(ino->attr in layout_inode()
1147 } while (i < ino->attr_count || count < ino->record_count); in layout_inode()
1148 return count - ino->record_count; in layout_inode()
1158 int ntfs_update_inode(ntfs_inode *ino) in ntfs_update_inode() argument
1165 error = layout_inode(ino, &store); in ntfs_update_inode()
1167 i = ntfs_split_indexroot(ino); in ntfs_update_inode()
1170 i = layout_inode(ino, &store); in ntfs_update_inode()
1175 error = ntfs_attr_allnonresident(ino); in ntfs_update_inode()
1177 error = layout_inode(ino, &store); in ntfs_update_inode()
1186 ino->i_number); in ntfs_update_inode()
1194 ino->vol->mft_record_size); in ntfs_update_inode()
1206 io.size = ino->vol->mft_record_size; in ntfs_update_inode()
1207 error = ntfs_write_attr(ino->vol->mft_ino, ino->vol->at_data, in ntfs_update_inode()
1209 ino->vol->mft_record_size_bits, &io); in ntfs_update_inode()
1210 if (error || io.size != ino->vol->mft_record_size) { in ntfs_update_inode()
1213 "0x%x\n", ino->i_number); in ntfs_update_inode()
2134 static int add_standard_information(ntfs_inode *ino) in add_standard_information() argument
2148 return ntfs_create_attr(ino, ino->vol->at_standard_information, 0, in add_standard_information()
2152 static int add_filename(ntfs_inode *ino, ntfs_inode *dir, in add_filename() argument
2195 error = ntfs_create_attr(ino, ino->vol->at_file_name, 0, data, size, in add_filename()
2198 error = ntfs_dir_add(dir, ino, fn); in add_filename()
2203 int add_security(ntfs_inode* ino, ntfs_inode* dir) in add_security() argument
2212 attr = ntfs_find_attr(dir, ino->vol->at_security_descriptor, 0); in add_security()
2225 error = ntfs_read_attr(dir, ino->vol->at_security_descriptor, 0, 0,&io); in add_security()
2233 error = ntfs_create_attr(ino, ino->vol->at_security_descriptor, in add_security()
2239 static int add_data(ntfs_inode* ino, unsigned char *data, int length) in add_data() argument
2243 return ntfs_create_attr(ino, ino->vol->at_data, 0, data, length, &da); in add_data()