1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2004-2005 Silicon Graphics, Inc.
12 static cmdinfo_t shutdown_cmd
;
19 int c
, flag
= XFS_FSOP_GOING_FLAGS_NOLOGFLUSH
;
21 while ((c
= getopt(argc
, argv
, "fv")) != -1) {
24 flag
= XFS_FSOP_GOING_FLAGS_LOGFLUSH
;
28 return command_usage(&shutdown_cmd
);
32 if ((xfsctl(file
->name
, file
->fd
, XFS_IOC_GOINGDOWN
, &flag
)) < 0) {
33 perror("XFS_IOC_GOINGDOWN");
45 " Shuts down the filesystem and prevents any further IO from occurring.\n"
47 " By default, shutdown will not flush completed transactions to disk\n"
48 " before shutting the filesystem down, simulating a disk failure or crash.\n"
49 " With -f, the log will be flushed to disk, matching XFS behavior when\n"
50 " metadata corruption is encountered.\n"
52 " -f -- Flush completed transactions to disk before shut down.\n"
59 shutdown_cmd
.name
= "shutdown";
60 shutdown_cmd
.cfunc
= shutdown_f
;
61 shutdown_cmd
.argmin
= 0;
62 shutdown_cmd
.argmax
= 1;
63 shutdown_cmd
.flags
= CMD_NOMAP_OK
| CMD_FLAG_ONESHOT
| CMD_FLAG_FOREIGN_OK
;
64 shutdown_cmd
.args
= _("[-f]");
65 shutdown_cmd
.help
= shutdown_help
;
66 shutdown_cmd
.oneline
=
67 _("shuts down the filesystem where the current file resides");
70 add_command(&shutdown_cmd
);