An old tool to detect bad blocks on disk. Will need that RSN :^)
Needs some spicing up. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28722 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,6 +17,7 @@ AddResources urlwrapper : urlwrapper.rdef ;
|
|||||||
|
|
||||||
# standard commands that don't need any additional library
|
# standard commands that don't need any additional library
|
||||||
StdBinCommands
|
StdBinCommands
|
||||||
|
badblocks.c
|
||||||
cal.c
|
cal.c
|
||||||
catattr.cpp
|
catattr.cpp
|
||||||
chop.c
|
chop.c
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#define BS 256
|
||||||
|
|
||||||
|
char buff[BS];
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
off_t at = 0LL;
|
||||||
|
off_t block = 0L;
|
||||||
|
int fd;
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("badblocks /dev/disk/...\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
fd = open(argv[1], O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("open");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for (; ; block++, at+=BS) {
|
||||||
|
if (lseek(fd, at, SEEK_SET) < 0) {
|
||||||
|
perror("lseek");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (read(fd, buff, BS) < BS) {
|
||||||
|
if (errno != EIO && errno != ENXIO) {
|
||||||
|
perror("read");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("%Ld\n", block);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user