From the Single Unix Specification - Issue 7:
3.228 Mount Point
Either the system root directory or a directory for which the st_dev field of structure stat differs from that of its parent directory.
Note: The stat structure is defined in detail in <sys/stat.h>.
In other words, yes, you can rely upon the device ID to determine whether you're at a mount point or not. The key to understand what a mount point is involves understanding that if something like /usr resides on the same file system as /, you will never type mount device /usr.
A simple example where /home, /tmp, /usr, and /usr/src are all on different devices:
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat stbuf;
if (stat(".", &stbuf) == -1) {
perror("couldn't get working directory");
return 1;
}
printf("Device ID for directory .: %lX\n", stbuf.st_dev);
/* Loop through the command line arguments. */
while (*++argv) {
if (stat(*argv, &stbuf) == -1) {
fprintf(stderr, "error: couldn't get device ID for directory '%s': %s\n", *argv, strerror(error));
continue;
}
printf("Device ID for directory %s: %lX\n", *argv, stbuf.st_dev);
}
return 0;
}
Sample run:
sh$ ./a.out /usr ~/misc\ files /nonexistent/path /usr/src /tmp
Device ID for directory .: 807
Device ID for directory /usr: 803
Device ID for directory /home/kit/misc files: 807
error: couldn't get device ID for directory '/nonexistent/path': No such file or directory
Device ID for directory /usr/src: 805
Device ID for directory /tmp: 802