diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-11 11:53:05 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-11 11:53:05 +0200 |
| commit | b9512fa6b32dacabdec3edf12ebfab927d1402ae (patch) | |
| tree | a56a374006cb3daa324332225b0e2eef42f505f7 /util-linux | |
| parent | a976aaab0be819d11575cbbde64406391ada873b (diff) | |
| download | busybox-w32-b9512fa6b32dacabdec3edf12ebfab927d1402ae.tar.gz busybox-w32-b9512fa6b32dacabdec3edf12ebfab927d1402ae.tar.bz2 busybox-w32-b9512fa6b32dacabdec3edf12ebfab927d1402ae.zip | |
fsfreeze: new applet
NAME
fsfreeze - suspend access to a filesystem (Ext3/4, ReiserFS, JFS, XFS)
SYNOPSIS
fsfreeze --freeze|--unfreeze mountpoint
DESCRIPTION
fsfreeze suspends or resumes access to a filesystem.
fsfreeze halts any new access to the filesystem and creates a stable
image on disk.
AVAILABILITY
The fsfreeze command is part of the util-linux 2.28
function old new delta
fsfreeze_main - 81 +81
applet_names 2597 2606 +9
applet_main 1504 1508 +4
applet_suid 94 95 +1
applet_install_loc 188 189 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/fsfreeze.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/util-linux/fsfreeze.c b/util-linux/fsfreeze.c new file mode 100644 index 000000000..fb1ebdc1e --- /dev/null +++ b/util-linux/fsfreeze.c | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com> | ||
| 4 | * | ||
| 5 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
| 6 | */ | ||
| 7 | |||
| 8 | //config:config FSFREEZE | ||
| 9 | //config: bool "fsfreeze" | ||
| 10 | //config: default y | ||
| 11 | //config: select PLATFORM_LINUX | ||
| 12 | //config: select LONG_OPTS | ||
| 13 | //config: help | ||
| 14 | //config: Halt new accesses and flush writes on a mounted filesystem. | ||
| 15 | |||
| 16 | //applet:IF_FSFREEZE(APPLET(fsfreeze, BB_DIR_SBIN, BB_SUID_DROP)) | ||
| 17 | |||
| 18 | //kbuild:lib-$(CONFIG_FSFREEZE) += fsfreeze.o | ||
| 19 | |||
| 20 | //usage:#define fsfreeze_trivial_usage | ||
| 21 | //usage: "--[un]freeze MOUNTPOINT" | ||
| 22 | //usage:#define fsfreeze_full_usage "\n\n" | ||
| 23 | //usage: "Flush and halt writes to MOUNTPOINT" | ||
| 24 | |||
| 25 | #include "libbb.h" | ||
| 26 | #include <linux/fs.h> | ||
| 27 | |||
| 28 | #ifndef FIFREEZE | ||
| 29 | # define FIFREEZE _IOWR('X', 119, int) | ||
| 30 | # define FITHAW _IOWR('X', 120, int) | ||
| 31 | #endif | ||
| 32 | |||
| 33 | int fsfreeze_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
| 34 | int fsfreeze_main(int argc UNUSED_PARAM, char **argv) | ||
| 35 | { | ||
| 36 | unsigned opts; | ||
| 37 | int fd; | ||
| 38 | |||
| 39 | applet_long_options = | ||
| 40 | "freeze\0" No_argument "\xff" | ||
| 41 | "unfreeze\0" No_argument "\xfe" | ||
| 42 | ; | ||
| 43 | /* exactly one non-option arg: the mountpoint */ | ||
| 44 | /* one of opts is required */ | ||
| 45 | /* opts are mutually exclusive */ | ||
| 46 | opt_complementary = "=1:""\xff:\xfe:""\xff--\xfe:\xfe--\xff"; | ||
| 47 | opts = getopt32(argv, ""); | ||
| 48 | |||
| 49 | fd = xopen(argv[optind], O_RDONLY); | ||
| 50 | /* Works with NULL arg on linux-4.8.0 */ | ||
| 51 | xioctl(fd, (opts & 1) ? FIFREEZE : FITHAW, NULL); | ||
| 52 | |||
| 53 | return EXIT_SUCCESS; | ||
| 54 | } | ||
