filesystems/fsw_ntfs.c
static fsw_status_t find_attrlist_direct(fsw_u8 *atlst, int atlen, int type, fsw_u64 vcn, fsw_u64 *out, int *pos)
{
    fsw_u64 mftno = BADMFT;
    int namelen;

    namelen = type>>ATTRBITS;
    type &= ATTRMASK;

    while( *pos + 0x18 <= atlen) {
	int off = *pos;
	fsw_u32 t = GETU32(atlst, off);
	fsw_u32 n = GETU16(atlst, off+4);

	*pos = off + n;
	if(t==0 || (t+1)==0 || t==0xffff || n < 0x18 || *pos > atlen)
	    break;

	fsw_u8 ns = GETU8(atlst, off+6);
	fsw_u8 *nm = atlst + off + GETU8(atlst, off+7);
	if( type == t && namelen==ns && (ns==0 || fsw_memeq(NAME_I30, nm, ns*2))) {
	    fsw_u64 avcn = GETU64(atlst, off+8);
	    if(vcn < avcn) {
		if(mftno == BADMFT)
		    return FSW_NOT_FOUND;
		*out = mftno;
		return FSW_SUCCESS;
	    }
	    if(vcn == avcn) {
		*out = GETU64(atlst, off+0x10) & MFTMASK;
		return FSW_SUCCESS;
	    }
	    mftno = GETU64(atlst, off+0x10) & MFTMASK;
	}
    }
    return FSW_NOT_FOUND;
}
/* only supported attribute name is $I30 */
only supported attribute name is $I30
only supported attribute name is $I30
static fsw_status_t find_attrlist_direct(fsw_u8 *atlst, int atlen, int type, fsw_u64 vcn, fsw_u64 *out, int *pos)
{
    fsw_u64 mftno = BADMFT;
    int namelen;
    namelen = type>>ATTRBITS;
    type &= ATTRMASK;
    while( *pos + 0x18 <= atlen) {
	int off = *pos;
	fsw_u32 t = GETU32(atlst, off);
	fsw_u32 n = GETU16(atlst, off+4);
	*pos = off + n;
	if(t==0 || (t+1)==0 || t==0xffff || n < 0x18 || *pos > atlen)
	    break;
	fsw_u8 ns = GETU8(atlst, off+6);
	fsw_u8 *nm = atlst + off + GETU8(atlst, off+7);
	if( type == t && namelen==ns && (ns==0 || fsw_memeq(NAME_I30, nm, ns*2))) {
	    fsw_u64 avcn = GETU64(atlst, off+8);
	    if(vcn < avcn) {
		if(mftno == BADMFT)
		    return FSW_NOT_FOUND;
		*out = mftno;
		return FSW_SUCCESS;
	    }
	    if(vcn == avcn) {
		*out = GETU64(atlst, off+0x10) & MFTMASK;
		return FSW_SUCCESS;
	    }
	    mftno = GETU64(atlst, off+0x10) & MFTMASK;
	}
    }
    return FSW_NOT_FOUND;
}
static fsw_status_t find_attrlist_direct ( fsw_u8 * atlst , int atlen , int type , fsw_u64 vcn , fsw_u64 * out , int * pos ) { fsw_u64 mftno = BADMFT ; int namelen ; namelen = type >> ATTRBITS ; type &= ATTRMASK ; while ( * pos + 0x18 <= atlen ) { int off = * pos ; fsw_u32 t = GETU32 ( atlst , off ) ; fsw_u32 n = GETU16 ( atlst , off + 4 ) ; * pos = off + n ; if ( t == 0 || ( t + 1 ) == 0 || t == 0xffff || n < 0x18 || * pos > atlen ) break ; fsw_u8 ns = GETU8 ( atlst , off + 6 ) ; fsw_u8 * nm = atlst + off + GETU8 ( atlst , off + 7 ) ; if ( type == t && namelen == ns && ( ns == 0 || fsw_memeq ( NAME_I30 , nm , ns * 2 ) ) ) { fsw_u64 avcn = GETU64 ( atlst , off + 8 ) ; if ( vcn < avcn ) { if ( mftno == BADMFT ) return FSW_NOT_FOUND ; * out = mftno ; return FSW_SUCCESS ; } if ( vcn == avcn ) { * out = GETU64 ( atlst , off + 0x10 ) & MFTMASK ; return FSW_SUCCESS ; } mftno = GETU64 ( atlst , off + 0x10 ) & MFTMASK ; } } return FSW_NOT_FOUND ; }
only supported attribute name is $I30
only supported attribute name is $I30