--- dosfstools-2.11/dosfsck/lfn.c~	2005-03-12 15:05:44.000000000 +0000
+++ dosfstools-2.11/dosfsck/lfn.c	2009-05-15 11:56:27.368614018 +0100
@@ -180,7 +180,11 @@ void lfn_add_slot( DIR_ENT *de, loff_t d
 		if (can_clear)
 		    printf( "3: Clear start bit and concatenate LFNs\n" );
 	    }
-	    else printf( "  Not auto-correcting this.\n" );
+	    else {
+		printf("  deleting previous LFN\n");
+		clear_lfn_slots( 0, lfn_parts-1 );
+		lfn_reset();
+	    }
 	    if (interactive) {
 		switch( get_key( can_clear ? "123" : "12", "?" )) {
 		  case '1':
@@ -216,7 +220,16 @@ void lfn_add_slot( DIR_ENT *de, loff_t d
 	    printf( "1: Delete fragment\n2: Leave it as it is.\n"
 		    "3: Set start bit\n" );
 	}
-	else printf( "  Not auto-correcting this.\n" );
+	else {
+	    printf("  deleting fragment.\n");
+	    if (!lfn_offsets)
+		lfn_offsets = alloc( sizeof(loff_t) );
+	    lfn_offsets[0] = dir_offset;
+	    clear_lfn_slots( 0, 0 );
+	    lfn_reset();
+	    return;
+	}
+	
 	if (interactive) {
 	    switch( get_key( "123", "?" )) {
 	      case '1':
@@ -266,7 +279,13 @@ void lfn_add_slot( DIR_ENT *de, loff_t d
 	    if (can_fix)
 		printf( "3: Correct sequence number\n" );
 	}
-	else printf( "  Not auto-correcting this.\n" );
+	else {
+	    printf( "  correcting sequence number\n" );
+		lfn->id = (lfn->id & ~LFN_ID_SLOTMASK) | lfn_slot;
+		fs_write( dir_offset+offsetof(LFN_ENT,id),
+			  sizeof(lfn->id), &lfn->id );
+	}
+	
 	if (interactive) {
 	    switch( get_key( can_fix ? "123" : "12", "?" )) {
 	      case '1':
@@ -297,7 +316,13 @@ void lfn_add_slot( DIR_ENT *de, loff_t d
 	    printf( "1: Delete LFN\n2: Leave it as it is.\n"
 		    "3: Correct checksum\n" );
 	}
-	else printf( "  Not auto-correcting this.\n" );
+	else {
+	    printf( "  correcting checksum\n" );
+		lfn->alias_checksum = lfn_checksum;
+		fs_write( dir_offset+offsetof(LFN_ENT,alias_checksum),
+			  sizeof(lfn->alias_checksum), &lfn->alias_checksum );
+	}
+	
 	if (interactive) {
 	    switch( get_key( "123", "?" )) {
 	      case '1':
@@ -389,7 +414,13 @@ char *lfn_get( DIR_ENT *de )
 		    "3: Fix numbering (truncates long name and attaches "
 		    "it to short name %s)\n", short_name );
 	}
-	else printf( "  Not auto-correcting this.\n" );
+	else {
+	    printf ("  deleting LFN.\n" );
+	    clear_lfn_slots( 0, lfn_parts-1 );
+	    lfn_reset();
+	    return NULL;
+	}
+	
 	if (interactive) {
 	    switch( get_key( "123", "?" )) {
 	      case '1':
@@ -429,7 +460,13 @@ char *lfn_get( DIR_ENT *de )
 		    "3: Fix checksum (attaches to short name %s)\n",
 		    short_name );
 	}
-	else printf( "  Not auto-correcting this.\n" );
+	else {
+	    printf( "  deleting LFN.\n");
+		clear_lfn_slots( 0, lfn_parts-1 );
+		lfn_reset();
+		return NULL;
+	}
+	
 	if (interactive) {
 	    switch( get_key( "123", "?" )) {
 	      case '1':
