]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/xfs_admin.sh
xfs: zero length symlinks are not valid
[thirdparty/xfsprogs-dev.git] / db / xfs_admin.sh
CommitLineData
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
BN
7status=0
8DB_OPTS=""
9REPAIR_OPTS=""
22bc10ed 10USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-U uuid] device"
2bd0ea18 11
22bc10ed 12while getopts "efjlpuc:L:U:V" c
2bd0ea18
NS
13do
14 case $c in
4af916f8
BN
15 c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;;
16 e) DB_OPTS=$DB_OPTS" -c 'version extflg'";;
17 f) DB_OPTS=$DB_OPTS" -f";;
18 j) DB_OPTS=$DB_OPTS" -c 'version log2'";;
19 l) DB_OPTS=$DB_OPTS" -r -c label";;
20 L) DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";;
22bc10ed 21 p) DB_OPTS=$DB_OPTS" -c 'version projid32bit'";;
4af916f8
BN
22 u) DB_OPTS=$DB_OPTS" -r -c uuid";;
23 U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
138aab65
CH
24 V) xfs_db -p xfs_admin -V
25 status=$?
26 exit $status
27 ;;
2bd0ea18
NS
28 \?) echo $USAGE 1>&2
29 exit 2
30 ;;
31 esac
32done
33set -- extra $@
34shift $OPTIND
35case $# in
4af916f8
BN
36 1) if [ -n "$DB_OPTS" ]
37 then
38 eval xfs_db -x -p xfs_admin $DB_OPTS $1
39 status=$?
40 fi
41 if [ -n "$REPAIR_OPTS" ]
42 then
43 # Hide normal repair output which is sent to stderr
44 # assuming the filesystem is fine when a user is
45 # running xfs_admin.
46 # Ideally, we need to improve the output behaviour
47 # of repair for this purpose (say a "quiet" mode).
48 eval xfs_repair $REPAIR_OPTS $1 2> /dev/null
49 status=`expr $? + $status`
50 if [ $status -ne 0 ]
51 then
52 echo "Conversion failed, is the filesystem unmounted?"
53 fi
54 fi
2bd0ea18
NS
55 ;;
56 *) echo $USAGE 1>&2
57 exit 2
58 ;;
59esac
60exit $status