Added a few previously unversioned utils.
[utils.git] / trunc.c
diff --git a/trunc.c b/trunc.c
new file mode 100644 (file)
index 0000000..1df035b
--- /dev/null
+++ b/trunc.c
@@ -0,0 +1,22 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+    if(argc < 3) {
+       fprintf(stderr, "usage: trunc FILE SIZE\n");
+       exit(1);
+    }
+    if(truncate(argv[1], atoll(argv[2]))) {
+       perror(argv[1]);
+       exit(1);
+    }
+    return(0);
+}
+
+/*
+ * Local Variables:
+ * compile-command: "gcc -Wall -g -o trunc trunc.c -D_FILE_OFFSET_BITS=64"
+ * End:
+ */