thejartender
thejartender

Reputation: 9379

Is there a way to test if a directories contents are only there because of a mount?

There are too many keywords in my question to google this :) I have a bash scripts and wish to test if a directory is only poupulated because of a mountI did in the script. IOW, the following events have occured:

1)The directory was created with the -p argument eg: mkdir -p myDir

2)It has been established that the system use VirtualBox:

if [ -f /sbin/mount.vboxsf ]
then
    echo "VirtualBox has been detected Please provide your home/user name and hit [Enter]"
    echo "If no name is given, NetBeans will be installed and script will exit Otherwise an attempt will be made
    to mount NetBeansProjects from the host. If this succeeds, an attempt will be made to automatically do this
    during system start up."
    read user
fi

Now I try an presumptuous mount to the 'myDir'

Is there a way to test this Projects directory after based on the contents? IOW, the directory is not empty and I need to establish that the contents are there because I mounted to the directory and not because the directory already contained them.

Thank you, Yucca

Upvotes: 1

Views: 120

Answers (1)

Chewie
Chewie

Reputation: 7235

Just check if myDir is a mount point.

mountpoint -q myDir && echo "This is a mount point."

Upvotes: 3

Related Questions