libstorage Documentation

Interface

The functionality of libstorage is entirely accessed through the abstract interface class StorageInterface. To ensure maximal possible compatibility user of libstorage must only include the header file StorageInterface.h.

Caching

All modifying functions of libstorage can either operate on an internal cache or directly on the system.

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().

Example

Here is a simple example to demonstrate the usage of libstorage:

 #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.


Generated on Thu Jul 6 00:40:24 2006 for yast2-storage by  doxygen 1.4.6