]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | #!/bin/sh -f |
959ef981 | 2 | # SPDX-License-Identifier: GPL-2.0 |
2bd0ea18 | 3 | # |
0d3e0b37 | 4 | # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. |
dfc130f3 | 5 | # |
2bd0ea18 | 6 | |
4af916f8 | 7 | status=0 |
e7cd89b2 CH |
8 | require_offline="" |
9 | require_online="" | |
4af916f8 BN |
10 | DB_OPTS="" |
11 | REPAIR_OPTS="" | |
e7cd89b2 | 12 | IO_OPTS="" |
9e5ce7a2 | 13 | REPAIR_DEV_OPTS="" |
1ff584b2 | 14 | LOG_OPTS="" |
ab9d8d69 | 15 | USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]" |
2bd0ea18 | 16 | |
ab9d8d69 | 17 | while getopts "c:efjlL:O:pr:uU:V" c |
2bd0ea18 NS |
18 | do |
19 | case $c in | |
e7cd89b2 CH |
20 | c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG |
21 | require_offline=1 | |
22 | ;; | |
23 | e) DB_OPTS=$DB_OPTS" -c 'version extflg'" | |
24 | require_offline=1 | |
25 | ;; | |
26 | f) DB_OPTS=$DB_OPTS" -f" | |
27 | require_offline=1 | |
28 | ;; | |
29 | j) DB_OPTS=$DB_OPTS" -c 'version log2'" | |
30 | require_offline=1 | |
31 | ;; | |
e9f14248 CH |
32 | l) DB_OPTS=$DB_OPTS" -r -c label" |
33 | IO_OPTS=$IO_OPTS" -r -c label" | |
34 | ;; | |
e7cd89b2 | 35 | L) DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'" |
e9f14248 | 36 | IO_OPTS=$IO_OPTS" -c 'label -s "$OPTARG"'" |
e7cd89b2 CH |
37 | ;; |
38 | O) REPAIR_OPTS=$REPAIR_OPTS" -c $OPTARG" | |
39 | require_offline=1 | |
40 | ;; | |
41 | p) DB_OPTS=$DB_OPTS" -c 'version projid32bit'" | |
42 | require_offline=1 | |
43 | ;; | |
44 | r) REPAIR_DEV_OPTS=" -r '$OPTARG'" | |
45 | require_offline=1 | |
46 | ;; | |
47 | u) DB_OPTS=$DB_OPTS" -r -c uuid" | |
48 | IO_OPTS=$IO_OPTS" -r -c fsuuid" | |
49 | ;; | |
50 | U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'" | |
51 | require_offline=1 | |
52 | ;; | |
138aab65 CH |
53 | V) xfs_db -p xfs_admin -V |
54 | status=$? | |
55 | exit $status | |
56 | ;; | |
2bd0ea18 NS |
57 | \?) echo $USAGE 1>&2 |
58 | exit 2 | |
59 | ;; | |
60 | esac | |
61 | done | |
62 | set -- extra $@ | |
63 | shift $OPTIND | |
64 | case $# in | |
8db10a9a | 65 | 1|2) |
e7cd89b2 CH |
66 | if mntpt="$(findmnt -t xfs -f -n -o TARGET "$1" 2>/dev/null)"; then |
67 | # filesystem is mounted | |
68 | if [ -n "$require_offline" ]; then | |
69 | echo "$1: filesystem is mounted." | |
70 | exit 2 | |
71 | fi | |
72 | ||
73 | if [ -n "$IO_OPTS" ]; then | |
77e8ce78 CH |
74 | eval xfs_io -p xfs_admin $IO_OPTS "$mntpt" |
75 | exit $? | |
e7cd89b2 CH |
76 | fi |
77 | fi | |
78 | ||
79 | # filesystem is not mounted | |
80 | if [ -n "$require_online" ]; then | |
81 | echo "$1: filesystem is not mounted" | |
82 | exit 2 | |
83 | fi | |
84 | ||
8db10a9a DW |
85 | # Pick up the log device, if present |
86 | if [ -n "$2" ]; then | |
1ff584b2 | 87 | LOG_OPTS=" -l '$2'" |
8db10a9a DW |
88 | fi |
89 | ||
90 | if [ -n "$DB_OPTS" ] | |
4af916f8 | 91 | then |
1ff584b2 | 92 | eval xfs_db -x -p xfs_admin $LOG_OPTS $DB_OPTS "$1" |
4af916f8 BN |
93 | status=$? |
94 | fi | |
95 | if [ -n "$REPAIR_OPTS" ] | |
96 | then | |
88ad1300 | 97 | echo "Running xfs_repair to upgrade filesystem." |
1ff584b2 | 98 | eval xfs_repair $LOG_OPTS $REPAIR_DEV_OPTS $REPAIR_OPTS "$1" |
4af916f8 | 99 | status=`expr $? + $status` |
4af916f8 | 100 | fi |
2bd0ea18 NS |
101 | ;; |
102 | *) echo $USAGE 1>&2 | |
103 | exit 2 | |
104 | ;; | |
105 | esac | |
106 | exit $status |