   UNIX Programming Question: Check Mount
  I need to check if a drive has been mounted.  I use struct statData;bool  CD_ROM_Mounted = false;if(stat("/mnt/cdrom", &Data) >= 0){    CD_ROM_Mounted = true;}This bit of code seems to work on the 1st attempt.  When the user removes the drive, I make the following callsystem("umount /mnt/cdrom");Then I insert a USB HD.  I make the same call.if(stat("/mnt/cdrom", &Data) >= 0){    CD_ROM_Mounted = true;}I would expect the stat call to return an error and not set my flag.  However, it sets mt CD Rom flag to true even though the folder should have been unmounted.  Am I doing something obviously wrong?  Should I use a different call to check if a folder is mounted?  Thanks.   
  why don't you check the /etc/mtab file?  It'll tell you whats mounted and where.Cheers, Bob   ;  The stat function is probably not what you want.  And, anyway, that will return zero so long as the directory (or file, or whatever) exists, whether anything's mounted on it or not.  (That stat returns zero doesn't tell you much anyway, you've got to look at the struct stat that it fills in.)See the stat man page (type "man 2 stat")But, to find what's mounted, you probably want getmntent, not stat.  (so, type "man getmntent")You probably do not want to read /etc/mtab directly, You probably want to use getmntent() to do it.  Beware of system specific differences though, HPUX, SYS V, Digital unix, etc have differences (being a game oriented site, I'm guessing you likely don't care about those too much, probably only linux, Mac OS X, and FreeBSD -- but that's a guess.);  Thank you for the suggestions.  Sorry for putting this post in the wrong place.  I should have put it in general programming.   