When the caching mode is enabled a call of e.g. createPartition() will only change the internal cache. The user has to call commit() later on to actually create the partition on the disk.
When caching mode is disabled the call of e.g. createPartition() will immediately create the partition on the disk.
Caching mode can be set with setCacheChanges() and queried with isCacheChanges().
Several processes may hold a read-lock, but only one process may hold a read-write lock. An read-write lock excludes all other locks, both read-only and read-write.
The support for multiple read-only locks is experimental.
Locking may also fail for other reasons, e.g. limited permissions.
The only size in bytes instead of kilobytes is the cylinder size of disks.
#include <storage/StorageInterface.h> using namespace storage; int main() { // Environment for StorageInterface with read-write enabled. Environment env(false); // Create a concrete StorageInterface object. StorageInterface* s = createStorageInterface(env); int ret; string name; // Create a primary partition on /dev/sdb. ret = s->createPartitionKb("/dev/sdb", PRIMARY, 0, 100000, name); // Commit the change to the system. ret = s->commit(); // Finally destroy the StorageInterface object. destroyStorageInterface(s); }
If you have installed the latest libstorage-devel package you can find more examples in the directory /usr/share/doc/packages/libstorage/examples.