-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.h
134 lines (108 loc) · 2.69 KB
/
config.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Configuration options for the fstest utility
*
* Copyright (C) 2013 Fraunhofer ITWM, Bernd Schubert
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
************************************************************************/
#include "fstest.h"
#ifndef CONFIG_H_
#define CONFIG_H_
#define MAX_USAGE_PERCENT 90 // fill file system up to this level
#define TIMEOUT -1 // timeout before leaving
// file sizes between min and max
#define DEFAULT_MIN_SIZE_BITS 20 // 2^20 = 1MiB
#define DEFAULT MAX_SIZE_BITS 30 // 2^30 = 1GiB
class Config_fstest {
public:
Config_fstest(void)
{
this->usage_percent = MAX_USAGE_PERCENT;
this->timeout = TIMEOUT;
this->immediate_check = false;
this->testdir = "";
this->min_size_bits = 20;
this->max_size_bits = 30;
}
private:
size_t usage_percent; // max fill level
ssize_t timeout; // in seconds
bool immediate_check;
string testdir;
int min_size_bits;
int max_size_bits;
public:
void set_usage(size_t value)
{
this->usage_percent = value;
}
size_t get_usage(void)
{
return this->usage_percent;
}
void set_timeout(ssize_t value)
{
this->timeout = value;
}
ssize_t get_timeout(void)
{
return this->timeout;
}
void set_immediate_check(bool value)
{
this->immediate_check = value;
}
bool get_immediate_check(void)
{
return this->immediate_check;
}
void set_testdir(string testdir)
{
if ((testdir.length() > 0)
&& (testdir.at(testdir.length() - 1) != '/')) {
testdir += '/';
}
// add pid to directory
pid_t pid = getpid();
stringstream str;
str << pid;
testdir += "fstest." + str.str() + "/";
this->testdir = testdir;
}
string get_testdir(void)
{
return this->testdir;
}
void set_min_size_bits(int min)
{
this->min_size_bits = min;
}
int get_min_size_bits(void)
{
return this->min_size_bits;
}
void set_max_size_bits(int max)
{
this->max_size_bits = max;
}
int get_max_size_bits(void)
{
return this->max_size_bits;
}
};
Config_fstest *get_global_cfg(void);
#endif /* CONFIG_H_ */