One of those unusual tests you sometimes need to do is to determine whether a given directory on the filesystem is a mount point for another filesystem.
A good approach to do this is to compare the directory with its parent directory, specifically the device ID as returned by the
stat() system call.
The following code would work:
stat (path, &path_stat);
parent = dirname (path);
stat (parent, &parent_stat);
is_mountpoint = (path_stat.st_dev != parent_stat.st_dev);
If you want to know more information about the filesystem mounted there, you can use the
statfs() system call. This returns, amongst other interesting details, the filesystem type.
if (statfs (path, &statfsbuf) == 0)
is_ext3 = statfsbuf.f_type == EXT3_SUPER_MAGIC;