[ros-diffs] [fireball] 35178: - Remove atari fs support. - Rename global variables to more meaningful names. - Add fs_isdirty function to determine is a filesystem is marked as dirty.

fireball at svn.reactos.org fireball at svn.reactos.org
Fri Aug 8 11:13:22 CEST 2008


Author: fireball
Date: Fri Aug  8 04:13:21 2008
New Revision: 35178

URL: http://svn.reactos.org/svn/reactos?rev=35178&view=rev
Log:
- Remove atari fs support.
- Rename global variables to more meaningful names.
- Add fs_isdirty function to determine is a filesystem is marked as dirty.

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/io.h
    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/boot.c?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/boot.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/boot.c [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -57,20 +57,14 @@
 static void dump_boot(DOS_FS *fs,struct boot_sector *b,unsigned lss)
 {
     unsigned short sectors;
+	char id[9];
 
     VfatPrint("Boot sector contents:\n");
-    if (!atari_format) {
-	char id[9];
+
 	strncpy(id,(char*)b->system_id,8);
 	id[8] = 0;
 	VfatPrint("System ID \"%s\"\n",id);
-    }
-    else {
-	/* On Atari, a 24 bit serial number is stored at offset 8 of the boot
-	 * sector */
-	VfatPrint("Serial number 0x%x\n",
-	       b->system_id[5] | (b->system_id[6]<<8) | (b->system_id[7]<<16));
-    }
+
     VfatPrint("Media byte 0x%02x (%s)\n",b->media,get_media_descr(b->media));
     VfatPrint("%10d bytes per logical sector\n",GET_UNALIGNED_W(b->sector_size));
     VfatPrint("%10d bytes per cluster\n",fs->cluster_size);
@@ -99,12 +93,7 @@
 	   (__u64)fs->clusters*fs->cluster_size);
     VfatPrint("%u sectors/track, %u heads\n",CF_LE_W(b->secs_track),
 	   CF_LE_W(b->heads));
-    VfatPrint("%10u hidden sectors\n",
-	   atari_format ?
-	   /* On Atari, the hidden field is only 16 bit wide and unused */
-	   (((unsigned char *)&b->hidden)[0] |
-	    ((unsigned char *)&b->hidden)[1] << 8) :
-	   CF_LE_L(b->hidden));
+    VfatPrint("%10u hidden sectors\n", CF_LE_L(b->hidden));
     sectors = GET_UNALIGNED_W( b->sectors );
     VfatPrint("%10u sectors total\n", sectors ? sectors : CF_LE_L(b->total_sect));
 }
@@ -320,27 +309,12 @@
 
 	read_fsinfo(fs,&b,logical_sector_size);
     }
-    else if (!atari_format) {
+    else {
 	/* On real MS-DOS, a 16 bit FAT is used whenever there would be too
-	 * much clusers otherwise. */
+	 * much clusters otherwise. */
 	fs->fat_bits = (fs->clusters > MSDOS_FAT12) ? 16 : 12;
     }
-    else {
-	/* On Atari, things are more difficult: GEMDOS always uses 12bit FATs
-	 * on floppies, and always 16 bit on harddisks. */
-	fs->fat_bits = 16; /* assume 16 bit FAT for now */
-	/* If more clusters than fat entries in 16-bit fat, we assume
-	 * it's a real MSDOS FS with 12-bit fat. */
-	if (fs->clusters+2 > fat_length*logical_sector_size*8/16 ||
-	    /* if it's a floppy disk --> 12bit fat */
-	    device_no == 2 ||
-	    /* if it's a ramdisk or loopback device and has one of the usual
-	     * floppy sizes -> 12bit FAT  */
-	    ((device_no == 1 || device_no == 7) &&
-	     (total_sectors == 720 || total_sectors == 1440 ||
-	      total_sectors == 2880)))
-	    fs->fat_bits = 12;
-    }
+
     /* On FAT32, the high 4 bits of a FAT entry are reserved */
     fs->eff_fat_bits = (fs->fat_bits == 32) ? 28 : fs->fat_bits;
     fs->fat_size = fat_length*logical_sector_size;
@@ -356,7 +330,7 @@
 	die("Logical sector size (%d bytes) is not a multiple of the physical "
 	  "sector size.",logical_sector_size);
     /* ++roman: On Atari, these two fields are often left uninitialized */
-    if (!atari_format && (!b.secs_track || !b.heads))
+    if ((!b.secs_track || !b.heads))
 	die("Invalid disk format in boot sector.");
     if (FsCheckFlags & FSCHECK_VERBOSE) dump_boot(fs,&b,logical_sector_size);
 }

Modified: trunk/reactos/lib/fslib/vfatlib/check/check.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/check.c?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/check.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/check.c [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -153,7 +153,7 @@
 	}
 	vffree(root);
     }
-    ++n_files;
+    ++FsCheckTotalFiles;
     return offset;
 }
 
@@ -221,7 +221,7 @@
 static int bad_name(unsigned char *name)
 {
     int i, spc, suspicious = 0;
-    char *bad_chars = atari_format ? "*?\\/:" : "*?<>|\"\\/:";
+    char *bad_chars = "*?<>|\"\\/:";
 
     /* Do not complain about (and auto-correct) the extended attribute files
      * of OS/2. */
@@ -260,10 +260,6 @@
 	    return 1;
     }
 
-    /* Under GEMDOS, chars >= 128 are never allowed. */
-    if (atari_format && suspicious)
-	return 1;
-
     /* 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. */
@@ -281,7 +277,7 @@
     for (cluster = FSTART(file,fs); cluster > 0 && cluster <
       fs->clusters+2; cluster = next_cluster(fs,cluster))
 	set_owner(fs,cluster,NULL);
-    --n_files;
+    --FsCheckTotalFiles;
 }
 
 
@@ -780,7 +776,7 @@
 	lfn_add_slot(&de,offset);
 	return;
     }
-    new = qalloc(&mem_queue,sizeof(DOS_FILE));
+    new = qalloc(&FsCheckMemQueue,sizeof(DOS_FILE));
     new->lfn = lfn_get(&de);
     new->offset = offset;
     memcpy(&new->dir_ent,&de,sizeof(de));
@@ -798,7 +794,7 @@
     if (offset &&
 	strncmp((char*)de.name,MSDOS_DOT,MSDOS_NAME) != 0 &&
 	strncmp((char*)de.name,MSDOS_DOTDOT,MSDOS_NAME) != 0)
-	++n_files;
+	++FsCheckTotalFiles;
     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/dosfsck.h?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/dosfsck.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/dosfsck.h [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -165,18 +165,17 @@
 #define FSCHECK_IMMEDIATE_WRITE 0x10
 
 extern ULONG FsCheckFlags;
-extern int atari_format;
-extern unsigned n_files;
-extern void *mem_queue;
+extern ULONG FsCheckTotalFiles;
+extern void *FsCheckMemQueue;
 
 /* value to use as end-of-file marker */
-#define FAT_EOF(fs)	((atari_format ? 0xfff : 0xff8) | FAT_EXTD(fs))
+#define FAT_EOF(fs)	(0xff8 | FAT_EXTD(fs))
 #define FAT_IS_EOF(fs,v) ((unsigned long)(v) >= (0xff8|FAT_EXTD(fs)))
 /* value to mark bad clusters */
 #define FAT_BAD(fs)	(0xff7 | FAT_EXTD(fs))
 /* range of values used for bad clusters */
-#define FAT_MIN_BAD(fs)	((atari_format ? 0xff0 : 0xff7) | FAT_EXTD(fs))
-#define FAT_MAX_BAD(fs)	((atari_format ? 0xff7 : 0xff7) | FAT_EXTD(fs))
+#define FAT_MIN_BAD(fs)	(0xff7 | FAT_EXTD(fs))
+#define FAT_MAX_BAD(fs)	(0xff7 | FAT_EXTD(fs))
 #define FAT_IS_BAD(fs,v) ((v) >= FAT_MIN_BAD(fs) && (v) <= FAT_MAX_BAD(fs))
 
 /* return -16 as a number with fs->fat_bits bits */

Modified: trunk/reactos/lib/fslib/vfatlib/check/fat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/fat.c?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/fat.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/fat.c [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -97,7 +97,7 @@
 	    //exit(1);
 	}
     }
-    fs->fat = qalloc(&mem_queue,sizeof(FAT_ENTRY)*(fs->clusters+2));
+    fs->fat = qalloc(&FsCheckMemQueue,sizeof(FAT_ENTRY)*(fs->clusters+2));
     for (i = 2; i < fs->clusters+2; i++) get_fat(&fs->fat[i],use,i,fs);
     for (i = 2; i < fs->clusters+2; i++)
 	if (fs->fat[i].value >= fs->clusters+2 &&

Modified: trunk/reactos/lib/fslib/vfatlib/check/io.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/io.c?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/io.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/io.c [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -16,6 +16,8 @@
 
 #define NDEBUG
 #include <debug.h>
+
+#define FSCTL_IS_VOLUME_DIRTY           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
 typedef struct _change {
     void *data;
@@ -74,6 +76,63 @@
 
     changes = last = NULL;
     did_change = 0;
+}
+
+BOOLEAN fs_isdirty(PUNICODE_STRING DriveRoot)
+{
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    ULONG DirtyMask = 0;
+    WCHAR TempRootBuf[128];
+    UNICODE_STRING TempRoot;
+    HANDLE FileSystem;
+    IO_STATUS_BLOCK IoSb;
+    NTSTATUS Status;
+
+    /* Add backslash to the end, so FS will be opened */
+    TempRoot.Length = 0;
+    TempRoot.MaximumLength = sizeof(TempRootBuf);
+    TempRoot.Buffer = TempRootBuf;
+    RtlCopyUnicodeString(&TempRoot, DriveRoot);
+    if (TempRoot.Length == (TempRoot.MaximumLength-1)) return FALSE;
+    wcscat(TempRoot.Buffer, L"\\");
+    TempRoot.Length += sizeof(WCHAR);
+
+    InitializeObjectAttributes(&ObjectAttributes,
+        &TempRoot,
+        0,
+        NULL,
+        NULL);
+
+    Status = NtOpenFile(&FileSystem,
+        FILE_GENERIC_READ,
+        &ObjectAttributes,
+        &IoSb,
+        0,
+        0);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("NtOpenFile() failed with status 0x%.08x\n", Status);
+        return FALSE;
+    }
+
+    /* Check if volume is dirty */
+    Status = NtFsControlFile(FileSystem,
+                             NULL, NULL, NULL, &IoSb,
+                             FSCTL_IS_VOLUME_DIRTY,
+                             NULL, 0, &DirtyMask, sizeof(DirtyMask));
+
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("NtFsControlFile() failed with Status 0x%08x\n", Status);
+        /* Close FS handle */
+        NtClose(FileSystem);
+        return FALSE;
+    }
+
+    /* Close FS handle */
+    NtClose(FileSystem);
+
+    return (DirtyMask & 1);
 }
 
 

Modified: trunk/reactos/lib/fslib/vfatlib/check/io.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/io.h?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/io.h [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/io.h [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -20,6 +20,10 @@
 
 /* Opens the file system PATH. If RW is zero, the file system is opened
    read-only, otherwise, it is opened read-write. */
+
+BOOLEAN fs_isdirty(PUNICODE_STRING DriveRoot);
+
+/* Checks if filesystem is dirty */
 
 void fs_read(loff_t pos,int size,void *data);
 

Modified: trunk/reactos/lib/fslib/vfatlib/check/lfn.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fslib/vfatlib/check/lfn.c?rev=35178&r1=35177&r2=35178&view=diff
==============================================================================
--- trunk/reactos/lib/fslib/vfatlib/check/lfn.c [iso-8859-1] (original)
+++ trunk/reactos/lib/fslib/vfatlib/check/lfn.c [iso-8859-1] Fri Aug  8 04:13:21 2008
@@ -81,7 +81,7 @@
 	else
 	    len += 4;
     }
-    cp = out = use_q ? qalloc( &mem_queue, len+1 ) : vfalloc( len+1 );
+    cp = out = use_q ? qalloc( &FsCheckMemQueue, len+1 ) : vfalloc( len+1 );
 
     for( up = uni; (up-uni)/2 < maxlen && (up[0] || up[1]); up += 2 ) {
 	if (UNICODE_CONVERTABLE(up[0],up[1]))



More information about the Ros-diffs mailing list