Author: fireball
Date: Wed Aug 6 08:07:28 2008
New Revision: 35146
URL:
http://svn.reactos.org/svn/reactos?rev=35146&view=rev
Log:
- Replace stupid concept of using a set of global variables for various boolean flags (1
variable per 1 flag) by a concept of one global var having a specified set of flags
(FSCHECK_VERBOSE, etc).
Modified:
trunk/reactos/lib/fslib/vfatlib/check/boot.c
trunk/reactos/lib/fslib/vfatlib/check/check.c
trunk/reactos/lib/fslib/vfatlib/check/dosfsck.h
trunk/reactos/lib/fslib/vfatlib/check/fat.c
trunk/reactos/lib/fslib/vfatlib/check/io.c
trunk/reactos/lib/fslib/vfatlib/check/lfn.c
Modified: trunk/reactos/lib/fslib/vfatlib/check/boot.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/bo…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/boot.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/boot.c [iso-8859-1] Wed Aug 6 08:07:28 2008
@@ -119,10 +119,10 @@
VfatPrint( "And there is no space for creating one!\n" );
return;
}
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Create one\n2) Do without a backup\n" );
else VfatPrint( " Auto-creating backup boot block.\n" );
- if (!interactive || get_key("12","?") == '1') {
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?")
== '1') {
int bbs;
/* The usual place for the backup boot sector is sector 6. Choose
* that or the last reserved sector. */
@@ -167,12 +167,12 @@
}
VfatPrint( "\n" );
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Copy original to backup\n"
"2) Copy backup to original\n"
"3) No action\n" );
else VfatPrint( " Not automatically fixing this.\n" );
- switch (interactive ? get_key("123","?") : '3') {
+ switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ?
get_key("123","?") : '3') {
case '1':
fs_write(fs->backupboot_start,sizeof(*b),b);
break;
@@ -200,10 +200,10 @@
if (!b->info_sector) {
VfatPrint( "No FSINFO sector\n" );
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Create one\n2) Do without FSINFO\n" );
else VfatPrint( " Not automatically creating it.\n" );
- if (interactive && get_key("12","?") == '1') {
+ if ((FsCheckFlags & FSCHECK_INTERACTIVE) &&
get_key("12","?") == '1') {
/* search for a free reserved sector (not boot sector and not
* backup boot sector) */
__u32 s;
@@ -248,10 +248,10 @@
VfatPrint( " Offset %llu: 0x%04x != expected 0x%04x\n",
(__u64)offsetof(struct info_sector,boot_sign),
CF_LE_W(i.boot_sign),0xaa55);
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Correct\n2) Don't correct (FSINFO invalid then)\n" );
else VfatPrint( " Auto-correcting it.\n" );
- if (!interactive || get_key("12","?") == '1') {
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?")
== '1') {
init_fsinfo(&i);
fs_write(fs->fsinfo_start,sizeof(i),&i);
}
@@ -280,7 +280,7 @@
fs->nfats = b.fats;
sectors = GET_UNALIGNED_W(b.sectors);
total_sectors = sectors ? sectors : CF_LE_L(b.total_sect);
- if (verbose) VfatPrint("Checking we can access the last sector of the
filesystem\n");
+ if (FsCheckFlags & FSCHECK_VERBOSE) VfatPrint("Checking we can access the
last sector of the filesystem\n");
/* Can't access last odd sector anyway, so round down */
fs_test((loff_t)((total_sectors & ~1)-1)*(loff_t)logical_sector_size,
logical_sector_size);
@@ -358,7 +358,7 @@
/* ++roman: On Atari, these two fields are often left uninitialized */
if (!atari_format && (!b.secs_track || !b.heads))
die("Invalid disk format in boot sector.");
- if (verbose) dump_boot(fs,&b,logical_sector_size);
+ if (FsCheckFlags & FSCHECK_VERBOSE) dump_boot(fs,&b,logical_sector_size);
}
/* Local Variables: */
Modified: trunk/reactos/lib/fslib/vfatlib/check/check.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/ch…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/check.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/check.c [iso-8859-1] Wed Aug 6 08:07:28 2008
@@ -267,7 +267,7 @@
/* Only complain about too much suspicious chars in interactive mode,
* never correct them automatically. The chars are all basically ok, so we
* shouldn't auto-correct such names. */
- if (interactive && suspicious > 6)
+ if ((FsCheckFlags & FSCHECK_INTERACTIVE) && suspicious > 6)
return 1;
return 0;
}
@@ -365,11 +365,11 @@
name = strncmp((char*)file->dir_ent.name,MSDOS_DOT,MSDOS_NAME) ? ".." :
".";
if (!(file->dir_ent.attr & ATTR_DIR)) {
VfatPrint("%s\n Is a non-directory.\n",path_name(file));
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Drop it\n2) Auto-rename\n3) Rename\n"
"4) Convert to directory\n");
else VfatPrint(" Auto-renaming it.\n");
- switch (interactive ? get_key("1234","?") : '2') {
+ switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ?
get_key("1234","?") : '2') {
case '1':
drop_file(fs,file);
return 1;
@@ -483,7 +483,7 @@
"is FAT32 root dir.\n", clusters*fs->cluster_size );
do_trunc = 1;
}
- else if (interactive)
+ else if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Truncate first to %lu bytes%s\n"
"2) Truncate second to %lu bytes\n",clusters*fs->cluster_size,
restart ? " and restart" : "",clusters2*fs->cluster_size);
@@ -491,7 +491,7 @@
fs->cluster_size);
if (do_trunc != 2 &&
(do_trunc == 1 ||
- (interactive && get_key("12","?") == '1'))) {
+ ((FsCheckFlags & FSCHECK_INTERACTIVE) &&
get_key("12","?") == '1'))) {
prev = 0;
clusters = 0;
for (this = FSTART(owner,fs); this > 0 && this != -1; this =
@@ -561,7 +561,7 @@
VfatPrint("%s\n Has a large number of bad entries. (%d/%d)\n",
path_name(parent),bad,good+bad);
if (!dots) VfatPrint( " Not dropping root directory.\n" );
- else if (!interactive) VfatPrint(" Not dropping it in auto-mode.\n");
+ else if (!(FsCheckFlags & FSCHECK_INTERACTIVE)) VfatPrint(" Not dropping it in
auto-mode.\n");
else if (get_key("yn","Drop directory ? (y/n)") == 'y') {
truncate_file(fs,parent,0);
MODIFY(parent,name[0],DELETED_FLAG);
@@ -584,11 +584,11 @@
if (!((*walk)->dir_ent.attr & ATTR_VOLUME) &&
bad_name((*walk)->dir_ent.name)) {
VfatPrint("%s\n Bad file name.\n",path_name(*walk));
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Drop file\n2) Rename file\n3) Auto-rename\n"
"4) Keep it\n");
else VfatPrint(" Auto-renaming it.\n");
- switch (interactive ? get_key("1234","?") : '3') {
+ switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ?
get_key("1234","?") : '3') {
case '1':
drop_file(fs,*walk);
walk = &(*walk)->next;
@@ -616,12 +616,12 @@
VfatPrint("%s\n Duplicate directory entry.\n First %s\n",
path_name(*walk),file_stat(*walk));
VfatPrint(" Second %s\n",file_stat(*scan));
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint("1) Drop first\n2) Drop second\n3) Rename first\n"
"4) Rename second\n5) Auto-rename first\n"
"6) Auto-rename second\n");
else VfatPrint(" Auto-renaming second.\n");
- switch (interactive ? get_key("123456","?") : '6') {
+ switch ((FsCheckFlags & FSCHECK_INTERACTIVE) ?
get_key("123456","?") : '6') {
case '1':
drop_file(fs,*walk);
*walk = (*walk)->next;
@@ -789,7 +789,7 @@
if (type == fdt_undelete) undelete(fs,new);
**chain = new;
*chain = &new->next;
- if (list) {
+ if (FsCheckFlags & FSCHECK_LIST_FILES) {
VfatPrint("Checking file %s",path_name(new));
if (new->lfn)
VfatPrint(" (%s)", file_name(new->dir_ent.name) );
@@ -799,7 +799,7 @@
strncmp((char*)de.name,MSDOS_DOT,MSDOS_NAME) != 0 &&
strncmp((char*)de.name,MSDOS_DOTDOT,MSDOS_NAME) != 0)
++n_files;
- test_file(fs,new,test);
+ test_file(fs,new,FsCheckFlags & FSCHECK_TEST_READ);
}
Modified: trunk/reactos/lib/fslib/vfatlib/check/dosfsck.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/do…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/dosfsck.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/dosfsck.h [iso-8859-1] Wed Aug 6 08:07:28 2008
@@ -28,13 +28,6 @@
#define CT_LE_L(v) (v)
#endif
-
-#define _LINUX_STAT_H /* hack to avoid inclusion of <linux/stat.h> */
-#define _LINUX_STRING_H_ /* hack to avoid inclusion of <linux/string.h>*/
-#define _LINUX_FS_H /* hack to avoid inclusion of <linux/fs.h> */
-
-//#include <linux/version.h>
-//# include "types.h"
#ifdef _M_IX86
#include "byteorder.h"
@@ -165,7 +158,13 @@
#define offsetof(t,e) ((int)&(((t *)0)->e))
#endif
-extern int interactive,list,verbose,test,write_immed;
+#define FSCHECK_INTERACTIVE 0x01
+#define FSCHECK_LIST_FILES 0x02
+#define FSCHECK_TEST_READ 0x04
+#define FSCHECK_VERBOSE 0x08
+#define FSCHECK_IMMEDIATE_WRITE 0x10
+
+extern ULONG FsCheckFlags;
extern int atari_format;
extern unsigned n_files;
extern void *mem_queue;
Modified: trunk/reactos/lib/fslib/vfatlib/check/fat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/fa…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/fat.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/fat.c [iso-8859-1] Wed Aug 6 08:07:28 2008
@@ -79,7 +79,7 @@
fs_write(fs->fat_start,eff_size,use = second);
}
if (first_ok && second_ok) {
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint("FATs differ but appear to be intact. Use which FAT ?\n"
"1) Use first FAT\n2) Use second FAT\n");
if (get_key("12","?") == '1')
@@ -199,7 +199,7 @@
{
unsigned long i;
- if (verbose)
+ if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Checking for bad clusters.\n");
for (i = 2; i < fs->clusters+2; i++)
if (!get_owner(fs,i) && !FAT_IS_BAD(fs,fs->fat[i].value))
@@ -215,7 +215,7 @@
int reclaimed;
unsigned long i;
- if (verbose)
+ if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Checking for unused clusters.\n");
reclaimed = 0;
for (i = 2; i < fs->clusters+2; i++)
@@ -261,7 +261,7 @@
int reclaimed,files,changed;
unsigned long i,next,walk;
- if (verbose)
+ if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Reclaiming unconnected clusters.\n");
for (i = 2; i < fs->clusters+2; i++) fs->fat[i].prev = 0;
for (i = 2; i < fs->clusters+2; i++) {
@@ -324,25 +324,25 @@
if (!fs->fsinfo_start)
return free;
- if (verbose)
+ if (FsCheckFlags & FSCHECK_VERBOSE)
VfatPrint("Checking free cluster summary.\n");
if (fs->free_clusters >= 0) {
if (free != fs->free_clusters) {
VfatPrint( "Free cluster summary wrong (%ld vs. really %ld)\n",
fs->free_clusters,free);
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Correct\n2) Don't correct\n" );
else VfatPrint( " Auto-correcting.\n" );
- if (!interactive || get_key("12","?") == '1')
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) ||
get_key("12","?") == '1')
do_set = 1;
}
}
else {
VfatPrint( "Free cluster summary uninitialized (should be %ld)\n", free );
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1) Set it\n2) Leave it uninitialized\n" );
else VfatPrint( " Auto-setting.\n" );
- if (!interactive || get_key("12","?") == '1')
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?")
== '1')
do_set = 1;
}
Modified: trunk/reactos/lib/fslib/vfatlib/check/io.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/io…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/io.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/io.c [iso-8859-1] Wed Aug 6 08:07:28 2008
@@ -139,7 +139,7 @@
int did;
#if 1 //SAE
- if (write_immed) {
+ if (FsCheckFlags & FSCHECK_IMMEDIATE_WRITE) {
void *scratch;
const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) :
size;
const loff_t seekpos_aligned = pos - (pos % 512);
@@ -204,10 +204,10 @@
static void fs_flush(void)
{
CHANGE *this;
- int old_write_immed = write_immed;
+ int old_write_immed = (FsCheckFlags & FSCHECK_IMMEDIATE_WRITE);
/* Disable writes to the list now */
- write_immed = 1;
+ FsCheckFlags |= FSCHECK_IMMEDIATE_WRITE;
while (changes) {
this = changes;
@@ -220,7 +220,7 @@
}
/* Restore values */
- write_immed = old_write_immed;
+ if (!old_write_immed) FsCheckFlags ^= FSCHECK_IMMEDIATE_WRITE;
}
Modified: trunk/reactos/lib/fslib/vfatlib/check/lfn.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/lf…
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/lfn.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/lfn.c [iso-8859-1] Wed Aug 6 08:07:28 2008
@@ -173,13 +173,13 @@
vffree( part2 );
can_clear = 1;
}
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete previous LFN\n2: Leave it as it is.\n" );
if (can_clear)
VfatPrint( "3: Clear start bit and concatenate LFNs\n" );
}
else VfatPrint( " Not auto-correcting this.\n" );
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( can_clear ? "123" : "12", "?" )) {
case '1':
clear_lfn_slots( 0, lfn_parts-1 );
@@ -210,12 +210,12 @@
VfatPrint( "Long filename fragment \"%s\" found outside a LFN "
"sequence.\n (Maybe the start bit is missing on the "
"last fragment)\n", part );
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete fragment\n2: Leave it as it is.\n"
"3: Set start bit\n" );
}
else VfatPrint( " Not auto-correcting this.\n" );
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) {
case '1':
if (!lfn_offsets)
@@ -259,13 +259,13 @@
vffree( part2 );
can_fix = 1;
}
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is (and ignore LFN so far)\n"
);
if (can_fix)
VfatPrint( "3: Correct sequence number\n" );
}
else VfatPrint( " Not auto-correcting this.\n" );
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( can_fix ? "123" : "12", "?" )) {
case '1':
lfn_offsets[lfn_parts++] = dir_offset;
@@ -291,12 +291,12 @@
VfatPrint( "Checksum in long filename part wrong "
"(%02x vs. expected %02x).\n",
lfn->alias_checksum, lfn_checksum );
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
"3: Correct checksum\n" );
}
else VfatPrint( " Not auto-correcting this.\n" );
- if (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) {
case '1':
lfn_offsets[lfn_parts++] = dir_offset;
@@ -326,10 +326,10 @@
if (lfn->reserved != 0) {
VfatPrint( "Reserved field in VFAT long filename slot is not 0 "
"(but 0x%02x).\n", lfn->reserved );
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1: Fix.\n2: Leave it.\n" );
else VfatPrint( "Auto-setting to 0.\n" );
- if (!interactive || get_key("12","?") == '1') {
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?")
== '1') {
lfn->reserved = 0;
fs_write( dir_offset+offsetof(LFN_ENT,reserved),
sizeof(lfn->reserved), &lfn->reserved );
@@ -338,10 +338,10 @@
if (lfn->start != CT_LE_W(0)) {
VfatPrint( "Start cluster field in VFAT long filename slot is not 0 "
"(but 0x%04x).\n", lfn->start );
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1: Fix.\n2: Leave it.\n" );
else VfatPrint( "Auto-setting to 0.\n" );
- if (!interactive || get_key("12","?") == '1') {
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) || get_key("12","?")
== '1') {
lfn->start = CT_LE_W(0);
fs_write( dir_offset+offsetof(LFN_ENT,start),
sizeof(lfn->start),&lfn->start );
@@ -382,13 +382,13 @@
" (Start may have been overwritten by %s)\n",
long_name, short_name );
vffree( long_name );
- if (interactive) {
+ 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 (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) {
case '1':
clear_lfn_slots( 0, lfn_parts-1 );
@@ -422,13 +422,13 @@
" (Short name %s may have changed without updating the long name)\n",
long_name, short_name );
vffree( long_name );
- if (interactive) {
+ 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 (interactive) {
+ if (FsCheckFlags & FSCHECK_INTERACTIVE) {
switch( get_key( "123", "?" )) {
case '1':
clear_lfn_slots( 0, lfn_parts-1 );
@@ -461,10 +461,10 @@
long_name = CNV_PARTS_SO_FAR();
VfatPrint("Orphaned long file name part \"%s\"\n", long_name);
- if (interactive)
+ if (FsCheckFlags & FSCHECK_INTERACTIVE)
VfatPrint( "1: Delete.\n2: Leave it.\n" );
else VfatPrint( " Auto-deleting.\n" );
- if (!interactive || get_key("12","?") == '1') {
+ if (!(FsCheckFlags & FSCHECK_INTERACTIVE) ||
get_key("12","?") == '1') {
clear_lfn_slots(0, lfn_parts - 1);
}
lfn_reset();