1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2004 Silicon Graphics, Inc.
10 static char *xprogname;
16 fprintf(stderr, "usage: %s [-f] [-v] mnt-dir\n", xprogname);
20 main(int argc, char *argv[])
32 while ((c = getopt(argc, argv, "fv")) != -1) {
46 /* process required cmd argument */
47 if (optind == argc-1) {
48 mnt_dir = argv[optind];
55 if ((stat(mnt_dir, &st)) == -1) {
56 fprintf(stderr, "%s: error on stat \"%s\": %s\n",
57 xprogname, mnt_dir, strerror(errno));
61 if (!S_ISDIR(st.st_mode)) {
62 fprintf(stderr, "%s: argument \"%s\" is not a directory\n",
71 if ((statvfs(mnt_dir, &stvfs)) == -1) {
72 fprintf(stderr, "%s: error on statfs \"%s\": %s\n",
73 xprogname, mnt_dir, strerror(errno));
77 if (strcmp(stvfs.f_basetype, "xfs") != 0) {
78 fprintf(stderr, "%s: filesys for \"%s\" is not XFS:\"%s\"\n",
79 xprogname, mnt_dir, stvfs.f_basetype);
86 flag = (flushlog_opt ? XFS_FSOP_GOING_FLAGS_LOGFLUSH
87 : XFS_FSOP_GOING_FLAGS_NOLOGFLUSH);
90 printf("Opening \"%s\"\n", mnt_dir);
92 if ((fd = open(mnt_dir, O_RDONLY)) == -1) {
93 fprintf(stderr, "%s: error on open of \"%s\": %s\n",
94 xprogname, mnt_dir, strerror(errno));
99 printf("Calling XFS_IOC_GOINGDOWN\n");
101 syslog(LOG_WARNING, "xfstests-induced forced shutdown of %s:\n",
103 if ((xfsctl(mnt_dir, fd, XFS_IOC_GOINGDOWN, &flag)) == -1) {
104 fprintf(stderr, "%s: error on xfsctl(GOINGDOWN) of \"%s\": %s\n",
105 xprogname, mnt_dir, strerror(errno));