| #!/usr/bin/env bash | |
| # This file is part of util-linux. | |
| # | |
| # This file is free software; you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation; either version 2 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # This file is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| # GNU General Public License for more details. | |
| # | |
| # Copyright (C) 2026 Christian Goeschel Ndjomouo <cgoesc2@wgu.edu> | |
| TS_TOPDIR="${0%/*}/../.." | |
| TS_DESC="shadowed" | |
| . "$TS_TOPDIR"/functions.sh | |
| ts_init "$*" | |
| ts_skip_nonroot | |
| ts_check_test_command "$TS_CMD_FINDMNT" | |
| ts_check_test_command "$TS_CMD_MOUNT" | |
| ts_check_test_command "$TS_CMD_UMOUNT" | |
| ts_check_prog "mkfs.ext2" | |
| ts_check_losetup | |
| [ -d "$TS_MOUNTPOINT" ] || mkdir -p "$TS_MOUNTPOINT" | |
| function umount_devs() { | |
| for d in "${@}"; do | |
| $TS_CMD_UMOUNT --force "$d" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| done | |
| } | |
| ts_device_init 10 | |
| DEV1="$TS_LODEV" | |
| mkfs.ext2 -U 102629a1-9058-4ecf-bdb4-94c45f6fe637 "$DEV1" &>/dev/null \ | |
| || ts_die "Cannot make ext2 on $DEV1" | |
| $TS_CMD_MOUNT "$DEV1" "$TS_MOUNTPOINT" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| if ! ts_is_mounted "$DEV1"; then | |
| umount_devs "$DEV1" | |
| ts_die "Cannot find $DEV1 in /proc/mounts" | |
| fi | |
| ts_device_init 10 | |
| DEV2="$TS_LODEV" | |
| mkfs.ext2 -U 7bf0f518-91c5-4ab1-af62-21817ac9c229 "$DEV2" &>/dev/null \ | |
| || ts_die "Cannot make ext2 on $DEV2" | |
| $TS_CMD_MOUNT "$DEV2" "$TS_MOUNTPOINT" >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| if ! ts_is_mounted "$DEV2"; then | |
| umount_devs "$DEV2" "$DEV1" | |
| ts_die "Cannot find $DEV2 in /proc/mounts" | |
| fi | |
| $TS_CMD_FINDMNT --noheadings --shadowed --output TARGET,FSTYPE,UUID "$TS_MOUNTPOINT" \ | |
| >>"$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| sed -i "s@${TS_MOUNTPOINT}@<mountpoint>@" "$TS_OUTPUT" 2>>"$TS_ERRLOG" | |
| umount_devs "$DEV2" "$DEV1" | |
| ts_finalize |