diff --git a/src/bin/Jamfile b/src/bin/Jamfile index 78188075c4..c84b457699 100644 --- a/src/bin/Jamfile +++ b/src/bin/Jamfile @@ -17,6 +17,7 @@ AddResources urlwrapper : urlwrapper.rdef ; # standard commands that don't need any additional library StdBinCommands + badblocks.c cal.c catattr.cpp chop.c diff --git a/src/bin/badblocks.c b/src/bin/badblocks.c new file mode 100644 index 0000000000..e5c2c564a8 --- /dev/null +++ b/src/bin/badblocks.c @@ -0,0 +1,39 @@ +#include +#include +#include + +#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; +}