Lines Matching refs:attr

202 int ntfs_make_attr_resident(ntfs_inode *ino, ntfs_attribute *attr)  in ntfs_make_attr_resident()  argument
204 __s64 size = attr->size; in ntfs_make_attr_resident()
209 attr->resident = 1; in ntfs_make_attr_resident()
214 int ntfs_insert_run(ntfs_attribute *attr, int cnum, ntfs_cluster_t cluster, in ntfs_insert_run() argument
218 if ((attr->d.r.len * sizeof(ntfs_runlist)) % PAGE_SIZE == 0) { in ntfs_insert_run()
224 attr->d.r.len); in ntfs_insert_run()
225 new_size = attr->d.r.len * sizeof(ntfs_runlist) + PAGE_SIZE; in ntfs_insert_run()
239 if (attr->d.r.runlist) { in ntfs_insert_run()
240 ntfs_memcpy(new, attr->d.r.runlist, attr->d.r.len in ntfs_insert_run()
242 ntfs_vfree(attr->d.r.runlist); in ntfs_insert_run()
244 attr->d.r.runlist = new; in ntfs_insert_run()
246 if (attr->d.r.len > cnum) in ntfs_insert_run()
247 ntfs_memmove(attr->d.r.runlist + cnum + 1, in ntfs_insert_run()
248 attr->d.r.runlist + cnum, in ntfs_insert_run()
249 (attr->d.r.len - cnum) * sizeof(ntfs_runlist)); in ntfs_insert_run()
250 attr->d.r.runlist[cnum].lcn = cluster; in ntfs_insert_run()
251 attr->d.r.runlist[cnum].len = len; in ntfs_insert_run()
252 attr->d.r.len++; in ntfs_insert_run()
269 int ntfs_extend_attr(ntfs_inode *ino, ntfs_attribute *attr, const __s64 len) in ntfs_extend_attr() argument
275 if ((attr->flags & (ATTR_IS_COMPRESSED | ATTR_IS_ENCRYPTED)) || in ntfs_extend_attr()
282 if (attr->resident) { in ntfs_extend_attr()
283 err = ntfs_make_attr_nonresident(ino, attr); in ntfs_extend_attr()
287 if (len <= attr->allocated) in ntfs_extend_attr()
289 rl = attr->d.r.runlist; in ntfs_extend_attr()
290 rlen = attr->d.r.len; in ntfs_extend_attr()
300 clen = (len - attr->allocated + ino->vol->cluster_size - 1) >> in ntfs_extend_attr()
308 attr->allocated += (__s64)clen << ino->vol->cluster_size_bits; in ntfs_extend_attr()
320 attr->d.r.runlist = rl; in ntfs_extend_attr()
321 attr->d.r.len = rlen; in ntfs_extend_attr()
325 int ntfs_make_attr_nonresident(ntfs_inode *ino, ntfs_attribute *attr) in ntfs_make_attr_nonresident() argument
329 void *data = attr->d.data; in ntfs_make_attr_nonresident()
330 __s64 len = attr->size; in ntfs_make_attr_nonresident()
332 attr->d.r.len = 0; in ntfs_make_attr_nonresident()
333 attr->d.r.runlist = NULL; in ntfs_make_attr_nonresident()
334 attr->resident = 0; in ntfs_make_attr_nonresident()
339 attr->allocated = attr->initialized = 0; in ntfs_make_attr_nonresident()
340 error = ntfs_extend_attr(ino, attr, len); in ntfs_make_attr_nonresident()
348 return ntfs_readwrite_attr(ino, attr, 0, &io); in ntfs_make_attr_nonresident()
371 int ntfs_resize_attr(ntfs_inode *ino, ntfs_attribute *attr, __s64 newsize) in ntfs_resize_attr() argument
374 __s64 oldsize = attr->size; in ntfs_resize_attr()
381 if (attr->flags & (ATTR_IS_COMPRESSED | ATTR_IS_ENCRYPTED)) in ntfs_resize_attr()
383 if (attr->resident) { in ntfs_resize_attr()
386 error = ntfs_make_attr_nonresident(ino, attr); in ntfs_resize_attr()
389 return ntfs_resize_attr(ino, attr, newsize); in ntfs_resize_attr()
391 v = attr->d.data; in ntfs_resize_attr()
394 attr->d.data = ntfs_malloc(newsize); in ntfs_resize_attr()
395 if (!attr->d.data) { in ntfs_resize_attr()
401 ntfs_bzero((char*)attr->d.data + oldsize, in ntfs_resize_attr()
404 ntfs_memcpy((char*)attr->d.data, v, minsize); in ntfs_resize_attr()
406 attr->d.data = 0; in ntfs_resize_attr()
408 attr->size = newsize; in ntfs_resize_attr()
412 rl = attr->d.r.runlist; in ntfs_resize_attr()
421 for (i = 0, count = 0; i < attr->d.r.len; i++) { in ntfs_resize_attr()
447 attr->d.r.len - i); in ntfs_resize_attr()
456 if (rl_size < ((attr->d.r.len * sizeof(ntfs_runlist) + in ntfs_resize_attr()
462 attr->d.r.runlist = rl = rlt; in ntfs_resize_attr()
467 attr->d.r.len = i; in ntfs_resize_attr()
469 error = ntfs_extend_attr(ino, attr, newsize); in ntfs_resize_attr()
476 attr->allocated = (__s64)newcount << clustersizebits; in ntfs_resize_attr()
477 attr->size = newsize; in ntfs_resize_attr()
478 if (attr->initialized > newsize) in ntfs_resize_attr()
479 attr->initialized = newsize; in ntfs_resize_attr()
481 error = ntfs_make_attr_resident(ino, attr); in ntfs_resize_attr()
492 ntfs_attribute *attr; in ntfs_create_attr() local
513 *rattr = attr = ino->attrs + i; in ntfs_create_attr()
520 attr->attrno = i; in ntfs_create_attr()
521 if (attr->attrno + 1 != NTFS_GETU16(ino->attr + 0x28)) in ntfs_create_attr()
523 "+ 0x28) (%i)\n", attr->attrno, in ntfs_create_attr()
524 NTFS_GETU16(ino->attr + 0x28)); in ntfs_create_attr()
525 attr->resident = 1; in ntfs_create_attr()
526 attr->flags = 0; in ntfs_create_attr()
527 attr->cengine = 0; in ntfs_create_attr()
528 attr->size = attr->allocated = attr->initialized = dsize; in ntfs_create_attr()
534 attr->indexed = 1; in ntfs_create_attr()
536 attr->indexed = 0; in ntfs_create_attr()
537 attr->d.data = ntfs_malloc(dsize); in ntfs_create_attr()
538 if (!attr->d.data) in ntfs_create_attr()
540 ntfs_memcpy(attr->d.data, data, dsize); in ntfs_create_attr()
550 static int ntfs_process_runs(ntfs_inode *ino, ntfs_attribute* attr, in ntfs_process_runs() argument
570 for (cnum = 0, vcn = 0; cnum < attr->d.r.len; cnum++) in ntfs_process_runs()
571 vcn += attr->d.r.runlist[cnum].len; in ntfs_process_runs()
575 "vcn = 0x%x, cnum = 0x%x\n", ino->i_number, attr->type, in ntfs_process_runs()
599 cnum = attr->d.r.len; in ntfs_process_runs()
609 er = ntfs_insert_run(attr, cnum, -1, len); in ntfs_process_runs()
611 er = ntfs_insert_run(attr, cnum, cluster, len); in ntfs_process_runs()
632 ntfs_attribute *attr; in ntfs_insert_attribute() local
675 attr = ino->attrs + i; in ntfs_insert_attribute()
676 attr->resident = NTFS_GETU8(attrdata + 8) == 0; in ntfs_insert_attribute()
677 attr->flags = *(__u16*)(attrdata + 0xC); in ntfs_insert_attribute()
678 attr->attrno = NTFS_GETU16(attrdata + 0xE); in ntfs_insert_attribute()
680 if (attr->resident) { in ntfs_insert_attribute()
681 attr->size = NTFS_GETU16(attrdata + 0x10); in ntfs_insert_attribute()
683 attr->d.data = (void*)ntfs_malloc(attr->size); in ntfs_insert_attribute()
684 if (!attr->d.data) in ntfs_insert_attribute()
686 ntfs_memcpy(attr->d.data, data, attr->size); in ntfs_insert_attribute()
687 attr->indexed = NTFS_GETU8(attrdata + 0x16); in ntfs_insert_attribute()
689 attr->allocated = NTFS_GETS64(attrdata + 0x28); in ntfs_insert_attribute()
690 attr->size = NTFS_GETS64(attrdata + 0x30); in ntfs_insert_attribute()
691 attr->initialized = NTFS_GETS64(attrdata + 0x38); in ntfs_insert_attribute()
692 attr->cengine = NTFS_GETU16(attrdata + 0x22); in ntfs_insert_attribute()
693 if (attr->flags & ATTR_IS_COMPRESSED) in ntfs_insert_attribute()
694 attr->compsize = NTFS_GETS64(attrdata + 0x40); in ntfs_insert_attribute()
697 "attr->initialized = 0x%Lx\n", attr->allocated, in ntfs_insert_attribute()
698 attr->size, attr->initialized); in ntfs_insert_attribute()
704 ntfs_process_runs(ino, attr, attrdata); in ntfs_insert_attribute()
727 int ntfs_read_compressed(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, in ntfs_read_compressed() argument
750 rl = attr->d.r.runlist; in ntfs_read_compressed()
751 for (rnum = vcn = 0; rnum < attr->d.r.len && vcn + rl->len <= s_vcn; in ntfs_read_compressed()
754 if (rnum == attr->d.r.len) { in ntfs_read_compressed()
867 int ntfs_write_compressed(ntfs_inode *ino, ntfs_attribute *attr, __s64 offset, in ntfs_write_compressed() argument