Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
statfs (batch)

Schedule a batch of asynchronous volume enumerations after preceding operations.

Description

Related types: statfs_t

Synopsis
future< statfs_t > dispatcher::statfs(const std::vector< future<>> & ops, const std::vector< fs_metadata_flags > & reqs)
Parameters

Type

Concept

Name

Description

const std::vector< future<>> &

ops

A batch of op handles.

const std::vector< fs_metadata_flags > &

reqs

A batch of metadata requests.

Returns

A batch of stl_future volume metadatas.

Header

#include <boost/afio/v2/afio.hpp>

Race Guarantees

Operating system Race guarantees under a changing file system
FreeBSD, OS X Race free.
Linux The following items are fetched in a single snapshot: bsize, iosize, blocks, bfree, bavail, files, ffree, namemax, fsid, flags.rdonly, flags.noexec, flags.nosuid.
Windows The following snapshot categories apply: (i) flags, namemax, fstypename (ii) bsize, blocks, bfree, bavail. Everything else is fetched separately.

Complexity

Amortised O(N) to dispatch. Amortised O(N/threadpool*M) to complete where M is the average number of entries in each directory.

Exception Model

Propagates exceptions of any input preconditions with an errored state at the point of dispatch, and throws a std::invalid_argument if any inputs have values which could not possibly be correct. Once a batch of input ops has been verified at the point of entry as not errored, you are guaranteed that the batch is atomically scheduled as a whole, unless a failure to allocate memory occurs.

Example
boost::afio::current_dispatcher_guard h(boost::afio::make_dispatcher().get());

// Open the root directory
boost::afio::handle_ptr rootdir(boost::afio::dir("/"));

// Ask the filing system of the root directory how much free space there is
boost::afio::statfs_t statfs(
boost::afio::statfs(rootdir, boost::afio::fs_metadata_flags::bsize |
                             boost::afio::fs_metadata_flags::bfree));

std::cout << "Your root filing system has "
          << (statfs.f_bfree * statfs.f_bsize / 1024.0 / 1024.0 / 1024.0)
          << " Gb free." << std::endl;


PrevUpHomeNext