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().
#include <y2storage/StorageInterface.h> using namespace std; using namespace storage; int main () { // First we must create a concrete StorageInterface object. StorageInterface* s = createStorageInterface (false, false, true); int ret; string name; // Create a primary partition on /dev/hda. ret = s->createPartitionKb ("/dev/hda", PRIMARY, 0, 100000, name); // Commit the change to the system. ret = s->commit (); // Finally destroy the StorageInterface object. delete s; }
If you have installed the latest yast2-storage package you can find more examples in the directory /usr/share/doc/packages/yast2-storage/examples/liby2storage.