workspace: add dosfstools

This adds dosfstools for its FAT32 fsck which is going to be used for
the FAT32 integration tests.

Change-Id: Ie4ae13ad3a63581868fea69fa7d91a27044f1d3b
Reviewed-on: https://review.monogon.dev/c/monogon/+/842
Tested-by: Jenkins CI
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/third_party/dosfstools/dosfstools.bzl b/third_party/dosfstools/dosfstools.bzl
new file mode 100644
index 0000000..6202cfe
--- /dev/null
+++ b/third_party/dosfstools/dosfstools.bzl
@@ -0,0 +1,42 @@
+load("@rules_cc//cc:defs.bzl", "cc_binary")
+load("@dev_source_monogon//build/utils:template_file.bzl", "template_file")
+
+cc_binary(
+    name = "fsck",
+    srcs = [
+        "src/boot.c",
+        "src/boot.h",
+        "src/charconv.c",
+        "src/charconv.h",
+        "src/check.c",
+        "src/check.h",
+        "src/common.c",
+        "src/common.h",
+        "src/endian_compat.h",
+        "src/fat.c",
+        "src/fat.h",
+        "src/file.c",
+        "src/file.h",
+        "src/fsck.fat.c",
+        "src/fsck.fat.h",
+        "src/io.c",
+        "src/io.h",
+        "src/lfn.c",
+        "src/lfn.h",
+        "src/msdos_fs.h",
+        ":version.h",
+    ],
+    copts = ["-DHAVE_ENDIAN_H"],
+    visibility = ["//visibility:public"],
+    includes = ["."],
+)
+
+template_file(
+    name = "version.h",
+    src = "src/version.h.in",
+    substitutions = {
+        # ONCHANGE(//third_party/dosfstools:external.bzl): version needs to be kept in sync
+        "@PACKAGE_VERSION@": "unstable-2022-07-25",
+        "@RELEASE_DATE@": "2022-07-25",
+    },
+)