Ai
1 Star 0 Fork 2

BuildOpenSource/busybox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fsfreeze.c 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
Denys Vlasenko 提交于 2022-11-29 21:14 +08:00 . Remove "select PLATFORM_LINUX"
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com>
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
//config:config FSFREEZE
//config: bool "fsfreeze (3.5 kb)"
//config: default y
//config: select LONG_OPTS
//config: help
//config: Halt new accesses and flush writes on a mounted filesystem.
//applet:IF_FSFREEZE(APPLET_NOEXEC(fsfreeze, fsfreeze, BB_DIR_USR_SBIN, BB_SUID_DROP, fsfreeze))
//kbuild:lib-$(CONFIG_FSFREEZE) += fsfreeze.o
//usage:#define fsfreeze_trivial_usage
//usage: "--[un]freeze MOUNTPOINT"
//usage:#define fsfreeze_full_usage "\n\n"
//usage: "Flush and halt writes to MOUNTPOINT"
#include "libbb.h"
#include <linux/fs.h>
#ifndef FIFREEZE
# define FIFREEZE _IOWR('X', 119, int)
# define FITHAW _IOWR('X', 120, int)
#endif
int fsfreeze_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int fsfreeze_main(int argc UNUSED_PARAM, char **argv)
{
unsigned opts;
int fd;
/* exactly one non-option arg: the mountpoint */
/* one of opts is required */
/* opts are mutually exclusive */
opts = getopt32long(argv, "^"
"" /* no opts */
"\0" "=1:""\xff:\xfe:""\xff--\xfe:\xfe--\xff",
"freeze\0" No_argument "\xff"
"unfreeze\0" No_argument "\xfe"
);
fd = xopen(argv[optind], O_RDONLY);
/* Works with NULL arg on linux-4.8.0 */
xioctl(fd, (opts & 1) ? FIFREEZE : FITHAW, NULL);
return EXIT_SUCCESS;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/build-open-source/busybox.git
git@gitee.com:build-open-source/busybox.git
build-open-source
busybox
busybox
master

搜索帮助