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
21 static char *xprogname;
27 fprintf(stderr, "usage: %s [-f] [-v] mnt-dir\n", xprogname);
31 main(int argc, char *argv[])
43 while ((c = getopt(argc, argv, "fv")) != -1) {
57 /* process required cmd argument */
58 if (optind == argc-1) {
59 mnt_dir = argv[optind];
66 if ((stat(mnt_dir, &st)) == -1) {
67 fprintf(stderr, "%s: error on stat \"%s\": %s\n",
68 xprogname, mnt_dir, strerror(errno));
72 if (!S_ISDIR(st.st_mode)) {
73 fprintf(stderr, "%s: argument \"%s\" is not a directory\n",
82 if ((statvfs(mnt_dir, &stvfs)) == -1) {
83 fprintf(stderr, "%s: error on statfs \"%s\": %s\n",
84 xprogname, mnt_dir, strerror(errno));
88 if (strcmp(stvfs.f_basetype, "xfs") != 0) {
89 fprintf(stderr, "%s: filesys for \"%s\" is not XFS:\"%s\"\n",
90 xprogname, mnt_dir, stvfs.f_basetype);
97 flag = (flushlog_opt ? XFS_FSOP_GOING_FLAGS_LOGFLUSH
98 : XFS_FSOP_GOING_FLAGS_NOLOGFLUSH);
101 printf("Opening \"%s\"\n", mnt_dir);
103 if ((fd = open(mnt_dir, O_RDONLY)) == -1) {
104 fprintf(stderr, "%s: error on open of \"%s\": %s\n",
105 xprogname, mnt_dir, strerror(errno));
110 printf("Calling XFS_IOC_GOINGDOWN\n");
112 if ((xfsctl(mnt_dir, fd, XFS_IOC_GOINGDOWN, &flag)) == -1) {
113 fprintf(stderr, "%s: error on xfsctl(GOINGDOWN) of \"%s\": %s\n",
114 xprogname, mnt_dir, strerror(errno));