Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
#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
Allows the administrator to configure the given device's autopush information. arg points to a strapush structure, which contains the following members:
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
Configure one minor device of a driver.
Configure a range of minor devices of a driver.
Configure all minor devices of a driver.
Undo configuration information for a driver.
arg points outside the allocated address space.
The major device number is invalid, the number of modules is invalid, or the list of module names is invalid.
The major device number does not represent a STREAMS driver.
The major-minor device pair is already configured.
The command is SAP_RANGE and sap_lastminor is not greater than sap_minor, or the command is SAP_CLEAR and sap_minor is not equal to the first minor in the range.
The command is SAP_CLEAR and the device is not configured for autopush.
An internal autopush data structure cannot be allocated.
Allows any user to query the sad driver to get the autopush configuration information for a given device. arg points to a strapush structure as described in the previous command. 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
arg points outside the allocated address space.
The major device number is invalid.
The major device number does not represent a STREAMS driver.
The device is not configured for autopush.
Allows any user to validate a list of modules (that is, to see if they are installed on the system). arg is a pointer to a str_list structure with the following members:
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
arg points outside the allocated address space.
The sl_nmods field of the str_list structure is less than or equal to zero.
Intro (2), ioctl (2), open (2)
STREAMS Programming Guide
Unless otherwise specified, the return value from ioctl() is 0 upon success and -1 upon failure with errno set as indicated.