SAD(4D) | Devices | SAD(4D) |
sad - STREAMS Administrative Driver
#include <sys/types.h>
#include <sys/conf.h>
#include <sys/sad.h>
#include <sys/stropts.h>
int ioctl(int fildes, int command, int arg);
The STREAMS Administrative Driver provides an interface for applications to perform administrative operations on STREAMS modules and drivers. The interface is provided through ioctl(2) commands. Privileged operations may access the sad driver using /dev/sad/admin. Unprivileged operations may access the sad driver using /dev/sad/user.
The fildes argument is an open file descriptor that refers to the sad driver. The command argument determines the control function to be performed as described below. The arg argument represents additional information that is needed by this command. The type of arg depends upon the command, but it is generally an integer or a pointer to a command-specific data structure.
The autopush facility (see autopush(8)) allows one to configure a list of modules to be automatically pushed on a stream when a driver is first opened. Autopush is controlled by the following commands:
SAD_SAP
unit_t ap_cmd;
major_t sap_major;
minor_t sap_minor;
minor_t sap_lastminor;
unit_t sap_npush;
unit_t sap_list [MAXAPUSH] [FMNAMESZ + 1];
The sap_cmd field indicates the type of configuration being done. It may take on one of the following values:
SAP_ONE
SAP_RANGE
SAP_ALL
SAP_CLEAR
The sap_major field is the major device number of the device to be configured. The sap_minor field is the minor device number of the device to be configured. The sap_lastminor field is used only with the SAP_RANGE command, which configures a range of minor devices between sap_minor and sap_lastminor, inclusive. The minor fields have no meaning for the SAP_ALL command. The sap_npush field indicates the number of modules to be automatically pushed when the device is opened. It must be less than or equal to MAXAPUSH, defined in sad.h. It must also be less than or equal to NSTRPUSH, the maximum number of modules that can be pushed on a stream, defined in the kernel master file. The field sap_list is an array of NULL-terminated module names to be pushed in the order in which they appear in the list.
When using the SAP_CLEAR command, the user sets only sap_major and sap_minor. This will undo the configuration information for any of the other commands. If a previous entry was configured as SAP_ALL, sap_minor should be set to zero. If a previous entry was configured as SAP_RANGE, sap_minor should be set to the lowest minor device number in the range configured.
On failure, errno is set to the following value:
EFAULT
EINVAL
ENOSTR
EEXIST
ERANGE
ENODEV
ENOSR
SAD_GAP
The user should set the sap_major and sap_minor fields of the strapush structure to the major and minor device numbers, respectively, of the device in question. On return, the strapush structure will be filled in with the entire information used to configure the device. Unused entries in the module list will be zero-filled.
On failure, errno is set to one of the following values:
EFAULT
EINVAL
ENOSTR
ENODEV
SAD_VML
int sl_nmods;
struct str_mlist *sl_modlist;
The str_mlist structure has the following member:
char l_name[FMNAMESZ+1];
sl_nmods indicates the number of entries the user has allocated in the array and sl_modlist points to the array of module names. The return value is 0 if the list is valid, 1 if the list contains an invalid module name, or −1 on failure. On failure, errno is set to one of the following values:
EFAULT
EINVAL
STREAMS Programming Guide
Unless otherwise specified, the return value from ioctl() is 0 upon success and −1 upon failure with errno set as indicated.
February 17, 2023 | OmniOS |