Created
April 13, 2016 21:46
-
-
Save ralt/ef56b1b564a7a3fcca9a2ca4b11463bd to your computer and use it in GitHub Desktop.
FIGETFROZEN in action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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