w_ioctl(), __w_pioctl() — Control of devices

Standards

Standards / Extensions C or C++ Dependencies
z/OS® UNIX both OS/390 V2R8

General Format

#define _OPEN_SYS
#include <termios.h>

int w_ioctl(int fildes, int cmd, int arglen, void *arg);
int __w_pioctl(const char *pathname, int cmd, int arglen, void *arg);
ACL format:
#define _OPEN_SYS
#include <termios.h>
#include <sys>

int w_ioctl(int fildes, int cmd, int arglen, void arg);
int __w_pioctl(const char pathname, int cmd, int arglen, void arg);

General description

The w_ioctl() and __w_pioctl() functions are general entry points for device-specific commands. The specific actions specified by w_ioctl() and __w_pioctl() vary with the device, and they are defined by the device driver.
fildes
A descriptor for an open character special file (used by w_ioctl).
pathname
The pathname of a file (used by __w_pioctl).
cmd
The command to be passed to the device driver as an integer value.
Command
Description
SIOCGPARTNERINFO
Provides an interface for an application to retrieve security information about its partner. For more information, see z/OS Communications Server: IP Programmer's Guide and Reference.
arglen
The length of the argument passed to the device driver.
arg
The address of the buffer where the argument to be passed to the device driver is stored.

w_ioctl() and __w_pioctl() pass the cmd, arglen, and arg arguments to the device driver to be interpreted and processed. When w_ioctl() and __w_pioctl() complete successfully, the device driver returns arglen and arg, if appropriate.

Note: The __w_pioctl() function has a dependency on the level of the Enhanced ASCII Extensions. See Enhanced ASCII support for details.

Returned value

If successful, w_ioctl() returns 0.

If unsuccessful, w_ioctl() returns -1 and sets errno to one of the following values:
Error Code
Description
EACCES
Permission is denied.
EINVAL
One of the following situations occurred:
  • An incorrect length was specified for arglen. The correct argument length range is 0 to 50,000.
  • An invalid message queue was specified when command _IOCC_REGFILEINT was used.
ENAMETOOLONG
The length of the pathname argument exceeds PATH_MAX, or a pathname component is longer than NAME_MAX and {_POSIX_NO_TRUNC} is in effect for that file. For symbolic links, the length of the pathname string substituted for a symbolic link exceeds PATH_MAX. PATH_MAX and NAME_MAX values can be determined by using pathconf().
ENODEV
The device does not exist. The function is not supported by the device driver.
ENOENT
Either there is no file named pathname or pathname is an empty string.
ENOTDIR
A component of the pathname prefix is not a directory.
ENOTSUP

Operation not supported. The following occurred:

Command _IOCC_REGFILEINT was used and fildes (w_ioctl) or pathname (__w_pioctl) refers to a file residing in a R/W file system that is shared across a sysplex with zFS, or is accessed through an NFS Client. In these cases, the file is able to be changed on a remote system without the local system being aware. Because the program would not receive notification, this operation is rejected.

Use __errno2() to obtain more diagnostic information.

ENOTTY
An incorrect file descriptor was specified. fildes was not a character special file.

ACLs description

The w_ioctl() and __w_pioctl() functions are general entry points for SETFACL and GETFACL HFS commands. SETFACL is used to set information into an Access Control List. GETFACL is used to retrieve information from an Access Control List.

fildes
A descriptor for an open character special file (used by w_ioctl).
pathname
The pathname of a file (used by __w_pioctl).
cmd
The command to be passed to the device driver as an integer value, either SETFACL or GETFACL.
arglen
The length of the user buffer passed to the HFS device driver as a value from 1 to 50,000 bytes. arglen is the combined size of the struct ACL_buf and the array of struct ACL_entrys.
arg
arg specifies the user buffer which is mapped by struct ACL_buf followed immediately by an array of struct ACL_entrys. See z/OS UNIX System Services Programming: Assembler Callable Services Reference for more information about ACL_buf and the ACL_entrys.

w_ioctl() and __w_pioctl() pass the cmd, arglen, and arg arguments to the device driver to be interpreted and processed. When w_ioctl() and __w_pioctl() complete successfully, the device driver returns arglen and arg, if appropriate.

ACLs returned value

If successful, w_ioctl() returns 0.

If unsuccessful, w_ioctl() returns -1 and sets errno to one of the following values:
Error Code
Description
EBADF
The fildes parameter is not a valid file descriptor.
EINVAL
The request is invalid or not supported.
EMVSPARM
Incorrect parameters were passed to the service.
ENODEV
The device is incorrect. The function is not supported by the device driver.

Example

CELEBW34
⁄* CELEBW34

   This example shows a general entry point for device-specific commands.

 *⁄
#include <termios.h>
#include <stdio.h>

main() {
  char buf[256];
  int  ret;

  memset(buf, 0x00, sizeof(buf));
  if ((ret = w_ioctl(0, 1, sizeof(buf), buf)) != 0)
    perror("w_ioctl() error");
  else
    printf("w_iotctl() returned '%s'\n", buf);
}
Output:
w_ioctl() error: Invalid argument
Note: w_ioctl() is dependent upon the file system device driver.

Related information