VTOC reading.

Diskomizer has to be able to read the VTOC (volume table of contents) from raw devices that it is testing to establish their size. Typically Diskomizer can do this using the read_vtoc(3EXT) routine. However there could be devices attached that are not supported by the read_vtoc(3EXT) routine. To allow users to use Diskomizer against these devices; Diskomizer can use a user supplied routine from a user supplied shared library to read the VTOC and pass the VTOC information back to Diskomizer in the correct form.

The option “VTOC_USER_LIB” should be set to be the full path to a shared object of the correct instruction set, containing a single symbol “user_read_vtoc” which has to be the entry point to a routine with the following semantics:

#include <diskomizer/user_vtoc.h>

struct disko_vtoc *user_read_vtoc(int fd);

The routine is called with the file descriptor from which to read the VTOC and should return a pointer to a “struct disko_vtoc” allocated using “alloc_disko_vtoc(uint_t count)” routine. alloc_disko_vtoc will return a pointer to a “struct disko_vtoc” large enough to store “count” partitions. The disko_vtoc structure looks like this:

struct disko_partition {
        uint64_t p_tag;
        uint64_t p_flag;
        uint64_t p_start;
        uint64_t p_size;
};

struct disko_vtoc {
        int             disko_vtoc_version; /* set this to DISKO_VTOC_VERSION */
        int             disko_vtoc_size; /* sizeof (struct disko_vtoc) */
        int             disko_part_size; /* sizeof (struct disko_partition) */
        char            v_volume[LEN_DKL_VVOL + 1];
        char            v_asciilabel[LEN_DKL_ASCII + 1];
        uint_t          v_sectorsz;
        uint_t          v_nparts;
        uint_t          this_part; /* the partition number of this device */
        struct disko_partition  v_part[1];
};

Note the comments, the first 3 elements of the disko_vtoc structure must be filled in correctly by the user library or Diskomizer will ignore the returned vtoc.

Source for an example vtoc reading library and a Makefile are included in the diskomizer package in /opt/SUNWdiskomizer/src that can be used as the basis of any libraries written by the user.