How can I best test if a directory is currently a mount point?

From: Alan Mackenzie (acm_at_muc.de)
Date: 07/31/04


Date: Sat, 31 Jul 2004 12:49:42 +0000

If it makes any difference, I'm in ksh in QNX on a PC.

I want to test if anything is currently mounted on a given directory,
specifically /ramdisk.

/ramdisk is the mount point for a ram disk (wow!), which our project uses
for software builds. The driver is started at the beginning of the
build script and mounted on /ramdisk. At the end, it is umounted and
stopped.

Starting a build when somebody else already has one in progress leads to
fouling up both builds. So....

I added a test at the beginning of the script to test for the thing being
mounted. The best I could come up with was

if mount | grep -q " /ramdisk " ....

However, the mount command is very slow on our QNX system, for some
reason. I want a command which tests "is there anything mounted on
/ramdisk?". Is there anything more direct than grepping mount's output?

Thanks in advance.

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").


Relevant Pages