code: public void fsck() throws IOException {
      InjectionHandler.processEvent(InjectionEvent.NAMENODE_FSCK_START);
      
      try {
        FileStatus[] files = nn.namesystem.dir.getListing(path);
        FsckResult res = new FsckResult();
        if (!this.showFiles && !this.showBlocks && !this.showLocations
            && !this.showRacks) {
          res.totalRacks = nn.getNetworkTopology().getNumOfRacks();
          res.totalDatanodes = nn.namesystem
              .getNumberOfDatanodes(DatanodeReportType.LIVE);
        }
        res.setReplication((short) conf.getInt("dfs.replication", 3));
        if (files != null) {
          if (showCorruptFileBlocks && showOpenFiles) {
            listCorruptOpenFiles();
          
            return;
          }
  
          if (showCorruptFileBlocks) {
            listCorruptFileBlocks();
            return;
          }
  
          for (int i = 0; i < files.length; i++) {
            check(files[i], res);
          }
          out.println(res);
          // DFSck client scans for the string HEALTHY/CORRUPT to check the status
          // of file system and return appropriate code. Changing the output 
          // string might break testcases. 
          if (res.isHealthy()) {
            out.print("\n\nThe filesystem under path '" + path + "' " + HEALTHY_STATUS);
          } else {
            out.print("\n\nThe filesystem under path '" + path + "' " + CORRUPT_STATUS);
          }
        } else {
          out.print("\n\nPath '" + path + "' " + NONEXISTENT_STATUS);
        }
      } catch (Throwable e) {
        String errMsg = "Fsck on path '" + path + "' " + FAILURE_STATUS;
        LOG.warn(errMsg, e);
        out.println(e.getMessage());
        out.print("\n\n" + errMsg);
      } finally {
        out.close();
      }
    }
docs: Check files on DFS, starting from the indicated path.
  @throws Exception