2 * Copyright (c) 2004 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 static char *xprogname;
28 fprintf(stderr, "usage: %s [-f] [-v] mnt-dir\n", xprogname);
32 main(int argc, char *argv[])
44 while ((c = getopt(argc, argv, "fv")) != -1) {
58 /* process required cmd argument */
59 if (optind == argc-1) {
60 mnt_dir = argv[optind];
67 if ((stat(mnt_dir, &st)) == -1) {
68 fprintf(stderr, "%s: error on stat \"%s\": %s\n",
69 xprogname, mnt_dir, strerror(errno));
73 if (!S_ISDIR(st.st_mode)) {
74 fprintf(stderr, "%s: argument \"%s\" is not a directory\n",
83 if ((statvfs(mnt_dir, &stvfs)) == -1) {
84 fprintf(stderr, "%s: error on statfs \"%s\": %s\n",
85 xprogname, mnt_dir, strerror(errno));
89 if (strcmp(stvfs.f_basetype, "xfs") != 0) {
90 fprintf(stderr, "%s: filesys for \"%s\" is not XFS:\"%s\"\n",
91 xprogname, mnt_dir, stvfs.f_basetype);
98 flag = (flushlog_opt ? XFS_FSOP_GOING_FLAGS_LOGFLUSH
99 : XFS_FSOP_GOING_FLAGS_NOLOGFLUSH);
102 printf("Opening \"%s\"\n", mnt_dir);
104 if ((fd = open(mnt_dir, O_RDONLY)) == -1) {
105 fprintf(stderr, "%s: error on open of \"%s\": %s\n",
106 xprogname, mnt_dir, strerror(errno));
111 printf("Calling XFS_IOC_GOINGDOWN\n");
113 syslog(LOG_WARNING, "xfstests-induced forced shutdown of %s:\n",
115 if ((xfsctl(mnt_dir, fd, XFS_IOC_GOINGDOWN, &flag)) == -1) {
116 fprintf(stderr, "%s: error on xfsctl(GOINGDOWN) of \"%s\": %s\n",
117 xprogname, mnt_dir, strerror(errno));