/usr/include/stxxl/bits/mng/config.h is in libstxxl-dev 1.4.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | /***************************************************************************
* include/stxxl/bits/mng/config.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2002-2005 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2008, 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
* Copyright (C) 2013 Timo Bingmann <tb@panthema.net>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_MNG_CONFIG_HEADER
#define STXXL_MNG_CONFIG_HEADER
#include <vector>
#include <string>
#include <cstdlib>
#include <cassert>
#include <stxxl/version.h>
#include <stxxl/bits/singleton.h>
#include <stxxl/bits/common/log.h>
STXXL_BEGIN_NAMESPACE
//! \addtogroup mnglayer
//! \{
//! Encapsulate the configuration of one "disk". The disk is actually a file
//! I/O object which block_manager uses to read/write blocks.
class disk_config
{
public:
//! \name Basic Disk Configuration Parameters
//! \{
//! the file path used by the io implementation
std::string path;
//! file size to initially allocate
uint64 size;
//! io implementation to access file
std::string io_impl;
//! \}
public:
//! default constructor
disk_config();
//! initializing constructor, also parses fileio parameter
disk_config(const std::string& path, uint64 size, const std::string& fileio);
//! initializing constructor, parse full line as in config files
disk_config(const std::string& line);
//! parse a disk=\<path>,\<size>,\<fileio> options line into disk_config,
//! throws std::runtime_error on parse errors.
void parse_line(const std::string& line);
//! parse the "io_impl" parameter into the optional parameter fields.
void parse_fileio();
//! return formatted fileio name and optional configuration parameters
std::string fileio_string() const;
public:
//! \name Optional Disk / File I/O Implementation Parameters
//! \{
//! autogrow file if more disk space is needed, automatically set if size == 0.
bool autogrow;
//! delete file on program exit (default for autoconfigurated files)
bool delete_on_exit;
//! tristate variable: direct=0 -> force direct OFF, direct=1 -> try direct
//! ON, if fails print warning and open without direct, direct=2 -> force
//! direct ON, fail if unavailable.
enum direct_type { DIRECT_OFF = 0, DIRECT_TRY = 1, DIRECT_ON = 2 } direct;
//! marks flash drives (configuration entries with flash= instead of disk=)
bool flash;
//! select request queue for disk. Use different queues for files on
//! different disks. queue=-1 -> default queue (one for each disk).
int queue;
//! the selected physical device id (e.g. for calculating prefetching
//! sequences). If -1 then the device id is chosen automatically.
unsigned int device_id;
//! turned on by syscall fileio when the path points to a raw block device
bool raw_device;
//! unlink file immediately after opening (available on most Unix)
bool unlink_on_open;
//! desired queue length for linuxaio_file and linuxaio_queue
int queue_length;
//! \}
};
//! Access point to disks properties. Since 1.4.0: no config files are read
//! automatically!
//! \remarks is a singleton
class config : public singleton<config>
{
friend class singleton<config>;
//! typedef of list of configured disks
typedef std::vector<disk_config> disk_list_type;
//! list of configured disks
disk_list_type disks_list;
//! In disks_list, flash devices come after all regular disks
unsigned first_flash;
//! Finished initializing config
bool is_initialized;
//! Constructor: this must be inlined to print the header version
//! string.
inline config()
: is_initialized(false)
{
logger::get_instance();
STXXL_MSG(get_version_string_long());
print_library_version_mismatch();
}
//! deletes autogrow files
~config();
//! Search several places for a config file.
void find_config();
//! If disk list is empty, then search different locations for a disk
//! configuration file, or load a default config if everything fails.
void initialize();
public:
//! \name Initialization Functions
//! \{
//! Check that initialize() was called.
//! \note This function need not be called by the user, block_manager will
//! always call it.
void check_initialized()
{
if (!is_initialized) initialize();
}
//! Load disk configuration file.
void load_config_file(const std::string& config_path);
//! Load default configuration.
void load_default_config();
//! Add a disk to the configuration list.
//!
//! \warning This function should only be used during initialization, as it
//! has no effect after construction of block_manager.
inline config & add_disk(const disk_config& cfg)
{
disks_list.push_back(cfg);
return *this;
}
//! \}
protected:
//! \name Automatic Disk Enumeration Functions
//! \{
//! static counter for automatic physical device enumeration
unsigned int m_max_device_id;
public:
//! Returns automatic physical device id counter
unsigned int get_max_device_id();
//! Returns next automatic physical device id counter
unsigned int get_next_device_id();
//! Update the automatic physical device id counter
void update_max_device_id(unsigned int devid);
//! \}
public:
//! \name Query Functions
//! \{
//! Returns number of disks available to user.
//! \return number of disks
inline size_t disks_number()
{
check_initialized();
return disks_list.size();
}
//! Returns contiguous range of regular disks w/o flash devices in the array of all disks.
//! \return range [begin, end) of regular disk indices
inline std::pair<unsigned, unsigned> regular_disk_range() const
{
assert(is_initialized);
return std::pair<unsigned, unsigned>(0, first_flash);
}
//! Returns contiguous range of flash devices in the array of all disks.
//! \return range [begin, end) of flash device indices
inline std::pair<unsigned, unsigned> flash_range() const
{
assert(is_initialized);
return std::pair<unsigned, unsigned>(first_flash, (unsigned)disks_list.size());
}
//! Returns mutable disk_config structure for additional disk parameters
inline disk_config & disk(size_t disk)
{
check_initialized();
return disks_list[disk];
}
//! Returns constant disk_config structure for additional disk parameters
inline const disk_config & disk(size_t disk) const
{
assert(is_initialized);
return disks_list[disk];
}
//! Returns path of disks.
//! \param disk disk's identifier
//! \return string that contains the disk's path name
inline const std::string & disk_path(size_t disk) const
{
assert(is_initialized);
return disks_list[disk].path;
}
//! Returns disk size.
//! \param disk disk's identifier
//! \return disk size in bytes
inline stxxl::uint64 disk_size(size_t disk) const
{
assert(is_initialized);
return disks_list[disk].size;
}
//! Returns name of I/O implementation of particular disk.
//! \param disk disk's identifier
inline const std::string & disk_io_impl(size_t disk) const
{
assert(is_initialized);
return disks_list[disk].io_impl;
}
//! Returns the total size over all disks
uint64 total_size() const;
//! \}
};
//! \}
STXXL_END_NAMESPACE
#endif // !STXXL_MNG_CONFIG_HEADER
// vim: et:ts=4:sw=4
|