2011-12-06 02:23:28 +00:00
|
|
|
/*
|
|
|
|
* badblocks.c - Bad blocks checker
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992, 1993, 1994 Remy Card <card@masi.ibp.fr>
|
|
|
|
* Laboratoire MASI, Institut Blaise Pascal
|
|
|
|
* Universite Pierre et Marie Curie (Paris VI)
|
|
|
|
*
|
|
|
|
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o
|
|
|
|
* Copyright 1999 by David Beattie
|
|
|
|
* Copyright 2011 by Pete Batard
|
|
|
|
*
|
|
|
|
* This file is based on the minix file system programs fsck and mkfs
|
|
|
|
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
|
|
|
|
*
|
|
|
|
* %Begin-Header%
|
|
|
|
* This file may be redistributed under the terms of the GNU Public
|
|
|
|
* License.
|
|
|
|
* %End-Header%
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#ifndef __u32
|
|
|
|
#define __u32 UINT32
|
|
|
|
#endif
|
|
|
|
typedef UINT32 blk_t;
|
|
|
|
typedef struct ext2_struct_u32_list *ext2_badblocks_list;
|
|
|
|
typedef struct ext2_struct_u32_iterate *ext2_badblocks_iterate;
|
|
|
|
typedef struct ext2_struct_u32_list *ext2_u32_list;
|
|
|
|
typedef struct ext2_struct_u32_iterate *ext2_u32_iterate;
|
|
|
|
typedef long errcode_t;
|
|
|
|
|
|
|
|
#define EXT2_ET_NO_MEMORY (2133571398L)
|
|
|
|
#define EXT2_ET_MAGIC_BADBLOCKS_LIST (2133571330L)
|
|
|
|
#define EXT2_ET_MAGIC_BADBLOCKS_ITERATE (2133571331L)
|
|
|
|
|
|
|
|
#define EXT2_CHECK_MAGIC(struct, code) \
|
|
|
|
if ((struct)->magic != (code)) return (code)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Badblocks list
|
|
|
|
*/
|
|
|
|
struct ext2_struct_u32_list {
|
|
|
|
int magic;
|
|
|
|
int num;
|
|
|
|
int size;
|
|
|
|
__u32 *list;
|
|
|
|
int badblocks_flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ext2_struct_u32_iterate {
|
|
|
|
int magic;
|
|
|
|
ext2_u32_list bb;
|
|
|
|
int ptr;
|
|
|
|
};
|
|
|
|
|
2011-12-06 14:05:53 +00:00
|
|
|
/* Test type */
|
|
|
|
enum {
|
|
|
|
BADBLOCKS_RO, /* Read-only */
|
|
|
|
BADBLOCKS_RW, /* *DESTRUCTIVE* read-write */
|
|
|
|
BADBLOCKS_ND /* non-destructive read-write */
|
|
|
|
};
|
|
|
|
|
2011-12-06 02:23:28 +00:00
|
|
|
/*
|
|
|
|
* Shared prototypes
|
|
|
|
*/
|
2011-12-06 14:05:53 +00:00
|
|
|
int BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size, int test_type);
|