ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

char* lfn_get ( DIR_ENT de)

Definition at line 353 of file lfn.c.

Referenced by add_file().

{
    char *lfn;
    __u8 sum;
    int i;

    if (de->attr == VFAT_LN_ATTR)
    die("lfn_get called with LFN directory entry");

#if 0
    if (de->lcase)
    VfatPrint( "lcase=%02x\n",de->lcase );
#endif

    if (lfn_slot == -1)
    /* no long name for this file */
    return NULL;

    if (lfn_slot != 0) {
    /* The long name isn't finished yet. */
    /* Causes: 1) LFN slot overwritten by non-VFAT aware tool */
    /* Fixes: 1) delete LFN 2) move overwriting entry to somewhere else
     * and let user enter missing part of LFN (hard to do :-()
     * 3) renumber entries and truncate name */
    char *long_name = CNV_PARTS_SO_FAR();
    char *short_name = file_name(de->name);
    VfatPrint( "Unfinished long file name \"%s\".\n"
        "  (Start may have been overwritten by %s)\n",
        long_name, short_name );
    vffree( long_name );
    if (FsCheckFlags & FSCHECK_INTERACTIVE) {
        VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
            "3: Fix numbering (truncates long name and attaches "
            "it to short name %s)\n", short_name );
    }
    else VfatPrint( "  Not auto-correcting this.\n" );
    if (FsCheckFlags & FSCHECK_INTERACTIVE) {
        switch( get_key( "123", "?" )) {
          case '1':
        clear_lfn_slots( 0, lfn_parts-1 );
        lfn_reset();
        return NULL;
          case '2':
        lfn_reset();
        return NULL;
          case '3':
        for( i = 0; i < lfn_parts; ++i ) {
            __u8 id = (lfn_parts-i) | (i==0 ? LFN_ID_START : 0);
            fs_write( lfn_offsets[i]+offsetof(LFN_ENT,id),
                  sizeof(id), &id );
        }
        memmove( lfn_unicode, lfn_unicode+lfn_slot*CHARS_PER_LFN*2,
             lfn_parts*CHARS_PER_LFN*2 );
        break;
        }
    }
    }

    for (sum = 0, i = 0; i < 8; i++)
    sum = (((sum&1) << 7) | ((sum&0xfe) >> 1)) + de->name[i];

    for (i = 0; i < 3; i++)
    sum = (((sum&1) << 7) | ((sum&0xfe) >> 1)) + de->ext[i];

    if (sum != lfn_checksum) {
    /* checksum doesn't match, long name doesn't apply to this alias */
    /* Causes: 1) alias renamed */
    /* Fixes: 1) Fix checksum in LFN entries */
    char *long_name = CNV_PARTS_SO_FAR();
    char *short_name = file_name(de->name);
    VfatPrint( "Wrong checksum for long file name \"%s\".\n"
        "  (Short name %s may have changed without updating the long name)\n",
        long_name, short_name );
    vffree( long_name );
    if (FsCheckFlags & FSCHECK_INTERACTIVE) {
        VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
            "3: Fix checksum (attaches to short name %s)\n",
            short_name );
    }
    else VfatPrint( "  Not auto-correcting this.\n" );
    if (FsCheckFlags & FSCHECK_INTERACTIVE) {
        switch( get_key( "123", "?" )) {
          case '1':
        clear_lfn_slots( 0, lfn_parts-1 );
        lfn_reset();
        return NULL;
          case '2':
        lfn_reset();
        return NULL;
          case '3':
        for( i = 0; i < lfn_parts; ++i ) {
            fs_write( lfn_offsets[i]+offsetof(LFN_ENT,alias_checksum),
                  sizeof(sum), &sum );
        }
        break;
        }
    }
    }

    lfn = cnv_unicode( lfn_unicode, UNTIL_0, 1 );
    lfn_reset();
    return( lfn );
}

Generated on Sun May 27 2012 06:04:13 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.