From ed1b8169436dd11d8548fb842e8a6ce5646d1796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 27 Dec 2015 02:01:52 +0000 Subject: [PATCH] [VFATLIB] It seems suspicious to directly return the value of fs_close as the NTSTATUS code of the check-disk operation (for FAT32 volumes it happens to return 1 whereas for FAT16 volumes it returns 0). The documentation of this function says that it "returns a non-zero integer if the file system has been changed since the last fs_open, zero otherwise." Maybe somebody has a more precise idea on that subject? In the meantime I also add some DPRINTs to attempt to diagnose the conditions where this problem occurs. svn path=/trunk/; revision=70434 --- reactos/lib/fslib/vfatlib/vfatlib.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/reactos/lib/fslib/vfatlib/vfatlib.c b/reactos/lib/fslib/vfatlib/vfatlib.c index b23c1e7ae96..8f7798becb8 100644 --- a/reactos/lib/fslib/vfatlib/vfatlib.c +++ b/reactos/lib/fslib/vfatlib/vfatlib.c @@ -351,6 +351,7 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot, BOOLEAN salvage_files; ULONG free_clusters; DOS_FS fs; + int ret; /* Store callback pointer */ ChkdskCallback = Callback; @@ -372,7 +373,11 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot, if (CheckOnlyIfDirty && !fs_isdirty()) { /* No need to check FS */ - return fs_close(FALSE); + // NOTE: Returning the value of fs_close looks suspicious. + // return fs_close(FALSE); + ret = fs_close(FALSE); + DPRINT1("No need to check FS; fs_close returning %d\n", ret); + return STATUS_SUCCESS; } read_boot(&fs); @@ -404,6 +409,8 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot, if (fs_changed()) { + DPRINT1("fs_changed is TRUE!\n"); + if (FixErrors) { if (FsCheckFlags & FSCHECK_INTERACTIVE) @@ -430,7 +437,11 @@ VfatChkdsk(IN PUNICODE_STRING DriveRoot, } /* Close the volume */ - return fs_close(FixErrors) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + // NOTE: Returning the value of fs_close looks suspicious. + // return fs_close(FixErrors) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL; + res = fs_close(FixErrors); + DPRINT1("fs_close returning %d\n", ret); + return STATUS_SUCCESS; } /* EOF */