From: Darrick J. Wong <djwong@xxxxxxxxxx> Define some exit codes that xfs_db will return when a sysadmin uses it (or more likely xfs_admin) to add a feature to the filesystem. At the moment we return zero for successful upgrades and 1 for fs errors, though we also allow for returning 2 if the upgrade cannot be applied because the fs cannot handle it. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- db/sb.c | 6 +++++- db/xfs_admin.sh | 3 +++ man/man8/xfs_db.8 | 8 ++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/db/sb.c b/db/sb.c index d09f653d..f306e939 100644 --- a/db/sb.c +++ b/db/sb.c @@ -617,6 +617,9 @@ do_version(xfs_agnumber_t agno, uint16_t version, uint32_t features) tsb.sb_bad_features2 = features; libxfs_sb_to_disk(iocur_top->data, &tsb); write_cur(); + if (!iocur_top->bp || iocur_top->bp->b_error) + return 0; + return 1; } @@ -804,7 +807,8 @@ version_f( if (!do_version(ag, version, features)) { dbprintf(_("failed to set versionnum " "in AG %d\n"), ag); - break; + exitcode = 1; + return 1; } mp->m_sb.sb_versionnum = version; mp->m_sb.sb_features2 = features; diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh index 71a9aa98..5c57b461 100755 --- a/db/xfs_admin.sh +++ b/db/xfs_admin.sh @@ -46,6 +46,9 @@ case $# in eval xfs_db -x -p xfs_admin $DB_OPTS "$1" status=$? fi + if [ $status -eq 1 ]; then + echo "Conversion failed due to filesystem errors; run xfs_repair." + fi if [ -n "$REPAIR_OPTS" ] then # Hide normal repair output which is sent to stderr diff --git a/man/man8/xfs_db.8 b/man/man8/xfs_db.8 index 58727495..ee57b03a 100644 --- a/man/man8/xfs_db.8 +++ b/man/man8/xfs_db.8 @@ -981,6 +981,14 @@ and .I features2 bits respectively, and their string equivalent reported (but no modifications are made). +.IP +If the feature upgrade succeeds, the program will return 0. +If the requested upgrade has already been applied to the filesystem, the +program will also return 0. +If the upgrade fails due to corruption or IO errors, the program will return +1. +If the requested upgrade is not appropriate for this filesystem, the program +will return 2. .TP .BI "write [\-c|\-d] [" "field value" "] ..." Write a value to disk.