2025-04-18 01:08:41 -05:00
|
|
|
#include "fs_mounts.hpp"
|
|
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
|
|
#include <mntent.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
void
|
|
|
|
|
fs::mounts(fs::MountVec &mounts_)
|
|
|
|
|
{
|
|
|
|
|
FILE *f;
|
|
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
f = ::setmntent("/proc/mounts","r");
|
2025-04-18 01:08:41 -05:00
|
|
|
if(f == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
struct mntent *entry;
|
2025-07-25 17:53:48 -05:00
|
|
|
while((entry = ::getmntent(f)) != NULL)
|
2025-04-18 01:08:41 -05:00
|
|
|
{
|
|
|
|
|
fs::Mount m;
|
|
|
|
|
|
|
|
|
|
m.dir = entry->mnt_dir;
|
|
|
|
|
m.fsname = entry->mnt_fsname;
|
|
|
|
|
m.type = entry->mnt_type;
|
|
|
|
|
m.opts = entry->mnt_opts;
|
|
|
|
|
|
|
|
|
|
mounts_.emplace_back(std::move(m));
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-25 17:53:48 -05:00
|
|
|
::endmntent(f);
|
2025-04-18 01:08:41 -05:00
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
void
|
|
|
|
|
fs::mounts(fs::MountVec &mounts_)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endif
|