typedef std::pair CPointTypePair; std::vector GetMountPoints() { std::vector mpoints; #ifdef __BSD__ #if defined(HAVE_SYS_STATVFS_H) && !defined(__FREEBSD__) struct statvfs* mntbuf; #else struct statfs* mntbuf; #endif long size = getmntinfo(&mntbuf, MNT_NOWAIT); for (long i = 0; i < size; i++) { std::string mpoint(mntbuf[i].f_mntonname); std::string mtype(mntbuf[i].f_fstypename); mpoints.push_back(CPointTypePair(mpoint, mtype)); } #elif defined(__SOLARIS__) FILE* mnt_tab = fopen("/etc/mntab", "r"); if (mnt_tab) { struct mntent* entries = getmntent(mnt_tab); while ( entries ) { std::string mpoint(entries->mnt_mountp); std::string mtype(entries->mnt_type); mpoints.push_back(CPointTypePair(mpoint, mtype)); entries = getmntent(mnt_tab); } flose(mnt_tab); } #else FILE* mnt_tab = setmntent(_PATH_FSTAB, "r"); if (mnt_tab) { struct mntent* entries = getmntent(mnt_tab); while ( entries ) { std::string mpoint(entries->mnt_dir); std::string mtype(entries->mnt_type); mpoints.push_back(CPointTypePair(mpoint, mtype)); entries = getmntent(mnt_tab); } endmntent(mnt_tab); } #endif return mpoints; }