-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathVolumeRoster.cpp
53 lines (43 loc) · 1.03 KB
/
VolumeRoster.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* VolumeReader.cpp
*
* Created on: 19/lug/2013
* Author: Stefano Ceccherini
*/
#include "VolumeRoster.h"
#include "Support.h"
#include <iostream>
#include <sstream>
VolumeRoster::VolumeRoster(const char* options)
{
std::string string("export LC_ALL=C; ");
string.append("df -T -l").append(options);
CommandStreamBuffer df(string.c_str(), "r");
std::istream stream(&df);
std::string line;
std::getline(stream, line); // Skip the first line
while (std::getline(stream, line)) {
std::istringstream iss(line);
volume_info info;
std::string dummy;
iss >> info.name;
iss >> info.filesystem;
iss >> info.total;
iss >> dummy;
iss >> info.free;
iss >> dummy;
iss >> info.type;
info.label = info.name;
// TODO: we could use -x to exclude these filesystems,
// but some "df" version doesn't support it (i.e. busybox)
if (info.filesystem != "tmpfs" &&
info.filesystem != "efivarfs" &&
info.filesystem != "overlay") {
fItems.push_back(info);
}
}
Rewind();
}
VolumeRoster::~VolumeRoster()
{
}