filesystems/fsw_ntfs.c
static fsw_status_t find_attribute_direct(fsw_u8 *mft, int mftsize, int type, fsw_u8 **outptr, int *outlen)
{
    int namelen;
    fsw_u32 n;

    if(GETU32(mft, 0x18) < mftsize)
	mftsize = GETU32(mft, 0x18);
    mftsize -= GETU16(mft, 0x14);
    mft += GETU16(mft, 0x14);

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

    for(n = 0; mftsize >= 8; mft += n, mftsize -= n) {
	int t = GETU32(mft, 0);
	n = GETU32(mft, 4);
	if( t==0 || (t+1)==0 || t==0xffff || n<24 || mftsize<n)
	    break;

	fsw_u8 ns = GETU8(mft, 9);
	fsw_u8 *nm = mft + GETU8(mft, 10);
	if(type==t && namelen==ns && (ns==0 || fsw_memeq(NAME_I30, nm, ns*2))) {
	    if(outptr) *outptr = mft;
	    if(outlen) *outlen = n;
	    return FSW_SUCCESS;
	}
    }
    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_attribute_direct(fsw_u8 *mft, int mftsize, int type, fsw_u8 **outptr, int *outlen)
{
    int namelen;
    fsw_u32 n;
    if(GETU32(mft, 0x18) < mftsize)
	mftsize = GETU32(mft, 0x18);
    mftsize -= GETU16(mft, 0x14);
    mft += GETU16(mft, 0x14);
    namelen = type>>ATTRBITS;
    type &= ATTRMASK;
    for(n = 0; mftsize >= 8; mft += n, mftsize -= n) {
	int t = GETU32(mft, 0);
	n = GETU32(mft, 4);
	if( t==0 || (t+1)==0 || t==0xffff || n<24 || mftsize<n)
	    break;
	fsw_u8 ns = GETU8(mft, 9);
	fsw_u8 *nm = mft + GETU8(mft, 10);
	if(type==t && namelen==ns && (ns==0 || fsw_memeq(NAME_I30, nm, ns*2))) {
	    if(outptr) *outptr = mft;
	    if(outlen) *outlen = n;
	    return FSW_SUCCESS;
	}
    }
    return FSW_NOT_FOUND;
}
static fsw_status_t find_attribute_direct ( fsw_u8 * mft , int mftsize , int type , fsw_u8 * * outptr , int * outlen ) { int namelen ; fsw_u32 n ; if ( GETU32 ( mft , 0x18 ) < mftsize ) mftsize = GETU32 ( mft , 0x18 ) ; mftsize -= GETU16 ( mft , 0x14 ) ; mft += GETU16 ( mft , 0x14 ) ; namelen = type >> ATTRBITS ; type &= ATTRMASK ; for ( n = 0 ; mftsize >= 8 ; mft += n , mftsize -= n ) { int t = GETU32 ( mft , 0 ) ; n = GETU32 ( mft , 4 ) ; if ( t == 0 || ( t + 1 ) == 0 || t == 0xffff || n < 24 || mftsize < n ) break ; fsw_u8 ns = GETU8 ( mft , 9 ) ; fsw_u8 * nm = mft + GETU8 ( mft , 10 ) ; if ( type == t && namelen == ns && ( ns == 0 || fsw_memeq ( NAME_I30 , nm , ns * 2 ) ) ) { if ( outptr ) * outptr = mft ; if ( outlen ) * outlen = n ; return FSW_SUCCESS ; } } return FSW_NOT_FOUND ; }
only supported attribute name is $I30
only supported attribute name is $I30