The gctl_* functions are used to send requests to GEOM classes. In order for a GEOM class to actually be able to receive these requests, it must have defined a "ctlreq" method.
.Vt "struct gctl_req *" , obtained with gctl_get_handle, can hold any number of parameters, which must be added to it with gctl_ro_param (for read-only parameters) or gctl_rw_param (for read/write parameters).
Both gctl_ro_param and gctl_rw_param take a string name, which is used to identify the parameter, and a value, which contains, in the read-only case, the data to be passed to the GEOM class, or, in the read/write case, a pointer to preallocated memory that the GEOM class should fill with the desired data. If len is negative, it is assumed that value is an ASCII string and the actual length is taken from the string length of value; otherwise it must hold the size of value.
A parameter with a name containing the string "class" is mandatory for each request, and the corresponding value must hold the name of the GEOM class where the request should be sent to.
Also mandatory for each request is a parameter with a name called "verb", and the corresponding value needs to hold the command string that the GEOM class should react upon.
Once all desired parameters are filled in, the request must be sent to the GEOM subsystem with gctl_issue, which returns NULL on success, or a string containing the error message on failure.
After the request is finished, the allocated memory should be released with gctl_free.
The gctl_dump function can be used to format the contents of req to the open file handle pointed to by f, for debugging purposes.
Error handling for the control functions is postponed until the call to gctl_issue, which returns NULL on success, or an error message corresponding to the first error which happened.
Create a request that is to be sent to the CCD class, and tell it to destroy a specific geom:
H = gctl_get_handle();
gctl_ro_param(H, "verb", -1, "destroy geom");
gctl_ro_param(H, "class", -1, "CCD");
sprintf(buf, "ccd%d", ccd);
gctl_ro_param(H, "geom", -1, buf);
errstr = gctl_issue(H);
if (errstr != NULL)
err(1, "could not destroy ccd: %s", errstr);