summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_msdosfs
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-02-05 06:32:16 +0000
committerbde <bde@FreeBSD.org>2004-02-05 06:32:16 +0000
commit12c02b35e97ff2d4f5bf34a44e06193b4315e534 (patch)
tree9008ab2913063932f40be7efb7bb3092cae7d6a8 /sbin/fsck_msdosfs
parentc03701303f41816c9200f9b8e4a89b06f6a94112 (diff)
downloadFreeBSD-src-12c02b35e97ff2d4f5bf34a44e06193b4315e534.zip
FreeBSD-src-12c02b35e97ff2d4f5bf34a44e06193b4315e534.tar.gz
Prepare to fix checkdirty() by moving it from check.c to fat.c. It is
identical to a subset of readfat(), so it belongs near readfat() if not in it.
Diffstat (limited to 'sbin/fsck_msdosfs')
-rw-r--r--sbin/fsck_msdosfs/check.c43
-rw-r--r--sbin/fsck_msdosfs/fat.c43
2 files changed, 43 insertions, 43 deletions
diff --git a/sbin/fsck_msdosfs/check.c b/sbin/fsck_msdosfs/check.c
index 16de7c7..6a40749 100644
--- a/sbin/fsck_msdosfs/check.c
+++ b/sbin/fsck_msdosfs/check.c
@@ -199,46 +199,3 @@ checkfilesys(const char *fname)
return ret;
}
-
-int
-checkdirty(int fs, struct bootblock *boot)
-{
- off_t off;
- u_char *buffer;
- int ret = 0;
-
- if (boot->ClustMask == CLUST12_MASK)
- return 0;
-
- off = boot->ResSectors;
- off *= boot->BytesPerSec;
-
- buffer = malloc(boot->BytesPerSec);
- if (buffer == NULL) {
- perror("No space for FAT");
- return 1;
- }
-
- if (lseek(fs, off, SEEK_SET) != off) {
- perror("Unable to read FAT");
- goto err;
- }
-
- if (read(fs, buffer, boot->BytesPerSec) != boot->BytesPerSec) {
- perror("Unable to read FAT");
- goto err;
- }
-
- if (buffer[0] == boot->Media && buffer[1] == 0xff && buffer[2] == 0xff
- && ((boot->ClustMask == CLUST16_MASK && buffer[3] == 0x7f)
- || (boot->ClustMask == CLUST32_MASK && buffer[3] == 0x0f
- && buffer[4] == 0xff && buffer[5] == 0xff
- && buffer[6] == 0xff && buffer[7] == 0x07)))
- ret = 0;
- else
- ret = 1;
-
-err:
- free(buffer);
- return ret;
-}
diff --git a/sbin/fsck_msdosfs/fat.c b/sbin/fsck_msdosfs/fat.c
index 9e0aef9..d04661a 100644
--- a/sbin/fsck_msdosfs/fat.c
+++ b/sbin/fsck_msdosfs/fat.c
@@ -52,6 +52,49 @@ static int clustdiffer(cl_t, cl_t *, cl_t *, int);
static int tryclear(struct bootblock *, struct fatEntry *, cl_t, cl_t *);
static int _readfat(int, struct bootblock *, int, u_char **);
+int
+checkdirty(int fs, struct bootblock *boot)
+{
+ off_t off;
+ u_char *buffer;
+ int ret = 0;
+
+ if (boot->ClustMask == CLUST12_MASK)
+ return 0;
+
+ off = boot->ResSectors;
+ off *= boot->BytesPerSec;
+
+ buffer = malloc(boot->BytesPerSec);
+ if (buffer == NULL) {
+ perror("No space for FAT");
+ return 1;
+ }
+
+ if (lseek(fs, off, SEEK_SET) != off) {
+ perror("Unable to read FAT");
+ goto err;
+ }
+
+ if (read(fs, buffer, boot->BytesPerSec) != boot->BytesPerSec) {
+ perror("Unable to read FAT");
+ goto err;
+ }
+
+ if (buffer[0] == boot->Media && buffer[1] == 0xff && buffer[2] == 0xff
+ && ((boot->ClustMask == CLUST16_MASK && buffer[3] == 0x7f)
+ || (boot->ClustMask == CLUST32_MASK && buffer[3] == 0x0f
+ && buffer[4] == 0xff && buffer[5] == 0xff
+ && buffer[6] == 0xff && buffer[7] == 0x07)))
+ ret = 0;
+ else
+ ret = 1;
+
+err:
+ free(buffer);
+ return ret;
+}
+
/*
* Check a cluster number for valid value
*/
OpenPOWER on IntegriCloud