1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (C) 2010 Hajime Taira <htaira@redhat.com> 4f08c3bdfSopenharmony_ci * Masatake Yamato <yamato@redhat.com> 5f08c3bdfSopenharmony_ci * Copyright (c) 2023 Petr Vorel <pvorel@suse.cz> 6f08c3bdfSopenharmony_ci * 7f08c3bdfSopenharmony_ci * Based on fsfreeze from util-linux. 8f08c3bdfSopenharmony_ci */ 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_ci#include <linux/fs.h> 11f08c3bdfSopenharmony_ci#include <stdio.h> 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_ci#define TST_NO_DEFAULT_MAIN 14f08c3bdfSopenharmony_ci#include "tst_test.h" 15f08c3bdfSopenharmony_ci#include "tst_safe_macros.h" 16f08c3bdfSopenharmony_ci 17f08c3bdfSopenharmony_cistatic void help(void) 18f08c3bdfSopenharmony_ci{ 19f08c3bdfSopenharmony_ci printf("Freeze and unfreeze the device.\n"); 20f08c3bdfSopenharmony_ci printf("Usage: tst_fsfreeze device\n"); 21f08c3bdfSopenharmony_ci} 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ciint main(int argc, char *argv[]) 24f08c3bdfSopenharmony_ci{ 25f08c3bdfSopenharmony_ci int fd; 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci if (argc < 2) { 28f08c3bdfSopenharmony_ci help(); 29f08c3bdfSopenharmony_ci return 1; 30f08c3bdfSopenharmony_ci } 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ci fd = SAFE_OPEN(argv[1], O_RDONLY); 33f08c3bdfSopenharmony_ci SAFE_IOCTL(fd, FIFREEZE, 0); 34f08c3bdfSopenharmony_ci SAFE_IOCTL(fd, FITHAW, 0); 35f08c3bdfSopenharmony_ci SAFE_CLOSE(fd); 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_ci return 0; 38f08c3bdfSopenharmony_ci} 39