commit f0eb6bf2db288821c38ede6f6fb40edb33d8dd94
parent 3245a5349a22c21a371c197168127ae5ef788f3a
Author: Richard Ipsum <richardipsum@vx21.xyz>
Date:   Sat, 30 Apr 2022 20:15:28 +0100
sparsemap: add platform check
sparsemap requires SEEK_HOLE, which some platforms such as OpenBSD
do not provide. exit early with an error if SEEK_HOLE isn't available.
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sparseutils/sparsemap.py b/sparseutils/sparsemap.py
@@ -1,6 +1,6 @@
 # sparsemap
 #
-# Copyright © 2017 Richard Ipsum
+# Copyright © 2017 - 2022 Richard Ipsum
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -71,6 +71,11 @@ def sparsemap(fd):
         what = os.SEEK_DATA if what == os.SEEK_HOLE else os.SEEK_HOLE
 
 def main():
+    if not hasattr(os, 'SEEK_HOLE'):
+        msgfmt = "{}: error: platform does not provide SEEK_HOLE"
+        print(msgfmt.format(sys.argv[0]), file=sys.stderr)
+        sys.exit(1)
+
     parser = argparse.ArgumentParser(
                     description=DESCRIPTION,
                     formatter_class=argparse.RawDescriptionHelpFormatter)