Skip to content

Instantly share code, notes, and snippets.

@ralt
Created April 13, 2016 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralt/ef56b1b564a7a3fcca9a2ca4b11463bd to your computer and use it in GitHub Desktop.
Save ralt/ef56b1b564a7a3fcca9a2ca4b11463bd to your computer and use it in GitHub Desktop.
FIGETFROZEN in action
root@localhost:/mnt# gcc is_frozen.c -o is_frozen
root@localhost:/mnt# ./is_frozen /
frozen status: 0
root@localhost:/mnt# fsfreeze --freeze /
root@localhost:/mnt# ./is_frozen /
frozen status: 4
root@localhost:/mnt# fsfreeze --unfreeze /
root@localhost:/mnt# ./is_frozen /
frozen status: 0
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
int
main(int argc, char* argv[])
{
int fd;
int frozen;
if (argc != 2)
{
printf("usage: ./is_frozen <mountpoint>\n");
return -1;
}
fd = open(argv[1], O_RDONLY);
if (fd < 0)
return -errno;
if (ioctl(fd, FIGETFROZEN, &frozen) < 0)
return -errno;
printf("frozen status: %d\n", frozen);
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment