I don't know English but analyzing is little possible.
I need the source code badblocks.
I hope header file for that too.(ex)com_err.h)
I wish to recommend programs tools, too.
badblocks is part of e2fsprogs, whose source code lives in this git repository. Specifically, you'll find badblocks.c in the misc folder. comm_err.h is in lib/et.