#!/bin/sh
#
# shellcheck disable=
#
# Copyright (c) 2021-2026 openmediavault plugin developers
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#

export LC_ALL=C.UTF-8

mnts=""

if [ -n "${1}" ]; then
  for dir in ${1}; do
    if [ "${dir}" = ".." ] || [ "${dir}" = "." ]; then
      continue
    fi
    if [ "$(basename "${dir}")" = "lost+found" ]; then
      continue
    fi
    if [ -d "${dir}" ]; then
      mnt="$(findmnt --first-only --noheadings --output TARGET --target "${dir}")"
      if [ -z "${mnt}" ] || [ "${mnt}" = "/" ]; then
        continue
      fi
      if [ -z "${mnts}" ]; then
        mnts="${mnt}"
      else
        mnts="${mnts} ${mnt}"
      fi
    fi
  done
fi

echo "${mnts}"
