[hackers] [ubase] Add fsfreeze(8) || sin
commit 5d85bb0cfe86c81e8b5e973098491faad23e66e0
Author: sin <sin_AT_2f30.org>
Date: Sat Jun 14 16:48:10 2014 +0100
Add fsfreeze(8)
diff --git a/Makefile b/Makefile
index ed73272..08513b2 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -31,6 +31,7 @@ SRC = \
eject.c \
fallocate.c \
free.c \
+ fsfreeze.c \
getty.c \
halt.c \
hwclock.c \
diff --git a/fsfreeze.c b/fsfreeze.c
new file mode 100644
index 0000000..24f55dc
--- /dev/null
+++ b/fsfreeze.c
_AT_@ -0,0 +1,51 @@
+/* See LICENSE file for copyright and license details. */
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "util.h"
+
+#define FIFREEZE _IOWR('X', 119, int /* Freeze */
+#define FITHAW _IOWR('X', 120, int) /* Thaw */
+
+static void
+usage(void)
+{
+ eprintf("usage: %s [-f] [-u] mountpoint
", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int fflag = 0;
+ int uflag = 0;
+ long p = 1;
+ int fd;
+
+ ARGBEGIN {
+ case 'f':
+ fflag = 1;
+ break;
+ case 'u':
+ uflag = 1;
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc != 1)
+ usage();
+
+ if ((fflag ^ uflag) == 0)
+ usage();
+
+ fd = open(argv[0], O_RDONLY);
+ if (fd < 0)
+ eprintf("open: %s:", argv[0]);
+ ioctl(fd, fflag == 1 ? FIFREEZE : FITHAW, &p);
+ close(fd);
+ return EXIT_SUCCESS;
+}
Received on Sat Jun 14 2014 - 17:49:49 CEST
This archive was generated by hypermail 2.3.0
: Sat Jun 14 2014 - 18:00:14 CEST