Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv17660
Modified Files:
attrib.c
Log Message:
Current status of library. (Still not working.)
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** attrib.c 2001/03/07 01:17:33 1.6
--- attrib.c 2001/03/15 23:13:45 1.7
***************
*** 313,398 ****
* for userspace we just return a pointer into the mft record @m.
*/
! ATTR_RECORD *lookup_attr_in_mft_rec(const ntfs_volume *v,
! const MFT_RECORD *m,
! const ATTR_TYPES t,
! const wchar_t *n,
! FIND_ATTR_CTX_FLAGS *ctx)
{
! ATTR_RECORD *a, *al = NULL;
int got_there = 0;
- /* Sanity/size/alignment checks. */
- if (!b || !ctx || !is_mft_recordp(b) ||
- !(b->flags & MFT_RECORD_IN_USE) ||
- b->base_mft_record ||
- p2n((char*)b + b->attributes_offset) & 7 ||
- p2n((char*)b + b->bytes_in_use) & 7 ||
- le16_to_cpu(b->attributes_offset) >= le32_to_cpu(b->bytes_in_use)) {
#ifdef DEBUG
puts("Sanity/size/allignment checks failed in " \
! "find_attribute()!");
! #endif
return NULL;
}
- /* Position of the first attribute. */
- a = (ATTR_RECORD*)(le16_to_cpu(b->attributes_offset) +
- (char*)b);
- if (p2n(a) & 7) {
- #ifdef DEBUG
- puts("Alignment check (2) failed in find_attribute()!");
#endif
! return NULL;
! }
! /* Look for an attribute list and at the same time check for attributes
! * which collate before the attribute list (i.e. the standard
! * information attribute). */
! while (a->type != $END) {
! if (le32_to_cpu(a->length) + (char*)a >=
! le32_to_cpu(b->bytes_in_use) + (char*)b) {
#ifdef DEBUG
- puts("Attribute length out of bounds in " \
- "find_attribute()!");
- #endif
- return NULL;
- }
- if (le32_to_cpu(a->type) > le32_to_cpu($ATTRIBUTE_LIST))
- break;
- if (a->type == t)
- /* FIXME: This is wrong. */
- return a;
- /* If an attribute list is present, handle it first. */
- if (a->type == $ATTRIBUTE_LIST)
- goto attr_list_handling;
- do_next_attr:
- /* Get next attribute. */
- a = (ATTR_RECORD*)((char *)a +
- le32_to_cpu(a->length));
if (p2n(a) & 7) {
! #ifdef DEBUG
! puts("Allignment check (4) failed in " \
! "find_attribute()!");
! #endif
return NULL;
}
}
not_found:
/* The requested attribute is not present. */
! return NULL;
!
! attr_list_handling:
! /* Looking for zero means we return the first attribute.
! FIXME: The first attribute is in the attr list! (AIA)
! Don't return the attr list itself but the attribute instead. */
! if (t == 0)
goto found_it;
! /* We have not found the attribute in the mft record @b. If an
! attribute_list was found, and we are not looking for it, search it
! now, otherwise return NULL. Second check needed if someone decides
! to search for a second attribute list, which, while braindamaged,
! could screw us up badly. */
! //return find_next_attr_in_attr_list(v, b, al, t, n, ctx);
!
! /* The requested attribute is not present. */
! goto not_found;
}
--- 313,412 ----
* for userspace we just return a pointer into the mft record @m.
*/
! ATTR_RECORD *lookup_attr(const ntfs_volume *vol, const MFT_RECORD *m,
! const IS_FIRST_BOOL *first, const ATTR_RECORD **attr,
! const ATTR_TYPES type, const wchar_t *name,
! const __u32 name_len, const IGNORE_CASE_BOOL ic,
! const __u8 *val, const __u32 val_len)
{
! ATTR_RECORD *a, *alist = NULL;
int got_there = 0;
#ifdef DEBUG
+ /* Sanity/size/alignment checks. */
+ if (!vol || !m || !attr || !is_mft_recordp(m) ||
+ !(m->flags & MFT_RECORD_IN_USE) ||
+ m->base_mft_record ||
+ p2n((char*)m + m->attributes_offset) & 7 ||
+ p2n((char*)m + m->bytes_in_use) & 7 ||
+ le16_to_cpu(m->attributes_offset) >= le32_to_cpu(m->bytes_in_use)) {
puts("Sanity/size/allignment checks failed in " \
! "lookup_attr()!");
return NULL;
}
#endif
! if (!*attr) {
! /* Position of the first attribute. */
! a = (ATTR_RECORD*)(le16_to_cpu(m->attributes_offset) +
! (char*)m);
#ifdef DEBUG
if (p2n(a) & 7) {
! puts("Alignment check (2) failed in lookup_attr()!");
return NULL;
}
+ #endif
+ } else {
+ if (*first) {
+ /* Where to commence the search. */
+ a = *attr;
+ } else {
+ /* Where to continue the search. */
+ a = (ATTR_RECORD*)((char*)*attr +
+ le32_to_cpu(*attr->length));
+ }
+ if (a < m || a > (char*)m + vol->mft_record_size)
+ goto file_corrupt;
+ *first = 0;
+ if (a->type == $END)
+ goto not_found;
+ if (!a->length)
+ goto file_corrupt;
+ if (!type)
+ goto call_find_attr;
+ goto found_it;
}
+ /*
+ * Look for an attribute list and at the same time check for attributes
+ * which collate before the attribute list (i.e. $STANDARD_INFORMATION).
+ */
+ if (le32_to_cpu(a->type) > le32_to_cpu($ATTRIBUTE_LIST))
+ goto no_attr_list;
+ do_next:
+ if (!a->length)
+ goto file_corrupt;
+ if (a->type == $ATTRIBUTE_LIST)
+ goto attr_list_present;
+ a = (ATTR_RECORD*)((char*)a + le32_to_cpu(a->length));
+ if (a < m || a > (char*)m + vol->mft_record_size)
+ goto file_corrupt;
+ if (le32_to_cpu(a->type) <= le32_to_cpu($ATTRIBUTE_LIST))
+ goto do_next;
+ no_attr_list:
+ if (!type ||
+ type == $STANDARD_INFORMATION && a->type == $STANDARD_INFORMATION)
+ goto found_it;
+ call_find_attr:
+ *attr = find_next_attr(vol, &a, type, name, name_len, ic, val, val_len);
+ return_now:
+ return a;
+ found_it:
+ *attr = a;
+ goto return_now;
not_found:
/* The requested attribute is not present. */
! a = NULL;
! goto return_now;
! attr_list_present:
! /* Looking for zero means we return the first attribute, which will
! * be the first one listed in the attribute list. */
! if (type == 0)
! goto search_attr_list;
! if (type == $ATTRIBUTE_LIST)
goto found_it;
! search_attr_list:
! *attr = a;
! al = a;
! _NtfsMapAttributeValue(arg_0, arg_4,
! arg_output_buf[0x24]pattr_valueOUT, attr_val_lenOUT,
! arg_output_buf[0x1c]OUT, arg_output_bufIN/OUT);
}
|