2014-06-14 11:48:10 -04:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2014-06-30 14:03:41 -04:00
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2014-06-14 11:48:10 -04:00
|
|
|
#include <unistd.h>
|
2014-06-30 14:03:41 -04:00
|
|
|
|
2014-06-14 11:48:10 -04:00
|
|
|
#include "util.h"
|
|
|
|
|
2014-06-14 15:39:47 -04:00
|
|
|
#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
|
2014-06-14 11:48:10 -04:00
|
|
|
#define FITHAW _IOWR('X', 120, int) /* Thaw */
|
|
|
|
|
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
eprintf("usage: %s [-f] [-u] mountpoint\n", 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]);
|
2014-06-26 11:17:57 -04:00
|
|
|
if (ioctl(fd, fflag == 1 ? FIFREEZE : FITHAW, &p) < 0)
|
|
|
|
eprintf("%s %s:", fflag == 1 ? "FIFREEZE" : "FITHAW", argv[0]);
|
2014-06-14 11:48:10 -04:00
|
|
|
close(fd);
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|