
# Grow rootfs ext4 to fill its partition. Build's mkfs sizes the image at
# ~1.2x rootfs content (function-img.sh), so on a 57G eMMC partition the fs
# starts at ~2.5G. resize2fs is idempotent (no-op once at max), safe each
# boot. Old check used /dev/rootfs which is never created by udev — silently
# skipped resize.
ROOT_DEV="$(findmnt -no SOURCE / 2>/dev/null)"
if [ -n "$ROOT_DEV" ] && [ -b "$ROOT_DEV" ]; then
    resize2fs "$ROOT_DEV" 2>/dev/null && echo "resize2fs $ROOT_DEV done"
fi

if [ -f "/etc/load_media_modules.sh" ]; then
    dos2unix /etc/load_media_modules.sh
    chmod +x /etc/load_media_modules.sh
    /etc/load_media_modules.sh
fi

echo "amlogic root environment setting done"
