Exemple #1
0
bool
SystemInformation::s_getFileSystem(fs_cont& out)
{
#if defined(OS_LINUX)
	FILE* fp(setmntent(_PATH_MOUNTED, "r"));
	if ( nullptr == fp ) return false;

	fs_cont tmp;
	fs_type fs;

	struct mntent mntbuf;
	char buf[1024+1];

	while ( nullptr not_eq getmntent_r(fp, &mntbuf, buf, sizeof(buf)) )
	{
		if ( not s_getFileSystem(fs, mntbuf.mnt_dir) )
		{
			::fclose(fp);
			return false;
		}

		tmp.insert(fs_cont::value_type(mntbuf.mnt_dir, fs));
	}

	::fclose(fp);
	out.swap(tmp);

	return true;
#elif defined(OS_BSD) || defined(OS_APPLE)
	auto fstab = getfsent();
	if ( nullptr == fstab ) return false;
	
	fs_cont tmp;
	fs_type fs;
	while ( fstab )
	{
		if ( not s_getFileSystem(fs, fstab->fs_file) )
		{
			endfsent();
			return false;
		}
		
		tmp.insert(fs_cont::value_type(fstab->fs_file, fs));
		++fstab;
	}
	
	endfsent();
	out.swap(tmp);
	
	return true;
#endif
}
Exemple #2
0
bool
SystemInformation::s_getFileSystem(fs_cont& out)
{
	FILE* fp(setmntent(_PATH_MOUNTED, "r"));
	if ( nullptr == fp ) return false;

	fs_cont tmp;
	fs_type fs;

	struct mntent mntbuf;
	char buf[1024+1];

	while ( nullptr not_eq getmntent_r(fp, &mntbuf, buf, sizeof(buf)) )
	{
		if ( not s_getFileSystem(fs, mntbuf.mnt_dir) )
		{
			::fclose(fp);
			return false;
		}

		tmp.insert(fs_cont::value_type(mntbuf.mnt_dir, fs));
	}

	::fclose(fp);
	out.swap(tmp);

	return true;
}
Exemple #3
0
bool
SystemInformation::getAll(void)
{
	if ( not s_getOS(m_os) ) return false;
	if ( not s_getCPU(m_cpu) ) return false;
	if ( not s_getMemory(m_memory) ) return false;
	if ( not s_getNIC(m_nic) ) return false;
	if ( not s_getFileSystem(m_fs) ) return false;

	return true;
}