Am Montag, 14. August 2006 08:27 schrieb Roger Oberholtzer: [...]
This assumes that the mount point will not exist until the media is inserted. This is not always the case. I am interested in the case where the mount point exists even when the media is not mounted. Like in the old days of fstab. BTW, I am hoping to do this from a C program. Preferably without calling a script. Unless the script is better than sliced bread. [...]
Try the statvfs() call (demo program without any checks or validations): #include <stdio.h> #include <sys/statvfs.h> #include <string.h> int main(int argc, char **argv) { char *p = NULL; struct statvfs st; if (argc == 2) p = strdup(argv[1]); else p = strdup("."); statvfs(p, &st); printf("%ld\n", st.f_fsid); free(p); exit(0); } You can check the f_fsid field of the mount point against his parent. If the path is a simple directory, you will get equal f_fsid for both of them, otherwise the mount point will have its own f_fsid. HTH Jan