diff options
author | Dan McDonald <danmcd@joyent.com> | 2022-02-22 13:43:04 -0500 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2022-02-22 13:43:04 -0500 |
commit | f3389cfd79d6c15fb8cfc797398159f1c8b353b9 (patch) | |
tree | afd1c5450f8e23e6fc466e5fcf9f66fdb25a1092 | |
parent | ebcd0fe2a47d2edd394ec05fe4e51389205135f7 (diff) | |
parent | ca783257c986cddcc674ae22916a6766b98a2d36 (diff) | |
download | illumos-joyent-f3389cfd79d6c15fb8cfc797398159f1c8b353b9.tar.gz |
[illumos-gate merge]
commit ca783257c986cddcc674ae22916a6766b98a2d36
5513 KM_NORMALPRI should be documented in kmem_alloc(9f) and kmem_cache_create(9f) man pages
14465 Present KM_NOSLEEP_LAZY as documented interface
commit 36589d6bb0cdae89e166b57b0d64ae56d53247d9
13500 Want support for overlay networks
commit 68df0c4f60a2e57680d6d1e6dba32ffa2d035538
14513 nvmeadm list-firmware
commit 8466ab889653be2119e4a8966b6bc4e2d5ee2fb6
14507 nvmeadm shouldn't allow writing firmware to a read-only slot 1
14508 improve nvmeadm firmware reporting
14509 nvmeadm commit-firmware error reporting isn't working as intended
commit 1fa2a66491e7d8ae0be84e7da4da8e812480c710
14249 pseudo-terminal nomenclature should reflect POSIX
Conflicts:
usr/src/cmd/cmd-inet/etc/services
usr/src/cmd/dladm/Makefile
usr/src/cmd/dladm/dladm.c
usr/src/cmd/varpd/Makefile
usr/src/cmd/varpd/varpd.c
usr/src/cmd/zoneadmd/zcons.c
usr/src/lib/Makefile
usr/src/lib/libdladm/Makefile
usr/src/lib/libdladm/common/libdladm.c
usr/src/lib/libdladm/common/libdladm.h
usr/src/lib/libdladm/common/libdladm_impl.h
usr/src/lib/libdladm/common/libdloverlay.c
usr/src/lib/libdladm/common/libdlvnic.c
usr/src/lib/varpd/Makefile
usr/src/lib/varpd/direct/Makefile.com
usr/src/lib/varpd/direct/amd64/Makefile
usr/src/lib/varpd/direct/common/libvarpd_direct.c
usr/src/lib/varpd/direct/i386/Makefile
usr/src/lib/varpd/files/Makefile
usr/src/lib/varpd/files/Makefile.com
usr/src/lib/varpd/files/amd64/Makefile
usr/src/lib/varpd/files/common/libvarpd_files.c
usr/src/lib/varpd/files/i386/Makefile
usr/src/lib/varpd/libvarpd/Makefile
usr/src/lib/varpd/libvarpd/Makefile.com
usr/src/lib/varpd/libvarpd/amd64/Makefile
usr/src/lib/varpd/libvarpd/common/libvarpd.c
usr/src/lib/varpd/libvarpd/common/libvarpd_arp.c
usr/src/lib/varpd/libvarpd/common/libvarpd_client.c
usr/src/lib/varpd/libvarpd/common/libvarpd_impl.h
usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c
usr/src/lib/varpd/libvarpd/common/libvarpd_panic.c
usr/src/lib/varpd/libvarpd/common/libvarpd_plugin.c
usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h
usr/src/lib/varpd/libvarpd/common/libvarpd_util.c
usr/src/lib/varpd/libvarpd/i386/Makefile
usr/src/man/man1m/dladm.1m
usr/src/man/man5/overlay.5
usr/src/man/man7p/Makefile
usr/src/man/man7p/vxlan.7p
usr/src/uts/Makefile.uts
usr/src/uts/common/Makefile.files
usr/src/uts/common/io/overlay/overlay.c
usr/src/uts/common/io/overlay/overlay_mux.c
usr/src/uts/common/io/overlay/overlay_target.c
usr/src/uts/common/sys/dls_mgmt.h
usr/src/uts/common/sys/mac_provider.h
usr/src/uts/common/sys/overlay_common.h
usr/src/uts/common/sys/overlay_impl.h
usr/src/uts/common/sys/overlay_plugin.h
usr/src/uts/common/sys/overlay_target.h
105 files changed, 3766 insertions, 3497 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging index 993ada83e4..06b804cfcb 100644 --- a/exception_lists/packaging +++ b/exception_lists/packaging @@ -400,6 +400,18 @@ usr/include/libidspace.h # VXLAN # usr/include/sys/vxlan.h +lib/libvarpd.so +lib/amd64/libvarpd.so +# +# Overlay +# +usr/include/libdloverlay.h +usr/include/libvarpd.h +usr/include/libvarpd_client.h +usr/include/libvarpd_provider.h +usr/include/sys/overlay.h +usr/include/sys/overlay_common.h +usr/include/sys/overlay_target.h # # Private interfaces in libsec # diff --git a/usr/src/cmd/cmd-inet/etc/services b/usr/src/cmd/cmd-inet/etc/services index 1029745480..5673b61626 100644 --- a/usr/src/cmd/cmd-inet/etc/services +++ b/usr/src/cmd/cmd-inet/etc/services @@ -409,6 +409,7 @@ epmd 4369/udp ipsec-nat-t 4500/udp # IPsec NAT-Traversal iax 4569/tcp # Inter-Asterisk eXchange iax 4569/udp +vxlan 4789/udp # Virtual eXtensible Local Area Network (VXLAN) radmin-port 4899/tcp # RAdmin Port radmin-port 4899/udp rfe 5002/udp # Radio Free Ethernet diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.rlogind.c b/usr/src/cmd/cmd-inet/usr.sbin/in.rlogind.c index 5d3bc60abf..1c495aff84 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.rlogind.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.rlogind.c @@ -3,8 +3,8 @@ * Use is subject to license terms. */ -/* Copyright(c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* Copyright(c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ /* * Copyright (c) 1983 The Regents of the University of California. @@ -1057,13 +1057,13 @@ doit(int f, if ((p = open("/dev/ptmx", O_RDWR)) == -1) fatalperror(f, "cannot open /dev/ptmx"); if (grantpt(p) == -1) - fatal(f, "could not grant slave pty"); + fatal(f, "could not grant subsidiary pty"); if (unlockpt(p) == -1) - fatal(f, "could not unlock slave pty"); + fatal(f, "could not unlock subsidiary pty"); if ((line = ptsname(p)) == NULL) - fatal(f, "could not enable slave pty"); + fatal(f, "could not enable subsidiary pty"); if ((t = open(line, O_RDWR)) == -1) - fatal(f, "could not open slave pty"); + fatal(f, "could not open subsidiary pty"); if (ioctl(t, I_PUSH, "ptem") == -1) fatalperror(f, "ioctl I_PUSH ptem"); if (ioctl(t, I_PUSH, "ldterm") == -1) @@ -1128,9 +1128,9 @@ doit(int f, /* * System V ptys allow the TIOC{SG}WINSZ ioctl to be - * issued on the master side of the pty. Luckily, that's + * issued on the manager side of the pty. Luckily, that's * the only tty ioctl we need to do do, so we can close the - * slave side in the parent process after the fork. + * subsidiary side in the parent process after the fork. */ (void) ioctl(p, TIOCSWINSZ, &win); @@ -1161,12 +1161,12 @@ doit(int f, if (setsid() == -1) fatalperror(f, "setsid"); if ((tt = open(line, O_RDWR)) == -1) - fatalperror(f, "could not re-open slave pty"); + fatalperror(f, "could not re-open subsidiary pty"); if (close(p) == -1) - fatalperror(f, "error closing pty master"); + fatalperror(f, "error closing pty manager"); if (close(t) == -1) - fatalperror(f, "error closing pty slave" + fatalperror(f, "error closing pty subsidiary" " opened before session established"); /* * If this fails we may or may not be able to output an @@ -1209,8 +1209,8 @@ doit(int f, /* * Must ignore SIGTTOU, otherwise we'll stop - * when we try and set slave pty's window shape - * (our controlling tty is the master pty). + * when we try and set subsidiary pty's window shape + * (our controlling tty is the manager pty). * Likewise, we don't want any of the tty-generated * signals from chars passing through. */ @@ -1332,7 +1332,7 @@ static void protocol(int f, int p, int encr_flag) { struct stat buf; - struct protocol_arg rloginp; + struct protocol_arg rloginp; struct strioctl rloginmod; int ptmfd; /* fd of logindmux coneected to ptmx */ int netfd; /* fd of logindmux connected to netf */ diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c b/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c index afeb5a5c55..bbd38a551c 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.telnetd.c @@ -242,7 +242,7 @@ static int cryptmod_fd = -1; #define TS_DONT 8 /* dont " */ static int ncc; -static int master; /* master side of pty */ +static int manager; /* manager side of pty */ static int pty; /* side of pty that gets ioctls */ static int net; static int inter; @@ -2754,20 +2754,20 @@ doit(int f, struct sockaddr_storage *who) char username[MAXUSERNAMELEN]; int len; uchar_t passthru; - char *slavename; + char *subsidname; if ((p = open("/dev/ptmx", O_RDWR | O_NOCTTY)) == -1) { fatalperror(f, "open /dev/ptmx", errno); } if (grantpt(p) == -1) - fatal(f, "could not grant slave pty"); + fatal(f, "could not grant subsidiary pty"); if (unlockpt(p) == -1) - fatal(f, "could not unlock slave pty"); - if ((slavename = ptsname(p)) == NULL) - fatal(f, "could not enable slave pty"); + fatal(f, "could not unlock subsidiary pty"); + if ((subsidname = ptsname(p)) == NULL) + fatal(f, "could not enable subsidiary pty"); (void) dup2(f, 0); - if ((t = open(slavename, O_RDWR | O_NOCTTY)) == -1) - fatal(f, "could not open slave pty"); + if ((t = open(subsidname, O_RDWR | O_NOCTTY)) == -1) + fatal(f, "could not open subsidiary pty"); if (ioctl(t, I_PUSH, "ptem") == -1) fatalperror(f, "ioctl I_PUSH ptem", errno); if (ioctl(t, I_PUSH, "ldterm") == -1) @@ -2775,7 +2775,7 @@ doit(int f, struct sockaddr_storage *who) if (ioctl(t, I_PUSH, "ttcompat") == -1) fatalperror(f, "ioctl I_PUSH ttcompat", errno); - line = slavename; + line = subsidname; pty = t; @@ -3039,7 +3039,7 @@ doit(int f, struct sockaddr_storage *who) fatal(netfd, "ioctl LOGDMX_IOC_QEXCHANGE of ptmfd failed\n"); net = netfd; - master = ptmfd; + manager = ptmfd; cryptmod_fd = netfd; /* @@ -3100,11 +3100,11 @@ doit(int f, struct sockaddr_storage *who) if ((pid = fork()) < 0) fatalperror(netfd, "fork", errno); if (pid) - telnet(net, master); + telnet(net, manager); /* * The child process needs to be the session leader * and have the pty as its controlling tty. Thus we need - * to re-open the slave side of the pty no without + * to re-open the subsidiary side of the pty no without * the O_NOCTTY flag that we have been careful to * use up to this point. */ @@ -3130,10 +3130,10 @@ doit(int f, struct sockaddr_storage *who) if (terminaltype) (void) local_setenv("TERM", terminaltype+5, 1); /* - * -h : pass on name of host. + * -h : pass on name of host. * WARNING: -h is accepted by login if and only if * getuid() == 0. - * -p : don't clobber the environment (so terminal type stays set). + * -p : don't clobber the environment (so terminal type stays set). */ { /* System V login expects a utmp entry to already be there */ @@ -3192,7 +3192,7 @@ doit(int f, struct sockaddr_storage *who) ((AuthenticatingUser != NULL) && strlen(AuthenticatingUser))) { (void) execl(LOGIN_PROGRAM, "login", "-p", - "-d", slavename, + "-d", subsidname, "-h", host, "-u", krb5_name, "-s", pam_svc_name, @@ -3208,7 +3208,7 @@ doit(int f, struct sockaddr_storage *who) */ (void) execl(LOGIN_PROGRAM, "login", "-p", - "-d", slavename, + "-d", subsidname, "-h", host, "-s", pam_svc_name, "--", (AuthenticatingUser != NULL ? AuthenticatingUser : @@ -3216,7 +3216,7 @@ doit(int f, struct sockaddr_storage *who) } else /* default, no auth. info available, login does it all */ { (void) execl(LOGIN_PROGRAM, "login", - "-p", "-h", host, "-d", slavename, "--", + "-p", "-h", host, "-d", subsidname, "--", getenv("USER"), 0); } @@ -3254,7 +3254,7 @@ fatalperror(int f, char *msg, int errnum) * inkernel telnet streams module (telmod). */ static void -telnet(int net, int master) +telnet(int net, int manager) { int on = 1; char mode; @@ -3265,7 +3265,7 @@ telnet(int net, int master) if (ioctl(net, FIONBIO, &on) == -1) syslog(LOG_INFO, "ioctl FIONBIO net: %m\n"); - if (ioctl(master, FIONBIO, &on) == -1) + if (ioctl(manager, FIONBIO, &on) == -1) syslog(LOG_INFO, "ioctl FIONBIO pty p: %m\n"); (void) signal(SIGTSTP, SIG_IGN); (void) signal(SIGCHLD, (void (*)())cleanup); @@ -3302,7 +3302,7 @@ telnet(int net, int master) * stuff in the corresponding output buffer */ if (pfrontp - pbackp) { - FD_SET(master, &obits); + FD_SET(manager, &obits); } else { FD_SET(net, &ibits); } @@ -3390,7 +3390,7 @@ telnet(int net, int master) fatal(net, "ioctl TEL_IOC_GETBLK failed\n"); } - if ((c = select(max(net, master) + 1, &ibits, &obits, &xbits, + if ((c = select(max(net, manager) + 1, &ibits, &obits, &xbits, (struct timeval *)0)) < 1) { if (c == -1) { if (errno == EINTR) { @@ -3427,7 +3427,7 @@ telnet(int net, int master) netflush(); if (ncc > 0) telrcv(); - if (FD_ISSET(master, &obits) && (pfrontp - pbackp) > 0) + if (FD_ISSET(manager, &obits) && (pfrontp - pbackp) > 0) ptyflush(); } cleanup(0); @@ -4279,7 +4279,7 @@ ptyflush(void) int n; if ((n = pfrontp - pbackp) > 0) - n = write(master, pbackp, n); + n = write(manager, pbackp, n); if (n < 0) return; pbackp += n; @@ -4447,9 +4447,9 @@ cleanup(int signum) /* * If the TEL_IOC_ENABLE ioctl hasn't completed, then we need to * handle closing differently. We close "net" first and then - * "master" in that order. We do close(net) first because + * "manager" in that order. We do close(net) first because * we have no other way to disconnect forwarding between the network - * and master. So by issuing the close()'s we ensure that no further + * and manager. So by issuing the close()'s we ensure that no further * data rises from TCP. A more complex fix would be adding proper * support for throwing a "stop" switch for forwarding data between * logindmux peers. It's possible to block in the close of the tty @@ -4460,7 +4460,7 @@ cleanup(int signum) if (!telmod_init_done) { (void) close(net); - (void) close(master); + (void) close(manager); } rmut(); diff --git a/usr/src/cmd/devfsadm/misc_link.c b/usr/src/cmd/devfsadm/misc_link.c index 49be9e9b2d..93112628a4 100644 --- a/usr/src/cmd/devfsadm/misc_link.c +++ b/usr/src/cmd/devfsadm/misc_link.c @@ -235,8 +235,8 @@ static devfsadm_remove_t misc_remove_cbt[] = { { "pseudo", "^daplt$", RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all }, - { "pseudo", "^zcons/" ZONENAME_REGEXP "/(" ZCONS_MASTER_NAME "|" - ZCONS_SLAVE_NAME ")$", + { "pseudo", "^zcons/" ZONENAME_REGEXP "/(" ZCONS_MANAGER_NAME "|" + ZCONS_SUBSIDIARY_NAME ")$", RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all }, { "pseudo", "^zfd/" ZONENAME_REGEXP "/(master|slave)/[0-9]+$", @@ -488,7 +488,7 @@ fc_port(di_minor_t minor, di_node_t node) /* * Handles: * minor node type "ddi_printer". - * rules of the form: type=ddi_printer;name=bpp \M0 + * rules of the form: type=ddi_printer;name=bpp \M0 */ static int printer_create(di_minor_t minor, di_node_t node) @@ -719,7 +719,7 @@ zfd_create(di_minor_t minor, di_node_t node) } /* - * /dev/cpu/self/cpuid -> /devices/pseudo/cpuid@0:self + * /dev/cpu/self/cpuid -> /devices/pseudo/cpuid@0:self */ static int cpuid(di_minor_t minor, di_node_t node) diff --git a/usr/src/cmd/dladm/Makefile b/usr/src/cmd/dladm/Makefile index 64b16e1042..0b4a2413c2 100644 --- a/usr/src/cmd/dladm/Makefile +++ b/usr/src/cmd/dladm/Makefile @@ -22,7 +22,6 @@ # Use is subject to license terms. # Copyright 2018 Joyent, Inc. # -# Copyright (c) 2018, Joyent, Inc. PROG= dladm ROOTFS_PROG= $(PROG) diff --git a/usr/src/cmd/dladm/dladm.c b/usr/src/cmd/dladm/dladm.c index 1f73e2c8e8..1a14de1de0 100644 --- a/usr/src/cmd/dladm/dladm.c +++ b/usr/src/cmd/dladm/dladm.c @@ -23,6 +23,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2017 Joyent, Inc. * Copyright 2016 Nexenta Systems, Inc. + * Copyright (c) 2015 Joyent, Inc. All rights reserved. * Copyright 2020 Peter Tribble. * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ @@ -1465,7 +1466,7 @@ static const struct option overlay_create_lopts[] = { { "encap", required_argument, NULL, 'e' }, { "prop", required_argument, NULL, 'p' }, { "search", required_argument, NULL, 's' }, - { "temporary", no_argument, NULL, 't' }, + { "temporary", no_argument, NULL, 't' }, { "vnetid", required_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } }; @@ -10015,7 +10016,7 @@ do_delete_overlay(int argc, char *argv[], const char *use) typedef struct showoverlay_state { ofmt_handle_t sho_ofmt; - const char *sho_linkname; + const char *sho_linkname; dladm_overlay_propinfo_handle_t sho_info; uint8_t sho_value[DLADM_OVERLAY_PROP_SIZEMAX]; uint32_t sho_size; @@ -10117,10 +10118,10 @@ print_overlay_value(char *outbuf, uint_t bufsize, uint_t type, const void *pbuf, static boolean_t print_overlay_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize) { - dladm_status_t status; + dladm_status_t status; showoverlay_state_t *sp = ofarg->ofmt_cbarg; dladm_overlay_propinfo_handle_t infop = sp->sho_info; - const char *pname; + const char *pname; uint_t type, prot; const void *def; uint32_t defsize; @@ -10312,7 +10313,7 @@ print_overlay_targ_cb(ofmt_arg_t *ofarg, char *buf, uint_t bufsize) } else if (inet_ntop(AF_INET6, &point->dop_ip, ipbuf, sizeof (ipbuf)) == NULL) { /* - * The only failrues we should get are + * The only failures we should get are * EAFNOSUPPORT and ENOSPC because of buffer * exhaustion. In either of these cases, that * means something has gone horribly wrong. @@ -10454,7 +10455,7 @@ do_show_overlay(int argc, char *argv[], const char *use) int i, opt; datalink_id_t linkid = DATALINK_ALL_LINKID; dladm_status_t status; - int (*funcp)(dladm_handle_t, datalink_id_t, void *); + int (*funcp)(dladm_handle_t, datalink_id_t, void *); char *fields_str = NULL; const ofmt_field_t *fieldsp; ofmt_status_t oferr; diff --git a/usr/src/cmd/enhance/enhance.c b/usr/src/cmd/enhance/enhance.c index 25650e378e..3fb004fbd0 100644 --- a/usr/src/cmd/enhance/enhance.c +++ b/usr/src/cmd/enhance/enhance.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -69,24 +67,24 @@ int unlockpt(int fd); #define PTY_CNTRL "pty" /* - * Pseudo-terminal slave device file names start with the following + * Pseudo-terminal subsidiary device file names start with the following * prefix. */ -#define PTY_SLAVE "tty" +#define PTY_SUBSID "tty" /* - * Specify the maximum suffix length for the control and slave device + * Specify the maximum suffix length for the control and subsidiary device * names. */ #define PTY_MAX_SUFFIX 10 /* - * Set the maximum length of the master and slave terminal device filenames, - * including space for a terminating '\0'. + * Set the maximum length of the manager and subsidiary terminal device + * filenames, including space for a terminating '\0'. */ #define PTY_MAX_NAME (sizeof(PTY_DEV_DIR)-1 + \ - (sizeof(PTY_SLAVE) > sizeof(PTY_CNTRL) ? \ - sizeof(PTY_SLAVE) : sizeof(PTY_CNTRL))-1 \ + (sizeof(PTY_SUBSID) > sizeof(PTY_CNTRL) ? \ + sizeof(PTY_SUBSID) : sizeof(PTY_CNTRL))-1 \ + PTY_MAX_SUFFIX + 1) /* * Set the maximum length of an input line. @@ -110,15 +108,15 @@ int unlockpt(int fd); */ #define PTY_READ_TIMEOUT 100000 /* micro-seconds */ -static int pty_open_master(const char *prog, int *cntrl, char *slave_name); -static int pty_open_slave(const char *prog, char *slave_name); -static int pty_child(const char *prog, int slave, char *argv[]); +static int pty_open_manager(const char *prog, int *cntrl, char *subsid_name); +static int pty_open_subsid(const char *prog, char *subsid_name); +static int pty_child(const char *prog, int subsid, char *argv[]); static int pty_parent(const char *prog, int cntrl); static int pty_stop_parent(int waserr, int cntrl, GetLine *gl, char *rbuff); static GL_FD_EVENT_FN(pty_read_from_program); static int pty_write_to_fd(int fd, const char *string, int n); static void pty_child_exited(int sig); -static int pty_master_readable(int fd, long usec); +static int pty_manager_readable(int fd, long usec); /*....................................................................... * Run a program with enhanced terminal editing facilities. @@ -129,11 +127,11 @@ static int pty_master_readable(int fd, long usec); int main(int argc, char *argv[]) { int cntrl = -1; /* The fd of the pseudo-terminal controller device */ - int slave = -1; /* The fd of the pseudo-terminal slave device */ + int subsid = -1; /* The fd of the pseudo-terminal subsidiary device */ pid_t pid; /* The return value of fork() */ int status; /* The return statuses of the parent and child functions */ - char slave_name[PTY_MAX_NAME]; /* The filename of the slave end of the */ - /* pseudo-terminal. */ + char subsid_name[PTY_MAX_NAME]; /* The filename of the subsidiary end of */ + /* the pseudo-terminal. */ char *prog; /* The name of the program (ie. argv[0]) */ /* * Check the arguments. @@ -165,11 +163,11 @@ int main(int argc, char *argv[]) }; }; /* - * Open the master side of a pseudo-terminal pair, and return + * Open the manager side of a pseudo-terminal pair, and return * the corresponding file descriptor and the filename of the - * slave end of the pseudo-terminal. + * subsidiary end of the pseudo-terminal. */ - if(pty_open_master(prog, &cntrl, slave_name)) + if(pty_open_manager(prog, &cntrl, subsid_name)) return 1; /* * Set up a signal handler to watch for the child process exiting. @@ -201,11 +199,11 @@ int main(int argc, char *argv[]) status = pty_parent(prog, cntrl); close(cntrl); } else { - close(cntrl); /* The child doesn't use the slave device */ + close(cntrl); /* The child doesn't use the subsidiary device */ signal(SIGCHLD, pty_child_exited); - if((slave = pty_open_slave(prog, slave_name)) >= 0) { - status = pty_child(prog, slave, argv + 1); - close(slave); + if((subsid = pty_open_subsid(prog, subsid_name)) >= 0) { + status = pty_child(prog, subsid, argv + 1); + close(subsid); } else { status = 1; }; @@ -214,24 +212,24 @@ int main(int argc, char *argv[]) } /*....................................................................... - * Open the master side of a pseudo-terminal pair, and return + * Open the manager side of a pseudo-terminal pair, and return * the corresponding file descriptor and the filename of the - * slave end of the pseudo-terminal. + * subsidiary end of the pseudo-terminal. * * Input/Output: * prog const char * The name of this program. * cntrl int * The file descriptor of the pseudo-terminal * controller device will be assigned tp *cntrl. - * slave_name char * The file-name of the pseudo-terminal slave device - * will be recorded in slave_name[], which must have + * subsid_name char * The file-name of the pseudo-terminal subsidiary device + * will be recorded in subsid_name[], which must have * at least PTY_MAX_NAME elements. * Output: * return int 0 - OK. * 1 - Error. */ -static int pty_open_master(const char *prog, int *cntrl, char *slave_name) +static int pty_open_manager(const char *prog, int *cntrl, char *subsid_name) { - char master_name[PTY_MAX_NAME]; /* The filename of the master device */ + char manager_name[PTY_MAX_NAME]; /* The filename of the manager device */ DIR *dir; /* The directory iterator */ struct dirent *file; /* A file in "/dev" */ /* @@ -240,26 +238,26 @@ static int pty_open_master(const char *prog, int *cntrl, char *slave_name) *cntrl = -1; /* * On systems with the Sys-V pseudo-terminal interface, we don't - * have to search for a free master terminal. We just open /dev/ptmx, - * and if there is a free master terminal device, we are given a file + * have to search for a free manager terminal. We just open /dev/ptmx, + * and if there is a free manager terminal device, we are given a file * descriptor connected to it. */ #if HAVE_SYSV_PTY *cntrl = open("/dev/ptmx", O_RDWR); if(*cntrl >= 0) { /* - * Get the filename of the slave side of the pseudo-terminal. + * Get the filename of the subsidiary side of the pseudo-terminal. */ char *name = ptsname(*cntrl); if(name) { if(strlen(name)+1 > PTY_MAX_NAME) { - fprintf(stderr, "%s: Slave pty filename too long.\n", prog); + fprintf(stderr, "%s: Subsidiary pty filename too long.\n", prog); return 1; }; - strlcpy(slave_name, name, PTY_MAX_NAME); + strlcpy(subsid_name, name, PTY_MAX_NAME); /* - * If unable to get the slave name, discard the controller file descriptor, - * ready to try a search instead. + * If unable to get the subsidiary name, discard the controller file + * descriptor, ready to try a search instead. */ } else { close(*cntrl); @@ -269,7 +267,7 @@ static int pty_open_master(const char *prog, int *cntrl, char *slave_name) #endif /* * On systems without /dev/ptmx, or if opening /dev/ptmx failed, - * we open one master terminal after another, until one that isn't + * we open one manager terminal after another, until one that isn't * in use by another program is found. * * Open the devices directory. @@ -287,7 +285,7 @@ static int pty_open_master(const char *prog, int *cntrl, char *slave_name) while(*cntrl < 0 && (file = readdir(dir))) { if(strncmp(file->d_name, PTY_CNTRL, sizeof(PTY_CNTRL)-1) == 0) { /* - * Get the common extension of the control and slave filenames. + * Get the common extension of the control and subsidiary filenames. */ const char *ext = file->d_name + sizeof(PTY_CNTRL)-1; if(strlen(ext) > PTY_MAX_SUFFIX) @@ -295,18 +293,18 @@ static int pty_open_master(const char *prog, int *cntrl, char *slave_name) /* * Attempt to open the control file. */ - strlcpy(master_name, PTY_DEV_DIR, sizeof(master_name)); - strlcat(master_name, PTY_CNTRL, sizeof(master_name)); - strlcat(master_name, ext, sizeof(master_name)); - *cntrl = open(master_name, O_RDWR); + strlcpy(manager_name, PTY_DEV_DIR, sizeof(manager_name)); + strlcat(manager_name, PTY_CNTRL, sizeof(manager_name)); + strlcat(manager_name, ext, sizeof(manager_name)); + *cntrl = open(manager_name, O_RDWR); if(*cntrl < 0) continue; /* - * Attempt to open the matching slave file. + * Attempt to open the matching subsidiary file. */ - strlcpy(slave_name, PTY_DEV_DIR, PTY_MAX_NAME); - strlcat(slave_name, PTY_SLAVE, PTY_MAX_NAME); - strlcat(slave_name, ext, PTY_MAX_NAME); + strlcpy(subsid_name, PTY_DEV_DIR, PTY_MAX_NAME); + strlcat(subsid_name, PTY_SUBSID, PTY_MAX_NAME); + strlcat(subsid_name, ext, PTY_MAX_NAME); }; }; closedir(dir); @@ -321,8 +319,8 @@ static int pty_open_master(const char *prog, int *cntrl, char *slave_name) return 1; }; /* - * System V systems require the program that opens the master to - * grant access to the slave side of the pseudo-terminal. + * System V systems require the program that opens the manager to + * grant access to the subsidiary side of the pseudo-terminal. */ #ifdef HAVE_SYSV_PTY if(grantpt(*cntrl) < 0 || @@ -339,18 +337,18 @@ static int pty_open_master(const char *prog, int *cntrl, char *slave_name) } /*....................................................................... - * Open the slave end of a pseudo-terminal. + * Open the subsidiary end of a pseudo-terminal. * * Input: * prog const char * The name of this program. - * slave_name char * The filename of the slave device. + * subsid_name char * The filename of the subsidiary device. * Output: * return int The file descriptor of the successfully opened - * slave device, or < 0 on error. + * subsidiary device, or < 0 on error. */ -static int pty_open_slave(const char *prog, char *slave_name) +static int pty_open_subsid(const char *prog, char *subsid_name) { - int fd; /* The file descriptor of the slave device */ + int fd; /* The file descriptor of the subsidiary device */ /* * Place the process in its own process group. In system-V based * OS's, this ensures that when the pseudo-terminal is opened, it @@ -364,16 +362,16 @@ static int pty_open_slave(const char *prog, char *slave_name) /* * Attempt to open the specified device. */ - fd = open(slave_name, O_RDWR); + fd = open(subsid_name, O_RDWR); if(fd < 0) { - fprintf(stderr, "%s: Unable to open pseudo-terminal slave device (%s).\n", + fprintf(stderr, "%s: Unable to open pty subsidiary device (%s).\n", prog, strerror(errno)); return -1; }; /* * On system-V streams based systems, we need to push the stream modules * that implement pseudo-terminal and termio interfaces. At least on - * Solaris, which pushes these automatically when a slave is opened, + * Solaris, which pushes these automatically when a subsidiary is opened, * this is redundant, so ignore errors when pushing the modules. */ #if HAVE_SYSV_PTY @@ -498,11 +496,11 @@ static int pty_stop_parent(int waserr, int cntrl, GetLine *gl, char *rbuff) /*....................................................................... * Run the user's program, with its stdin and stdout connected to the - * slave end of the psuedo-terminal. + * subsidiary end of the psuedo-terminal. * * Input: * prog const char * The name of this program. - * slave int The file descriptor of the slave end of the + * subsid int The file descriptor of the subsidiary end of the * pseudo terminal. * argv char *[] The argument vector to pass to the user's program, * where argv[0] is the name of the user's program, @@ -514,33 +512,33 @@ static int pty_stop_parent(int waserr, int cntrl, GetLine *gl, char *rbuff) * with the user's program. In this case 1 is * returned. */ -static int pty_child(const char *prog, int slave, char *argv[]) +static int pty_child(const char *prog, int subsid, char *argv[]) { struct termios attr; /* The terminal attributes */ /* * We need to stop the pseudo-terminal from echoing everything that we send it. */ - if(tcgetattr(slave, &attr)) { + if(tcgetattr(subsid, &attr)) { fprintf(stderr, "%s: Can't get pseudo-terminal attributes (%s).\n", prog, strerror(errno)); return 1; }; attr.c_lflag &= ~(ECHO); - while(tcsetattr(slave, TCSADRAIN, &attr)) { + while(tcsetattr(subsid, TCSADRAIN, &attr)) { if(errno != EINTR) { fprintf(stderr, "%s: tcsetattr error: %s\n", prog, strerror(errno)); return 1; }; }; /* - * Arrange for stdin, stdout and stderr to be connected to the slave device, - * ignoring errors that imply that either stdin or stdout is closed. + * Arrange for stdin, stdout and stderr to be connected to the subsidiary + * device, ignoring errors that imply that either stdin or stdout is closed. */ - while(dup2(slave, STDIN_FILENO) < 0 && errno==EINTR) + while(dup2(subsid, STDIN_FILENO) < 0 && errno==EINTR) ; - while(dup2(slave, STDOUT_FILENO) < 0 && errno==EINTR) + while(dup2(subsid, STDOUT_FILENO) < 0 && errno==EINTR) ; - while(dup2(slave, STDERR_FILENO) < 0 && errno==EINTR) + while(dup2(subsid, STDERR_FILENO) < 0 && errno==EINTR) ; /* * Run the user's program. @@ -648,7 +646,7 @@ static GL_FD_EVENT_FN(pty_read_from_program) */ memmove(rbuff, nextp, len - (nextp - rbuff) + 1); }; - } while(pty_master_readable(fd, PTY_READ_TIMEOUT)); + } while(pty_manager_readable(fd, PTY_READ_TIMEOUT)); /* * Make the incomplete line in the output buffer the current prompt. */ @@ -686,7 +684,7 @@ static int pty_write_to_fd(int fd, const char *string, int n) /*....................................................................... * This is the signal handler that is called when the child process * that is running the user's program exits for any reason. It closes - * the slave end of the terminal, so that gl_get_line() in the parent + * the subsidiary end of the terminal, so that gl_get_line() in the parent * process sees an end of file. */ static void pty_child_exited(int sig) @@ -707,7 +705,7 @@ static void pty_child_exited(int sig) * available). * 1 - Data is waiting to be read. */ -static int pty_master_readable(int fd, long usec) +static int pty_manager_readable(int fd, long usec) { #if HAVE_SELECT fd_set rfds; /* The set of file descriptors to check */ diff --git a/usr/src/cmd/nvmeadm/nvmeadm.c b/usr/src/cmd/nvmeadm/nvmeadm.c index e177e04d82..b592a2bd25 100644 --- a/usr/src/cmd/nvmeadm/nvmeadm.c +++ b/usr/src/cmd/nvmeadm/nvmeadm.c @@ -10,10 +10,9 @@ */ /* - * Copyright 2016 Nexenta Systems, Inc. * Copyright 2017 Joyent, Inc. - * Copyright 2019 Western Digital Corporation. * Copyright 2021 Oxide Computer Company + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ /* @@ -28,8 +27,7 @@ * secure-erase ... * detach ... * attach ... - * get-param ... - * set-param ... + * list-firmware ... * load-firmware ... * commit-firmware ... * activate-firmware ... @@ -110,6 +108,7 @@ static void usage_get_features(const char *); static void usage_format(const char *); static void usage_secure_erase(const char *); static void usage_attach_detach(const char *); +static void usage_firmware_list(const char *); static void usage_firmware_load(const char *); static void usage_firmware_commit(const char *); static void usage_firmware_activate(const char *); @@ -169,6 +168,12 @@ static const nvmeadm_cmd_t nvmeadm_cmds[] = { do_attach_detach, usage_attach_detach, B_FALSE }, { + "list-firmware", + "list firmware on a controller", + NULL, + do_get_logpage_fwslot, usage_firmware_list, B_FALSE + }, + { "load-firmware", "load firmware to a controller", NULL, @@ -722,6 +727,14 @@ usage_get_logpage(const char *c_name) "are error, health, and firmware.\n", c_name); } +static void +usage_firmware_list(const char *c_name) +{ + (void) fprintf(stderr, "%s <ctl>\n\n" + " Print the log page that contains the list of firmware " + "images installed on the specified NVMe controller.\n", c_name); +} + static int do_get_logpage_error(int fd, const nvme_process_arg_t *npa) { @@ -788,7 +801,7 @@ do_get_logpage_fwslot(int fd, const nvme_process_arg_t *npa) return (-1); (void) printf("%s: ", npa->npa_name); - nvme_print_fwslot_log(fwlog); + nvme_print_fwslot_log(fwlog, npa->npa_idctl); free(fwlog); @@ -1314,6 +1327,7 @@ do_firmware_load(int fd, const nvme_process_arg_t *npa) ssize_t len; offset_t offset = 0; size_t size; + uint16_t sc; char buf[FIRMWARE_READ_BLKSIZE]; if (npa->npa_argc > 2) @@ -1323,6 +1337,10 @@ do_firmware_load(int fd, const nvme_process_arg_t *npa) errx(-1, "Requires firmware file name, and an " "optional offset"); + if (npa->npa_isns) + errx(-1, "Firmware loading not available on a per-namespace " + "basis"); + if (npa->npa_argc == 2) offset = get_fw_offsetb(npa->npa_argv[1]); @@ -1342,9 +1360,9 @@ do_firmware_load(int fd, const nvme_process_arg_t *npa) if (len == 0) break; - if (!nvme_firmware_load(fd, buf, len, offset)) + if (!nvme_firmware_load(fd, buf, len, offset, &sc)) errx(-1, "Error loading \"%s\": %s", npa->npa_argv[0], - strerror(errno)); + nvme_fw_error(errno, sc)); offset += len; size += len; @@ -1390,7 +1408,7 @@ static int do_firmware_commit(int fd, const nvme_process_arg_t *npa) { uint_t slot; - uint16_t sct, sc; + uint16_t sc; if (npa->npa_argc > 1) errx(-1, "Too many arguments"); @@ -1398,11 +1416,18 @@ do_firmware_commit(int fd, const nvme_process_arg_t *npa) if (npa->npa_argc == 0) errx(-1, "Firmware slot number is required"); + if (npa->npa_isns) + errx(-1, "Firmware committing not available on a per-namespace " + "basis"); + slot = get_slot_number(npa->npa_argv[0]); - if (!nvme_firmware_commit(fd, slot, NVME_FWC_SAVE, &sct, &sc)) + if (slot == 1 && npa->npa_idctl->id_frmw.fw_readonly) + errx(-1, "Cannot commit firmware to slot 1: slot is read-only"); + + if (!nvme_firmware_commit(fd, slot, NVME_FWC_SAVE, &sc)) errx(-1, "Failed to commit firmware to slot %u: %s", - slot, nvme_str_error(sct, sc)); + slot, nvme_fw_error(errno, sc)); if (verbose) (void) printf("Firmware committed to slot %u.\n", slot); @@ -1423,7 +1448,7 @@ static int do_firmware_activate(int fd, const nvme_process_arg_t *npa) { uint_t slot; - uint16_t sct, sc; + uint16_t sc; if (npa->npa_argc > 1) errx(-1, "Too many arguments"); @@ -1431,15 +1456,19 @@ do_firmware_activate(int fd, const nvme_process_arg_t *npa) if (npa->npa_argc == 0) errx(-1, "Firmware slot number is required"); + if (npa->npa_isns) + errx(-1, "Firmware activation not available on a per-namespace " + "basis"); + slot = get_slot_number(npa->npa_argv[0]); - if (!nvme_firmware_commit(fd, slot, NVME_FWC_ACTIVATE, &sct, &sc)) + if (!nvme_firmware_commit(fd, slot, NVME_FWC_ACTIVATE, &sc)) errx(-1, "Failed to activate slot %u: %s", slot, - nvme_str_error(sct, sc)); + nvme_fw_error(errno, sc)); if (verbose) printf("Slot %u activated: %s.\n", slot, - nvme_str_error(sct, sc)); + nvme_fw_error(errno, sc)); return (0); } diff --git a/usr/src/cmd/nvmeadm/nvmeadm.h b/usr/src/cmd/nvmeadm/nvmeadm.h index ff6a21c87f..6b620f8fab 100644 --- a/usr/src/cmd/nvmeadm/nvmeadm.h +++ b/usr/src/cmd/nvmeadm/nvmeadm.h @@ -10,9 +10,8 @@ */ /* - * Copyright 2016 Nexenta Systems, Inc. - * Copyright 2019 Western Digital Corporation * Copyright 2021 Oxide Computer Company + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ #ifndef _NVMEADM_H @@ -69,7 +68,7 @@ extern void nvme_print_error_log(int, nvme_error_log_entry_t *, nvme_version_t *); extern void nvme_print_health_log(nvme_health_log_t *, nvme_identify_ctrl_t *, nvme_version_t *); -extern void nvme_print_fwslot_log(nvme_fwslot_log_t *); +extern void nvme_print_fwslot_log(nvme_fwslot_log_t *, nvme_identify_ctrl_t *); extern void nvme_print_feat_arbitration(uint64_t, void *, size_t, nvme_identify_ctrl_t *, nvme_version_t *); @@ -97,7 +96,7 @@ extern void nvme_print_feat_auto_pst(uint64_t, void *, size_t, nvme_identify_ctrl_t *, nvme_version_t *); extern void nvme_print_feat_progress(uint64_t, void *, size_t, nvme_identify_ctrl_t *, nvme_version_t *); -extern const char *nvme_str_error(int, int); +extern const char *nvme_fw_error(int, int); /* device node functions */ extern int nvme_open(di_minor_t); @@ -113,8 +112,8 @@ extern int nvme_intr_cnt(int); extern boolean_t nvme_format_nvm(int, uint8_t, uint8_t); extern boolean_t nvme_detach(int); extern boolean_t nvme_attach(int); -extern boolean_t nvme_firmware_load(int, void *, size_t, offset_t); -extern boolean_t nvme_firmware_commit(int fd, int, int, uint16_t *, uint16_t *); +extern boolean_t nvme_firmware_load(int, void *, size_t, offset_t, uint16_t *); +extern boolean_t nvme_firmware_commit(int, int, int, uint16_t *); /* * ofmt related diff --git a/usr/src/cmd/nvmeadm/nvmeadm_dev.c b/usr/src/cmd/nvmeadm/nvmeadm_dev.c index fca609a320..1617de5da9 100644 --- a/usr/src/cmd/nvmeadm/nvmeadm_dev.c +++ b/usr/src/cmd/nvmeadm/nvmeadm_dev.c @@ -10,8 +10,7 @@ */ /* - * Copyright 2016 Nexenta Systems, Inc. - * Copyright 2019 Western Digital Corporation + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ #include <sys/types.h> @@ -35,9 +34,6 @@ nvme_ioctl(int fd, int ioc, size_t *bufsize, void **buf, uint64_t arg, void *ptr = NULL; int ret; - if (res != NULL) - *res = ~0ULL; - if (bufsize != NULL && *bufsize != 0) { assert(buf != NULL); @@ -62,6 +58,13 @@ nvme_ioctl(int fd, int ioc, size_t *bufsize, void **buf, uint64_t arg, *res = nioc.n_arg; if (ret != 0) { + /* + * We're not clearing *res here as there may be cases where + * we get an error _and_ we have interesting information in + * returned in *res that callers of this functions might be + * interested in. + */ + if (debug) warn("nvme_ioctl()"); if (ptr != NULL) @@ -178,14 +181,28 @@ nvme_attach(int fd) } boolean_t -nvme_firmware_load(int fd, void *buf, size_t len, offset_t offset) +nvme_firmware_load(int fd, void *buf, size_t len, offset_t offset, uint16_t *sc) { - return (nvme_ioctl(fd, NVME_IOC_FIRMWARE_DOWNLOAD, &len, &buf, offset, - NULL)); + boolean_t rv; + uint64_t res; + + rv = nvme_ioctl(fd, NVME_IOC_FIRMWARE_DOWNLOAD, &len, &buf, offset, + &res); + + /* + * If the hardware returned a command-specific status code, we'll get + * it as a negative value from the driver. + */ + if ((int64_t)res < 0) + *sc = (uint16_t)-(int64_t)res; + else + *sc = 0; + + return (rv); } boolean_t -nvme_firmware_commit(int fd, int slot, int action, uint16_t *sct, uint16_t *sc) +nvme_firmware_commit(int fd, int slot, int action, uint16_t *sc) { boolean_t rv; uint64_t res; @@ -193,10 +210,14 @@ nvme_firmware_commit(int fd, int slot, int action, uint16_t *sct, uint16_t *sc) rv = nvme_ioctl(fd, NVME_IOC_FIRMWARE_COMMIT, NULL, NULL, ((uint64_t)action << 32) | slot, &res); - if (sct != NULL) - *sct = (uint16_t)(res >> 16); - if (sc != NULL) - *sc = (uint16_t)res; + /* + * If the hardware returned a command-specific status code, we'll get + * it as a negative value from the driver. + */ + if ((int64_t)res < 0) + *sc = (uint16_t)-(int64_t)res; + else + *sc = 0; return (rv); } diff --git a/usr/src/cmd/nvmeadm/nvmeadm_print.c b/usr/src/cmd/nvmeadm/nvmeadm_print.c index 6a5da3d4e2..43c15925b2 100644 --- a/usr/src/cmd/nvmeadm/nvmeadm_print.c +++ b/usr/src/cmd/nvmeadm/nvmeadm_print.c @@ -10,10 +10,9 @@ */ /* - * Copyright 2016 Nexenta Systems, Inc. - * Copyright 2019 Western Digital Corporation * Copyright 2021 Oxide Computer Company * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ /* @@ -1910,17 +1909,25 @@ nvme_print_health_log(nvme_health_log_t *hlog, nvme_identify_ctrl_t *idctl, * This function pretty-prints the firmware slot information. */ void -nvme_print_fwslot_log(nvme_fwslot_log_t *fwlog) +nvme_print_fwslot_log(nvme_fwslot_log_t *fwlog, nvme_identify_ctrl_t *idctl) { int i; + char str[NVME_FWVER_SZ + sizeof (" (read-only)")]; + nvme_print(0, "Firmware Slot Information", -1, NULL); nvme_print_uint64(2, "Active Firmware Slot", fwlog->fw_afi, NULL, NULL); if (fwlog->fw_next != 0) nvme_print_uint64(2, "Next Firmware Slot", fwlog->fw_next, NULL, NULL); - for (i = 0; i != ARRAYSIZE(fwlog->fw_frs); i++) { + + (void) snprintf(str, sizeof (str), "%.*s%s", + nvme_strlen(fwlog->fw_frs[0], sizeof (fwlog->fw_frs[0])), + fwlog->fw_frs[0], idctl->id_frmw.fw_readonly ? " (read-only)" : ""); + nvme_print_str(2, "Firmware Revision for Slot", 1, str, sizeof (str)); + + for (i = 1; i < idctl->id_frmw.fw_nslot; i++) { nvme_print_str(2, "Firmware Revision for Slot", i + 1, fwlog->fw_frs[i][0] == '\0' ? "<Unused>" : fwlog->fw_frs[i], sizeof (fwlog->fw_frs[i])); @@ -2243,21 +2250,12 @@ nvme_print_feat_progress(uint64_t res, void *b, size_t s, spm.b.spm_pbslc, NULL, NULL); } -static const char * -nvme_str_generic_error(int sc) +const char * +nvme_fw_error(int err, int sc) { - switch (sc) { - case NVME_CQE_SC_GEN_SUCCESS: - return ("Success"); - default: - return ("See message log (usually /var/adm/messages) " - "for details"); - } -} + if (sc == 0) + return (strerror(err)); -static const char * -nvme_str_specific_error(int sc) -{ switch (sc) { case NVME_CQE_SC_SPC_INV_FW_SLOT: return ("Invalid firmware slot"); @@ -2279,20 +2277,5 @@ nvme_str_specific_error(int sc) return ("See message log (usually /var/adm/messages) " "for details"); } -} - -const char * -nvme_str_error(int sct, int sc) -{ - switch (sct) { - case NVME_CQE_SCT_GENERIC: - return (nvme_str_generic_error(sc)); - case NVME_CQE_SCT_SPECIFIC: - return (nvme_str_specific_error(sc)); - - default: - return ("See message log (usually /var/adm/messages) " - "for details"); - } } diff --git a/usr/src/cmd/script/script.c b/usr/src/cmd/script/script.c index 313a35df8a..0e73a9fd9b 100644 --- a/usr/src/cmd/script/script.c +++ b/usr/src/cmd/script/script.c @@ -3,8 +3,8 @@ * Use is subject to license terms. */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ /* @@ -33,8 +33,8 @@ #include <sys/file.h> #include <errno.h> -int grantpt(); -int unlockpt(); +int grantpt(); +int unlockpt(); char *ptsname(); void doinput() __NORETURN; void dooutput(); @@ -42,13 +42,13 @@ void doshell(); void fixtty(); void fail(); void done() __NORETURN; -void getmaster(); -void getslave(); +void getmanager(); +void getsubsid(); char *shell; FILE *fscript; -int master; /* file descriptor for master pseudo-tty */ -int slave; /* file descriptor for slave pseudo-tty */ +int manager; /* file descriptor for manager pseudo-tty */ +int subsid; /* file descriptor for subsidiary pseudo-tty */ int child; int subchild; char *fname = "typescript"; @@ -59,7 +59,7 @@ struct termios b; struct winsize size; int lb; int l; -char *mptname = "/dev/ptmx"; /* master pseudo-tty device */ +char *mptname = "/dev/ptmx"; /* manager pseudo-tty device */ int aflg; @@ -103,7 +103,7 @@ main(int argc, char *argv[]) } setbuf(fscript, NULL); chown(fname, ruidt, gidt); - getmaster(); + getmanager(); printf(gettext("Script started, file is %s\n"), fname); fixtty(); @@ -146,7 +146,7 @@ doinput() break; } } - (void) write(master, ibuf, cc); + (void) write(manager, ibuf, cc); } done(); } @@ -157,7 +157,7 @@ sigwinch() struct winsize ws; if (ioctl(0, TIOCGWINSZ, &ws) == 0) - (void) ioctl(master, TIOCSWINSZ, &ws); + (void) ioctl(manager, TIOCSWINSZ, &ws); } #include <sys/wait.h> @@ -190,7 +190,7 @@ dooutput() strftime(tbuf, BUFSIZ, "%c", localtime(&tvec)); fprintf(fscript, gettext("Script started on %s\n"), tbuf); for (;;) { - cc = read(master, obuf, sizeof (obuf)); + cc = read(manager, obuf, sizeof (obuf)); if (cc <= 0) break; (void) write(1, obuf, cc); @@ -204,13 +204,13 @@ doshell() { setpgrp(); /* relinquish control terminal */ - getslave(); - (void) close(master); + getsubsid(); + (void) close(manager); (void) fclose(fscript); - (void) dup2(slave, 0); - (void) dup2(slave, 1); - (void) dup2(slave, 2); - (void) close(slave); + (void) dup2(subsid, 0); + (void) dup2(subsid, 1); + (void) dup2(subsid, 2); + (void) close(subsid); execl(shell, shell, "-i", (char *)0); perror(shell); fail(); @@ -249,7 +249,7 @@ done() strftime(tbuf, BUFSIZ, "%c", localtime(&tvec)); fprintf(fscript, gettext("\nscript done on %s\n"), tbuf); (void) fclose(fscript); - (void) close(master); + (void) close(manager); } else { (void) ioctl(0, TCSETSW, (char *)&b); printf(gettext("Script done, file is %s\n"), fname); @@ -258,11 +258,11 @@ done() } void -getmaster() +getmanager() { struct stat stb; - if ((master = open(mptname, O_RDWR)) >= 0) { /* a pseudo-tty is free */ + if ((manager = open(mptname, O_RDWR)) >= 0) { /* a pseudo-tty is free */ (void) ioctl(0, TCGETS, (char *)&b); (void) ioctl(0, TIOCGWINSZ, (char *)&size); return; @@ -274,21 +274,21 @@ getmaster() } void -getslave() +getsubsid() { - char *slavename; /* name of slave pseudo-tty */ - - grantpt(master); /* change permissions of slave */ - unlockpt(master); /* unlock slave */ - slavename = ptsname(master); /* get name of slave */ - slave = open(slavename, O_RDWR); /* open slave */ - if (slave < 0) { /* error on opening slave */ - perror(slavename); + char *subsidname; /* name of subsidiary pseudo-tty */ + + grantpt(manager); /* change permissions of subsidiary */ + unlockpt(manager); /* unlock subsidiary */ + subsidname = ptsname(manager); /* get name of subsidiary */ + subsid = open(subsidname, O_RDWR); /* open subsidiary */ + if (subsid < 0) { /* error opening subsidiary */ + perror(subsidname); fail(); } - ioctl(slave, I_PUSH, "ptem"); /* push pt hw emulation module */ - ioctl(slave, I_PUSH, "ldterm"); /* push line discipline */ + ioctl(subsid, I_PUSH, "ptem"); /* push pt hw emulation module */ + ioctl(subsid, I_PUSH, "ldterm"); /* push line discipline */ - (void) ioctl(slave, TCSETSF, (char *)&b); - (void) ioctl(slave, TIOCSWINSZ, (char *)&size); + (void) ioctl(subsid, TCSETSF, (char *)&b); + (void) ioctl(subsid, TIOCSWINSZ, (char *)&size); } diff --git a/usr/src/cmd/truss/codes.c b/usr/src/cmd/truss/codes.c index 95b15ca787..1c15c31b5c 100644 --- a/usr/src/cmd/truss/codes.c +++ b/usr/src/cmd/truss/codes.c @@ -1503,8 +1503,8 @@ const struct ioc { { (uint_t)IPTUN_GET_6TO4RELAY, "IPTUN_GET_6TO4RELAY", NULL}, /* zcons ioctls */ - { (uint_t)ZC_HOLDSLAVE, "ZC_HOLDSLAVE", NULL }, - { (uint_t)ZC_RELEASESLAVE, "ZC_RELEASESLAVE", NULL }, + { (uint_t)ZC_HOLDSUBSID, "ZC_HOLDSUBSID", NULL }, + { (uint_t)ZC_RELEASESUBSID, "ZC_RELEASESUBSID", NULL }, /* hid ioctls - ('h' << 8) - hid.h */ { (uint_t)HIDIOCKMGDIRECT, "HIDIOCKMGDIRECT", NULL }, diff --git a/usr/src/cmd/ttymon/parms.h b/usr/src/cmd/ttymon/parms.h index b293eb45a2..9299147f7c 100644 --- a/usr/src/cmd/ttymon/parms.h +++ b/usr/src/cmd/ttymon/parms.h @@ -19,13 +19,12 @@ * * CDDL HEADER END */ -/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */ +/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ +#ifndef _PARMS_H +#define _PARMS_H /* If running SVR3, #define both ATTSVR3 and ATTSV */ #define ATTSVR3 /* System V Release 3 */ @@ -155,8 +154,8 @@ #define DEFAULT_BAUDRATE "9600" /* */ /*define permission modes for the device */ -#define M_DEVICEMODE (mode_t) 0600 /* MASTER device mode */ -#define S_DEVICEMODE (mode_t) 0600 /* SLAVE device mode */ +#define M_DEVICEMODE (mode_t) 0600 /* manager device mode */ +#define S_DEVICEMODE (mode_t) 0600 /* subsidiary device mode */ #define R_DEVICEMODE (mode_t) 0600 /* default mode to restore */ /* NO_MODEM_CTRL - define this if you have very old hardware @@ -232,7 +231,7 @@ /* define USRSPOOLLOCKS if you like your lock files in /var/spool/locks * be sure other programs such as 'cu' and 'ct' know about this * - * WARNING: if you do not define USRSPOOLLOCKS, then $LOCK in + * WARNING: if you do not define USRSPOOLLOCKS, then $LOCK in * uudemon.cleanup must be changed. */ #define USRSPOOLLOCKS /* define to use /var/spool/locks for LCK files */ @@ -241,3 +240,5 @@ * this entails sleeping between reads at low baud rates. */ #define PKSPEEDUP /* */ + +#endif /* !_PARMS_H */ diff --git a/usr/src/cmd/varpd/Makefile b/usr/src/cmd/varpd/Makefile index ceb719f256..05569be767 100644 --- a/usr/src/cmd/varpd/Makefile +++ b/usr/src/cmd/varpd/Makefile @@ -32,8 +32,7 @@ CFLAGS += $(CCVERBOSE) LDLIBS += -lvarpd -lumem -lscf $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG -C99MODE= -xc99=%all -C99LMODE= -Xc99=%all +CSTD= $(CSTD_GNU99) .KEEP_STATE: diff --git a/usr/src/cmd/varpd/varpd.c b/usr/src/cmd/varpd/varpd.c index 0a200a68fc..cfba560e9f 100644 --- a/usr/src/cmd/varpd/varpd.c +++ b/usr/src/cmd/varpd/varpd.c @@ -20,18 +20,19 @@ * truly understand its purpose and how it fits into things, you should read the * overlay big theory statement in uts/common/io/overlay/overlay.c. * - * varod's purpose it to provide a means for looking up the destination on the + * varpd's purpose it to provide a means for looking up the destination on the * underlay network for a host on an overlay network and to also be a door * server such that dladm(1M) via libdladm can configure and get useful status * information. The heavy lifting is all done by libvarpd and the various lookup * plugins. * - * When varpd first starts up, we take of chdiring into /var/run/varpd, which is - * also where we create /var/run/varpd.door, our door server. After that we - * daemonize and only after we daemonize do we go ahead and load plugins. The - * reason that we don't load plugins before daemonizing is that they could very - * well be creating threads and thus lose them all. In general, we want to make - * things easier on our children and not require them to be fork safe. + * When varpd first starts up, we take care of chdiring into /var/run/varpd, + * which is also where we create /var/run/varpd/varpd.door, our door server. + * After that we daemonize and only after we daemonize do we go ahead and load + * plugins. The reason that we don't load plugins before daemonizing is that + * they could very well be creating threads and thus lose them all. In general, + * we want to make things easier on our children and not require them to be + * fork safe. * * Once it's spun up, the main varpd thread sits in sigsuspend and really just * hangs out waiting for something, libvarpd handles everything else. @@ -334,7 +335,7 @@ varpd_cleanup(void) * Load default information from SMF and apply any of if necessary. We recognize * the following properties: * - * varpd/include_path Treat these as a series of -i options. + * varpd/include_path Treat these as a series of -i options. * * If we're not under SMF, just move on. */ @@ -481,7 +482,7 @@ main(int argc, char *argv[]) doorpath, strerror(err)); /* - * At this point, finish up signal intialization and finally go ahead, + * At this point, finish up signal initialization and finally go ahead, * notify the parent that we're okay, and enter the sigsuspend loop. */ bzero(&act, sizeof (struct sigaction)); diff --git a/usr/src/cmd/zoneadmd/zcons.c b/usr/src/cmd/zoneadmd/zcons.c index 5f415b0210..efc3c390d4 100644 --- a/usr/src/cmd/zoneadmd/zcons.c +++ b/usr/src/cmd/zoneadmd/zcons.c @@ -57,9 +57,9 @@ * | +-[Anchor]--+ * | | ptem | * V +-----------+ - * +---master---+---slave---+ + * +---manager--+-subsidiary+ * | | - * | zcons driver | + * | Zcons driver | * | zonename="myzone" | * +------------------------+ * @@ -71,7 +71,7 @@ * to online new instances of zcons as needed. Care is taken to * prune and manage these appropriately; see init_console_dev() and * destroy_console_dev(). The end result is the creation of the - * zcons(7D) instance and an open file descriptor to the master side. + * zcons(7D) instance and an open file descriptor to the manager side. * zcons instances are associated with zones via their zonename device * property. This the console instance to persist across reboots, * and while the zone is halted. @@ -79,7 +79,7 @@ * - Acting as a server for 'zlogin -C' instances. When zlogin -C is * run, zlogin connects to zoneadmd via unix domain socket. zoneadmd * functions as a two-way proxy for console I/O, relaying user input - * to the master side of the console, and relaying output from the + * to the manager side of the console, and relaying output from the * zone to the user. * * - Logging output to <zonepath>/logs/console.log. @@ -133,9 +133,9 @@ char boot_args[BOOTARGS_MAX]; */ static int eventstream[2]; -/* flag used to cope with race creating master zcons devlink */ -static boolean_t master_zcons_failed = B_FALSE; -/* flag to track if we've seen a state change when there is no master zcons */ +/* flag used to cope with race creating manager zcons devlink */ +static boolean_t manager_zcons_failed = B_FALSE; +/* flag to track if we've seen a state change when there is no manager zcons */ static boolean_t state_changed = B_FALSE; int @@ -271,34 +271,35 @@ destroy_console_devs(zlog_t *zlogp) char conspath[MAXPATHLEN]; di_node_t root; struct cb_data cb; - int masterfd; - int slavefd; + int managerfd; + int subfd; /* - * Signal the master side to release its handle on the slave side by - * issuing a ZC_RELEASESLAVE ioctl. + * Signal the manager side to release its handle on the subsidiary side + * by issuing a ZC_RELEASESUBSID ioctl. */ (void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s", - zone_name, ZCONS_MASTER_NAME); - if ((masterfd = open(conspath, O_RDWR | O_NOCTTY)) != -1) { + zone_name, ZCONS_MANAGER_NAME); + if ((managerfd = open(conspath, O_RDWR | O_NOCTTY)) != -1) { (void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s", - zone_name, ZCONS_SLAVE_NAME); - if ((slavefd = open(conspath, O_RDWR | O_NOCTTY)) != -1) { - if (ioctl(masterfd, ZC_RELEASESLAVE, - (caddr_t)(intptr_t)slavefd) != 0) + zone_name, ZCONS_SUBSIDIARY_NAME); + if ((subfd = open(conspath, O_RDWR | O_NOCTTY)) != -1) { + if (ioctl(managerfd, ZC_RELEASESUBSID, + (caddr_t)(intptr_t)subfd) != 0) zerror(zlogp, B_TRUE, "WARNING: error while " - "releasing slave handle of zone console for" - " %s", zone_name); - (void) close(slavefd); + "releasing subsidiary handle of zone " + "console for %s", zone_name); + (void) close(subfd); } else { - zerror(zlogp, B_TRUE, "WARNING: could not open slave " - "side of zone console for %s to release slave " - "handle", zone_name); + zerror(zlogp, B_TRUE, "WARNING: could not open " + "subsidiary side of zone console for %s to " + "release subsidiary handle", zone_name); } - (void) close(masterfd); + (void) close(managerfd); } else { - zerror(zlogp, B_TRUE, "WARNING: could not open master side of " - "zone console for %s to release slave handle", zone_name); + zerror(zlogp, B_TRUE, "WARNING: could not open manager side of " + "zone console for %s to release subsidiary handle", + zone_name); } bzero(&cb, sizeof (cb)); @@ -329,8 +330,8 @@ destroy_console_devs(zlog_t *zlogp) * sanity checking, and are careful to reuse a console if one exists. * * Once the device is in the device tree, we kick devfsadm via di_devlink_init() - * to ensure that the appropriate symlinks (to the master and slave console - * devices) are placed in /dev in the global zone. + * to ensure that the appropriate symlinks (to the manager and subsidiary + * console devices) are placed in /dev in the global zone. */ static int init_console_dev(zlog_t *zlogp) @@ -342,8 +343,8 @@ init_console_dev(zlog_t *zlogp) di_devlink_handle_t dl = NULL; int rv = -1; int ndevs; - int masterfd; - int slavefd; + int managerfd; + int subfd; int i; /* @@ -411,9 +412,10 @@ devlinks: } /* - * Open the master side of the console and issue the ZC_HOLDSLAVE ioctl, - * which will cause the master to retain a reference to the slave. - * This prevents ttymon from blowing through the slave's STREAMS anchor. + * Open the manager side of the console and issue the ZC_HOLDSUBSID + * ioctl, which will cause the manager to retain a reference to the + * subsidiary. This prevents ttymon from blowing through the + * subsidiary's STREAMS anchor. * * In very rare cases the open returns ENOENT if devfs doesn't have * everything setup yet due to heavy zone startup load. Wait for @@ -421,40 +423,42 @@ devlinks: * console, we still go ahead and boot the zone. */ (void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s", - zone_name, ZCONS_MASTER_NAME); + zone_name, ZCONS_MANAGER_NAME); for (i = 0; i < ZCONS_RETRY; i++) { - masterfd = open(conspath, O_RDWR | O_NOCTTY); - if (masterfd >= 0 || errno != ENOENT) + managerfd = open(conspath, O_RDWR | O_NOCTTY); + if (managerfd >= 0 || errno != ENOENT) break; (void) sleep(1); } - if (masterfd == -1) { - zerror(zlogp, B_TRUE, "ERROR: could not open master side of " - "zone console for %s to acquire slave handle", zone_name); - master_zcons_failed = B_TRUE; + if (managerfd == -1) { + zerror(zlogp, B_TRUE, "ERROR: could not open manager side of " + "zone console for %s to acquire subsidiary handle", + zone_name); + manager_zcons_failed = B_TRUE; } (void) snprintf(conspath, sizeof (conspath), "/dev/zcons/%s/%s", - zone_name, ZCONS_SLAVE_NAME); + zone_name, ZCONS_SUBSIDIARY_NAME); for (i = 0; i < ZCONS_RETRY; i++) { - slavefd = open(conspath, O_RDWR | O_NOCTTY); - if (slavefd >= 0 || errno != ENOENT) + subfd = open(conspath, O_RDWR | O_NOCTTY); + if (subfd >= 0 || errno != ENOENT) break; (void) sleep(1); } - if (slavefd == -1) - zerror(zlogp, B_TRUE, "ERROR: could not open slave side of zone" - " console for %s to acquire slave handle", zone_name); + if (subfd == -1) + zerror(zlogp, B_TRUE, "ERROR: could not open subsidiary side " + "of zone console for %s to acquire subsidiary handle", + zone_name); /* * This ioctl can occasionally return ENXIO if devfs doesn't have * everything plumbed up yet due to heavy zone startup load. Wait for * 1 sec. and retry a few times before we fail to boot the zone. */ - if (masterfd != -1 && slavefd != -1) { + if (managerfd != -1 && subfd != -1) { for (i = 0; i < ZCONS_RETRY; i++) { - if (ioctl(masterfd, ZC_HOLDSLAVE, - (caddr_t)(intptr_t)slavefd) == 0) { + if (ioctl(managerfd, ZC_HOLDSUBSID, + (caddr_t)(intptr_t)subfd) == 0) { rv = 0; break; } else if (errno != ENXIO) { @@ -464,13 +468,14 @@ devlinks: } if (rv != 0) zerror(zlogp, B_TRUE, "ERROR: error while acquiring " - "slave handle of zone console for %s", zone_name); + "subsidiary handle of zone console for %s", + zone_name); } - if (slavefd != -1) - (void) close(slavefd); - if (masterfd != -1) - (void) close(masterfd); + if (subfd != -1) + (void) close(subfd); + if (managerfd != -1) + (void) close(managerfd); error: if (ddef_hdl) @@ -723,7 +728,7 @@ test_client(int clifd) /* * This routine drives the console I/O loop. It polls for input from the - * master side of the console (output to the console), and from the client + * manager side of the console (output to the console), and from the client * (input from the console user). Additionally, it polls on the server fd, * and disconnects any clients that might try to hook up with the zone while * the console is in use. @@ -944,7 +949,7 @@ zcons_statechanged() void serve_console(zlog_t *zlogp) { - int masterfd; + int managerfd; zone_state_t zstate; char conspath[MAXPATHLEN]; static boolean_t cons_warned = B_FALSE; @@ -953,12 +958,12 @@ serve_console(zlog_t *zlogp) conslog = logstream_open("console.log", "console", LS_LINE_BUFFERED); (void) snprintf(conspath, sizeof (conspath), - "/dev/zcons/%s/%s", zone_name, ZCONS_MASTER_NAME); + "/dev/zcons/%s/%s", zone_name, ZCONS_MANAGER_NAME); for (;;) { - masterfd = open(conspath, O_RDWR|O_NONBLOCK|O_NOCTTY); - if (masterfd == -1) { - if (master_zcons_failed) { + managerfd = open(conspath, O_RDWR|O_NONBLOCK|O_NOCTTY); + if (managerfd == -1) { + if (manager_zcons_failed) { /* * If we don't have a console and the zone is * not shutting down, there may have been a @@ -998,7 +1003,7 @@ serve_console(zlog_t *zlogp) } } - zerror(zlogp, B_TRUE, "failed to open console master"); + zerror(zlogp, B_TRUE, "failed to open console manager"); (void) mutex_lock(&lock); goto death; } @@ -1010,14 +1015,14 @@ serve_console(zlog_t *zlogp) * messages, we wouldn't be able to use read(2), as it fails * (EBADMSG) when a message with a control element is received. */ - if (ioctl(masterfd, I_SRDOPT, RNORM|RPROTDIS) == -1) { + if (ioctl(managerfd, I_SRDOPT, RNORM|RPROTDIS) == -1) { zerror(zlogp, B_TRUE, "failed to set options on " - "console master"); + "console manager"); (void) mutex_lock(&lock); goto death; } - do_console_io(zlogp, masterfd, serverfd, conslog); + do_console_io(zlogp, managerfd, serverfd, conslog); /* * We would prefer not to do this, but hostile zone processes @@ -1026,7 +1031,7 @@ serve_console(zlog_t *zlogp) * we dismantle the stream and reopen the console when we * take another lap. */ - (void) close(masterfd); + (void) close(managerfd); (void) mutex_lock(&lock); /* diff --git a/usr/src/common/core/core_shstrtab.c b/usr/src/common/core/core_shstrtab.c index b1bcbce682..ea2d15db40 100644 --- a/usr/src/common/core/core_shstrtab.c +++ b/usr/src/common/core/core_shstrtab.c @@ -46,8 +46,7 @@ static void * shstrtab_alloc(void) { #ifdef _KERNEL - return (kmem_zalloc(sizeof (shstrtab_ent_t), - KM_NOSLEEP | KM_NORMALPRI)); + return (kmem_zalloc(sizeof (shstrtab_ent_t), KM_NOSLEEP_LAZY)); #else return (calloc(1, sizeof (shstrtab_ent_t))); #endif diff --git a/usr/src/lib/libdladm/Makefile.com b/usr/src/lib/libdladm/Makefile.com index 19db4ccace..0737012ec7 100644 --- a/usr/src/lib/libdladm/Makefile.com +++ b/usr/src/lib/libdladm/Makefile.com @@ -52,9 +52,10 @@ CPPFLAGS += -I$(SRCDIR) -D_REENTRANT # not linted SMATCH=off +CSTD= $(CSTD_GNU99) + .KEEP_STATE: all: $(LIBS) - include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libdladm/common/libdladm.c b/usr/src/lib/libdladm/common/libdladm.c index 446a15893b..b7c9824991 100644 --- a/usr/src/lib/libdladm/common/libdladm.c +++ b/usr/src/lib/libdladm/common/libdladm.c @@ -459,6 +459,9 @@ dladm_status2str(dladm_status_t status, char *buf) case DLADM_STATUS_PERSIST_ON_TEMP: s = "can't create persistent object on top of temporary object"; break; + case DLADM_STATUS_BAD_ENCAP: + s = "invalid encapsulation protocol"; + break; default: s = "<unknown error>"; break; diff --git a/usr/src/lib/libdladm/common/libdladm.h b/usr/src/lib/libdladm/common/libdladm.h index 685356fa64..ecbbab0e86 100644 --- a/usr/src/lib/libdladm/common/libdladm.h +++ b/usr/src/lib/libdladm/common/libdladm.h @@ -24,6 +24,7 @@ */ /* + * Copyright 2015, Joyent, Inc. * Copyright 2020 OmniOS Community Edition (OmniOSce) Association */ @@ -185,8 +186,8 @@ typedef enum { DLADM_STATUS_INVALID_PKEY_TBL_SIZE, DLADM_STATUS_PORT_NOPROTO, DLADM_STATUS_INVALID_MTU, - DLADM_STATUS_BAD_ENCAP, - DLADM_STATUS_PERSIST_ON_TEMP + DLADM_STATUS_PERSIST_ON_TEMP, + DLADM_STATUS_BAD_ENCAP } dladm_status_t; typedef enum { diff --git a/usr/src/lib/libdladm/common/libdloverlay.c b/usr/src/lib/libdladm/common/libdloverlay.c index a83105b91c..ecb604fde9 100644 --- a/usr/src/lib/libdladm/common/libdloverlay.c +++ b/usr/src/lib/libdladm/common/libdloverlay.c @@ -59,7 +59,6 @@ dladm_overlay_prop_info(dladm_overlay_propinfo_handle_t phdl, if (sizep != NULL) *sizep = oinfop->oipi_defsize; if (possp != NULL) { - /* LINTED: E_BAD_PTR_CAST_ALIGN */ *possp = (const mac_propval_range_t *)oinfop->oipi_poss; } @@ -452,7 +451,6 @@ dladm_overlay_walk_prop(dladm_handle_t handle, datalink_id_t linkid, &bufsize) != DLADM_STATUS_OK) continue; - /* LINTED: E_BAD_PTR_CAST_ALIGN */ vp = (uint64_t *)buf; varpdid = *vp; } diff --git a/usr/src/lib/varpd/direct/Makefile.com b/usr/src/lib/varpd/direct/Makefile.com index 2987d2a260..9d62140620 100644 --- a/usr/src/lib/varpd/direct/Makefile.com +++ b/usr/src/lib/varpd/direct/Makefile.com @@ -24,8 +24,7 @@ LIBS = $(DYNLIB) LDLIBS += -lc -lumem -lnvpair CPPFLAGS += -I../common -C99MODE= -xc99=%all -C99LMODE= -Xc99=%all +CSTD= $(CSTD_GNU99) SRCDIR = ../common diff --git a/usr/src/lib/varpd/direct/amd64/Makefile b/usr/src/lib/varpd/direct/amd64/Makefile index d552642882..1881990d79 100644 --- a/usr/src/lib/varpd/direct/amd64/Makefile +++ b/usr/src/lib/varpd/direct/amd64/Makefile @@ -16,4 +16,4 @@ include ../Makefile.com include ../../../Makefile.lib.64 -install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/varpd/direct/common/libvarpd_direct.c b/usr/src/lib/varpd/direct/common/libvarpd_direct.c index 018cdf641c..ed9f79fc7f 100644 --- a/usr/src/lib/varpd/direct/common/libvarpd_direct.c +++ b/usr/src/lib/varpd/direct/common/libvarpd_direct.c @@ -19,7 +19,7 @@ * This plugin implements a simple point to point plugin for a packet. It * represents the traditional tunnel, just in overlay form. As such, the only * properties it needs are those to determine where to send everything. At this - * time, we don't allow a mulicast address; however, there's no reason that the + * time, we don't allow a multicast address; however, there's no reason that the * direct plugin shouldn't in theory support multicast, though when implementing * it the best path will become clear. * @@ -48,7 +48,7 @@ typedef struct varpd_direct { mutex_t vad_lock; /* Protects the rest */ boolean_t vad_hip; boolean_t vad_hport; - struct in6_addr vad_ip; + struct in6_addr vad_ip; uint16_t vad_port; } varpd_direct_t; diff --git a/usr/src/lib/varpd/direct/i386/Makefile b/usr/src/lib/varpd/direct/i386/Makefile index f2b4f63da5..4398507523 100644 --- a/usr/src/lib/varpd/direct/i386/Makefile +++ b/usr/src/lib/varpd/direct/i386/Makefile @@ -15,4 +15,4 @@ include ../Makefile.com -install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/varpd/files/Makefile.com b/usr/src/lib/varpd/files/Makefile.com index 815f883ea2..dc24395673 100644 --- a/usr/src/lib/varpd/files/Makefile.com +++ b/usr/src/lib/varpd/files/Makefile.com @@ -25,11 +25,7 @@ LIBS = $(DYNLIB) LDLIBS += -lc -lumem -lnvpair -lsocket -lcustr CPPFLAGS += -I../common -LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTFLAGS64 += -erroff=E_BAD_PTR_CAST_ALIGN - -C99MODE= -xc99=%all -C99LMODE= -Xc99=%all +CSTD= $(CSTD_GNU99) SRCDIR = ../common diff --git a/usr/src/lib/varpd/files/amd64/Makefile b/usr/src/lib/varpd/files/amd64/Makefile index d552642882..1881990d79 100644 --- a/usr/src/lib/varpd/files/amd64/Makefile +++ b/usr/src/lib/varpd/files/amd64/Makefile @@ -16,4 +16,4 @@ include ../Makefile.com include ../../../Makefile.lib.64 -install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/varpd/files/common/libvarpd_files.c b/usr/src/lib/varpd/files/common/libvarpd_files.c index 812919a07d..84cb27f9e8 100644 --- a/usr/src/lib/varpd/files/common/libvarpd_files.c +++ b/usr/src/lib/varpd/files/common/libvarpd_files.c @@ -17,7 +17,7 @@ * Files based plug-in for varpd * * This is a dynamic varpd plug-in that has a static backing store. It's really - * nothing more than a glorified version of /etc/ethers, though it facilitiates + * nothing more than a glorified version of /etc/ethers, though it facilitates * a bit more. The files module allows for the full set of mappings to be fixed * at creation time. In addition, it also provides support for proxying ARP, * NDP, and DHCP. @@ -28,7 +28,7 @@ * The plug-in only has a single property, which is the location of the JSON * file. The JSON file itself looks something like: * - * { + * { * "aa:bb:cc:dd:ee:ff": { * "arp": "10.23.69.1", * "ndp": "2600:3c00::f03c:91ff:fe96:a264", diff --git a/usr/src/lib/varpd/files/i386/Makefile b/usr/src/lib/varpd/files/i386/Makefile index f2b4f63da5..4398507523 100644 --- a/usr/src/lib/varpd/files/i386/Makefile +++ b/usr/src/lib/varpd/files/i386/Makefile @@ -15,4 +15,4 @@ include ../Makefile.com -install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/varpd/libvarpd/Makefile.com b/usr/src/lib/varpd/libvarpd/Makefile.com index 67f824f7b2..efb86887e9 100644 --- a/usr/src/lib/varpd/libvarpd/Makefile.com +++ b/usr/src/lib/varpd/libvarpd/Makefile.com @@ -28,6 +28,9 @@ OBJECTS = libvarpd.o \ include ../../../Makefile.lib +# install this library in the root filesystem +include ../../../Makefile.rootfs + LIBS = $(DYNLIB) LDLIBS += -lc -lavl -lumem -lidspace -lnvpair -lmd5 -lrename \ -lbunyan @@ -35,8 +38,7 @@ CPPFLAGS += -I../common CERRWARN += -erroff=E_STRUCT_DERIVED_FROM_FLEX_MBR -C99MODE= -xc99=%all -C99LMODE= -Xc99=%all +CSTD= $(CSTD_GNU99) SRCDIR = ../common diff --git a/usr/src/lib/varpd/libvarpd/amd64/Makefile b/usr/src/lib/varpd/libvarpd/amd64/Makefile index d552642882..1881990d79 100644 --- a/usr/src/lib/varpd/libvarpd/amd64/Makefile +++ b/usr/src/lib/varpd/libvarpd/amd64/Makefile @@ -16,4 +16,4 @@ include ../Makefile.com include ../../../Makefile.lib.64 -install: all $(ROOTLIBS64) $(ROOTLINKS64) $(ROOTLINT64) +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_arp.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_arp.c index df69207fe0..7180fcb2de 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_arp.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_arp.c @@ -14,7 +14,7 @@ */ /* - * Common routines for implmeenting proxy arp + * Common routines for implementing proxy arp */ #include <sys/types.h> @@ -43,7 +43,7 @@ typedef struct varpd_arp_query { varpd_query_handle_t *vaq_query; const overlay_targ_lookup_t *vaq_otl; ip6_t *vaq_ip6; - nd_neighbor_solicit_t *vaq_ns; + nd_neighbor_solicit_t *vaq_ns; } varpd_arp_query_t; typedef struct varpd_dhcp_query { @@ -320,7 +320,7 @@ libvarpd_plugin_proxy_ndp(varpd_provider_handle_t *hdl, } /* - * Now we know that this is an ICMPv6 request targetting the right + * Now we know that this is an ICMPv6 request targeting the right * IPv6 multicast prefix. Let's go through and verify that ICMPv6 * indicates that we have the real thing and ensure that per RFC 4861 * the target address is not a multicast address. Further, because this @@ -422,7 +422,6 @@ libvarpd_proxy_ndp_fini(varpd_arp_query_t *vaq) na->nd_na_code = 0; /* * RFC 4443 defines that we should set the checksum to zero before we - * calculate the checksumat we should set the checksum to zero before we * calculate it. */ na->nd_na_cksum = 0; @@ -605,7 +604,7 @@ libvarpd_plugin_dhcp_reply(varpd_dhcp_handle_t *vdh, int action) } /* - * Inject a gratuitious ARP packet to the specified mac address. + * Inject a gratuitous ARP packet to the specified mac address. */ void libvarpd_inject_arp(varpd_provider_handle_t *vph, const uint16_t vlan, diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_client.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_client.c index 18e220259c..1254c14e19 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_client.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_client.c @@ -76,7 +76,7 @@ libvarpd_c_door_call(varpd_client_t *client, varpd_client_arg_t *argp, case ENOTSUP: case EOVERFLOW: case ENFILE: - libvarpd_panic("unhandalable errno from door_call: %d", + libvarpd_panic("unhandleable errno from door_call: %d", errno); } ret = errno; diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c index cedd58dad9..f314440056 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_overlay.c @@ -232,11 +232,11 @@ libvarpd_overlay_lookup_reply(varpd_impl_t *vip, /* * The only errors that should cause us to end up here are due to - * programmer errors. Aruably the EINAVL case indicates that something + * programmer errors. Arguably the EINVAL case indicates that something * is a bit off; however, at this time we don't opt to kill varpd. */ if (ret != 0 && errno != EINVAL) - libvarpd_panic("receieved bad errno from lookup_reply " + libvarpd_panic("received bad errno from lookup_reply " "(cmd %d): %d\n", cmd, errno); } @@ -504,7 +504,7 @@ libvarpd_plugin_query_reply(varpd_query_handle_t *vqh, int action) varpd_query_t *vqp = (varpd_query_t *)vqh; if (vqp == NULL) - libvarpd_panic("unkonwn plugin passed invalid " + libvarpd_panic("unknown plugin passed invalid " "varpd_query_handle_t"); if (action == VARPD_LOOKUP_DROP) diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_panic.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_panic.c index 6728d79d6e..ba6bc26bf6 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_panic.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_panic.c @@ -15,7 +15,7 @@ /* * No, 'tis not so deep as a well, nor so wide as a church door; but 'tis - * enough,'twill serve. Ask for me tomorrow, and you shall find me a grave man. + * enough, 'twill serve. Ask for me tomorrow, and you shall find me a grave man. * * This file maintains various routines for handling when we die. */ diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h b/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h index 64fa99d308..17ea02fe03 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_provider.h @@ -86,158 +86,158 @@ * * varpd_plugin_create_f * - * Create a new instance of a plugin. Each instance refers to a different - * overlay device and thus a different overlay identifier. Each instance - * has its own property space and is unique. This function gives the chance - * for the plugin to create and provide any private data that it will - * require. + * Create a new instance of a plugin. Each instance refers to a different + * overlay device and thus a different overlay identifier. Each instance + * has its own property space and is unique. This function gives the chance + * for the plugin to create and provide any private data that it will + * require. * - * In addition, the plugin is given the type of destination that is - * required and it is its job to determine whether or not it supports it. + * In addition, the plugin is given the type of destination that is + * required and it is its job to determine whether or not it supports it. * - * varpd_plugin_destory_f + * varpd_plugin_destroy_f * - * This is the opposite of varpd_plugin_create_f. It is called to allow the - * plugin to reclaim any resources with the private argument that it passed - * out as part of the destroy function. + * This is the opposite of varpd_plugin_create_f. It is called to allow the + * plugin to reclaim any resources with the private argument that it passed + * out as part of the destroy function. * * varpd_plugin_start_f * - * This routine is called to indicate that an instance should be started. - * This is a plugin's chance to verify that it has all of its required - * properties set and to take care of any action that needs to be handled - * to begin the plugin. After this point it will be legal to have the - * varpd_plugin_default_f, varpd_plugin_lookup_f, varpd_plugin_arp_f and - * varpd_plugin_dhcp_f endpoints called. + * This routine is called to indicate that an instance should be started. + * This is a plugin's chance to verify that it has all of its required + * properties set and to take care of any action that needs to be handled + * to begin the plugin. After this point it will be legal to have the + * varpd_plugin_default_f, varpd_plugin_lookup_f, varpd_plugin_arp_f and + * varpd_plugin_dhcp_f endpoints called. * * varpd_plugin_stop_f * - * This routine is called to indicate that an instance is stopping, it is - * the opposite of varpd_plugin_start_f. This is a chance to clean up - * resources that are a side effect of having started the instance. + * This routine is called to indicate that an instance is stopping, it is + * the opposite of varpd_plugin_start_f. This is a chance to clean up + * resources that are a side effect of having started the instance. * * varpd_plugin_default_f * - * This routine is defined by plugins of type OVERLAY_TARGET_POINT. It is - * used to answer the question of where should all traffic for this - * instance be destined. Plugins of type OVERLAY_TARGET_DYNAMIC should - * leave this entry set to NULL. + * This routine is defined by plugins of type OVERLAY_TARGET_POINT. It is + * used to answer the question of where should all traffic for this + * instance be destined. Plugins of type OVERLAY_TARGET_DYNAMIC should + * leave this entry set to NULL. * - * On success, the default routine should return VARPD_LOOKUP_OK. On - * failure, it should return the macro VARPD_LOOKUP_DROP. + * On success, the default routine should return VARPD_LOOKUP_OK. On + * failure, it should return the macro VARPD_LOOKUP_DROP. * * varpd_plugin_lookup_f * - * This routine must be defined by plugins of type OVERLAY_TARGET_DYNAMIC. - * It is used to lookup the destination for a given request. Each request - * comes in with its own MAC address this allows a plugin to direct it to - * any remote location. - * - * This is designed as an asynchronous API. Once a lookup is completed it - * should call libvarpd_plugin_query_reply() and pass as the second - * argument either VARPD_LOOKUP_OK to indicate that it went alright or it - * should reply VARPD_LOOKUP_DROP to indicate that the packet should be - * dropped. - * - * In addition, there are several utility routines that can take care of - * various kinds of traffic automatically. For example, if an ARP, NDP, or - * DHCP packet comes in, there are utilities such as - * libvarpd_plugin_proxy_arp(), libvarpd_plugin_proxy_ndp() and - * libvarpd_plugin_proxy_dhcp(), which allows the system to do the heavy - * lifting of validating the packet once it finds that it matches certain - * properties. + * This routine must be defined by plugins of type OVERLAY_TARGET_DYNAMIC. + * It is used to lookup the destination for a given request. Each request + * comes in with its own MAC address this allows a plugin to direct it to + * any remote location. + * + * This is designed as an asynchronous API. Once a lookup is completed it + * should call libvarpd_plugin_query_reply() and pass as the second + * argument either VARPD_LOOKUP_OK to indicate that it went alright or it + * should reply VARPD_LOOKUP_DROP to indicate that the packet should be + * dropped. + * + * In addition, there are several utility routines that can take care of + * various kinds of traffic automatically. For example, if an ARP, NDP, or + * DHCP packet comes in, there are utilities such as + * libvarpd_plugin_proxy_arp(), libvarpd_plugin_proxy_ndp() and + * libvarpd_plugin_proxy_dhcp(), which allows the system to do the heavy + * lifting of validating the packet once it finds that it matches certain + * properties. * * varpd_plugin_arp_f * - * This is an optional entry for plugins of type OVERLAY_TARGET_DYNAMIC. - * This is called after a plugin calls libvarpd_plugin_proxy_arp() and is - * used to ask the plugin to perform an ARP or NDP query. The type of query - * is passed in in the third argument, the only valid value for which will - * be VARPD_QTYPE_ETHERNET, to indicate we're doing an Ethernet lookup. + * This is an optional entry for plugins of type OVERLAY_TARGET_DYNAMIC. + * This is called after a plugin calls libvarpd_plugin_proxy_arp() and is + * used to ask the plugin to perform an ARP or NDP query. The type of query + * is passed in in the third argument, the only valid value for which will + * be VARPD_QTYPE_ETHERNET, to indicate we're doing an Ethernet lookup. * - * The layer three IP address that is being looked up will be included in - * the struct sockaddr. The sockaddr(3SOCKET)'s sa_family will be set to - * indicate the type, eg. AF_INET or AF_INET6 and that will indicate the - * kind of sockaddr that will be used. For more information see - * sockaddr(3SOCKET). The implementation ensures that enough space for the - * link layer address will exist. + * The layer three IP address that is being looked up will be included in + * the struct sockaddr. The sockaddr(3SOCKET)'s sa_family will be set to + * indicate the type, eg. AF_INET or AF_INET6 and that will indicate the + * kind of sockaddr that will be used. For more information see + * sockaddr(3SOCKET). The implementation ensures that enough space for the + * link layer address will exist. * - * This is an asynchronous lookup. Once the answer has been written, a - * plugin should call libvarpd_plugin_arp_reply and if it was successful, - * VARPD_LOOKUP_OK should be passed in and if it failed, VARPD_LOOKUP_DROP - * should be passed in instead. + * This is an asynchronous lookup. Once the answer has been written, a + * plugin should call libvarpd_plugin_arp_reply and if it was successful, + * VARPD_LOOKUP_OK should be passed in and if it failed, VARPD_LOOKUP_DROP + * should be passed in instead. * * varpd_plugin_dhcp_f * - * This is an optional entry for plugins of type OVERLAY_TARGET_DYNAMIC. - * This is called after a plugin calls the libvarpd_plugin_proxy_dhcp() and - * is used to ask the plugin to determine where is the DHCP server that - * this packet should actually be sent to. What is happening here is that - * rather than broadcast the initial DHCP request, we instead unicast it to - * a specified DHCP server that this operation vector indicates. - * - * The plugin is given a type, the same as the ARP plugin which indicates - * the kind of link layer address, the only valid type is - * VARPD_QTYPE_ETHERNET, other types should be rejected. Then, like the arp - * entry point, the dhcp entry point should determine the link layer - * address of the DHCP server and write that out in the appropriate memory - * and call libvarpd_plugin_dhcp_reply() when done. Similar to the arp - * entry point, it should use VARPD_LOOKUP_OK to indicate that it was - * filled in and VARPD_LOOKUP_DROP to indicate that it was not. + * This is an optional entry for plugins of type OVERLAY_TARGET_DYNAMIC. + * This is called after a plugin calls the libvarpd_plugin_proxy_dhcp() and + * is used to ask the plugin to determine where is the DHCP server that + * this packet should actually be sent to. What is happening here is that + * rather than broadcast the initial DHCP request, we instead unicast it to + * a specified DHCP server that this operation vector indicates. + * + * The plugin is given a type, the same as the ARP plugin which indicates + * the kind of link layer address, the only valid type is + * VARPD_QTYPE_ETHERNET, other types should be rejected. Then, like the arp + * entry point, the dhcp entry point should determine the link layer + * address of the DHCP server and write that out in the appropriate memory + * and call libvarpd_plugin_dhcp_reply() when done. Similar to the arp + * entry point, it should use VARPD_LOOKUP_OK to indicate that it was + * filled in and VARPD_LOOKUP_DROP to indicate that it was not. * * varpd_plugin_nprops_f * - * This is used by a plugin to indicate the number of properties that - * should exist for this instance. Recall from the section that Plugin - * types and Destinations, that the number of entries here may vary. As - * such, the plugin should return the number that is appropriate for the - * instance. + * This is used by a plugin to indicate the number of properties that + * should exist for this instance. Recall from the section that Plugin + * types and Destinations, that the number of entries here may vary. As + * such, the plugin should return the number that is appropriate for the + * instance. * - * This number will be used to obtain information about a property via the - * propinfo functions. However, the getprop and setprop interfaces will - * always use names to indicate the property it is getting and setting. - * This difference is structured this way to deal with property discovery - * and to make the getprop and setprop interfaces slightly easier for other - * parts of the broader varpd/dladm infrastructure. + * This number will be used to obtain information about a property via the + * propinfo functions. However, the getprop and setprop interfaces will + * always use names to indicate the property it is getting and setting. + * This difference is structured this way to deal with property discovery + * and to make the getprop and setprop interfaces slightly easier for other + * parts of the broader varpd/dladm infrastructure. * * varpd_plugin_propinfo_f * - * This interface is used to get information about a property, the property - * that information is being requested for is being passed in via the - * second argument. Here, callers should set properties such as the name, - * the protection, whether or not the property is required, set any default - * value, if it exist, and if relevant, set the valid range of values. + * This interface is used to get information about a property, the property + * that information is being requested for is being passed in via the + * second argument. Here, callers should set properties such as the name, + * the protection, whether or not the property is required, set any default + * value, if it exist, and if relevant, set the valid range of values. * * varpd_plugin_getprop_f * - * This is used to get the value of a property, if it is set. The passed in - * length indicates the length of the buffer that is used for updating - * properties. If it is not of sufficient size, the function should return - * an error and not update the buffer. Otherwise, it should update the size - * pointer with the valid size. + * This is used to get the value of a property, if it is set. The passed in + * length indicates the length of the buffer that is used for updating + * properties. If it is not of sufficient size, the function should return + * an error and not update the buffer. Otherwise, it should update the size + * pointer with the valid size. * * varpd_plugin_setprop_f * - * This is used to set the value of a property. An endpoint should validate - * that the property is valid before updating it. In addition, it should - * update its state as appropriate. + * This is used to set the value of a property. An endpoint should validate + * that the property is valid before updating it. In addition, it should + * update its state as appropriate. * * varpd_plugin_save_f * - * This is used to serialize the state of a given instance of a plugin such - * that if varpd crashes, it can be recovered. The plugin should write all - * state into the nvlist that it is passed in, it may use any keys and - * values that it wants. The only consumer of that nvlist will be the - * plugin itself when the restore endpoint is called. + * This is used to serialize the state of a given instance of a plugin such + * that if varpd crashes, it can be recovered. The plugin should write all + * state into the nvlist that it is passed in, it may use any keys and + * values that it wants. The only consumer of that nvlist will be the + * plugin itself when the restore endpoint is called. * * varpd_plugin_restore_f * - * This is called by the server to restore an instance that used to exist, - * but was lost due to a crash. This is a combination of calling create and - * setting properties. The plugin should restore any private state that it - * can find recorded from the nvlist. The only items in the nvlist will be - * those that were written out during a previous call to - * varpd_plugin_save_f. + * This is called by the server to restore an instance that used to exist, + * but was lost due to a crash. This is a combination of calling create and + * setting properties. The plugin should restore any private state that it + * can find recorded from the nvlist. The only items in the nvlist will be + * those that were written out during a previous call to + * varpd_plugin_save_f. * * * Once all of these interfaces are implemented, the plugin should define the @@ -245,28 +245,28 @@ * * vpr_version * - * This indicates the version of the plugin. Plugins should set this to the - * macro VARPD_CURRENT_VERSION. + * This indicates the version of the plugin. Plugins should set this to the + * macro VARPD_CURRENT_VERSION. * * vpr_mode * - * This indicates the mode of the plugin. The plugin's mode should be one - * of OVERLAY_TARGET_POINT and OVERLAY_TARGET_DYNAMIC. For more discussion - * of these types and the differences, see the section on Plugin Types and - * Destinations. + * This indicates the mode of the plugin. The plugin's mode should be one + * of OVERLAY_TARGET_POINT and OVERLAY_TARGET_DYNAMIC. For more discussion + * of these types and the differences, see the section on Plugin Types and + * Destinations. * * vpr_name * - * This is the name of the plugin. This is how users will refer to it in - * the context of running dladm(1M) commands. Note, this name must be - * unique across the different plugins, as it will cause others with the - * same name not to be registered. + * This is the name of the plugin. This is how users will refer to it in + * the context of running dladm(1M) commands. Note, this name must be + * unique across the different plugins, as it will cause others with the + * same name not to be registered. * * vpr_ops * - * This is the operations vector as described above. Importantly, the - * member vpo_callbacks must be set to zero, this is being used for future - * expansion of the structure. + * This is the operations vector as described above. Importantly, the + * member vpo_callbacks must be set to zero, this is being used for future + * expansion of the structure. * * * -------------------------------------------------- @@ -281,7 +281,7 @@ * varpd_plugin_lookup_f, varpd_default_f, varpd_plugin_arp_f, and * varpd_plugin_dhcp_f will be called until after a call to varpd_plugin_start_f * has been called. Similarly, they will not be called after a call to - * vardp_plugin_stop_f. + * varpd_plugin_stop_f. * * The functions documented in this header may be called back into from any * context, including from the operation vectors. diff --git a/usr/src/lib/varpd/libvarpd/common/libvarpd_util.c b/usr/src/lib/varpd/libvarpd/common/libvarpd_util.c index e21fed2126..92e50b5f1b 100644 --- a/usr/src/lib/varpd/libvarpd/common/libvarpd_util.c +++ b/usr/src/lib/varpd/libvarpd/common/libvarpd_util.c @@ -25,18 +25,12 @@ const char * libvarpd_isaext(void) { -#if defined(__sparc) -#if defined(__sparcv9) - return ("64"); -#else /* __sparcv9 */ - return (""); -#endif /* __sparvc9 */ -#elif defined(__amd64) +#if defined(__amd64) return ("64"); #elif defined(__i386) return (""); #else -#error "unkonwn ISA" +#error "unknown ISA" #endif } diff --git a/usr/src/lib/varpd/libvarpd/i386/Makefile b/usr/src/lib/varpd/libvarpd/i386/Makefile index f2b4f63da5..4398507523 100644 --- a/usr/src/lib/varpd/libvarpd/i386/Makefile +++ b/usr/src/lib/varpd/libvarpd/i386/Makefile @@ -15,4 +15,4 @@ include ../Makefile.com -install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/man/man1m/dladm.1m b/usr/src/man/man1m/dladm.1m index 618c4be6f3..fb7ad61939 100644 --- a/usr/src/man/man1m/dladm.1m +++ b/usr/src/man/man1m/dladm.1m @@ -4595,13 +4595,12 @@ Flushes all values in the target table for \fIoverlay\fR. .ad .sp .6 .RS 4n -Sets the value of \fIoverlay\fR's target table entry for \fImac\fR to -the specified value. The specified value varies upon the encapsulation -plugin. The value may be a combination of a MAC address, IP address, -and port. Generally, this looks like -[\fImac\fR,][\fIIP\fR:][\fIport\fR]. If a component is the last one, -then there is no need for a separator. eg. if just the MAC address or -IP is needed, it would look like \fImac\fR and \fIIP\fR respectively. +Sets the value of \fIoverlay\fR's target table entry for \fImac\fR to the +specified value. The specified value varies upon the encapsulation plugin. The +value may be a combination of a MAC address, IP address, and port. Generally, +this looks like [\fImac\fR,][\fIIP\fR:][\fIport\fR]. If a component is the last +one, then there is no need for a separator. eg. if just the MAC address or IP +is needed, it would look like \fImac\fR and \fIIP\fR respectively. .RE .RE diff --git a/usr/src/man/man1m/in.rlogind.1m b/usr/src/man/man1m/in.rlogind.1m index fdddcee08d..4504cd5c8a 100644 --- a/usr/src/man/man1m/in.rlogind.1m +++ b/usr/src/man/man1m/in.rlogind.1m @@ -4,7 +4,7 @@ .\" 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] -.TH IN.RLOGIND 1M "June 20, 2021" +.TH IN.RLOGIND 1M "February 5, 2022" .SH NAME in.rlogind, rlogind \- remote login server .SH SYNOPSIS @@ -82,9 +82,9 @@ client is present in \fB/etc/hosts.equiv\fR. See \fBhosts\fR(4) and .sp .LP Once the source port and address have been checked, \fBin.rlogind\fR allocates -a pseudo-terminal and manipulates file descriptors so that the slave half of -the pseudo-terminal becomes the \fBstdin\fR, \fBstdout\fR, and \fBstderr\fR for -a login process. The login process is an instance of the \fBlogin\fR(1) +a pseudo-terminal and manipulates file descriptors so that the subsidiary half +of the pseudo-terminal becomes the \fBstdin\fR, \fBstdout\fR, and \fBstderr\fR +for a login process. The login process is an instance of the \fBlogin\fR(1) program, invoked with the \fB-r\fR. .sp .LP @@ -93,7 +93,7 @@ process. See \fBSECURITY\fR below. If automatic authentication fails, it reprompts the user to login. .sp .LP -The parent of the login process manipulates the master side of the +The parent of the login process manipulates the manager side of the pseudo-terminal, operating as an intermediary between the login process and the client instance of the \fBrlogin\fR program. In normal operation, a packet protocol is invoked to provide Ctrl-S and Ctrl-Q type facilities and propagate diff --git a/usr/src/man/man1m/in.telnetd.1m b/usr/src/man/man1m/in.telnetd.1m index c233dccf49..b736fa082a 100644 --- a/usr/src/man/man1m/in.telnetd.1m +++ b/usr/src/man/man1m/in.telnetd.1m @@ -4,7 +4,7 @@ .\" 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] -.TH IN.TELNETD 1M "June 20, 2021" +.TH IN.TELNETD 1M "February 5, 2022" .SH NAME in.telnetd, telnetd \- DARPA TELNET protocol server .SH SYNOPSIS @@ -22,10 +22,11 @@ the internet server (see \fBinetd\fR(1M)), for requests to connect to the .sp .LP \fBin.telnetd\fR operates by allocating a pseudo-terminal device for a client, -then creating a login process which has the slave side of the pseudo-terminal -as its standard input, output, and error. \fBin.telnetd\fR manipulates the -master side of the pseudo-terminal, implementing the \fBTELNET\fR protocol and -passing characters between the remote client and the login process. +then creating a login process which has the subsidiary side of the +pseudo-terminal as its standard input, output, and error. \fBin.telnetd\fR +manipulates the manager side of the pseudo-terminal, implementing the +\fBTELNET\fR protocol and passing characters between the remote client and the +login process. .sp .LP When a \fBTELNET\fR session starts up, \fBin.telnetd\fR sends \fBTELNET\fR diff --git a/usr/src/man/man1m/nvmeadm.1m b/usr/src/man/man1m/nvmeadm.1m index 32620b6747..0ec278936e 100644 --- a/usr/src/man/man1m/nvmeadm.1m +++ b/usr/src/man/man1m/nvmeadm.1m @@ -9,11 +9,10 @@ .\" http://www.illumos.org/license/CDDL. .\" .\" -.\" Copyright 2016 Nexenta Systems, Inc. All rights reserved. -.\" Copyright 2019 Western Digital Corporation. .\" Copyright 2021 Oxide Computer Company +.\" Copyright 2022 Tintri by DDN, Inc. All rights reserved. .\" -.Dd March 24, 2021 +.Dd February 15, 2022 .Dt NVMEADM 1M .Os .Sh NAME @@ -65,6 +64,10 @@ .Ar ctl[/ns] .Nm .Op Fl dv +.Cm list-firmware +.Ar ctl +.Nm +.Op Fl dv .Cm load-firmware .Ar ctl .Ar firmware-file @@ -174,11 +177,10 @@ using the command, and subsequently activated with the .Cm activate-firmware command. -Slots and their contents can be printed using -.Cm nvmeadm get-logpage -to request the -.Ar firmware -logpage. +Slots and their contents can be printed using the +.Nm +.Cm list-firmware +command. .El .Sh COMMANDS .Bl -tag -width "" @@ -403,6 +405,19 @@ previous command. .It Xo .Nm +.Cm list-firmware +.Ar ctl +.Xc +List currently active firmware slot, the next active firmware slot, and the +current contents of all firmware slots of an NVMe controller. +This is a synonym for the +.Nm +.Cm get-logpage +.Ar ctl +.Cm firmware +command. +.It Xo +.Nm .Cm load-firmware .Ar ctl .Ar firmware-file @@ -528,17 +543,15 @@ nvme4: Get Features .Ed .It Sy Example 5: Load and activate firmware .Bd -literal -# nvmeadm get-logpage nvme3 firmware +# nvmeadm list-firmware nvme3 nvme3: Firmware Slot Information Active Firmware Slot: 4 Next Firmware Slot: 4 - Firmware Revision for Slot 1: KNGND110 + Firmware Revision for Slot 1: KNGND110 (read-only) Firmware Revision for Slot 2: KNGND110 Firmware Revision for Slot 3: KNGND110 Firmware Revision for Slot 4: KNGND112 Firmware Revision for Slot 5: KNGND110 - Firmware Revision for Slot 6: <Unused> - Firmware Revision for Slot 7: <Unused> # nvmeadm -v load-firmware nvme3 KNGND113.bin 1740544 bytes downloaded. @@ -549,17 +562,15 @@ Firmware committed to slot 5. # nvmeadm -v activate-firmware nvme3 5 Slot 5 activated: NVM subsystem reset required - power cycle your system. -# nvmeadm get-logpage nvme3 firmware +# nvmeadm list-firmware nvme3 nvme3: Firmware Slot Information Active Firmware Slot: 4 Next Firmware Slot: 5 - Firmware Revision for Slot 1: KNGND110 + Firmware Revision for Slot 1: KNGND110 (read-only) Firmware Revision for Slot 2: KNGND110 Firmware Revision for Slot 3: KNGND110 Firmware Revision for Slot 4: KNGND112 Firmware Revision for Slot 5: KNGND113 - Firmware Revision for Slot 6: <Unused> - Firmware Revision for Slot 7: <Unused> .Ed .El .Sh INTERFACE STABILITY diff --git a/usr/src/man/man1m/pppd.1m b/usr/src/man/man1m/pppd.1m index 8862ee9b94..4a2bdb360d 100644 --- a/usr/src/man/man1m/pppd.1m +++ b/usr/src/man/man1m/pppd.1m @@ -3,7 +3,7 @@ .\" Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by Carnegie Mellon University. The name of the University may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" Portions Copyright (c) 2008, Sun Microsystems, Inc. All Right Reserved. -.TH PPPD 1M "November 22, 2021" +.TH PPPD 1M "February 5, 2022" .SH NAME pppd \- point to point protocol daemon .SH SYNOPSIS @@ -1301,11 +1301,11 @@ proxy ARP entries with \fBpppd\fR, place this option in the .sp .6 .RS 4n Normally, \fBpppd\fR requires a terminal device. With this option, \fBpppd\fR -allocates itself a pseudo-tty master/slave pair and uses the slave as its +allocates itself a pseudo-terminal pair and uses the subsidiary as its terminal device. \fBpppd\fR creates a child process to act as a character shunt -to transfer characters between the pseudo-tty master and its standard input and -output. Thus, \fBpppd\fR transmits characters on its standard output and -receives characters on its standard input even if they are not terminal +to transfer characters between the pseudo-terminal manager and its standard +input and output. Thus, \fBpppd\fR transmits characters on its standard output +and receives characters on its standard input even if they are not terminal devices. This option increases the latency and CPU overhead of transferring data over the ppp interface as all of the characters sent and received must flow through the character shunt process. An explicit device name may not be @@ -1506,12 +1506,12 @@ Ethernet interface. .sp .6 .RS 4n Specifies that the command \fIscript\fR, and not a specific terminal device is -used for serial communication. \fBpppd\fR allocates itself a pseudo-tty -master/slave pair and uses the slave as its terminal device. \fIscript\fR runs -in a child process with the pseudo-tty master as its standard input and output. -An explicit device name may not be given if this option is used. (Note: if the -\fBrecord\fR option is used in conjunction with the \fBpty\fR option, the child -process will have pipes on its standard input and output.) +used for serial communication. \fBpppd\fR allocates itself a pseudo-terminal +pair and uses the subsidiary as its terminal device. \fIscript\fR runs +in a child process with the pseudo-terminal manager as its standard input and +output. An explicit device name may not be given if this option is used. +(Note: if the \fBrecord\fR option is used in conjunction with the \fBpty\fR +option, the child process will have pipes on its standard input and output.) .RE .sp @@ -1537,14 +1537,14 @@ dial-back implementations. .RS 4n Directs \fBpppd\fR to record all characters sent and received to a file named \fIfilename\fR. \fIfilename\fR is opened in append mode, using the user's -user-ID and permissions. Because this option uses a pseudo-tty and a process to -transfer characters between the pseudo-tty and the real serial device, it -increases the latency and CPU overhead of transferring data over the PPP -interface. Characters are stored in a tagged format with timestamps that can be -displayed in readable form using the \fBpppdump\fR(1M) program. This option is -generally used when debugging the kernel portion of \fBpppd\fR (especially CCP -compression algorithms) and not for debugging link configuration problems. See -the \fBdebug\fR option. +user-ID and permissions. Because this option uses a pseudo-terminal and a +process to transfer characters between the pseudo-terminal and the real serial +device, it increases the latency and CPU overhead of transferring data over the +PPP interface. Characters are stored in a tagged format with timestamps that +can be displayed in readable form using the \fBpppdump\fR(1M) program. This +option is generally used when debugging the kernel portion of \fBpppd\fR +(especially CCP compression algorithms) and not for debugging link +configuration problems. See the \fBdebug\fR option. .RE .sp diff --git a/usr/src/man/man2/close.2 b/usr/src/man/man2/close.2 index ad1ff95b8f..281a3f8956 100644 --- a/usr/src/man/man2/close.2 +++ b/usr/src/man/man2/close.2 @@ -43,173 +43,193 @@ .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2022 Oxide Computer Company .\" -.TH CLOSE 2 "Oct 18, 2005" -.SH NAME -close \- close a file descriptor -.SH SYNOPSIS -.LP -.nf -#include <unistd.h> - -\fBint\fR \fBclose\fR(\fBint\fR \fIfildes\fR); -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBclose()\fR function deallocates the file descriptor indicated by -\fIfildes\fR. To deallocate means to make the file descriptor available for -return by subsequent calls to \fBopen\fR(2) or other functions that allocate -file descriptors. All outstanding record locks owned by the process on the file -associated with the file descriptor will be removed (that is, unlocked). -.sp -.LP -If \fBclose()\fR is interrupted by a signal that is to be caught, it will -return \fB\(mi1\fR with \fBerrno\fR set to \fBEINTR\fR and the state of -\fIfildes\fR is unspecified. If an I/O error occurred while reading from or -writing to the file system during \fBclose()\fR, it returns -1, sets -\fBerrno\fR to \fBEIO\fR, and the state of \fIfildes\fR is unspecified. -.sp -.LP -When all file descriptors associated with a pipe or \fBFIFO\fR special file are -closed, any data remaining in the pipe or \fBFIFO\fR will be discarded. -.sp -.LP +.Dd February 5, 2022 +.Dt CLOSE 2 +.Os +.Sh NAME +.Nm close +.Nd close a file descriptor +.Sh SYNOPSIS +.In unistd.h +.Ft int +.Fo close +.Fa "int fildes" +.Fc +.Sh DESCRIPTION +The +.Fn close +function deallocates the file descriptor indicated by +.Fa fildes . +To deallocate means to make the file descriptor available for return by +subsequent calls to +.Xr open 2 +or other functions that allocate file descriptors. +All outstanding record locks owned by the process on the file associated with +the file descriptor will be removed +.Pq "that is, unlocked" . +.Pp +If +.Fn close +is interrupted by a signal that is to be caught, it will return +.Sy -1 +with +.Va errno +set to +.Er EINTR +and the state of +.Fa fildes +is unspecified. +If an I/O error occurred while reading from or writing to the file system during +.Fn close , +it returns +.Sy -1 , +sets +.Va errno +to +.Er EIO , +and the state of +.Fa fildes +is unspecified. +.Pp +When all file descriptors associated with a pipe or FIFO special file are +closed, any data remaining in the pipe or FIFO will be discarded. +.Pp When all file descriptors associated with an open file description have been closed the open file description will be freed. -.sp -.LP -If the link count of the file is 0, when all file descriptors associated with -the file are closed, the space occupied by the file will be freed and the file -will no longer be accessible. -.sp -.LP -If a streams-based (see \fBIntro\fR(2)) \fIfildes\fR is closed and the calling -process was previously registered to receive a \fBSIGPOLL\fR signal (see -\fBsignal\fR(3C)) for events associated with that stream (see \fBI_SETSIG\fR in -\fBstreamio\fR(7I)), the calling process will be unregistered for events -associated with the stream. The last \fBclose()\fR for a stream causes the -stream associated with \fIfildes\fR to be dismantled. If \fBO_NONBLOCK\fR and -\fBO_NDELAY\fR are not set and there have been no signals posted for the -stream, and if there is data on the module's write queue, \fBclose()\fR waits -up to 15 seconds (for each module and driver) for any output to drain before -dismantling the stream. The time delay can be changed via an \fBI_SETCLTIME\fR -\fBioctl\fR(2) request (see \fBstreamio\fR(7I)). If the \fBO_NONBLOCK\fR or -\fBO_NDELAY\fR flag is set, or if there are any pending signals, \fBclose()\fR +.Pp +If the link count of the file is +.Sy 0 , +when all file descriptors associated with the file are closed, the space +occupied by the file will be freed and the file will no longer be accessible. +.Pp +If a streams-based +.Po +see +.Xr Intro 2 +.Pc +.Fa fildes +is closed and the calling process was previously registered to receive a +.Dv SIGPOLL +signal +.Po +see +.Xr signal 3C +.Pc +for events associated with that stream +.Po +see +.Dv I_SETSIG +in +.Xr streamio 7I +.Pc , +the calling process will be unregistered for events associated with the stream. +The last +.Fn close +for a stream causes the stream associated with +.Fa fildes +to be dismantled. +If +.Dv O_NONBLOCK +and +.Dv O_NDELAY +are not set and there have been no signals posted for the stream, and if there +is data on the module's write queue, +.Fn close +waits up to 15 seconds +.Pq for each module and driver +for any output to drain +before dismantling the stream. +The time delay can be changed via an +.Dv I_SETCLTIME +.Xr ioctl 2 +request +.Po +see +.Xr streamio 7I +.Pc . +If the +.Dv O_NONBLOCK +or +.Dv O_NDELAY +flag is set, or if there are any pending signals, +.Fn close does not wait for output to drain, and dismantles the stream immediately. -.sp -.LP -If \fIfildes\fR is associated with one end of a pipe, the last \fBclose()\fR -causes a hangup to occur on the other end of the pipe. In addition, if the -other end of the pipe has been named by \fBfattach\fR(3C), then the last -\fBclose()\fR forces the named end to be detached by \fBfdetach\fR(3C). If the -named end has no open file descriptors associated with it and gets detached, -the stream associated with that end is also dismantled. -.sp -.LP -If \fIfildes\fR refers to the master side of a pseudo-terminal, a \fBSIGHUP\fR -signal is sent to the session leader, if any, for which the slave side of the -pseudo-terminal is the controlling terminal. It is unspecified whether closing -the master side of the pseudo-terminal flushes all queued input and output. -.sp -.LP -If \fIfildes\fR refers to the slave side of a streams-based pseudo-terminal, a -zero-length message may be sent to the master. -.sp -.LP +.Pp +If +.Fa fildes +is associated with one end of a pipe, the last +.Fn close +causes a hangup to occur on the other end of the pipe. +In addition, if the other end of the pipe has been named by +.Xr fattach 3C , +then the last +.Fn close +forces the named end to be detached by +.Xr fdetach 3C . +If the named end has no open file descriptors associated with it and gets +detached, the stream associated with that end is also dismantled. +.Pp +If +.Fa fildes +refers to the manager side of a pseudo-terminal, a +.Dv SIGHUP +signal is sent to the session leader, if any, for which the subsidiary side of +the pseudo-terminal is the controlling terminal. +It is unspecified whether closing the manager side of the pseudo-terminal +flushes all queued input and output. +.Pp +If +.Fa fildes +refers to the subsidiary side of a streams-based pseudo-terminal, a zero-length +message may be sent to the manager. +.Pp When there is an outstanding cancelable asynchronous I/O operation against -\fIfildes\fR when \fBclose()\fR is called, that I/O operation is canceled. An -I/O operation that is not canceled completes as if the \fBclose()\fR operation -had not yet occurred. All operations that are not canceled will complete as if -the \fBclose()\fR blocked until the operations completed. -.sp -.LP +.Fa fildes +when +.Fn close +is called, that I/O operation is canceled. +An I/O operation that is not canceled completes as if the +.Fn close +operation had not yet occurred. +All operations that are not canceled will complete as if the +.Fn close +blocked until the operations completed. +.Pp If a shared memory object or a memory mapped file remains referenced at the -last close (that is, a process has it mapped), then the entire contents of the -memory object will persist until the memory object becomes unreferenced. If -this is the last close of a shared memory object or a memory mapped file and +last close +.Pq "that is, a process has it mapped" , +then the entire contents of the memory object will persist until the memory +object becomes unreferenced. +If this is the last close of a shared memory object or a memory mapped file and the close results in the memory object becoming unreferenced, and the memory object has been unlinked, then the memory object will be removed. -.sp -.LP -If \fIfildes\fR refers to a socket, \fBclose()\fR causes the socket to be -destroyed. If the socket is connection-mode, and the \fBSO_LINGER\fR option is -set for the socket with non-zero linger time, and the socket has untransmitted -data, then \fBclose()\fR will block for up to the current linger interval until -all data is transmitted. -.SH RETURN VALUES -.sp -.LP -Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is -returned and \fBerrno\fR is set to indicate the error. -.SH ERRORS -.sp -.LP -The \fBclose()\fR function will fail if: -.sp -.ne 2 -.na -\fB\fBEBADF\fR\fR -.ad -.RS 11n -The \fIfildes\fR argument is not a valid file descriptor. -.RE - -.sp -.ne 2 -.na -\fB\fBEINTR\fR\fR -.ad -.RS 11n -The \fBclose()\fR function was interrupted by a signal. -.RE - -.sp -.ne 2 -.na -\fB\fBENOLINK\fR\fR -.ad -.RS 11n -The \fIfildes\fR argument is on a remote machine and the link to that machine -is no longer active. -.RE - -.sp -.ne 2 -.na -\fB\fBENOSPC\fR\fR -.ad -.RS 11n -There was no free space remaining on the device containing the file. -.RE - -.sp -.LP -The \fBclose()\fR function may fail if: -.sp -.ne 2 -.na -\fB\fBEIO\fR\fR -.ad -.RS 7n -An I/O error occurred while reading from or writing to the file system. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRReassign a file descriptor. -.sp -.LP +.Pp +If +.Fa fildes +refers to a socket, +.Fn close +causes the socket to be destroyed. +If the socket is connection-mode, and the +.Dv SO_LINGER +option is set for the socket with non-zero linger time, and the socket has +untransmitted data, then +.Fn close +will block for up to the current linger interval until all data is transmitted. +.Sh RETURN VALUES +.Rv -std close +.Sh EXAMPLES +.Sy Example 1 +Reassign a file descriptor. +.Pp The following example closes the file descriptor associated with standard output for the current process, re-assigns standard output to a new file -descriptor, and closes the original file descriptor to clean up. This example -assumes that the file descriptor 0, which is the descriptor for standard input, -is not closed. - -.sp -.in +2 -.nf +descriptor, and closes the original file descriptor to clean up. +This example assumes that the file descriptor +.Sy 0 , +which is the descriptor for standard input, is not closed. +.Bd -literal -offset Ds #include <unistd.h> \&... int pfd; @@ -218,32 +238,22 @@ close(1); dup(pfd); close(pfd); \&... -.fi -.in -2 - -.sp -.LP +.Ed +.Pp Incidentally, this is exactly what could be achieved using: - -.sp -.in +2 -.nf +.Bd -literal -offset Ds dup2(pfd, 1); close(pfd); -.fi -.in -2 - -.LP -\fBExample 2 \fRClose a file descriptor. -.sp -.LP -In the following example, \fBclose()\fR is used to close a file descriptor -after an unsuccessful attempt is made to associate that file descriptor with a -stream. - -.sp -.in +2 -.nf +.Ed +.Pp +.Sy Example 2 +Close a file descriptor. +.Pp +In the following example, +.Fn close +is used to close a file descriptor after an unsuccessful attempt is made to +associate that file descriptor with a stream. +.Bd -literal -offset Ds #include <stdio.h> #include <unistd.h> #include <stdlib.h> @@ -259,38 +269,64 @@ if ((fpfd = fdopen (pfd, "w")) == NULL) { exit(1); } \&... -.fi -.in -2 - -.SH USAGE -.sp -.LP -An application that used the \fBstdio\fR function \fBfopen\fR(3C) to open a -file should use the corresponding \fBfclose\fR(3C) function rather than -\fBclose()\fR. -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Standard -_ -MT-Level Async-Signal-Safe -.TE - -.SH SEE ALSO -.sp -.LP -\fBIntro\fR(2), \fBcreat\fR(2), \fBdup\fR(2), \fBexec\fR(2), \fBfcntl\fR(2), -\fBioctl\fR(2), \fBopen\fR(2) \fBpipe\fR(2), \fBfattach\fR(3C), -\fBfclose\fR(3C), \fBfdetach\fR(3C), \fBfopen\fR(3C), \fBsignal\fR(3C), -\fBsignal.h\fR(3HEAD), \fBattributes\fR(5), \fBstandards\fR(5), -\fBstreamio\fR(7I) +.Ed +.Sh ERRORS +The +.Fn close +function will fail if: +.Bl -tag -width Er +.It Er EBADF +The +.Fa fildes +argument is not a valid file descriptor. +.It Er EINTR +The +.Fn close +function was interrupted by a signal. +.It Er ENOLINK +The +.Fa fildes +argument is on a remote machine and the link to that machine is no longer +active. +.It Er ENOSPC +There was no free space remaining on the device containing the file. +.El +.Pp +The +.Fn close +function may fail if: +.Bl -tag -width Er +.It Er EIO +An I/O error occurred while reading from or writing to the file system. +.El +.Sh USAGE +An application that used the +.Xr stdio 3C +function +.Xr fopen 3C +to open a file should use the corresponding +.Xr fclose 3C +function rather than +.Fn close . +.Sh INTERFACE STABILITY +.Sy Committed +.Sh MT-LEVEL +.Sy Async-Signal-Safe +.Sh SEE ALSO +.Xr creat 2 , +.Xr dup 2 , +.Xr exec 2 , +.Xr fcntl 2 , +.Xr Intro 2 , +.Xr ioctl 2 , +.Xr open 2 , +.Xr pipe 2 , +.Xr fattach 3C , +.Xr fclose 3C , +.Xr fdetach 3C , +.Xr fopen 3C , +.Xr signal 3C , +.Xr signal.h 3HEAD , +.Xr attributes 5 , +.Xr standards 5 , +.Xr streamio 7I diff --git a/usr/src/man/man2/open.2 b/usr/src/man/man2/open.2 index aa9048c660..ce23eac084 100644 --- a/usr/src/man/man2/open.2 +++ b/usr/src/man/man2/open.2 @@ -47,879 +47,586 @@ .\" All Rights Reserved. .\" Copyright 2015 Nexenta Systems, Inc. All rights reserved. .\" Copyright 2020 Joyent, Inc. +.\" Copyright 2022 Oxide Computer Company .\" -.TH OPEN 2 "Mar 10, 2020" -.SH NAME -open, openat \- open a file -.SH SYNOPSIS -.nf -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -\fBint\fR \fBopen\fR(\fBconst char *\fR\fIpath\fR, \fBint\fR \fIoflag\fR, \fB/* mode_t\fR \fImode\fR */); -.fi - -.LP -.nf -\fBint\fR \fBopenat\fR(\fBint\fR \fIfildes\fR, \fBconst char *\fR\fIpath\fR, \fBint\fR \fIoflag\fR, - \fB/* mode_t\fR \fImode\fR */); -.fi - -.SH DESCRIPTION -The \fBopen()\fR function establishes the connection between a file and a file -descriptor. It creates an open file description that refers to a file and a -file descriptor that refers to that open file description. The file descriptor -is used by other I/O functions to refer to that file. The \fIpath\fR argument -points to a pathname naming the file. -.sp -.LP -The \fBopenat()\fR function is identical to the \fBopen()\fR function except -that the \fIpath\fR argument is interpreted relative to the starting point -implied by the \fIfildes\fR argument. If the \fIfildes\fR argument has the -special value \fBAT_FDCWD\fR, a relative path argument will be resolved -relative to the current working directory. If the \fIpath\fR argument is -absolute, the \fIfildes\fR argument is ignored. -.sp -.LP -The \fBopen()\fR function returns a file descriptor for the named file that is -the lowest file descriptor not currently open for that process. The open file -description is new, and therefore the file descriptor does not share it with -any other process in the system. The \fBFD_CLOEXEC\fR file descriptor flag -associated with the new file descriptor is cleared. -.sp -.LP +.Dd February 5, 2022 +.Dt OPEN 2 +.Os +.Sh NAME +.Nm open , +.Nm openat +.Nd open a file +.Sh SYNOPSIS +.In sys/types.h +.In sys/stat.h +.In fcntl.h +.Ft int +.Fo open +.Fa "const char *path" +.Fa "int oflag" +.Op , Fa "mode_t mode" +.Fc +.Ft int +.Fo openat +.Fa "int fildes" +.Fa "const char *path" +.Fa "int oflag" +.Op , Fa "mode_t mode" +.Fc +.Sh DESCRIPTION +The +.Fn open +function establishes the connection between a file and a file descriptor. +It creates an open file description that refers to a file and a file descriptor +that refers to that open file description. +The file descriptor is used by other I/O functions to refer to that file. +The +.Fa path +argument points to a pathname naming the file. +.Pp +The +.Fn openat +function is identical to the +.Fn open +function except +that the +.Fa path +argument is interpreted relative to the starting point +implied by the +.Fa fildes +argument. +If the +.Fa fildes +argument has the special value +.Dv AT_FDCWD , +a relative path argument will be resolved relative to the current working +directory. +If the +.Fa path +argument is absolute, the +.Fa fildes +argument is ignored. +.Pp +The +.Fn open +function returns a file descriptor for the named file that is the lowest file +descriptor not currently open for that process. +The open file description is new, and therefore the file descriptor does not +share it with any other process in the system. +The +.Dv FD_CLOEXEC +file descriptor flag associated with the new file descriptor is cleared. +.Pp The file offset used to mark the current position within the file is set to the beginning of the file. -.sp -.LP +.Pp The file status flags and file access modes of the open file description are -set according to the value of \fIoflag\fR. The \fImode\fR argument is used only -when \fBO_CREAT\fR is specified (see below.) -.sp -.LP -Values for \fIoflag\fR are constructed by a bitwise-inclusive-OR of flags from -the following list, defined in <\fBfcntl.h\fR>. Applications must specify -exactly one of the first three values (file access modes) below in the value of -\fIoflag\fR: -.sp -.ne 2 -.na -\fB\fBO_RDONLY\fR\fR -.ad -.RS 12n +set according to the value of +.Fa oflag . +The +.Fa mode +argument is used only +when +.Dv O_CREAT +is specified +.Pq "see below" . +.Pp +Values for +.Fa oflag +are constructed by a bitwise-inclusive-OR of flags from +the following list, defined in +.Xr fcntl.h 3HEAD . +Applications must specify exactly one of the first three values (file access +modes) below in the value of +.Fa oflag : +.Bl -tag -width Ds +.It Dv O_RDONLY Open for reading only. -.RE - -.sp -.ne 2 -.na -\fB\fBO_WRONLY\fR\fR -.ad -.RS 12n +.It Dv O_WRONLY Open for writing only. -.RE - -.sp -.ne 2 -.na -\fB\fBO_RDWR\fR\fR -.ad -.RS 12n -Open for reading and writing. The result is undefined if this flag is applied -to a FIFO. -.RE - -.sp -.LP +.It Dv O_RDWR +Open for reading and writing. +The result is undefined if this flag is applied to a FIFO. +.El +.Pp Any combination of the following may be used: -.sp -.ne 2 -.na -\fB\fBO_APPEND\fR\fR -.ad -.sp .6 -.RS 4n +.Bl -tag -width Ds +.It Dv O_APPEND If set, the file offset is set to the end of the file prior to each write. -.RE - -.sp -.ne 2 -.na -\fB\fBO_CREAT\fR\fR -.ad -.sp .6 -.RS 4n -Create the file if it does not exist. This flag requires that the \fImode\fR +.It Dv O_CREAT +Create the file if it does not exist. +This flag requires that the +.Fa mode argument be specified. -.sp -If the file exists, this flag has no effect except as noted under \fBO_EXCL\fR -below. Otherwise, the file is created with the user \fBID\fR of the file set -to the effective user \fBID\fR of the process. The group \fBID\fR of the file -is set to the effective group \fBIDs\fR of the process, or if the \fBS_ISGID\fR +.Pp +If the file exists, this flag has no effect except as noted under +.Dv O_EXCL +below. +Otherwise, the file is created with the user ID of the file set to the +effective user ID of the process. +The group ID of the file is set to the effective group IDs of the process, or +if the +.Dv S_ISGID bit is set in the directory in which the file is being created, the file's -group \fBID\fR is set to the group \fBID\fR of its parent directory. If the -group \fBID\fR of the new file does not match the effective group \fBID\fR or -one of the supplementary groups IDs, the \fBS_ISGID\fR bit is cleared. The -access permission bits (see \fB<sys/stat.h>\fR) of the file mode are set to the -value of \fImode\fR, modified as follows (see \fBcreat\fR(2)): a bitwise-AND is -performed on the file-mode bits and the corresponding bits in the complement of -the process's file mode creation mask. Thus, all bits set in the process's file -mode creation mask (see \fBumask\fR(2)) are correspondingly cleared in the -file's permission mask. The "save text image after execution bit" of the mode -is cleared (see \fBchmod\fR(2)). When bits other than the file permission bits -are set, the effect is unspecified. The \fImode\fR argument does not affect -whether the file is open for reading, writing or for both. -.RE - -.sp -.ne 2 -.na -.B O_DIRECT -.ad -.sp .6 -.RS 4n +group ID is set to the group ID of its parent directory. +If the group ID of the new file does not match the effective group +ID or one of the supplementary groups IDs, the +.Dv S_ISGID bit is cleared. +.Pp +The access permission bits +.Po +see +.Xr stat.h 3HEAD +.Pc +of the file mode are set to the value of +.Fa mode , +modified as follows +.Po +see +.Xr creat 2 +.Pc : +a bitwise-AND is performed on the file-mode bits and the corresponding bits in +the complement of the process's file mode creation mask. +Thus, all bits set in the process's file mode creation mask +.Po +see +.Xr umask 2 +.Pc +are correspondingly cleared in the file's permission mask. +The +.Dq save text image after execution bit +of the mode is cleared +.Po +see +.Xr chmod 2 +.Pc . +When bits other than the file permission bits are set, the effect is +unspecified. +The +.Fa mode +argument does not affect whether the file is open for reading, writing or for +both. +.It Dv O_DIRECT Indicates that the file data is not going to be reused in the near future. When possible, data is read or written directly between the application's -memory and the device when the data is accessed with \fBread\fR(2) and -\fBwrite\fR(2) operations. See \fBdirectio\fR(3C) for more details. -.RE - -.sp -.ne 2 -.na -.B O_DIRECTORY -.ad -.sp .6 -.RS 4n +memory and the device when the data is accessed with +.Xr read 2 +and +.Xr write 2 +operations. +See +.Xr directio 3C +for more details. +.It Dv O_DIRECTORY Indicates that attempts to open -.I path +.Fa path should fail unless -.I path +.Fa path is a directory. If both -.B O_CREAT +.Dv O_CREAT and -.B O_DIRECTORY +.Dv O_DIRECTORY are specified then the call will fail if it would result in a file being created. If a directory already exists at -.I path +.Fa path then it will behave as if the -.B O_DIRECTORY +.Dv O_DIRECTORY flag had not been present. If the -.B O_EXCL +.Dv O_EXCL and -.B O_CREAT -flags are specified, then the call will always fail as they imply a file -should always be created. -.RE - -.sp -.ne 2 -.na -\fB\fBO_DSYNC\fR\fR -.ad -.sp .6 -.RS 4n +.Dv O_CREAT +flags are specified, then the call will always fail as they imply a file should +always be created. +.It Dv O_DSYNC Write I/O operations on the file descriptor complete as defined by synchronized I/O data integrity completion. -.RE - -.sp -.ne 2 -.na -\fB\fBO_EXCL\fR\fR -.ad -.sp .6 -.RS 4n -If \fBO_CREAT\fR and \fBO_EXCL\fR are set, \fBopen()\fR fails if the file -exists. The check for the existence of the file and the creation of the file if +.It Dv O_EXCL +If +.Dv O_CREAT +and +.Dv O_EXCL +are set, +.Fn open +fails if the file exists. +The check for the existence of the file and the creation of the file if it does not exist is atomic with respect to other threads executing -\fBopen()\fR naming the same filename in the same directory with \fBO_EXCL\fR -and \fBO_CREAT\fR set. If \fBO_EXCL\fR and \fBO_CREAT\fR are set, and path -names a symbolic link, \fBopen()\fR fails and sets \fBerrno\fR to \fBEEXIST\fR, -regardless of the contents of the symbolic link. If \fBO_EXCL\fR is set and -\fBO_CREAT\fR is not set, the result is undefined. -.RE - -.sp -.ne 2 -.na -.B O_EXEC -.na -.ad -.sp .6 -.RS 4n +.Fn open +naming the same filename in the same directory with +.Dv O_EXCL +and +.Dv O_CREAT +set. +If +.Dv O_EXCL +and +.Dv O_CREAT +are set, and +.Fa path +names a symbolic link, +.Fn open +fails and sets +.Va errno +to +.Er EEXIST , +regardless of the contents of the symbolic link. +If +.Dv O_EXCL +is set and +.Dv O_CREAT +is not set, the result is undefined. +.It Dv O_EXEC If set, indicates that the file should be opened for execute permission. -This option is only valid for regular files, an error will be returned -if it is not. -.RE - -.sp -.ne 2 -.na -\fB\fBO_LARGEFILE\fR\fR -.ad -.sp .6 -.RS 4n +This option is only valid for regular files; an error will be returned if the +target is not a regular file. +.It Dv O_LARGEFILE If set, the offset maximum in the open file description is the largest value -that can be represented correctly in an object of type \fBoff64_t\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBO_NOCTTY\fR\fR -.ad -.sp .6 -.RS 4n -If set and \fIpath\fR identifies a terminal device, \fBopen()\fR does not cause -the terminal device to become the controlling terminal for the process. -.RE - -.sp -.ne 2 -.na -\fB\fBO_NOFOLLOW\fR\fR -.ad -.sp .6 -.RS 4n -If the path names a symbolic link, \fBopen()\fR fails and sets \fBerrno\fR to -\fBELOOP\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBO_NOLINKS\fR\fR -.ad -.sp .6 -.RS 4n -If the link count of the named file is greater than 1, \fBopen()\fR fails and -sets \fBerrno\fR to \fBEMLINK\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBO_CLOEXEC\fR\fR -.ad -.sp .6 -.RS 4n +that can be represented correctly in an object of type +.Vt off64_t . +.It Dv O_NOCTTY +If set and +.Fa path +identifies a terminal device, +.Fn open +does not cause the terminal device to become the controlling terminal for the +process. +.It Dv O_NOFOLLOW +If the path names a symbolic link, +.Fn open +fails and sets +.Va errno +to +.Er ELOOP . +.It Dv O_NOLINKS +If the link count of the named file is greater than +.Sy 1 , +.Fn open +fails and sets +.Va errno +to +.Er EMLINK . +.It Dv O_CLOEXEC If set, the file descriptor returned will be closed prior to any future -\fBexec()\fR calls. -.RE - -.sp -.ne 2 -.na -\fB\fBO_NONBLOCK\fR or \fBO_NDELAY\fR\fR -.ad -.sp .6 -.RS 4n -These flags can affect subsequent reads and writes (see \fBread\fR(2) and -\fBwrite\fR(2)). If both \fBO_NDELAY\fR and \fBO_NONBLOCK\fR are set, -\fBO_NONBLOCK\fR takes precedence. -.sp -When opening a \fBFIFO\fR with \fBO_RDONLY\fR or \fBO_WRONLY\fR set: -.RS +4 -.TP -.ie t \(bu -.el o -If \fBO_NONBLOCK\fR or \fBO_NDELAY\fR is set, an \fBopen()\fR for reading only -returns without delay. An \fBopen()\fR for writing only returns an error if no -process currently has the file open for reading. -.RE -.RS +4 -.TP -.ie t \(bu -.el o -If \fBO_NONBLOCK\fR and \fBO_NDELAY\fR are clear, an \fBopen()\fR for reading -only blocks until a thread opens the file for writing. An \fBopen()\fR for -writing only blocks the calling thread until a thread opens the file for +.Xr exec 2 +calls. +.It Dv O_NONBLOCK O_NDELAY +These flags can affect subsequent reads and writes +.Po +see +.Xr read 2 +and +.Xr write 2 +.Pc . +If both +.Dv O_NDELAY +and +.Dv O_NONBLOCK +are set, +.Dv O_NONBLOCK +takes precedence. +.Pp +When opening a FIFO with +.Dv O_RDONLY +or +.Dv O_WRONLY +set: +.Bl -bullet +.It +If +.Dv O_NONBLOCK +or +.Dv O_NDELAY +is set, an +.Fn open +for reading only returns without delay. +An +.Fn open +for writing only returns an error if no process currently has the file open for reading. -.RE -After both ends of a \fBFIFO\fR have been opened, there is no guarantee that -further calls to \fBopen()\fR \fBO_RDONLY\fR (\fBO_WRONLY\fR) will synchronize -with later calls to \fBopen()\fR \fBO_WRONLY\fR (\fBO_RDONLY\fR) until both -ends of the \fBFIFO\fR have been closed by all readers and writers. Any data -written into a \fBFIFO\fR will be lost if both ends of the \fBFIFO\fR are -closed before the data is read. -.sp +.It +If +.Dv O_NONBLOCK +and +.Dv O_NDELAY +are clear, an +.Fn open +for reading only blocks until a thread opens the file for writing. +An +.Fn open +for writing only blocks the calling thread until a thread opens the file for +reading. +.El +.Pp +After both ends of a FIFO have been opened once, there is no guarantee that +further calls to +.Fn open +.Dv O_RDONLY +.Pq Dv O_WRONLY +will synchronize with later calls to +.Fn open +.Dv O_WRONLY +.Pq Dv O_RDONLY +until both ends of the FIFO have been closed by all readers and writers. +Any data written into a FIFO will be lost if both ends of the FIFO are closed +before the data is read. +.Pp When opening a block special or character special file that supports non-blocking opens: -.RS +4 -.TP -.ie t \(bu -.el o -If \fBO_NONBLOCK\fR or \fBO_NDELAY\fR is set, the \fBopen()\fR function returns -without blocking for the device to be ready or available. Subsequent behavior -of the device is device-specific. -.RE -.RS +4 -.TP -.ie t \(bu -.el o -If \fBO_NONBLOCK\fR and \fBO_NDELAY\fR are clear, the \fBopen()\fR function -blocks the calling thread until the device is ready or available before -returning. -.RE -Otherwise, the behavior of \fBO_NONBLOCK\fR and \fBO_NDELAY\fR is unspecified. -.RE - -.sp -.ne 2 -.na -\fB\fBO_RSYNC\fR\fR -.ad -.sp .6 -.RS 4n +.Bl -bullet +.It +If +.Dv O_NONBLOCK +or +.Dv O_NDELAY +is set, the +.Fn open +function returns without blocking for the device to be ready or available. +Subsequent behavior of the device is device-specific. +.It +If +.Dv O_NONBLOCK +and +.Dv O_NDELAY +are clear, the +.Fn open +function blocks the calling thread until the device is ready or available +before returning. +.El +.Pp +Otherwise, the behavior of +.Dv O_NONBLOCK +and +.Dv O_NDELAY +is unspecified. +.It Dv O_RSYNC Read I/O operations on the file descriptor complete at the same level of -integrity as specified by the \fBO_DSYNC\fR and \fBO_SYNC\fR flags. If both -\fBO_DSYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all I/O operations on -the file descriptor complete as defined by synchronized I/O data integrity -completion. If both \fBO_SYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all -I/O operations on the file descriptor complete as defined by synchronized I/O -file integrity completion. -.RE - -.sp -.ne 2 -.na -.B O_SEARCH -.ad -.sp .6 -.RS 4n +integrity as specified by the +.Dv O_DSYNC +and +.Dv O_SYNC +flags. +If both +.Dv O_DSYNC +and +.Dv O_RSYNC +are set in +.Fa oflag , +all I/O operations on the file descriptor complete as defined by synchronized +I/O data integrity completion. +If both +.Dv O_SYNC +and +.Dv O_RSYNC +are set in +.Fa oflag , +all I/O operations on the file descriptor complete as defined by synchronized +I/O file integrity completion. +.It Dv O_SEARCH If set, indicates that the directory should be opened for searching. -This option is only valid for a directory, an error will be returned if -it is not. -.RE - -.sp -.ne 2 -.na -\fB\fBO_SYNC\fR\fR -.ad -.sp .6 -.RS 4n +This option is only valid for a directory; an error will be returned if the +target is not a directory. +.It Dv O_SYNC Write I/O operations on the file descriptor complete as defined by synchronized -I/O file integrity completion (see \fBfcntl.h\fR(3HEAD) definition of -\fBO_SYNC\fR). -.RE - -.sp -.ne 2 -.na -\fB\fBO_TRUNC\fR\fR -.ad -.sp .6 -.RS 4n +I/O file integrity completion +.Po +see +.Xr fcntl.h 3HEAD +.Pc +definition of +.Dv O_SYNC . +.It Dv O_TRUNC If the file exists and is a regular file, and the file is successfully opened -\fBO_RDWR\fR or \fBO_WRONLY\fR, its length is truncated to 0 and the mode and -owner are unchanged. It has no effect on \fBFIFO\fR special files or terminal -device files. Its effect on other file types is implementation-dependent. The -result of using \fBO_TRUNC\fR with \fBO_RDONLY\fR is undefined. -.RE - -.sp -.ne 2 -.na -\fB\fBO_XATTR\fR\fR -.ad -.sp .6 -.RS 4n -If set in \fBopenat()\fR, a relative path argument is interpreted as a -reference to an extended attribute of the file associated with the supplied -file descriptor. This flag therefore requires the presence of a legal -\fIfildes\fR argument. If set in \fBopen()\fR, the implied file descriptor is -that for the current working directory. Extended attributes must be referenced -with a relative path; providing an absolute path results in a normal file -reference. -.RE - -.sp -.LP -If \fBO_CREAT\fR is set and the file did not previously exist, upon successful -completion, \fBopen()\fR marks for update the \fBst_atime\fR, \fBst_ctime\fR, -and \fBst_mtime\fR fields of the file and the \fBst_ctime\fR and \fBst_mtime\fR +.Dv O_RDWR +or +.Dv O_WRONLY , +its length is truncated to +.Sy 0 +and the mode and owner are unchanged. +It has no effect on FIFO special files or terminal device files. +Its effect on other file types is implementation-dependent. +The result of using +.Dv O_TRUNC +with +.Dv O_RDONLY +is undefined. +.It Dv O_XATTR +If set in +.Fn openat , +a relative path argument is interpreted as a reference to an extended attribute +of the file associated with the supplied file descriptor. +This flag therefore requires the presence of a legal +.Fa fildes +argument. +If set in +.Fn open , +the implied file descriptor is that for the current working directory. +Extended attributes must be referenced with a relative path; providing an +absolute path results in a normal file reference. +.El +.Pp +If +.Dv O_CREAT +is set and the file did not previously exist, upon successful completion, +.Fn open +marks for update the +.Fa st_atime , +.Fa st_ctime , +and +.Fa st_mtime +fields of the file and the +.Fa st_ctime +and +.Fa st_mtime fields of the parent directory. -.sp -.LP -If \fBO_TRUNC\fR is set and the file did previously exist, upon successful -completion, \fBopen()\fR marks for update the \fBst_ctime\fR and \fBst_mtime\fR +.Pp +If +.Dv O_TRUNC +is set and the file did previously exist, upon successful completion, +.Fn open +marks for update the +.Fa st_ctime +and +.Fa st_mtime fields of the file. -.sp -.LP -If both the \fBO_SYNC\fR and \fBO_DSYNC\fR flags are set, the effect is as if -only the \fBO_SYNC\fR flag was set. -.sp -.LP -If \fIpath\fR refers to a \fBSTREAMS\fR file, \fIoflag\fR may be constructed -from \fBO_NONBLOCK\fR or \fBO_NODELAY\fR OR-ed with either \fBO_RDONLY\fR, -\fBO_WRONLY\fR, or \fBO_RDWR\fR. Other flag values are not applicable to -\fBSTREAMS\fR devices and have no effect on them. The values \fBO_NONBLOCK\fR -and \fBO_NODELAY\fR affect the operation of \fBSTREAMS\fR drivers and certain -functions (see \fBread\fR(2), \fBgetmsg\fR(2), \fBputmsg\fR(2), and -\fBwrite\fR(2)) applied to file descriptors associated with \fBSTREAMS\fR -files. For \fBSTREAMS\fR drivers, the implementation of \fBO_NONBLOCK\fR and -\fBO_NODELAY\fR is device-specific. -.sp -.LP -When \fBopen()\fR is invoked to open a named stream, and the \fBconnld\fR -module (see \fBconnld\fR(7M)) has been pushed on the pipe, \fBopen()\fR blocks -until the server process has issued an \fBI_RECVFD\fR \fBioctl()\fR (see -\fBstreamio\fR(7I)) to receive the file descriptor. -.sp -.LP -If \fIpath\fR names the master side of a pseudo-terminal device, then it is -unspecified whether \fBopen()\fR locks the slave side so that it cannot be -opened. Portable applications must call \fBunlockpt\fR(3C) before opening the -slave side. -.sp -.LP +.Pp +If both the +.Dv O_SYNC +and +.Dv O_DSYNC +flags are set, the effect is as if only the +.Dv O_SYNC +flag was set. +.Pp +If +.Fa path +refers to a STREAMS file, +.Fa oflag +may be constructed from +.Dv O_NONBLOCK +or +.Dv O_NODELAY +OR-ed with either +.Dv O_RDONLY , +.Dv O_WRONLY , +or +.Dv O_RDWR . +Other flag values are not applicable to STREAMS devices and have no effect on +them. +The values +.Dv O_NONBLOCK +and +.Dv O_NODELAY +affect the operation of STREAMS drivers and certain functions +.Po +see +.Xr read 2 , +.Xr getmsg 2 , +.Xr putmsg 2 , +and +.Xr write 2 +.Pc +applied to file descriptors associated with STREAMS files. +For STREAMS drivers, the implementation of +.Dv O_NONBLOCK +and +.Dv O_NODELAY +is device-specific. +.Pp +When +.Fn open +is invoked to open a named stream, and the +.Xr connld 7M +module has been pushed on the pipe, +.Fn open +blocks until the server process has issued an +.Dv I_RECVFD +.Xr ioctl 2 +.Po +see +.Xr streamio 7I +.Pc +to receive the file descriptor. +.Pp +If +.Fa path +names the manager side of a pseudo-terminal device, then it is unspecified +whether +.Fn open +locks the subsidiary side so that it cannot be opened. +Portable applications must call +.Xr unlockpt 3C +before opening the subsidiary side. +.Pp If the file is a regular file and the local file system is mounted with the -\fBnbmand\fR mount option, then a mandatory share reservation is automatically -obtained on the file. The share reservation is obtained as if \fBfcntl\fR(2) -were called with \fIcmd\fR \fBF_SHARE_NBMAND\fR and the \fBfshare_t\fR values -set as follows: -.sp -.ne 2 -.na -\fB\fBf_access\fR\fR -.ad -.RS 12n +.Cm nbmand +mount option, then a mandatory share reservation is automatically obtained on +the file. +The share reservation is obtained as if +.Xr fcntl 2 +were called with +.Fa cmd +.Dv F_SHARE_NBMAND +and the +.Vt fshare_t +values set as follows: +.Bl -tag -width Ds -offset Ds +.It Fa f_access Set to the type of read/write access for which the file is opened. -.RE - -.sp -.ne 2 -.na -\fB\fBf_deny\fR\fR -.ad -.RS 12n -\fBF_NODNY\fR -.RE - -.sp -.ne 2 -.na -\fB\fBf_id\fR\fR -.ad -.RS 12n -The file descriptor value returned from \fBopen()\fR. -.RE - -.sp -.LP -If \fIpath\fR is a symbolic link and \fBO_CREAT\fR and \fBO_EXCL\fR are set, -the link is not followed. -.sp -.LP -Certain flag values can be set following \fBopen()\fR as described in -\fBfcntl\fR(2). -.sp -.LP +.It Fa f_deny +.Dv F_NODNY +.It Fa f_id +The file descriptor value returned from +.Fn open . +.El +.Pp +If +.Fa path +is a symbolic link and +.Dv O_CREAT +and +.Dv O_EXCL +are set, the link is not followed. +.Pp +Certain flag values can be set following +.Fn open +as described in +.Xr fcntl 2 . +.Pp The largest value that can be represented correctly in an object of type -\fBoff_t\fR is established as the offset maximum in the open file description. -.SH RETURN VALUES -Upon successful completion, both \fBopen()\fR and \fBopenat()\fR functions open -the file and return a non-negative integer representing the lowest numbered -unused file descriptor. Otherwise, \fB\(mi1\fR is returned, \fBerrno\fR is set -to indicate the error, and no files are created or modified. -.SH ERRORS -The \fBopen()\fR and \fBopenat()\fR functions will fail if: -.sp -.ne 2 -.na -\fB\fBEACCES\fR\fR -.ad -.RS 16n -Search permission is denied on a component of the path prefix. -.sp -The file exists and the permissions specified by \fIoflag\fR are denied. -.sp -The file does not exist and write permission is denied for the parent directory -of the file to be created. -.sp -\fBO_TRUNC\fR is specified and write permission is denied. -.sp -The {\fBPRIV_FILE_DAC_SEARCH\fR} privilege allows processes to search -directories regardless of permission bits. The {\fBPRIV_FILE_DAC_WRITE\fR} -privilege allows processes to open files for writing regardless of permission -bits. See \fBprivileges\fR(5) for special considerations when opening files -owned by UID 0 for writing. The {\fBPRIV_FILE_DAC_READ\fR} privilege allows -processes to open files for reading regardless of permission bits. -.RE - -.sp -.ne 2 -.na -\fB\fBEAGAIN\fR\fR -.ad -.RS 16n -A mandatory share reservation could not be obtained because the desired access -conflicts with an existing \fBf_deny\fR share reservation. -.RE - -.sp -.ne 2 -.na -\fB\fBEDQUOT\fR\fR -.ad -.RS 16n -The file does not exist, \fBO_CREAT\fR is specified, and either the directory -where the new file entry is being placed cannot be extended because the user's -quota of disk blocks on that file system has been exhausted, or the user's -quota of inodes on the file system where the file is being created has been -exhausted. -.RE - -.sp -.ne 2 -.na -\fB\fBEEXIST\fR\fR -.ad -.RS 16n -The \fBO_CREAT\fR and \fBO_EXCL\fR flags are set and the named file exists. -.RE - -.sp -.ne 2 -.na -\fB\fBEILSEQ\fR\fR -.ad -.RS 16n -The \fIpath\fR argument includes non-UTF8 characters and the file system -accepts only file names where all characters are part of the UTF-8 character -codeset. -.RE - -.sp -.ne 2 -.na -\fB\fBEINTR\fR\fR -.ad -.RS 16n -A signal was caught during \fBopen()\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBEFAULT\fR\fR -.ad -.RS 16n -The \fIpath\fR argument points to an illegal address. -.RE - -.sp -.ne 2 -.na -\fB\fBEINVAL\fR\fR -.ad -.RS 16n -The system does not support synchronized or direct I/O for this file, or the -\fBO_XATTR\fR flag was supplied and the underlying file system does not support -extended file attributes. -.RE - -.sp -.ne 2 -.na -\fB\fBEIO\fR\fR -.ad -.RS 16n -The \fIpath\fR argument names a \fBSTREAMS\fR file and a hangup or error -occurred during the \fBopen()\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBEISDIR\fR\fR -.ad -.RS 16n -The named file is a directory and \fIoflag\fR includes \fBO_WRONLY\fR or -\fBO_RDWR\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBELOOP\fR\fR -.ad -.RS 16n -Too many symbolic links were encountered in resolving \fIpath\fR. -.sp -A loop exists in symbolic links encountered during resolution of the \fIpath\fR -argument. -.sp -The \fBO_NOFOLLOW\fR flag is set and the final component of path is a symbolic -link. -.RE - -.sp -.ne 2 -.na -\fB\fBEMFILE\fR\fR -.ad -.RS 16n -There are currently {\fBOPEN_MAX\fR} file descriptors open in the calling -process. -.RE - -.sp -.ne 2 -.na -\fB\fBEMLINK\fR\fR -.ad -.RS 16n -The \fBO_NOLINKS\fR flag is set and the named file has a link count greater -than 1. -.RE - -.sp -.ne 2 -.na -\fB\fBEMULTIHOP\fR\fR -.ad -.RS 16n -Components of \fIpath\fR require hopping to multiple remote machines and the -file system does not allow it. -.RE - -.sp -.ne 2 -.na -\fB\fBENAMETOOLONG\fR\fR -.ad -.RS 16n -The length of the \fIpath\fR argument exceeds {\fBPATH_MAX\fR} or a pathname -component is longer than {\fBNAME_MAX\fR}. -.RE - -.sp -.ne 2 -.na -\fB\fBENFILE\fR\fR -.ad -.RS 16n -The maximum allowable number of files is currently open in the system. -.RE - -.sp -.ne 2 -.na -\fB\fBENOENT\fR\fR -.ad -.RS 16n -The \fBO_CREAT\fR flag is not set and the named file does not exist; or the -\fBO_CREAT\fR flag is set and either the path prefix does not exist or the -\fIpath\fR argument points to an empty string. -.sp +.Vt off_t +is established as the offset maximum in the open file description. +.Sh RETURN VALUES The -.B O_CREAT +.Fn open and -.B O_DIRECTORY -flags were both set and -.I path -did not point to a file. -.RE - -.sp -.ne 2 -.na -.B ENOEXEC -.ad -.RS 16n -The \fBO_EXEC\fR flag is set and \fIpath\fR does not point to a regular -file. -.RE - -.sp -.ne 2 -.na -\fB\fBENOLINK\fR\fR -.ad -.RS 16n -The \fIpath\fR argument points to a remote machine, and the link to that -machine is no longer active. -.RE - -.sp -.ne 2 -.na -\fB\fBENOSR\fR\fR -.ad -.RS 16n -The \fIpath\fR argument names a STREAMS-based file and the system is unable to -allocate a STREAM. -.RE - -.sp -.ne 2 -.na -\fB\fBENOSPC\fR\fR -.ad -.RS 16n -The directory or file system that would contain the new file cannot be -expanded, the file does not exist, and \fBO_CREAT\fR is specified. -.RE - -.sp -.ne 2 -.na -\fB\fBENOSYS\fR\fR -.ad -.RS 16n -The device specified by \fIpath\fR does not support the open operation. -.RE - -.sp -.ne 2 -.na -\fB\fBENOTDIR\fR\fR -.ad -.RS 16n -A component of the path prefix is not a directory or a relative path was -supplied to \fBopenat()\fR, the \fBO_XATTR\fR flag was not supplied, and the -file descriptor does not refer to a directory. The \fBO_SEARCH\fR flag -was passed and \fIpath\fR does not refer to a directory. -.sp -The -.B O_DIRECTORY -flag was set and the file was not a directory. -.RE - -.sp -.ne 2 -.na -\fB\fBENXIO\fR\fR -.ad -.RS 16n -The \fBO_NONBLOCK\fR flag is set, the named file is a FIFO, the \fBO_WRONLY\fR -flag is set, and no process has the file open for reading; or the named file is -a character special or block special file and the device associated with this -special file does not exist or has been retired by the fault management -framework . -.RE - -.sp -.ne 2 -.na -\fB\fBEOPNOTSUPP\fR\fR -.ad -.RS 16n -An attempt was made to open a path that corresponds to a \fBAF_UNIX\fR socket. -.RE - -.sp -.ne 2 -.na -\fB\fBEOVERFLOW\fR\fR -.ad -.RS 16n -The named file is a regular file and either \fBO_LARGEFILE\fR is not set and -the size of the file cannot be represented correctly in an object of type -\fBoff_t\fR or \fBO_LARGEFILE\fR is set and the size of the file cannot be -represented correctly in an object of type \fBoff64_t\fR. -.RE - -.sp -.ne 2 -.na -\fB\fBEROFS\fR\fR -.ad -.RS 16n -The named file resides on a read-only file system and either \fBO_WRONLY\fR, -\fBO_RDWR\fR, \fBO_CREAT\fR (if file does not exist), or \fBO_TRUNC\fR is set -in the \fIoflag\fR argument. -.RE - -.sp -.LP -The \fBopenat()\fR function will fail if: -.sp -.ne 2 -.na -\fB\fBEBADF\fR\fR -.ad -.RS 9n -The \fIfildes\fR argument is not a valid open file descriptor or is not -\fBAT_FTCWD\fR. -.RE - -.sp -.LP -The \fBopen()\fR function may fail if: -.sp -.ne 2 -.na -\fB\fBEAGAIN\fR\fR -.ad -.RS 16n -The \fIpath\fR argument names the slave side of a pseudo-terminal device that -is locked. -.RE - -.sp -.ne 2 -.na -\fB\fBEINVAL\fR\fR -.ad -.RS 16n -The value of the \fIoflag\fR argument is not valid. -.RE - -.sp -.ne 2 -.na -\fB\fBENAMETOOLONG\fR\fR -.ad -.RS 16n -Pathname resolution of a symbolic link produced an intermediate result whose -length exceeds {\fBPATH_MAX\fR}. -.RE - -.sp -.ne 2 -.na -\fB\fBENOMEM\fR\fR -.ad -.RS 16n -The \fIpath\fR argument names a \fBSTREAMS\fR file and the system is unable to -allocate resources. -.RE - -.sp -.ne 2 -.na -\fB\fBETXTBSY\fR\fR -.ad -.RS 16n -The file is a pure procedure (shared text) file that is being executed and -\fIoflag\fR is \fBO_WRONLY\fR or \fBO_RDWR\fR. -.RE - -.SH EXAMPLES -\fBExample 1 \fROpen a file for writing by the owner. -.sp -.LP -The following example opens the file \fB/tmp/file\fR, either by creating it if -it does not already exist, or by truncating its length to 0 if it does exist. +.Fn openat +functions open the file and, if successful, return a non-negative integer +representing the lowest numbered unused file descriptor; otherwise the +value +.Sy -1 +is returned and the global variable +.Va errno +is set to indicate the error and no files are created or modified. +.Sh EXAMPLES +.Sy Example 1 +Open a file for writing by the owner. +.Pp +The following example opens the file +.Pa /tmp/file , +either by creating it if it does not already exist, or by truncating its length +to +.Sy 0 +if it does exist. If the call creates a new file, the access permission bits in the file mode of the file are set to permit reading and writing by the owner, and to permit reading only by group members and others. - -.sp -.LP -If the call to \fBopen()\fR is successful, the file is opened for writing. - -.sp -.in +2 -.nf +.Pp +If the call to +.Fn open +is successful, the file is opened for writing. +.Bd -literal -offset Ds #include <fcntl.h> \&... int fd; @@ -928,98 +635,361 @@ char *filename = "/tmp/file"; \&... fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, mode); \&... -.fi -.in -2 - -.LP -\fBExample 2 \fROpen a file using an existence check. -.sp -.LP -The following example uses the \fBopen()\fR function to try to create the -\fBLOCKFILE\fR file and open it for writing. Since the \fBopen()\fR function -specifies the \fBO_EXCL\fR flag, the call fails if the file already exists. In -that case, the application assumes that someone else is updating the password -file and exits. - -.sp -.in +2 -.nf +.Ed +.Pp +.Sy Example 2 +Open a file using an existence check. +.Pp +The following example uses the +.Fn open +function to try to create the +.Dv LOCKFILE +file and open it for writing. +Since the +.Fn open +function specifies the +.Dv O_EXCL +flag, the call fails if the file already exists. +In that case, the application assumes that someone else is updating the +password file and exits. +.Bd -literal -offset Ds #include <fcntl.h> #include <stdio.h> #include <stdlib.h> +#include <err.h> +\&... #define LOCKFILE "/etc/ptmp" \&... int pfd; /* Integer for file descriptor returned by open() call. */ \&... if ((pfd = open(LOCKFILE, O_WRONLY | O_CREAT | O_EXCL, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) -{ - fprintf(stderr, "Cannot open /etc/ptmp. Try again later.\en"); - exit(1); + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { + err(1, "Cannot open %s. Try again later.", LOCKFILE); } \&... -.fi -.in -2 - -.LP -\fBExample 3 \fROpen a file for writing. -.sp -.LP +.Ed +.Pp +.Sy Example 3 +Open a file for writing. +.Pp The following example opens a file for writing, creating the file if it does -not already exist. If the file does exist, the system truncates the file to -zero bytes. - -.sp -.in +2 -.nf +not already exist. +If the file does exist, the system truncates the file to zero bytes. +.Bd -literal -offset Ds #include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#define LOCKFILE "/etc/ptmp" +#include <err.h> \&... int pfd; char filename[PATH_MAX+1]; \&... if ((pfd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) -{ - perror("Cannot open output file\en"); exit(1); + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { + err(1, "Cannot open output file"); } \&... -.fi -.in -2 - -.SH USAGE -The \fBopen()\fR function has a transitional interface for 64-bit file offsets. -See \fBlf64\fR(5). Note that using \fBopen64()\fR is equivalent to using -\fBopen()\fR with \fBO_LARGEFILE\fR set in \fIoflag\fR. -.SH ATTRIBUTES -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Committed -_ -MT-Level Async-Signal-Safe -_ -Standard For \fBopen()\fR, see \fBstandards\fR(5). -.TE - -.SH SEE ALSO -\fBIntro\fR(2), \fBchmod\fR(2), \fBclose\fR(2), \fBcreat\fR(2), \fBdup\fR(2), -\fBexec\fR(2), \fBfcntl\fR(2), \fBgetmsg\fR(2), \fBgetrlimit\fR(2), -\fBlseek\fR(2), \fBputmsg\fR(2), \fBread\fR(2), \fBstat\fR(2), \fBumask\fR(2), -\fBwrite\fR(2), \fBattropen\fR(3C), \fBdirectio\fR(3C), -\fBfcntl.h\fR(3HEAD), \fBstat.h\fR(3HEAD), -\fBunlockpt\fR(3C), \fBattributes\fR(5), \fBlf64\fR(5), \fBprivileges\fR(5), -\fBstandards\fR(5), \fBconnld\fR(7M), \fBstreamio\fR(7I) -.SH NOTES -Hierarchical Storage Management (HSM) file systems can sometimes cause long -delays when opening a file, since HSM files must be recalled from secondary -storage. +.Ed +.Sh ERRORS +The +.Fn open +and +.Fn openat +functions will fail if: +.Bl -tag -width Er +.It Er EACCES +Search permission is denied on a component of the path prefix. +.Pp +The file exists and the permissions specified by +.Fa oflag +are denied. +.Pp +The file does not exist and write permission is denied for the parent directory +of the file to be created. +.Pp +.Dv O_TRUNC +is specified and write permission is denied. +.Pp +The +.Brq Dv PRIV_FILE_DAC_SEARCH +privilege allows processes to search directories regardless of permission bits. +The +.Brq Dv PRIV_FILE_DAC_WRITE +privilege allows processes to open files for writing regardless of permission +bits. +See +.Xr privileges 5 for special considerations when opening files owned by user ID +.Sy 0 +for writing. +The +.Brq Dv PRIV_FILE_DAC_READ +privilege allows +processes to open files for reading regardless of permission bits. +.It Er EAGAIN +A mandatory share reservation could not be obtained because the desired access +conflicts with an existing +.Fa f_deny +share reservation +.Po +see +.Xr fcntl 2 +.Pc . +.It Er EDQUOT +The file does not exist, +.Dv O_CREAT +is specified, and either the directory where the new file entry is being placed +cannot be extended because the user's quota of disk blocks on that file system +has been exhausted, or the user's quota of inodes on the file system where the +file is being created has been exhausted. +.It Er EEXIST +The +.Dv O_CREAT +and +.Dv O_EXCL +flags are set and the named file already exists. +.It Er EILSEQ +The +.Fa path +argument includes bytes that are not valid UTF-8 characters, and the file +system accepts only file names where all characters are part of the UTF-8 +character codeset. +.It Er EINTR +A signal was caught during +.Fn open . +.It Er EFAULT +The +.Fa path +argument points to an illegal address. +.It Er EINVAL +Either the system does not support synchronized or direct I/O for this file, or +the +.Dv O_XATTR +flag was supplied and the underlying file system does not support extended file +attributes. +.It Er EIO +The +.Fa path +argument names a STREAMS file and a hangup or error occurred during the +.Fn open . +.It Er EISDIR +The named file is a directory and +.Fa oflag +includes +.Dv O_WRONLY +or +.Dv O_RDWR . +.It Er ELOOP +Too many symbolic links were encountered in resolving +.Fa path . +.Pp +A loop exists in symbolic links encountered during resolution of the +.Fa path +argument. +.Pp +The +.Dv O_NOFOLLOW +flag is set and the final component of path is a symbolic link. +.It Er EMFILE +There are currently +.Brq Dv OPEN_MAX +file descriptors open in the calling process. +.It Er EMLINK +The +.Dv O_NOLINKS +flag is set and the named file has a link count greater than +.Sy 1 . +.It Er EMULTIHOP +Components of +.Fa path +require hopping to multiple remote machines and the file system does not allow +it. +.It Er ENAMETOOLONG +The length of the +.Fa path +argument exceeds +.Brq Dv PATH_MAX +or a pathname component is longer than +.Brq Dv NAME_MAX . +.It Er ENFILE +The maximum allowable number of files is currently open in the system. +.It Er ENOENT +The +.Dv O_CREAT +flag is not set and the named file does not exist; or the +.Dv O_CREAT +flag is set and either the path prefix does not exist or the +.Fa path +argument points to an empty string. +.Pp +The +.Dv O_CREAT +and +.Dv O_DIRECTORY +flags were both set and +.Fa path +did not point to a file. +.It Er ENOEXEC +The +.Dv O_EXEC +flag is set and +.Fa path +does not point to a regular file. +.It Er ENOLINK +The +.Fa path +argument points to a remote machine, and the link to that machine is no longer +active. +.It Er ENOSR +Th +.Fa path +argument names a STREAMS-based file and the system is unable to allocate a +STREAM. +.It Er ENOSPC +The directory or file system that would contain the new file cannot be +expanded, the file does not exist, and +.Dv O_CREAT +is specified. +.It Er ENOSYS +The device specified by +.Fa path +does not support the open operation. +.It Er ENOTDIR +A component of the path prefix is not a directory or a relative path was +supplied to +.Fn openat , +the +.Dv O_XATTR +flag was not supplied, and the file descriptor does not refer to a directory. +The +.Dv O_SEARCH +flag was passed and +.Fa path +does not refer to a directory. +.Pp +The +.Dv O_DIRECTORY +flag was set and the file was not a directory. +.It Er ENXIO +The +.Dv O_NONBLOCK +flag is set, the named file is a FIFO, the +.Dv O_WRONLY +flag is set, and no process has the file open for reading; or the named file is +a character special or block special file and the device associated with this +special file does not exist or has been retired by the fault management +framework. +.It Er EOPNOTSUPP +An attempt was made to open a path that corresponds to an +.Dv AF_UNIX +socket. +.It Er EOVERFLOW +The named file is a regular file and either +.Dv O_LARGEFILE +is not set and the size of the file cannot be represented correctly in an +object of type +.Vt off_t +or +.Dv O_LARGEFILE +is set and the size of the file cannot be represented correctly in an object of +type +.Vt off64_t . +.It Er EROFS +The named file resides on a read-only file system and either +.Dv O_WRONLY , +.Dv O_RDWR , +.Dv O_CREAT +(if file does not exist), or +.Dv O_TRUNC +is set in the +.Fa oflag +argument. +.El +.Pp +The +.Fn openat +function will fail if: +.Bl -tag -width Er +.It Er EBADF +The +.Fa fildes +argument is not a valid open file descriptor or is not +.Dv AT_FTCWD . +.El +.Pp +The +.Fn open +function may fail if: +.Bl -tag -width Er +.It Er EAGAIN +The +.Fa path +argument names the subsidiary side of a pseudo-terminal device that is locked. +.It Er EINVAL +The value of the +.Fa oflag +argument is not valid. +.It Er ENAMETOOLONG +Pathname resolution of a symbolic link produced an intermediate result whose +length exceeds +.Brq Dv PATH_MAX . +.It Er ENOMEM +The +.Fa path +argument names a STREAMS file and the system is unable to allocate resources. +.It Er ETXTBSY +The file is a pure procedure (shared text) file that is being executed and +.Fa oflag +is +.Dv O_WRONLY +or +.Dv O_RDWR . +.El +.Sh USAGE +The +.Fn open +function has a transitional interface for 64-bit file offsets. +See +.Xr lf64 5 . +Note that using +.Fn open64 +is equivalent to using +.Fn open with +.Dv O_LARGEFILE +set in +.Fa oflag . +.Sh INTERFACE STABILITY +.Sy Committed +.Sh MT LEVEL +.Sy Async-Signal-Safe +.Sh SEE ALSO +.Xr chmod 2 , +.Xr close 2 , +.Xr creat 2 , +.Xr dup 2 , +.Xr exec 2 , +.Xr fcntl 2 , +.Xr getmsg 2 , +.Xr getrlimit 2 , +.Xr Intro 2 , +.Xr lseek 2 , +.Xr putmsg 2 , +.Xr read 2 , +.Xr stat 2 , +.Xr umask 2 , +.Xr write 2 , +.Xr attropen 3C , +.Xr directio 3C , +.Xr unlockpt 3C , +.Xr fcntl.h 3HEAD , +.Xr stat.h 3HEAD , +.Xr attributes 5 , +.Xr lf64 5 , +.Xr privileges 5 , +.Xr standards 5 , +.Xr streamio 7I , +.Xr connld 7M +.Sh NOTES +Hierarchical Storage Management +.Pq HSM +file systems can sometimes cause long delays when opening a file, since HSM +files must be recalled from secondary storage. diff --git a/usr/src/man/man3c/grantpt.3c b/usr/src/man/man3c/grantpt.3c index 7e523af80b..154a5a07f5 100644 --- a/usr/src/man/man3c/grantpt.3c +++ b/usr/src/man/man3c/grantpt.3c @@ -43,88 +43,76 @@ .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1994, X/Open Company Limited. All Rights Reserved. .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2022 Oxide Computer Company .\" -.TH GRANTPT 3C "Aug 14, 2006" -.SH NAME -grantpt \- grant access to the slave pseudo-terminal device -.SH SYNOPSIS -.LP -.nf -#include <stdlib.h> - -\fBint\fR \fBgrantpt\fR(\fBint\fR \fIfildes\fR); -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBgrantpt()\fR function changes the mode and ownership of the slave -pseudo-terminal device associated with its master pseudo-terminal counterpart. -\fIfildes\fR is the file descriptor returned from a successful open of the -master pseudo-terminal device. The user ID of the slave is set to the real UID -of the calling process and the group ID is set to a reserved group. The -permission mode of the slave pseudo-terminal is set to readable and writable by -the owner and writable by the group. -.SH RETURN VALUES -.sp -.LP -Upon successful completion, \fBgrantpt()\fR returns \fB0\fR. Otherwise, it -returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error. -.SH ERRORS -.sp -.LP -The \fBgrantpt()\fR function may fail if: -.sp -.ne 2 -.na -\fB\fBEBADF\fR\fR -.ad -.RS 10n -The \fIfildes\fR argument is not a valid open file descriptor. -.RE - -.sp -.ne 2 -.na -\fB\fBEINVAL\fR\fR -.ad -.RS 10n -The \fIfildes\fR argument is not associated with a master pseudo-terminal +.Dd February 5, 2022 +.Dt GRANTPT 3C +.Os +.Sh NAME +.Nm grantpt +.Nd grant access to the subsidiary device of a pseudo-terminal +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fo grantpt +.Fa "int fildes" +.Fc +.Sh DESCRIPTION +The +.Fn grantpt +function changes the mode and ownership of the pseudo-terminal subsidiary +device associated with its pseudo-terminal manager counterpart. +.Pp +The +.Fa fildes +argument is the file descriptor returned from a successful +.Xr open 2 +of the pseudo-terminal manager device; e.g., by calling +.Xr posix_openpt 3C +or by performing an +.Xr open 2 +of the +.Xr ptm 7D device. -.RE - -.sp -.ne 2 -.na -\fB\fBEACCES\fR\fR -.ad -.RS 10n -The corresponding slave pseudo-terminal device could not be accessed. -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Standard -_ -MT-Level Safe -.TE - -.SH SEE ALSO -.sp -.LP -\fBopen\fR(2), \fBptsname\fR(3C), \fBunlockpt\fR(3C), \fBattributes\fR(5), -\fBstandards\fR(5) -.sp -.LP -\fISTREAMS Programming Guide\fR +.Pp +The user ID owner of the subsidiary device is set to the real user ID of the +calling process. +The group ID owner is set to a reserved group. +.Pp +The permission mode of the subsidiary device is set to be readable and writable +by the owner, and writable by the group. +.Sh RETURN VALUES +.Rv -std grantpt +.Sh EXAMPLES +See +.Xr posix_openpt 3C +for an example that includes a call to +.Fn grantpt . +.Sh ERRORS +The +.Fn grantpt +function may fail if: +.Bl -tag -width Er +.It Er EBADF +The +.Fa fildes +argument is not a valid open file descriptor. +.It Er EINVAL +The +.Fa fildes +argument is not associated with a pseudo-terminal manager device. +.It Er EACCES +The corresponding pseudo-terminal subsidiary device could not be accessed. +.El +.Sh INTERFACE STABILITY +.Sy Committed +.Sh MT LEVEL +.Sy Safe +.Sh SEE ALSO +.Xr open 2 , +.Xr posix_openpt 3C , +.Xr ptsname 3C , +.Xr unlockpt 3C , +.Xr attributes 5 , +.Xr standards 5 , +.Xr ptm 7D diff --git a/usr/src/man/man3c/posix_openpt.3c b/usr/src/man/man3c/posix_openpt.3c index 16193b89f3..b009dd6e17 100644 --- a/usr/src/man/man3c/posix_openpt.3c +++ b/usr/src/man/man3c/posix_openpt.3c @@ -42,160 +42,142 @@ .\" .\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved. .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2022 Oxide Computer Company .\" -.TH POSIX_OPENPT 3C "June 18, 2021" -.SH NAME -posix_openpt \- open a pseudo terminal device -.SH SYNOPSIS -.nf -#include <stdlib.h> -#include <fcntl.h> - -\fBint\fR \fBposix_openpt\fR(\fBint\fR \fIoflag\fR); -.fi - -.SH DESCRIPTION -The \fBposix_openpt()\fR function establishes a connection between a master -device for a pseudo-terminal and a file descriptor. The file descriptor is used -by other I/O functions that refer to that pseudo-terminal. -.sp -.LP +.Dd February 5, 2022 +.Dt POSIX_OPENPT 3C +.Os +.Sh NAME +.Nm posix_openpt +.Nd open a pseudo-terminal manager device +.Sh SYNOPSIS +.In stdlib.h +.In fcntl.h +.Ft int +.Fo posix_openpt +.Fa "int oflag" +.Fc +.Sh DESCRIPTION +The +.Fn posix_openpt +function establishes a connection between a manager device for a +pseudo-terminal and a file descriptor. +The file descriptor is used by other I/O functions that refer to that +pseudo-terminal. +.Pp The file status flags and file access modes of the open file description are -set according to the value of \fIoflag\fR. -.sp -.LP -Values for \fIoflag\fR are constructed by a bitwise-inclusive OR of flags from -the following list, defined in <\fBfcntl.h\fR>. -.sp -.ne 2 -.na -\fB\fBO_RDWR\fR\fR -.ad -.RS 12n +set according to the value of +.Fa oflag . +.Pp +Values for +.Fa oflag +are constructed by a bitwise-inclusive OR of flags from +the following list, defined in +.Xr fcntl.h 3HEAD : +.Bl -tag -width Ds +.It Dv O_RDWR Open for reading and writing. -.RE - -.sp -.ne 2 -.na -\fB\fBO_NOCTTY\fR\fR -.ad -.RS 12n -If set, \fBposix_openpt()\fR does not cause the terminal device to become the -controlling terminal for the process. -.RE - -.sp -.LP -The behavior of other values for the \fIoflag\fR argument is unspecified. -.SH RETURN VALUES -Upon successful completion, the \fBposix_openpt()\fR function opens a master -pseudo-terminal device and returns a non-negative integer representing the -lowest numbered unused file descriptor. Otherwise, -1 is returned and -\fBerrno\fR is set to indicate the error. -.SH ERRORS -The \fBposix_openpt()\fR function will fail if: -.sp -.ne 2 -.na -\fB\fBEMFILE\fR\fR -.ad -.RS 10n -{\fBOPEN_MAX\fR} file descriptors are currently open in the calling process. -.RE - -.sp -.ne 2 -.na -\fB\fBENFILE\fR\fR -.ad -.RS 10n -The maximum allowable number of files is currently open in the system. -.RE - -.sp -.LP -The \fBposix_openpt()\fR function may fail if: -.sp -.ne 2 -.na -\fB\fBEINVAL\fR\fR -.ad -.RS 10n -The value of \fIoflag\fR is not valid. -.RE - -.sp -.ne 2 -.na -\fB\fBEAGAIN\fR\fR -.ad -.RS 10n -Out of pseudo-terminal resources. -.RE - -.sp -.ne 2 -.na -\fB\fBENOSR\fR\fR -.ad -.RS 10n -Out of STREAMS resources. -.RE - -.SH EXAMPLES -\fBExample 1 \fROpen a pseudo-terminal. -.sp -.LP -The following example opens a pseudo-terminal and returns the name of the slave -device and a file descriptor. - -.sp -.in +2 -.nf +.It Dv O_NOCTTY +If set, +.Fn posix_openpt +does not cause the terminal device to become the controlling terminal for the +process. +.El +.Pp +The behavior of other values for the +.Fa oflag +argument is unspecified. +.Sh RETURN VALUES +The +.Fn posix_getopt +function opens a manager pseudo-terminal device and, if successful, returns a +non-negative integer representing the lowest numbered unused file descriptor ; +otherwise, the value +.Sy -1 +is returned and the global variable +.Va errno +is set to indicate the error. +.Sh EXAMPLES +.Sy Example 1 +Open a pseudo-terminal. +.Pp +The following example opens a pseudo-terminal and returns the name of the +subsidiary device and a file descriptor. +.Bd -literal -offset Ds #include <fcntl.h> #include <stdio.h> - -int masterfd, slavefd; -char *slavedevice; - -masterfd = posix_openpt(O_RDWR|O_NOCTTY); - -if (masterfd == -1 - || grantpt (masterfd) == -1 - || unlockpt (masterfd) == -1 - || (slavedevice = ptsname (masterfd)) == NULL) - return -1; - -printf("slave device is: %s\en", slavedevice); - -slavefd = open(slave, O_RDWR|O_NOCTTY); -if (slavefd < 0) - return -1; -.fi -.in -2 - -.SH USAGE -This function provides a method for portably obtaining a file descriptor of a -master terminal device for a pseudo-terminal. The \fBgrantpt\fR(3C) and -\fBptsname\fR(3C) functions can be used to manipulate mode and ownership -permissions and to obtain the name of the slave device, respectively. -.SH ATTRIBUTES -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Standard -_ -MT-Level MT-Safe -.TE - -.SH SEE ALSO -\fBopen\fR(2), \fBgrantpt\fR(3C), \fBptsname\fR(3C), \fBunlockpt\fR(3C), -\fBattributes\fR(5), \fBstandards\fR(5) +#include <err.h> + +int managerfd, subsidiaryfd; +char *subsidiarydevice; + +if ((managerfd = posix_openpt(O_RDWR|O_NOCTTY)) < 0) { + err(1, "opening pseudo-terminal manager"); +} + +if (grantpt(managerfd) != 0 || + unlockpt(managerfd) != 0 || + (subsidiarydevice = ptsname(managerfd)) == NULL) { + (void) close(managerfd); + err(1, "locating pseudo-terminal subsidiary"); +} + +printf("subsidiary device is: %s\en", subsidiarydevice); + +if ((subsidiaryfd = open(subsidiary, O_RDWR|O_NOCTTY)) < 0) { + err(1, "opening pseudo-terminal subsidiary"); +} +.Ed +.Sh ERRORS +The +.Fn posix_openpt +function will fail if: +.Bl -tag -width Er +.It Er EMFILE +.Brq Dv OPEN_MAX +file descriptors are currently open in the calling process. +.It Er ENFILE +The maximum allowable number of files is currently open in the system. +.El +.Pp +The +.Fn posix_openpt +function may fail if: +.Bl -tag -width Er +.It Er EINVAL +The value of +.Fa oflag +is not valid. +.It Er EAGAIN +The system has run out of pseudo-terminal resources. +.It Er ENOSR +The system has run out of STREAMS resources. +.El +.Sh USAGE +This function provides a portable method for obtaining the file descriptor of a +manager terminal device for a pseudo-terminal, as opposed to using +.Xr open 2 +on the +.Xr ptm 7D +device which is system-specific. +.Pp +The +.Xr grantpt 3C +function can be used to manipulate the mode and ownership permissions +of the subsidiary device. +The +.Xr ptsname 3C +function can be used to obtain the name of the subsidiary device. +.Sh INTERFACE STABILITY +.Sy Committed +.Sh MT LEVEL +.Sy MT-Safe +.Sh SEE ALSO +.Xr open 2 , +.Xr grantpt 3C , +.Xr ptsname 3C , +.Xr unlockpt 3C , +.Xr attributes 5 , +.Xr standards 5 , +.Xr ptm 7D , +.Xr pts 7D diff --git a/usr/src/man/man3c/ptsname.3c b/usr/src/man/man3c/ptsname.3c index 8fa25e2ea6..264a3dcc90 100644 --- a/usr/src/man/man3c/ptsname.3c +++ b/usr/src/man/man3c/ptsname.3c @@ -43,59 +43,72 @@ .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2022 Oxide Computer Company .\" -.TH PTSNAME 3C "Aug 14, 2002" -.SH NAME -ptsname \- get name of the slave pseudo-terminal device -.SH SYNOPSIS -.LP -.nf -#include <stdlib.h> - -\fBchar *\fR\fBptsname\fR(\fBint\fR \fIfildes\fR); -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBptsname()\fR function returns the name of the slave pseudo-terminal -device associated with a master pseudo-terminal device. \fIfildes\fR is a file -descriptor returned from a successful open of the master device. -\fBptsname()\fR returns a pointer to a string containing the null-terminated -path name of the slave device of the form \fB/dev/pts/N\fR, where \fBN\fR is a -non-negative integer. -.SH RETURN VALUES -.sp -.LP -Upon successful completion, the function \fBptsname()\fR returns a pointer to a -string which is the name of the pseudo-terminal slave device. This value points -to a static data area that is overwritten by each call to \fBptsname()\fR. Upon -failure, \fBptsname()\fR returns \fINULL\fR. This could occur if \fIfildes\fR -is an invalid file descriptor or if the slave device name does not exist in -the file system. -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Standard -_ -MT-Level Safe -.TE - -.SH SEE ALSO -.sp -.LP -\fBopen\fR(2), \fBgrantpt\fR(3C), \fBttyname\fR(3C), \fBunlockpt\fR(3C), -\fBattributes\fR(5), \fBstandards\fR(5) -.sp -.LP -\fISTREAMS Programming Guide\fR +.Dd February 5, 2022 +.Dt PTSNAME 3C +.Os +.Sh NAME +.Nm ptsname +.Nd get the name of the subsidiary device of a pseudo-terminal +.Sh SYNOPSIS +.In stdlib.h +.Ft char * +.Fo ptsname +.Fa "int fildes" +.Fc +.Sh DESCRIPTION +The +.Fn ptsname +function returns the name of the pseudo-terminal subsidiary device associated +with a pseudo-terminal manager device. +The +.Fa fildes +argument is a file descriptor returned from a successful open of the +pseudo-terminal manager device; e.g., by calling +.Xr posix_openpt 3C +or by performing an +.Xr open 2 +of the +.Xr ptm 7D +device. +.Pp +The +.Fn ptsname +function returns a pointer to a string containing the null-terminated +path name of the subsidiary device. +This string is of the form +.Pa /dev/pts/N , +where +.Sy N +is a non-negative integer. +.Sh RETURN VALUES +If successful, the +.Fn ptsname +function returns a pointer to a string which is the name of the pseudo-terminal +subsidiary device. +This value points to a static data area that is overwritten by each call to +.Fn ptsname . +.Pp +Upon failure, +.Fn ptsname +returns +.Dv NULL . +This could occur if +.Fa fildes +is an invalid file descriptor or if the subsidiary device name does not exist +in the file system. +.Sh INTERFACE STABILITY +.Sy Committed +.Sh MT LEVEL +.Sy Safe +.Sh SEE ALSO +.Xr open 2 , +.Xr grantpt 3C , +.Xr posix_openpt 3C , +.Xr ttyname 3C , +.Xr unlockpt 3C , +.Xr attributes 5 , +.Xr standards 5 , +.Xr ptm 7D , +.Xr pts 7D diff --git a/usr/src/man/man3c/unlockpt.3c b/usr/src/man/man3c/unlockpt.3c index 598a56717d..865c217e32 100644 --- a/usr/src/man/man3c/unlockpt.3c +++ b/usr/src/man/man3c/unlockpt.3c @@ -43,78 +43,69 @@ .\" Copyright 1989 AT&T .\" Copyright (c) 1997, The Open Group. All Rights Reserved. .\" Portions Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2022 Oxide Computer Company .\" -.TH UNLOCKPT 3C "Aug 14, 2002" -.SH NAME -unlockpt \- unlock a pseudo-terminal master/slave pair -.SH SYNOPSIS -.LP -.nf -#include <stdlib.h> - -\fBint\fR \fBunlockpt\fR(\fBint\fR \fIfildes\fR); -.fi - -.SH DESCRIPTION -.sp -.LP -The \fBunlockpt()\fR function unlocks the slave pseudo-terminal device -associated with the master to which \fIfildes\fR refers. -.sp -.LP -Portable applications must call \fBunlockpt()\fR before opening the slave side -of a pseudo-terminal device. -.SH RETURN VALUES -.sp -.LP -Upon successful completion, \fBunlockpt()\fR returns \fB0\fR. Otherwise, it -returns \fB\(mi1\fR and sets \fBerrno\fR to indicate the error. -.SH ERRORS -.sp -.LP -The \fBunlockpt()\fR function may fail if: -.sp -.ne 2 -.na -\fB\fBEBADF\fR\fR -.ad -.RS 10n -The \fIfildes\fR argument is not a file descriptor open for writing. -.RE - -.sp -.ne 2 -.na -\fB\fBEINVAL\fR\fR -.ad -.RS 10n -The \fIfildes\fR argument is not associated with a master pseudo-terminal -device. -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Standard -_ -MT-Level Safe -.TE - -.SH SEE ALSO -.sp -.LP -\fBopen\fR(2), \fBgrantpt\fR(3C), \fBptsname\fR(3C), \fBattributes\fR(5), -\fBstandards\fR(5) -.sp -.LP -\fISTREAMS Programming Guide\fR +.Dd February 5, 2022 +.Dt UNLOCKPT 3C +.Os +.Sh NAME +.Nm unlockpt +.Nd unlock a pseudo-terminal device pair +.Sh SYNOPSIS +.In stdlib.h +.Ft int +.Fo unlockpt +.Fa "int fildes" +.Fc +.Sh DESCRIPTION +When a pseudo-terminal manager device is opened, whether through +.Xr posix_openpt 3C +or +.Xr open 2 +on a +.Xr ptm 7D +device, the subsidiary device begins operation in a locked state. +The +.Fn unlockpt +function unlocks the pseudo-terminal subsidiary device associated with the +manager device to which +.Fa fildes +refers. +.Pp +Portable applications must call +.Fn unlockpt +before opening the pseudo-terminal subsidiary device. +.Sh RETURN VALUES +.Rv -std unlockpt +.Sh EXAMPLES +See +.Xr posix_openpt 3C +for an example that includes a call to +.Fn unlockpt . +.Sh ERRORS +The +.Fn unlockpt +function may fail if: +.Bl -tag -width Er +.It Er EBADF +The +.Fa fildes +argument is not a file descriptor open for writing. +.It Er EINVAL +EINVAL +The +.Fa fildes +argument is not associated with a pseudo-terminal manager device. +.El +.Sh INTERFACE STABILITY +.Sy Committed +.Sh MT LEVEL +.Sy Safe +.Sh SEE ALSO +.Xr open 2 , +.Xr grantpt 3C , +.Xr posix_openpt 3C , +.Xr ptsname 3C , +.Xr attributes 5 , +.Xr standards 5 , +.Xr ptm 7D diff --git a/usr/src/man/man3utempter/utempter_add_record.3utempter b/usr/src/man/man3utempter/utempter_add_record.3utempter index da6cbb7211..21f0f44a94 100644 --- a/usr/src/man/man3utempter/utempter_add_record.3utempter +++ b/usr/src/man/man3utempter/utempter_add_record.3utempter @@ -23,7 +23,7 @@ .\" SUCH DAMAGE. .\" .\" -.Dd May 5, 2020 +.Dd February 5, 2022 .Dt UTEMPTER_ADD_RECORD 3UTEMPTER .Os .Sh NAME @@ -67,7 +67,7 @@ and .Fn addToUtmp functions add a login record to the .Xr utmpx 4 -database for the TTY belonging to the pseudo-terminal master file descriptor +database for the TTY belonging to the pseudo-terminal manager file descriptor .Fa fd , using the username corresponding with the real user ID of the calling process and the optional hostname @@ -83,7 +83,7 @@ The and .Fn removeLineFromUtmp functions mark the login session as being closed for the TTY belonging -to the pseudo-terminal master file descriptor +to the pseudo-terminal manager file descriptor .Fa fd . .Pp The diff --git a/usr/src/man/man5/overlay.5 b/usr/src/man/man5/overlay.5 index 4e884fd382..41d1b18739 100644 --- a/usr/src/man/man5/overlay.5 +++ b/usr/src/man/man5/overlay.5 @@ -407,7 +407,7 @@ The file is a JSON file that is formatted according to .El .El .Ss General Properties -Each overaly has the following properties which are used to give +Each overlay has the following properties which are used to give additional information about the system. None of these properties may be specified as part of a .Sy dladm create-overlay , diff --git a/usr/src/man/man7d/Makefile b/usr/src/man/man7d/Makefile index 07e1708efc..fe827d1053 100644 --- a/usr/src/man/man7d/Makefile +++ b/usr/src/man/man7d/Makefile @@ -16,7 +16,7 @@ # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> # Copyright 2018 Nexenta Systems, Inc. # Copyright 2020 Peter Tribble -# Copyright 2021 Oxide Computer Company +# Copyright 2022 Oxide Computer Company # include $(SRC)/Makefile.master @@ -105,7 +105,6 @@ _MANFILES= aac.7d \ poll.7d \ profile.7d \ ptm.7d \ - pts.7d \ pty.7d \ qlc.7d \ ramdisk.7d \ @@ -258,6 +257,7 @@ _MANLINKS= 1394.7d \ firewire.7d \ kmem.7d \ lo0.7d \ + pts.7d \ ticots.7d \ ticotsord.7d \ urandom.7d \ @@ -281,6 +281,8 @@ firewire.7d := LINKSRC = ieee1394.7d lo0.7d := LINKSRC = ipnet.7d +pts.7d := LINKSRC = ptm.7d + allkmem.7d := LINKSRC = mem.7d kmem.7d := LINKSRC = mem.7d diff --git a/usr/src/man/man7d/ptm.7d b/usr/src/man/man7d/ptm.7d index 83c7830293..adf66469bc 100644 --- a/usr/src/man/man7d/ptm.7d +++ b/usr/src/man/man7d/ptm.7d @@ -4,89 +4,255 @@ .\" 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] -.TH PTM 7D "Feb 5, 1997" -.SH NAME -ptm \- STREAMS pseudo-tty master driver -.SH DESCRIPTION -.sp -.LP -The pseudo-tty subsystem simulates a terminal connection, where the master side -represents the terminal and the slave represents the user process's special -device end point. In order to use the pseudo-tty subsystem, a node for the -master side driver \fB/dev/ptmx\fR and \fBN\fR number of nodes for the slave -driver must be installed. See \fBpts\fR(7D). The master device is set up as a -cloned device where its major device number is the major for the clone device -and its minor device number is the major for the \fBptm\fR driver. There are no -nodes in the file system for master devices. The master pseudo driver is opened -using the \fBopen\fR(2) system call with \fB/dev/ptmx\fR as the device -parameter. The clone open finds the next available minor device for the -\fBptm\fR major device. -.sp -.LP -A master device is available only if it and its corresponding slave device are -not already open. When the master device is opened, the corresponding slave -device is automatically locked out. Only one open is allowed on a master -device. Multiple opens are allowed on the slave device. After both the master -and slave have been opened, the user has two file descriptors which are the end -points of a full duplex connection composed of two streams which are -automatically connected at the master and slave drivers. The user may then push -modules onto either side of the stream pair. -.sp -.LP -The master and slave drivers pass all messages to their adjacent queues. Only -the \fBM_FLUSH\fR needs some processing. Because the read queue of one side is -connected to the write queue of the other, the \fBFLUSHR\fR flag is changed to -the \fBFLUSHW\fR flag and vice versa. When the master device is closed an -\fBM_HANGUP\fR message is sent to the slave device which will render the device -unusable. The process on the slave side gets the errno \fBEIO\fR when -attempting to write on that stream but it will be able to read any data -remaining on the stream head read queue. When all the data has been read, -\fBread()\fR returns 0 indicating that the stream can no longer be used. On the -last close of the slave device, a 0-length message is sent to the master -device. When the application on the master side issues a \fBread()\fR or -\fBgetmsg()\fR and 0 is returned, the user of the master device decides whether -to issue a \fBclose()\fR that dismantles the pseudo-terminal subsystem. If the -master device is not closed, the pseudo-tty subsystem will be available to -another user to open the slave device. -.sp -.LP -If \fBO_NONBLOCK\fR or \fBO_NDELAY\fR is set, read on the master side returns -\(mi1 with errno set to \fBEAGAIN\fR if no data is available, and write returns -\(mi1 with errno set to \fBEAGAIN\fR if there is internal flow control. -.SH IOCTLS -.sp -.LP -The master driver supports the \fBISPTM\fR and \fBUNLKPT\fR ioctls that are -used by the functions \fBgrantpt\fR(3C), \fBunlockpt\fR(3C) and -\fBptsname\fR(3C). The ioctl \fBISPTM\fR determines whether the file descriptor -is that of an open master device. On success, it returns the 0. The ioctl -\fBUNLKPT\fR unlocks the master and slave devices. It returns 0 on success. On -failure, the errno is set to \fBEINVAL\fR indicating that the master device is -not open. -.SH FILES -.sp -.ne 2 -.na -\fB\fB/dev/ptmx\fR\fR -.ad -.RS 14n -master clone device -.RE - -.sp -.ne 2 -.na -\fB\fB/dev/pts/M\fR\fR -.ad -.RS 14n -slave devices (M = 0 -> N-1) -.RE - -.SH SEE ALSO -.sp -.LP -\fBgrantpt\fR(3C), \fBptsname\fR(3C), \fBunlockpt\fR(3C), \fBpckt\fR(7M), -\fBpts\fR(7D) -.sp -.LP -\fISTREAMS Programming Guide\fR +.\" Copyright 2022 Oxide Computer Company +.Dd February 5, 2022 +.Dt PTM 7D +.Os +.Sh NAME +.Nm ptm , +.Nm pts +.Nd STREAMS pseudo-terminal manager and subsidiary drivers +.Sh SYNOPSIS +.Pa /dev/ptmx +.Pp +.Pa /dev/pts/* +.Sh DESCRIPTION +The pseudo-terminal subsystem simulates a terminal connection, where the +manager side represents the terminal and the subsidiary represents the user +process's special device end point. +The manager device is set up as a cloned device where its major device number +is the major for the clone device and its minor device number is the major for +the +.Nm ptm +driver; see +.Dv CLONE_DEV +in +.Xr ddi_create_minor_node 9F . +.Pp +There are no nodes in the file system for manager devices. +The manager pseudo driver is opened using the +.Xr open 2 +system call with +.Pa /dev/ptmx +as the device parameter. +The clone open finds the next available minor device for the +.Nm ptm +major device. +.Pp +A manager device is only available if it and its corresponding subsidiary +device are not already open. +Only one open is allowed on a manager device. +Multiple opens are allowed on the subsidiary device. +.Pp +When the manager device is opened, the corresponding subsidiary device is +automatically locked out. +No user may open the subsidiary device until its permissions are adjusted and +the device is unlocked by calling the functions +.Xr grantpt 3C +and +.Xr unlockpt 3C . +The user can then invoke the +.Xr open 2 +system call with the device name returned by the +.Xr ptsname 3C +function. +.Pp +After both the manager and subsidiary have been opened, the user has two file +descriptors which are the end points of a full duplex connection composed of +two streams which are automatically connected at the manager and subsidiary +drivers. +The user may then push modules onto either side of the stream pair. +Unless compiled in XPG4v2 mode +.Po +see +.Sx "XPG4v2 MODE" +.Pc , +the consumer needs to push the +.Xr ptem 7M +and +.Xr ldterm 7M +modules onto the subsidiary device to get terminal semantics. +.Pp +The manager and subsidiary drivers pass all messages to their adjacent queues. +Only the +.Dv M_FLUSH +needs some processing. +Because the read queue of one side is connected to the write queue of the +other, the +.Dv FLUSHR +flag is changed to the +.Dv FLUSHW +flag and vice versa. +.Pp +When the manager device is closed, an +.Dv M_HANGUP +message is sent to the subsidiary device which will render the device unusable. +The process on the subsidiary side gets an +.Er EIO +error when attempting to write on that stream, but it will be able to read +any data remaining on the stream head read queue. +When all the data has been read, +.Xr read 2 +returns +.Sy 0 +indicating that the stream can no longer be used. +.Pp +On the last close of the subsidiary device, a 0-length message is sent to the +manager device. +When the application on the manager side issues a +.Xr read 2 +or +.Xr getmsg 2 +and +.Sy 0 +is returned, the user of the manager device decides whether to issue a +.Xr close 2 +that dismantles the entire pseudo-terminal. +If the manager device is not closed, the pseudo-terminal will be available to +another user to open the subsidiary device. +.Pp +Since 0-length messages are used to indicate that the process on the +subsidiary side has closed, and should be interpreted that way by the process +on the manager side, applications on the subsidiary side should not write +0-length messages. +Unless the application is compiled in XPG4v2 mode +.Po +see +.Sx "XPG4v2 MODE" +.Pc , +then any 0-length messages written to the subsidiary device will be discarded +by the +.Xr ptem 7M +module. +.Pp +If +.Dv O_NONBLOCK +or +.Dv O_NDELAY +is set on the manager side: +.Bl -bullet +.It +Read on the manager side returns +.Sy -1 +with +.Va errno +set to +.Er EAGAIN +if no data is available +.It +Write returns +.Sy -1 +with +.Va errno +set to +.Er EAGAIN +if there is internal flow control +.El +.Pp +Standard STREAMS system calls can access pseudo-terminal devices. +The subsidiary devices support the +.Dv O_NDELAY +and +.Dv O_NONBLOCK +flags. +.Sh XPG4v2 MODE +.Em XPG4v2 +requires that subsidiary pseudo-terminal devices provide the process with an +interface that is identical to the terminal interface, without needing to +explicitly push any modules to achieve this. +It also requires that 0-length messages written on the subsidiary device will +be propagated to the manager device. +.Pp +Experience has shown that most software does not expect subsidiary +pseudo-terminal devices to operate in this manner. +This XPG4v2-compliant behaviour is only enabled in XPG4v2/SUS +.Po +see +.Xr standards 5 +.Pc +mode. +.Sh IOCTLS +The manager driver provides several ioctls to support the +.Xr grantpt 3C , +.Xr unlockpt 3C , +and +.Xr ptsname 3C +functions: +.Bl -tag -width Ds +.It Dv ISPTM +Determines whether the file descriptor is that of an open manager device. +On success, it returns the value +.Sy 0 . +.It Dv UNLKPT +Unlocks the manager and subsidiary devices. +It returns +.Sy 0 +on success. +On failure, +.Vt errno +is set to +.Vt EINVAL +indicating that the manager device is not open. +.El +.Sh FILES +.Bl -tag -width Pa +.It Pa /dev/ptmx +Pseudo-terminal manager clone device. +.It Pa /dev/pts/N +Pseudo-terminal subsidiary devices, where +.Sy N +is a non-negative integer. +Located via calls to +.Xr ptsname 3C . +.El +.Sh EXAMPLES +.Sy Example 1 +Opening the manager and subsidiary device for a pseudo-terminal. +.Bd -literal -offset Ds +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <stropts.h> +#include <fcntl.h> +#include <err.h> +\&... +int fdm, fds; +char *subsidiaryname; +\&... +/* + * NOTE: Portable applications should use posix_openpt(3C) here: + */ +if ((fdm = open("/dev/ptmx", O_RDWR | O_NOCTTY)) < 0) { + err(1, "open manager"); +} +if (grantpt(fdm) != 0 || unlockpt(fdm) != 0 || + (subsidiaryname = ptsname(fdm)) == NULL) { + close(fdm); + err(1, "locate subsidiary"); +} +if ((fds = open(subsidiaryname, O_RDWR | O_NOCTTY)) < 0) { + close(fdm); + err(1, "open subsidiary"); +} +if (ioctl(fds, I_PUSH, "ptem") != 0 || + ioctl(fds, I_PUSH, "ldterm") != 0) { + close(fds); + close(fdm); + err(1, "push modules"); +} +.Ed +.Sh SEE ALSO +.Xr close 2 , +.Xr getmsg 2 , +.Xr open 2 , +.Xr read 2 , +.Xr grantpt 3C , +.Xr posix_openpt 3C , +.Xr ptsname 3C , +.Xr unlockpt 3C , +.Xr standards 5 , +.Xr ldterm 7M , +.Xr pckt 7M , +.Xr ptem 7M , +.Xr ddi_create_minor_node 9F diff --git a/usr/src/man/man7d/pts.7d b/usr/src/man/man7d/pts.7d deleted file mode 100644 index 6ac5bbcbd1..0000000000 --- a/usr/src/man/man7d/pts.7d +++ /dev/null @@ -1,107 +0,0 @@ -'\" te -.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association. -.\" Copyright 1992 Sun Microsystems -.\" 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] -.TH PTS 7D "Feb 29, 2020" -.SH NAME -pts \- STREAMS pseudo-tty slave driver -.SH DESCRIPTION -The pseudo-tty subsystem simulates a terminal connection, where the master side -represents the terminal and the slave represents the user process's special -device end point. In order to use the pseudo-tty subsystem, a node for the -master side driver \fB/dev/ptmx\fR and N nodes for the slave driver (N is -determined at installation time) must be installed. The names of the slave -devices are \fB/dev/pts/M\fR where \fBM\fR has the values 0 through N-1. When -the master device is opened, the corresponding slave device is automatically -locked out. No user may open that slave device until its permissions are -adjusted and the device unlocked by calling functions \fBgrantpt\fR(3C) and -\fBunlockpt\fR(3C). The user can then invoke the open system call with the name -that is returned by the \fBptsname\fR(3C) function. See the example below. -.sp -.LP -Only one open is allowed on a master device. Multiple opens are allowed on the -slave device. After both the master and slave have been opened, the user has -two file descriptors which are end points of a full duplex connection composed -of two streams automatically connected at the master and slave drivers. The -user may then push modules onto either side of the stream pair. Unless compiled -in XPG4v2 mode (see below), the consumer needs to push the \fBptem\fR(7M) and -\fBldterm\fR(7M) modules onto the slave side of the pseudo-terminal subsystem -to get terminal semantics. -.sp -.LP -The master and slave drivers pass all messages to their adjacent queues. Only -the \fBM_FLUSH\fR needs some processing. Because the read queue of one side is -connected to the write queue of the other, the \fBFLUSHR\fR flag is changed to -the \fBFLUSHW\fR flag and vice versa. When the master device is closed an -\fBM_HANGUP\fR message is sent to the slave device which will render the device -unusable. The process on the slave side gets the errno \fBEIO\fR when -attempting to write on that stream but it will be able to read any data -remaining on the stream head read queue. When all the data has been read, read -returns 0 indicating that the stream can no longer be used. On the last close -of the slave device, a 0-length message is sent to the master device. When the -application on the master side issues a \fBread()\fR or \fBgetmsg()\fR and 0 is -returned, the user of the master device decides whether to issue a -\fBclose()\fR that dismantles the pseudo-terminal subsystem. If the master -device is not closed, the pseudo-tty subsystem will be available to another -user to open the slave device. Since 0-length messages are used to indicate -that the process on the slave side has closed and should be interpreted that -way by the process on the master side, applications on the slave side should -not write 0-length messages. Unless the application is compiled in XPG4v2 mode -(see below) then any 0-length messages written on the slave side will be -discarded by the \fBptem\fR module. -.sp -.LP -The standard STREAMS system calls can access the pseudo-tty devices. The slave -devices support the \fBO_NDELAY\fR and \fBO_NONBLOCK\fR flags. -.SH XPG4v2 MODE -XPG4v2 requires that open of a slave pseudo terminal device provides the -process with an interface that is identical to the terminal interface (without -having to explicitly push any modules to achieve this). It also requires that -0-length messages written on the slave side will be propagated to the master. -.sp -Experience has shown, however, that most software does not expect slave pty -devices to operate in this manner and therefore this XPG4v2-compliant -behaviour is only enabled in XPG4v2/SUS (see \fBstandards\fR(5)) mode. -.SH EXAMPLES -.in +2 -.nf -int fdm fds; -char *slavename; -extern char *ptsname(); - -fdm = open("/dev/ptmx", O_RDWR); /* open master */ -grantpt(fdm); /* change permission of slave */ -unlockpt(fdm); /* unlock slave */ -slavename = ptsname(fdm); /* get name of slave */ -fds = open(slavename, O_RDWR); /* open slave */ -ioctl(fds, I_PUSH, "ptem"); /* push ptem */ -ioctl(fds, I_PUSH, "ldterm"); /* push ldterm*/ -.fi -.in -2 - -.SH FILES -.ne 2 -.na -\fB\fB/dev/ptmx\fR\fR -.ad -.RS 14n -master clone device -.RE - -.sp -.ne 2 -.na -\fB\fB/dev/pts/M\fR\fR -.ad -.RS 14n -slave devices (M = 0 -> N-1) -.RE - -.SH SEE ALSO -\fBgrantpt\fR(3C), \fBptsname\fR(3C), \fBunlockpt\fR(3C), \fBldterm\fR(7M), -\fBptm\fR(7D), \fBptem\fR(7M), \fBstandards\fR(5) -.sp -.LP -\fISTREAMS Programming Guide\fR diff --git a/usr/src/man/man7d/pty.7d b/usr/src/man/man7d/pty.7d index e2f85c3224..8e14dd3ea2 100644 --- a/usr/src/man/man7d/pty.7d +++ b/usr/src/man/man7d/pty.7d @@ -3,244 +3,263 @@ .\" 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] -.TH PTY 7D "Aug 8, 1994" -.SH NAME -pty \- pseudo-terminal driver -.SH DESCRIPTION -.sp -.LP -The \fBpty\fR driver provides support for a pair of devices collectively known -as a \fIpseudo-terminal\fR. The two devices comprising a pseudo-terminal are -known as a \fIcontroller\fR and a \fIslave\fR. The slave device distinguishes -between the \fBB0\fR baud rate and other baud rates specified in the -\fBc_cflag\fR word of the \fBtermios\fR structure, and the \fBCLOCAL\fR flag in -that word. It does not support any of the other \fBtermio\fR(7I) device control -functions specified by flags in the \fBc_cflag\fR word of the \fBtermios\fR -structure and by the \fB\fR\fBIGNBRK\fR\fB, \fR \fB\fR\fBIGNPAR\fR\fB, \fR -\fB\fR\fBPARMRK\fR\fB, \fR or \fBINPCK\fR flags in the \fBc_iflag\fR word of -the \fBtermios\fR structure, as these functions apply only to asynchronous -serial ports. All other \fBtermio\fR(7I) functions must be performed by -\fBSTREAMS\fR modules pushed atop the driver; when a slave device is opened, -the \fBldterm\fR(7M) and \fBttcompat\fR(7M) \fBSTREAMS\fR modules are -automatically pushed on top of the stream, providing the standard -\fBtermio\fR(7I) interface. -.sp -.LP +.\" Copyright 2022 Oxide Computer Company +.Dd February 5, 2022 +.Dt PTY 7D +.Os +.Sh NAME +.Nm pty +.Nd legacy pseudo-terminal driver +.Sh SYNOPSIS +.Pa /dev/pty[p-r]* +.Pp +.Pa /dev/tty[p-r]* +.Sh DESCRIPTION +This driver provides support for legacy static pseudo-terminal devices. +Modern software does not use this driver, preferring instead the STREAMS-based +.Xr ptm 7D +and +.Xr pts 7D +pseudo-terminal drivers, consumed through the portable +.Xr posix_openpt 3C +interface. +.Pp +The +.Nm pty +driver provides support for a pair of devices collectively known +as a +.Em pseudo-terminal . +The two devices comprising a pseudo-terminal are known as a +.Em manager +and a +.Em subsidiary . +The subsidiary device distinguishes between the +.Dv B0 baud rate and other baud rates specified in +the +.Fa c_cflag +field of the +.Vt termios +structure, and the +.Dv CLOCAL +flag in that member. +It does not support any of the other +.Xr termio 7I +device control functions specified by flags in the +.Fa c_cflag +field of the +.Vt termios +structure and by the +.Dv IGNBRK , +.Dv IGNPAR , +.Dv PARMRK , +or +.Dv INPCK +flags in the +.Fa c_iflag +field of the +.Vt termios +structure, as these functions apply only to asynchronous serial ports. +All other +.Xr termio 7I +functions must be performed by STREAMS modules pushed atop the driver; when a +subsidiary device is opened, the +.Xr ldterm 7M +and +.Xr ttcompat 7M +STREAMS modules are automatically pushed on top of the stream, providing the +standard +.Xr termio 7I +interface. +.Pp Instead of having a hardware interface and associated hardware that supports the terminal functions, the functions are implemented by another process -manipulating the controller device of the pseudo-terminal. -.sp -.LP -The controller and the slave devices of the pseudo-terminal are tightly -connected. Any data written on the controller device is given to the slave -device as input, as though it had been received from a hardware interface. Any -data written on the slave terminal can be read from the controller device -(rather than being transmitted from a \fBUAR\fR). -.sp -.LP -By default, 48 pseudo-terminal pairs are configured as follows: -.sp -.in +2 -.nf -/dev/pty[p-r][0-9a-f] controller devices -/dev/tty[p-r][0-9a-f] slave devices -.fi -.in -2 - -.SH IOCTLS -.sp -.LP -The standard set of \fBtermio ioctl\fRs are supported by the slave device. -None of the bits in the \fBc_cflag\fR word have any effect on the -pseudo-terminal, except that if the baud rate is set to \fBB0\fR, it will -appear to the process on the controller device as if the last process on the -slave device had closed the line; thus, setting the baud rate to \fBB0\fR has -the effect of ``hanging up'' the pseudo-terminal, just as it has the effect of -``hanging up'' a real terminal. -.sp -.LP -There is no notion of ``parity'' on a pseudo-terminal, so none of the flags in -the \fBc_iflag\fR word that control the processing of parity errors have any -effect. Similarly, there is no notion of a ``break'', so none of the flags that -control the processing of breaks, and none of the \fBioctl\fRs that generate -breaks, have any effect. -.sp -.LP +manipulating the manager device of the pseudo-terminal. +.Pp +The manager and the subsidiary devices of the pseudo-terminal are tightly +connected. +Any data written on the manager device is given to the subsidiary device as +input, as though it had been received from a hardware interface. +Any data written on the subsidiary terminal can be read from the manager device +.Pq "rather than being transmitted from a UAR" . +.Pp +The driver is statically configured to provide 48 pseudo-terminal pairs. +Software that requires dynamic pseudo-terminal devices, or a greater number +of devices, must be converted to use +.Xr ptm 7D . +.Sh IOCTLS +The standard set of +.Xr termio 7I +ioctls are supported by the subsidiary device. +None of the bits in the +.Fa c_cflag +field have any effect on the pseudo-terminal, except that if the baud rate is +set to +.Dv B0 , +it will appear to the process on the manager device as if the last process on +the subsidiary device had closed the line; thus, setting the baud rate to +.Dv B0 +has the effect of +.Dq hanging up +the pseudo-terminal, just as it has the effect of +.Dq hanging up +a real terminal. +.Pp +There is no notion of +.Dq parity +on a pseudo-terminal, so none of the flags in the +.Fa c_iflag +field that control the processing of parity errors have any +effect. +Similarly, there is no notion of a +.Fa break , +so none of the flags that control the processing of breaks, and none of the +ioctls that generate breaks, have any effect. +.Pp Input flow control is automatically performed; a process that attempts to write -to the controller device will be blocked if too much unconsumed data is -buffered on the slave device. The input flow control provided by the -\fBIXOFF\fR flag in the \fBc_iflag\fR word is not supported. -.sp -.LP -The delays specified in the \fBc_oflag\fR word are not supported. -.sp -.LP -As there are no modems involved in a pseudo-terminal, the \fBioctl\fRs that -return or alter the state of modem control lines are silently ignored. -.sp -.LP -A few special \fBioctl\fRs are provided on the controller devices of -pseudo-terminals to provide the functionality needed by applications programs -to emulate real hardware interfaces: -.sp -.ne 2 -.na -\fB\fBTIOCSTOP\fR\fR -.ad -.RS 14n -The argument is ignored. Output to the pseudo-terminal is suspended, as if a -\fBSTOP\fR character had been typed. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCSTART\fR\fR -.ad -.RS 14n -The argument is ignored. Output to the pseudo-terminal is restarted, as if a -\fBSTART\fR character had been typed. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCPKT\fR\fR -.ad -.RS 14n -The argument is a pointer to an \fBint\fR. If the value of the \fBint\fR is -non-zero, \fIpacket\fR mode is enabled; if the value of the \fBint\fR is zero, -packet mode is disabled. When a pseudo-terminal is in packet mode, each -subsequent \fBread\fR(2) from the controller device will return data written on -the slave device preceded by a zero byte (symbolically defined as -\fB\fR\fBTIOCPKT_DATA\fR\fB), \fR or a single byte reflecting control status -information. In the latter case, the byte is an inclusive-or of zero or more -of the bits: -.sp -.ne 2 -.na -\fB\fBTIOCPKT_FLUSHREAD\fR\fR -.ad -.RS 22n -whenever the read queue for the terminal is flushed. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCPKT_FLUSHWRITE\fR\fR -.ad -.RS 22n -whenever the write queue for the terminal is flushed. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCPKT_STOP\fR\fR -.ad -.RS 22n -whenever output to the terminal is stopped using ^S. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCPKT_START\fR\fR -.ad -.RS 22n -whenever output to the terminal is restarted. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCPKT_DOSTOP\fR\fR -.ad -.RS 22n -whenever \fBXON/XOFF\fR flow control is enabled after being disabled; it is -considered ``enabled'' when the \fBIXON\fR flag in the \fBc_iflag\fR word is -set, the \fBVSTOP\fR member of the \fBc_cc\fR array is ^S and the \fBVSTART\fR -member of the \fBc_cc\fR array is ^Q. -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCPKT_NOSTOP\fR\fR -.ad -.RS 22n -whenever \fBXON/XOFF\fR flow control is disabled after being enabled. -.RE - -.RE - -.sp -.ne 2 -.na -\fB\fBTIOCREMOTE\fR\fR -.ad -.RS 14n -The argument is a pointer to an \fBint\fR. If the value of the \fBint\fR is -non-zero, \fIremote\fR mode is enabled; if the value of the \fBint\fR is zero, -remote mode is disabled. This mode can be enabled or disabled independently of -packet mode. When a pseudo-terminal is in remote mode, input to the slave -device of the pseudo-terminal is flow controlled and not input edited -(regardless of the mode the slave side of the pseudo-terminal). Each write to -the controller device produces a record boundary for the process reading the -slave device. In normal usage, a write of data is like the data typed as a -line on the terminal; a write of 0 bytes is like typing an \fBEOF\fR character. -Note: this means that a process writing to a pseudo-terminal controller in -\fIremote\fR mode must keep track of line boundaries, and write only one line -at a time to the controller. If, for example, it were to buffer up several -\fBNEWLINE\fR characters and write them to the controller with one -\fBwrite()\fR, it would appear to a process reading from the slave as if a -single line containing several \fBNEWLINE\fR characters had been typed (as if, -for example, a user had typed the \fBLNEXT\fR character before typing all but -the last of those \fBNEWLINE\fR characters). Remote mode can be used when doing -remote line editing in a window manager, or whenever flow controlled input is -required. -.RE - -.SH EXAMPLES -.sp -.in +2 -.nf -#include <fcntl.h> -#include <sys/termios.h> - -int fdm fds; -fdm = open("/dev/ptyp0, O_RDWR); /* open master */ -fds = open("/dev/ttyp0, O_RDWR); /* open slave */ -.fi -.in -2 - -.SH FILES -.sp -.ne 2 -.na -\fB\fB/dev/pty[p-z][0-9a-f]\fR\fR -.ad -.RS 25n -pseudo-terminal controller devices -.RE - -.sp -.ne 2 -.na -\fB\fB/dev/tty[p-z][0-9a-f]\fR\fR -.ad -.RS 25n -pseudo-terminal slave devices -.RE - -.SH SEE ALSO -.sp -.LP -\fBrlogin\fR(1), \fBrlogind\fR(1M), \fBldterm\fR(7M), \fBtermio\fR(7I), -\fBttcompat\fR(7M), -.SH NOTES -.sp -.LP -It is apparently not possible to send an \fBEOT\fR by writing zero bytes in -\fBTIOCREMOTE\fR mode. +to the manager device will be blocked if too much unconsumed data is buffered +on the subsidiary device. +The input flow control provided by the +.Dv IXOFF +flag in the +.Fa c_iflag +field is not supported. +.Pp +The delays specified in the +.Fa c_oflag +field are not supported. +.Pp +As there are no modems involved in a pseudo-terminal, the ioctls that return or +alter the state of modem control lines are silently ignored. +.Pp +A few special ioctls are provided on the manager devices of pseudo-terminals to +provide the functionality needed by applications programs to emulate real +hardware interfaces: +.Bl -tag -width Ds +.It Dv TIOCSTOP +The argument is ignored. +Output to the pseudo-terminal is suspended, as if a +.Sy STOP +character had been typed. +.It Dv TIOCSTART +The argument is ignored. +Output to the pseudo-terminal is restarted, as if a +.Sy START +character had been typed. +.It Dv TIOCPKT +The argument is a pointer to an +.Vt int . +If the value of the +.Vt int +is non-zero, +.Em packet +mode is enabled; if the value of the +.Vt int +is zero, packet mode is disabled. +When a pseudo-terminal is in packet mode, each subsequent +.Xr read 2 +from the manager device will return data written on the subsidiary device +preceded by a zero byte +.Po +symbolically defined as +.Dv TIOCPKT_DATA +.Pc , +or a single byte reflecting control status information. +In the latter case, the byte is an inclusive-or of zero or more of the bits: +.Bl -tag -width Ds +.It Dv TIOCPKT_FLUSHREAD +Whenever the read queue for the terminal is flushed. +.It Dv TIOCPKT_FLUSHWRITE +Whenever the write queue for the terminal is flushed. +.It Dv TIOCPKT_STOP +Whenever output to the terminal is stopped using +.Sy ^S . +.It Dv TIOCPKT_START +Whenever output to the terminal is restarted. +.It Dv TIOCPKT_DOSTOP +Whenever +.Em XON/XOFF +flow control is enabled after being disabled; it is +considered +.Dq enabled +when the +.Dv IXON +flag in the +.Fa c_iflag +field is set, the +.Dv VSTOP +member of the +.Fa c_cc +array is +.Sy ^S +and the +.Dv VSTART +member of the +.Fa c_cc +array is +.Sy ^Q. +.It Dv TIOCPKT_NOSTOP +Whenever +.Em XON/XOFF +flow control is disabled after being enabled. +.El +.It Dv TIOCREMOTE +The argument is a pointer to an +.Vt int . +If the value of the +.Vt int +is non-zero, +.Em remote +mode is enabled; if the value of the +.Vt int +is zero, remote mode is disabled. +This mode can be enabled or disabled independently of packet mode. +When a pseudo-terminal is in remote mode, input to the subsidiary device of the +pseudo-terminal is flow controlled and not input edited (regardless of the mode +the subsidiary side of the pseudo-terminal). +.Pp +Each write to the manager device produces a record boundary for the process +reading the subsidiary device. +In normal usage, a write of data is like the data typed as a line on the +terminal; a write of 0 bytes is like typing an +.Sy EOF +character. +Note: this means that a process writing to a pseudo-terminal manager in remote +mode must keep track of line boundaries, and write only one line at a time to +the manager. +.Pp +If, for example, it were to buffer up several newline characters and write them +to the manager with one +.Xr write 2 , +it would appear to a process reading from the subsidiary as if a single line +containing several newline characters had been typed +.Po +as if, for example, a user had typed the literal next +.Pq Sy LNEXT +character before typing all but the last of those newline characters +.Pc . +Remote mode can be used when doing remote line editing in a window manager, or +whenever flow controlled input is required. +.El +.Sh FILES +.Bl -tag -width Pa +.It Pa /dev/pty[p-r][0-9a-f] +Pseudo-terminal manager devices. +.It Pa /dev/tty[p-r][0-9a-f] +Pseudo-terminal subsidiary devices. +.El +.Sh SEE ALSO +.Xr rlogin 1 , +.Xr rlogind 1M , +.Xr posix_openpty 3C , +.Xr ptm 7D , +.Xr termio 7I , +.Xr ldterm 7M , +.Xr ttcompat 7M +.Sh NOTES +This is a legacy device and should not be used by new software. +.Pp +It is apparently not possible to send an +.Sy EOT +by writing zero bytes in +.Dv TIOCREMOTE +mode. diff --git a/usr/src/man/man7d/zcons.7d b/usr/src/man/man7d/zcons.7d index 433daddbcf..07df6b458e 100644 --- a/usr/src/man/man7d/zcons.7d +++ b/usr/src/man/man7d/zcons.7d @@ -3,73 +3,62 @@ .\" 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] -.TH ZCONS 7D "Aug 24, 2003" -.SH NAME -zcons \- Zone console device driver -.SH DESCRIPTION -.sp -.LP -The \fBzcons\fR character driver exports the console for system zones. The -driver is comprised of two "sides:" a master side with which applications in -the global zone communicate, and a slave side, which receives I/O from the -master side. The slave side is available in the global zones. -.sp -.LP -Applications must not depend on the location of \fB/dev\fR or \fB/devices\fR -entries exported by \fBzcons\fR. Inside a zone, the \fBzcons\fR slave side is -fronted by \fB/dev/console\fR and other console-related symbolic links, which -are used by applications that expect to write to the system console. -.sp -.LP -The \fBzcons\fR driver is Sun Private, and may change in future releases. -.SH FILES -.sp -.ne 2 -.na -\fB\fB/dev/zcons/<\fIzonename\fR>/masterconsole\fR \fR -.ad -.sp .6 -.RS 4n -Global zone master side console for zone <\fIzonename\fR>. -.RE - -.sp -.ne 2 -.na -\fB\fB/dev/zcons/<\fIzonename\fR>/slaveconsole\fR \fR -.ad -.sp .6 -.RS 4n -Global zone slave side console for zone <\fIzonename\fR>. -.RE - -.sp -.ne 2 -.na -\fB\fB/dev/zconsole\fR \fR -.ad -.sp .6 -.RS 4n -Non-global zone console (slave side). -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ - Interface Stability Sun Private -.TE - -.SH SEE ALSO -.sp -.LP -\fBzoneadm\fR(1M), \fBzonecfg\fR(1M), \fBattributes\fR(5), \fBzones\fR(5) +.\" Copyright 2022 Oxide Computer Company +.Dd February 5, 2022 +.Dt ZCONS 7D +.Os +.Sh NAME +.Nm zcons +.Nd Zone console device driver +.Sh DESCRIPTION +The +.Nm zcons +character driver exports the console for system zones. +The driver is fundamentally similar to a pseudo-terminal device, and is thus +comprised of two sides: +.Bl -bullet +.It +a manager device, which applications in the global zone can open for +communication +.It +a subsidiary device, which processes in the non-global zone can write to, to +communicate with global zone management applications +.El +.Pp +Applications must not depend on the location of +.Pa /dev +or +.Pa /devices +entries exposed by +.Nm zcons +in the global zone. +Inside a non-global zone, the +.Nm zcons +subsidiary device is fronted by +.Pa /dev/console +and other console-related symbolic links, which are used by applications that +expect to write to the system console. +.Pp +The +.Nm +driver is not a +.Sy Committed +interface, and may change at any time. +.Sh FILES +.Bl -tag -width Pa +.It Pa /dev/zcons/ZONENAME/globalconsole +Global zone console manager device for zone +.Sy ZONENAME . +.It Pa /dev/zcons/ZONENAME/zoneconsole +Global zone console subsidiary device for zone +.Sy ZONENAME . +.It Pa /dev/zconsole +Non-global zone console (subsidiary device). +.El +.Sh INTERFACE STABILITY +.Sy Uncommitted +.Sh SEE ALSO +.Xr zoneadm 1M , +.Xr zonecfg 1M , +.Xr attributes 5 , +.Xr zones 5 diff --git a/usr/src/man/man7m/pckt.7m b/usr/src/man/man7m/pckt.7m index 9cb6149cd5..909e1e0367 100644 --- a/usr/src/man/man7m/pckt.7m +++ b/usr/src/man/man7m/pckt.7m @@ -3,21 +3,18 @@ .\" 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] -.TH PCKT 7M "Jul 3, 1990" +.TH PCKT 7M "Feb 5, 2022" .SH NAME pckt \- STREAMS Packet Mode module .SH SYNOPSIS -.LP .nf int ioctl(\fI fd, \fRI_PUSH, "pckt"); .fi .SH DESCRIPTION -.sp -.LP \fBpckt\fR is a STREAMS module that may be used with a pseudo terminal to packetize certain messages. The \fBpckt\fR module should be pushed (see -\fBI_PUSH\fR on \fBstreamio\fR(7I)) onto the master side of a pseudo terminal. +\fBI_PUSH\fR on \fBstreamio\fR(7I)) onto the manager side of a pseudo terminal. .sp .LP Packetizing is performed by prefixing a message with an \fBM_PROTO\fR message. @@ -31,21 +28,19 @@ On the read-side, only the \fBM_PROTO\fR, \fBM_PCPROTO\fR, \fBM_STOP\fR, types are passed upstream unmodified. .sp .LP -Since all unread state information is held in the master's stream head read +Since all unread state information is held in the manager's stream head read queue, flushing of this queue is disabled. .sp .LP On the write-side, all messages are sent down unmodified. .sp .LP -With this module in place, all reads from the master side of the pseudo +With this module in place, all reads from the manager side of the pseudo terminal should be performed with the \fBgetmsg\fR(2) or \fBgetpmsg\fR() function. The control part of the message contains the message type. The data part contains the actual data associated with that message type. The onus is on the application to separate the data into its component parts. .SH SEE ALSO -.sp -.LP \fBgetmsg\fR(2), \fBioctl\fR(2), \fBldterm\fR(7M), \fBptem\fR(7M), \fBstreamio\fR(7I), \fBtermio\fR(7I) .sp diff --git a/usr/src/man/man7m/ptem.7m b/usr/src/man/man7m/ptem.7m index aefea791d6..0a5354b222 100644 --- a/usr/src/man/man7m/ptem.7m +++ b/usr/src/man/man7m/ptem.7m @@ -4,65 +4,127 @@ .\" 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] -.TH PTEM 7M "Jul 3, 1990" -.SH NAME -ptem \- STREAMS Pseudo Terminal Emulation module -.SH SYNOPSIS -.LP -.nf -\fBint ioctl(\fR\fIfd\fR, \fBI_PUSH\fR,\fB "ptem");\fR -.fi - -.SH DESCRIPTION -.sp -.LP -\fBptem\fR is a STREAMS module that, when used in conjunction with a line -discipline and pseudo terminal driver, emulates a terminal. -.sp -.LP -The \fBptem\fR module must be pushed (see \fBI_PUSH\fR, \fBstreamio\fR(7I)) -onto the slave side of a pseudo terminal STREAM, before the \fBldterm\fR(7M) +.\" Copyright 2022 Oxide Computer Company +.Dd February 5, 2022 +.Dt PTEM 7M +.Os +.Sh NAME +.Nm ptem +.Nd STREAMS Pseudo-Terminal Emulation module +.Sh SYNOPSIS +.In unistd.h +.In stropts.h +.Ft int +.Fo ioctl +.Fa "int fildes" , +.Dv I_PUSH , +.Qq ptem +.Fc +.Sh DESCRIPTION +.Nm ptem +is a STREAMS module that emulates a terminal device when used in conjunction +with the line discipline, +.Xr ldterm 7M , +and the pseudo terminal driver, +.Xr ptm 7D . +.Pp +The +.Nm ptem +module must be pushed +.Po +see +.Dv I_PUSH +in +.Xr streamio 7I +.Pc +onto the subsidiary device of a pseudo-terminal STREAM, before the +.Xr ldterm 7M module is pushed. -.sp -.LP -On the write-side, the \fBTCSETA\fR, \fBTCSETAF\fR, \fBTCSETAW\fR, -\fBTCGETA\fR, \fBTCSETS\fR, \fBTCSETSW\fR, \fBTCSETSF\fR, \fBTCGETS\fR, -\fBTCSBRK\fR, \fBJWINSIZE\fR, \fBTIOCGWINSZ\fR, and \fBTIOCSWINSZ\fR -\fBtermio\fR \fBioctl\fR(2) messages are processed and acknowledged. If remote -mode is not in effect, \fBptem\fR handles the \fBTIOCSTI\fR ioctl by copying -the argument bytes into an \fBM_DATA\fR message and passing it back up the -read side. Regardless of the remote mode setting, \fBptem\fR acknowledges the -ioctl and passes a copy of it downstream for possible further processing. A -hang up (that is, \fBstty 0\fR) is converted to a zero length \fBM_DATA\fR -message and passed downstream. Termio \fBcflags\fR and window row and column -information are stored locally one per stream. \fBM_DELAY\fR messages are -discarded. All other messages are passed downstream unmodified. -.sp -.LP -On the read-side all messages are passed upstream unmodified with the following -exceptions. All \fBM_READ\fR and \fBM_DELAY\fR messages are freed in both -directions. A \fBTCSBRK\fR ioctl is converted to an \fBM_BREAK\fR message and -passed upstream and an acknowledgement is returned downstream. A -\fBTIOCSIGNAL\fR ioctl is converted into an \fBM_PCSIG\fR message, and passed -upstream and an acknowledgement is returned downstream. Finally a -\fBTIOCREMOTE\fR ioctl is converted into an \fBM_CTL\fR message, acknowledged, -and passed upstream; the resulting mode is retained for use in subsequent -\fBTIOCSTI\fR parsing. -.SH FILES -.sp -.ne 2 -.na -\fB<\fBsys/ptem.h\fR> \fR -.ad -.RS 17n - -.RE - -.SH SEE ALSO -.sp -.LP -\fBstty\fR(1), \fBioctl\fR(2), \fBldterm\fR(7M), \fBpckt\fR(7M), -\fBstreamio\fR(7I), \fBtermio\fR(7I) -.sp -.LP -\fISTREAMS Programming Guide\fR +.Ss Write-side Behaviour +The +.Dv TCSETA , +.Dv TCSETAF , +.Dv TCSETAW , +.Dv TCGETA , +.Dv TCSETS , +.Dv TCSETSW , +.Dv TCSETSF , +.Dv TCGETS , +.Dv TCSBRK , +.Dv JWINSIZE , +.Dv TIOCGWINSZ , +and +.Dv TIOCSWINSZ +.Xr termio 7I +.Xr ioctl 2 +messages are processed and acknowledged. +.Pp +If +.Em remote mode +is not in effect, +.Nm ptem +handles the +.Dv TIOCSTI +ioctl by copying the argument bytes into an +.Dv M_DATA +message and passing it back up the read side. +Regardless of the +.Em remote mode +setting, +.Nm ptem +acknowledges the ioctl and passes a copy of it downstream for possible further +processing. +.Pp +A hang up +.Po +e.g., +.Ic stty 0 +.Pc +is converted to a zero length +.Dv M_DATA +message and passed downstream. +.Xr termio 7I +.Sy cflags +and window row and column information are stored locally, one per stream. +.Dv M_DELAY +messages are discarded. +.Pp +All other messages are passed downstream unmodified. +.Ss Read-side Behaviour +All messages are passed upstream unmodified with the following exceptions: +.Bl -bullet +.It +All +.Dv M_READ +and +.Dv M_DELAY +messages are freed in both directions. +.It +A +.Dv TCSBRK +ioctl is converted to an +.Dv M_BREAK +message and passed upstream and an acknowledgement is returned downstream. +.It +A +.Dv TIOCSIGNAL +ioctl is converted into an +.Dv M_PCSIG +message, passed upstream, and an acknowledgement is returned downstream. +.It +A +.Dv TIOCREMOTE +ioctl is converted into an +.Dv M_CTL +message, acknowledged, and passed upstream; the resulting mode is retained for +use in subsequent +.Dv TIOCSTI +parsing. +.El +.Sh SEE ALSO +.Xr stty 1 , +.Xr ioctl 2 , +.Xr streamio 7I , +.Xr termio 7I , +.Xr ldterm 7M , +.Xr pckt 7M diff --git a/usr/src/man/man7p/Makefile b/usr/src/man/man7p/Makefile index f73a157f47..9186b1ac20 100644 --- a/usr/src/man/man7p/Makefile +++ b/usr/src/man/man7p/Makefile @@ -16,30 +16,30 @@ include $(SRC)/Makefile.master -MANSECT= 7p - -MANFILES= arp.7p \ - dlpi.7p \ - icmp.7p \ - icmp6.7p \ - if_tcp.7p \ - inet.7p \ - inet6.7p \ - ip.7p \ - ip6.7p \ - ipsec.7p \ - ipsecah.7p \ - ipsecesp.7p \ - ndp.7p \ - pf_key.7p \ - rarp.7p \ - route.7p \ - routing.7p \ - sctp.7p \ - sip.7p \ - slp.7p \ - tcp.7p \ - udp.7p \ +MANSECT= 7p + +MANFILES= arp.7p \ + dlpi.7p \ + icmp.7p \ + icmp6.7p \ + if_tcp.7p \ + inet.7p \ + inet6.7p \ + ip.7p \ + ip6.7p \ + ipsec.7p \ + ipsecah.7p \ + ipsecesp.7p \ + ndp.7p \ + pf_key.7p \ + rarp.7p \ + route.7p \ + routing.7p \ + sctp.7p \ + sip.7p \ + slp.7p \ + tcp.7p \ + udp.7p \ vxlan.7p MANLINKS= AH.7p \ @@ -53,7 +53,7 @@ MANLINKS= AH.7p \ TCP.7p \ UDP.7p \ VXLAN.7p \ - if.7p + if.7p ARP.7p := LINKSRC = arp.7p @@ -69,9 +69,9 @@ ESP.7p := LINKSRC = ipsecesp.7p NDP.7p := LINKSRC = ndp.7p -RARP.7p := LINKSRC = rarp.7p +RARP.7p := LINKSRC = rarp.7p -SCTP.7p := LINKSRC = sctp.7p +SCTP.7p := LINKSRC = sctp.7p TCP.7p := LINKSRC = tcp.7p diff --git a/usr/src/man/man9f/kmem_alloc.9f b/usr/src/man/man9f/kmem_alloc.9f index 56c4fb6a2d..5a53bd2451 100644 --- a/usr/src/man/man9f/kmem_alloc.9f +++ b/usr/src/man/man9f/kmem_alloc.9f @@ -1,5 +1,6 @@ '\" te .\" Copyright 2014 Nexenta Systems, Inc. All rights reserved. +.\" Copyright 2022 Joyent, Inc. .\" Copyright 1989 AT&T .\" Copyright (c) 2006, 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. @@ -46,8 +47,14 @@ Number of bytes to allocate. .ad .RS 8n Determines whether caller can sleep for memory. Possible flags are -\fBKM_SLEEP\fR to allow sleeping until memory is available, or \fBKM_NOSLEEP\fR -to return \fINULL\fR immediately if memory is not available. +\fBKM_SLEEP\fR to allow sleeping until memory is available, \fBKM_NOSLEEP\fR +to return \fINULL\fR if memory is not available even after some reclamation +attempts, and \fBKM_NOSLEEP_LAZY\fR to return \fINULL\fR without reclamation +attempts. \fBKM_NOSLEEP_LAZY\fR is actually two flags combined: +(\fBKM_NOSLEEP\fR | \fBKM_NORMALPRI\fR), the latter flag indicating not to +attempt reclamation before giving up and returning NULL. If any mention of +\fBKM_NOSLEEP\fR appears in this man page by itself, it applies equally to +\fBKM_NOSLEEP_LAZY\fR as well. .RE .sp @@ -65,9 +72,12 @@ returns a pointer to the allocated memory. The allocated memory is at least double-word aligned, so it can hold any C data structure. No greater alignment can be assumed. \fIflag\fR determines whether the caller can sleep for memory. \fBKM_SLEEP\fR allocations may sleep but are guaranteed to succeed. -\fBKM_NOSLEEP\fR allocations are guaranteed not to sleep but may fail (return -\fINULL\fR) if no memory is currently available. The initial contents of memory -allocated using \fBkmem_alloc()\fR are random garbage. +\fBKM_NOSLEEP\fR and \fBKM_NOSLEEP_LAZY\fR allocations are guaranteed not to +sleep but may fail (return \fINULL\fR) if no memory is currently +available. \fBKM_NOSLEEP\fR will first attempt to aggressively reclaim memory +from otherwise unused blocks, while \fBKM_NOSLEEP_LAZY\fR will not attempt any +reclamation. The initial contents of memory allocated using +\fBkmem_alloc()\fR are random garbage. .sp .LP The \fBkmem_zalloc()\fR function is like \fBkmem_alloc()\fR but returns @@ -79,13 +89,14 @@ buffer address and size must exactly match the original allocation. Memory cannot be returned piecemeal. .SH RETURN VALUES If successful, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return a pointer to -the allocated memory. If \fBKM_NOSLEEP\fR is set and memory cannot be allocated -without sleeping, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return \fINULL\fR. +the allocated memory. If \fBKM_NOSLEEP\fR is set and memory cannot be +allocated without sleeping, \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR return +\fINULL\fR. .SH CONTEXT The \fBkmem_alloc()\fR and \fBkmem_zalloc()\fR functions can be called from -interrupt context only if the \fBKM_NOSLEEP\fR flag is set. They can be called -from user context with any valid \fIflag\fR. The \fBkmem_free()\fR function can -be called from from user, interrupt, or kernel context. +interrupt context only if the \fBKM_NOSLEEP\fR flag is set. They can be +called from user context with any valid \fIflag\fR. The \fBkmem_free()\fR +function can be called from from user, interrupt, or kernel context. .SH SEE ALSO \fBcopyout\fR(9F), \fBfreerbuf\fR(9F), \fBgetrbuf\fR(9F) .sp diff --git a/usr/src/man/man9f/kmem_cache_create.9f b/usr/src/man/man9f/kmem_cache_create.9f index 73e3b67570..e08f120244 100644 --- a/usr/src/man/man9f/kmem_cache_create.9f +++ b/usr/src/man/man9f/kmem_cache_create.9f @@ -1,5 +1,6 @@ '\" te .\" Copyright 2015 Nexenta Systems, Inc. All rights reserved. +.\" Copyright 2022 Joyent, Inc. .\" Copyright (c) 2002, 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. @@ -169,7 +170,21 @@ Allow sleeping (blocking) until memory is available. \fB\fBKM_NOSLEEP\fR\fR .ad .RS 15n -Return NULL immediately if memory is not available. +Return NULL immediately if memory is not available, but after an aggressive +reclaiming attempt. Any mention of \fBKM_NOSLEEP\fR without mentioning +\fBKM_NOSLEEP_LAZY\fR (see below) applies to both values. +.RE + +.sp +.ne 2 +.na +\fB\fBKM_NOSLEEP_LAZY\fR\fR +.ad +.RS 15n +Return NULL immediately if memory is not available, without the aggressive +reclaiming attempt. This is actually two flags combined: +(\fBKM_NOSLEEP\fR | \fBKM_NORMALPRI\fR), the latter flag indicating not to +attempt reclamation before giving up and returning NULL. .RE .sp @@ -350,8 +365,8 @@ object cache. .LP \fBkmem_cache_alloc()\fR gets an object from the cache. The object will be in its constructed state. \fIkmflag\fR has either \fBKM_SLEEP\fR or -\fBKM_NOSLEEP\fR set, indicating whether it is acceptable to wait for memory if -none is currently available. +\fBKM_NOSLEEP\fR set, indicating whether it is acceptable to wait for memory +if none is currently available. .sp .LP A small pool of reserved memory is available to allow the system to progress @@ -573,8 +588,8 @@ memory. .sp .LP \fBkmem_cache_alloc()\fR can be called from interrupt context only if the -\fBKM_NOSLEEP\fR flag is set. It can be called from user or kernel context with -any valid flag. +\fBKM_NOSLEEP\fR flag is set. It can be called from user or kernel context +with any valid flag. .sp .LP \fBkmem_cache_free()\fR can be called from user, kernel, or interrupt context. @@ -709,9 +724,11 @@ kmem_cache_set_move(object_cache, object_move); .in -2 .SH RETURN VALUES -If successful, the constructor function must return \fB0\fR. If KM_NOSLEEP is -set and memory cannot be allocated without sleeping, the constructor must -return -\fB1\fR. +If successful, the constructor function must return \fB0\fR. If +\fBKM_NOSLEEP\fR or \fBKM_NOSLEEP_LAZY\fR is set and memory cannot be +allocated without sleeping, the constructor must return -\fB1\fR. If the +constructor takes extraordinary steps during a \fBKM_NOSLEEP\fR construction, +it may not take those for a \fBKM_NOSLEEP_LAZY\fR construction. .sp .LP \fBkmem_cache_create()\fR returns a pointer to the allocated cache. diff --git a/usr/src/pkg/manifests/SUNWcs.man7d.inc b/usr/src/pkg/manifests/SUNWcs.man7d.inc index 66aec80ed4..901eb05c4e 100644 --- a/usr/src/pkg/manifests/SUNWcs.man7d.inc +++ b/usr/src/pkg/manifests/SUNWcs.man7d.inc @@ -14,4 +14,4 @@ file path=usr/share/man/man7d/kstat.7d file path=usr/share/man/man7d/ksyms.7d file path=usr/share/man/man7d/ptm.7d -file path=usr/share/man/man7d/pts.7d +link path=usr/share/man/man7d/pts.7d target=ptm.7d diff --git a/usr/src/pkg/manifests/system-network-overlay.p5m b/usr/src/pkg/manifests/system-network-overlay.p5m new file mode 100644 index 0000000000..8cdbd10775 --- /dev/null +++ b/usr/src/pkg/manifests/system-network-overlay.p5m @@ -0,0 +1,62 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. +# + +<include global_zone_only_component> +set name=pkg.fmri value=pkg:/system/network/overlay@$(PKGVERS) +set name=pkg.summary value="illumos overlay driver" +set name=pkg.description value="Device driver implementing network overlays" +set name=info.classification \ + value=org.opensolaris.category.2008:Drivers/Networking +set name=variant.arch value=$(ARCH) +dir path=kernel group=sys +dir path=kernel/drv group=sys +dir path=kernel/drv/$(ARCH64) group=sys +file path=kernel/drv/$(ARCH64)/overlay group=sys +file path=kernel/drv/overlay.conf group=sys +dir path=kernel/overlay +dir path=kernel/overlay/$(ARCH64) +file path=kernel/overlay/$(ARCH64)/vxlan group=sys mode=0755 +dir path=lib +file path=lib/$(ARCH64)/libvarpd.so.1 mode=0755 \ + variant.opensolaris.zone=__NODEFAULT +file path=lib/libvarpd.so.1 mode=0755 variant.opensolaris.zone=__NODEFAULT +dir path=lib/svc +dir path=lib/svc/manifest group=sys +dir path=lib/svc/manifest/network group=sys +file path=lib/svc/manifest/network/varpd.xml mode=0444 +dir path=usr/lib +dir path=usr/lib/$(ARCH64) +dir path=usr/lib/varpd +dir path=usr/lib/varpd/$(ARCH64) +link path=usr/lib/varpd/$(ARCH64)/libvarpd_direct.so target=libvarpd_direct.so.1 +file path=usr/lib/varpd/$(ARCH64)/libvarpd_direct.so.1 +link path=usr/lib/varpd/$(ARCH64)/libvarpd_files.so target=libvarpd_files.so.1 +file path=usr/lib/varpd/$(ARCH64)/libvarpd_files.so.1 +link path=usr/lib/varpd/64 target=$(ARCH64) +link path=usr/lib/varpd/libvarpd_direct.so target=libvarpd_direct.so.1 +file path=usr/lib/varpd/libvarpd_direct.so.1 +link path=usr/lib/varpd/libvarpd_files.so target=libvarpd_files.so.1 +file path=usr/lib/varpd/libvarpd_files.so.1 +file path=usr/lib/varpd/varpd mode=0555 +dir path=usr/share/man +dir path=usr/share/man/man4 +file path=usr/share/man/man4/overlay_files.4 +dir path=usr/share/man/man5 +file path=usr/share/man/man5/overlay.5 +dir path=usr/share/man/man7p +link path=usr/share/man/man7p/VXLAN.7p target=vxlan.7p +file usr/share/man/man7p/vxlan.7p path=usr/share/man/man7p/vxlan.7p mode=0444 +driver name=overlay +license lic_CDDL license=lic_CDDL diff --git a/usr/src/test/util-tests/tests/dladm/Makefile b/usr/src/test/util-tests/tests/dladm/Makefile index 2ce969fcc4..8bbc8e3841 100644 --- a/usr/src/test/util-tests/tests/dladm/Makefile +++ b/usr/src/test/util-tests/tests/dladm/Makefile @@ -25,8 +25,6 @@ all: install: $(ROOTPROG) -lint: - clobber: clean clean: diff --git a/usr/src/uts/Makefile.uts b/usr/src/uts/Makefile.uts index caa4c26197..ff1f86f846 100644 --- a/usr/src/uts/Makefile.uts +++ b/usr/src/uts/Makefile.uts @@ -581,7 +581,7 @@ PARALLEL_KMODS = $(DRV_KMODS) $(EXEC_KMODS) $(FS_KMODS) $(SCHED_KMODS) \ $(MMU_KMODS) $(DACF_KMODS) $(EXPORT_KMODS) $(IPP_KMODS) \ $(CRYPTO_KMODS) $(PCBE_KMODS) \ $(DRV_KMODS_$(CLASS)) $(MISC_KMODS_$(CLASS)) $(MAC_KMODS) \ - $(BRAND_KMODS) $(KICONV_KMODS) $(OVERLAY_KMODS) $(CC_KMODS) \ + $(BRAND_KMODS) $(KICONV_KMODS) $(CC_KMODS) $(OVERLAY_KMODS) \ $(SOCKET_KMODS) KMODS = $(GENUNIX_KMODS) $(PARALLEL_KMODS) diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c index b46e871ecc..67ce0c24fe 100644 --- a/usr/src/uts/common/dtrace/dtrace.c +++ b/usr/src/uts/common/dtrace/dtrace.c @@ -11618,8 +11618,8 @@ dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags, ASSERT(buf->dtb_xamot == NULL); - if ((buf->dtb_tomax = kmem_zalloc(size, - KM_NOSLEEP | KM_NORMALPRI)) == NULL) + if ((buf->dtb_tomax = kmem_zalloc(size, KM_NOSLEEP_LAZY)) == + NULL) goto err; buf->dtb_size = size; @@ -11630,8 +11630,8 @@ dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags, if (flags & DTRACEBUF_NOSWITCH) continue; - if ((buf->dtb_xamot = kmem_zalloc(size, - KM_NOSLEEP | KM_NORMALPRI)) == NULL) + if ((buf->dtb_xamot = kmem_zalloc(size, KM_NOSLEEP_LAZY)) == + NULL) goto err; } while ((cp = cp->cpu_next) != cpu_list); @@ -13579,7 +13579,7 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) if (size < (min = dstate->dtds_chunksize + sizeof (dtrace_dynhash_t))) size = min; - if ((base = kmem_zalloc(size, KM_NOSLEEP | KM_NORMALPRI)) == NULL) + if ((base = kmem_zalloc(size, KM_NOSLEEP_LAZY)) == NULL) return (ENOMEM); dstate->dtds_size = size; @@ -14106,7 +14106,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu) } spec = kmem_zalloc(nspec * sizeof (dtrace_speculation_t), - KM_NOSLEEP | KM_NORMALPRI); + KM_NOSLEEP_LAZY); if (spec == NULL) { rval = ENOMEM; @@ -14117,8 +14117,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu) state->dts_nspeculations = (int)nspec; for (i = 0; i < nspec; i++) { - if ((buf = kmem_zalloc(bufsize, - KM_NOSLEEP | KM_NORMALPRI)) == NULL) { + if ((buf = kmem_zalloc(bufsize, KM_NOSLEEP_LAZY)) == NULL) { rval = ENOMEM; goto err; } diff --git a/usr/src/uts/common/fs/bootfs/bootfs_vfsops.c b/usr/src/uts/common/fs/bootfs/bootfs_vfsops.c index e642e86169..5b3171e0d1 100644 --- a/usr/src/uts/common/fs/bootfs/bootfs_vfsops.c +++ b/usr/src/uts/common/fs/bootfs/bootfs_vfsops.c @@ -93,7 +93,7 @@ bootfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr) * there's nothing to be done about that. */ vfs_setresource(vfsp, bootfs_name, 0); - bfs = kmem_zalloc(sizeof (bootfs_t), KM_NOSLEEP | KM_NORMALPRI); + bfs = kmem_zalloc(sizeof (bootfs_t), KM_NOSLEEP_LAZY); if (bfs == NULL) return (ENOMEM); diff --git a/usr/src/uts/common/fs/dev/sdev_ptsops.c b/usr/src/uts/common/fs/dev/sdev_ptsops.c index 4d8f47397b..1b3f1561de 100644 --- a/usr/src/uts/common/fs/dev/sdev_ptsops.c +++ b/usr/src/uts/common/fs/dev/sdev_ptsops.c @@ -97,7 +97,6 @@ devpts_strtol(const char *nm, minor_t *mp) * away, we use the validator to do deferred cleanup i.e. when such * nodes are encountered during subsequent lookup() and readdir(). */ -/*ARGSUSED*/ int devpts_validate(struct sdev_node *dv) { @@ -124,8 +123,8 @@ devpts_validate(struct sdev_node *dv) /* * Check if pts driver is attached */ - if (ptms_slave_attached() == (major_t)-1) { - sdcmn_err7(("devpts_validate: slave not attached\n")); + if (ptms_subsidiary_attached() == (major_t)-1) { + sdcmn_err7(("devpts_validate: subsidiary not attached\n")); return (SDEV_VTOR_INVALID); } @@ -159,7 +158,6 @@ devpts_validate(struct sdev_node *dv) * This callback is invoked from devname_lookup_func() to create * a pts entry when the node is not found in the cache. */ -/*ARGSUSED*/ static int devpts_create_rvp(struct sdev_node *ddv, char *nm, void **arg, cred_t *cred, void *whatever, char *whichever) @@ -177,12 +175,11 @@ devpts_create_rvp(struct sdev_node *ddv, char *nm, } /* - * Check if pts driver is attached and if it is - * get the major number. + * Check if pts driver is attached and if it is get the major number. */ - maj = ptms_slave_attached(); + maj = ptms_subsidiary_attached(); if (maj == (major_t)-1) { - sdcmn_err7(("devpts_create_rvp: slave not attached\n")); + sdcmn_err7(("devpts_create_rvp: subsidiary not attached\n")); return (-1); } @@ -286,7 +283,6 @@ devpts_prunedir(struct sdev_node *ddv) * access the realvp of the specfs node directly instead of using * VOP_REALVP(). */ -/*ARGSUSED3*/ static int devpts_lookup(struct vnode *dvp, char *nm, struct vnode **vpp, struct pathname *pnp, int flags, struct vnode *rdir, struct cred *cred, @@ -326,7 +322,6 @@ devpts_lookup(struct vnode *dvp, char *nm, struct vnode **vpp, * - creating an existing dir read-only succeeds, otherwise EISDIR * - exclusive creates fail - EEXIST */ -/*ARGSUSED2*/ static int devpts_create(struct vnode *dvp, char *nm, struct vattr *vap, vcexcl_t excl, int mode, struct vnode **vpp, struct cred *cred, int flag, @@ -359,11 +354,10 @@ devpts_create(struct vnode *dvp, char *nm, struct vattr *vap, vcexcl_t excl, } /* - * Display all instantiated pts (slave) device nodes. - * A /dev/pts entry will be created only after the first lookup of the slave - * device succeeds. + * Display all instantiated pts (subsidiary) device nodes. + * A /dev/pts entry will be created only after the first lookup of the + * subsidiary device succeeds. */ -/*ARGSUSED4*/ static int devpts_readdir(struct vnode *dvp, struct uio *uiop, struct cred *cred, int *eofp, caller_context_t *ct, int flags) @@ -387,7 +381,6 @@ devpts_set_id(struct sdev_node *dv, struct vattr *vap, int protocol) } -/*ARGSUSED4*/ static int devpts_setattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cred, caller_context_t *ctp) diff --git a/usr/src/uts/common/fs/nfs/nfs_auth.c b/usr/src/uts/common/fs/nfs/nfs_auth.c index e132346545..c20a18f433 100644 --- a/usr/src/uts/common/fs/nfs/nfs_auth.c +++ b/usr/src/uts/common/fs/nfs/nfs_auth.c @@ -922,7 +922,7 @@ nfsauth_cache_get(struct exportinfo *exi, struct svc_req *req, int flavor, rw_exit(&exi->exi_cache_lock); - nc = kmem_alloc(sizeof (*nc), KM_NOSLEEP | KM_NORMALPRI); + nc = kmem_alloc(sizeof (*nc), KM_NOSLEEP_LAZY); if (nc == NULL) goto retrieve; @@ -930,8 +930,7 @@ nfsauth_cache_get(struct exportinfo *exi, struct svc_req *req, int flavor, * Initialize the new auth_cache_clnt */ nc->authc_addr = addr; - nc->authc_addr.buf = kmem_alloc(addr.maxlen, - KM_NOSLEEP | KM_NORMALPRI); + nc->authc_addr.buf = kmem_alloc(addr.maxlen, KM_NOSLEEP_LAZY); if (addr.maxlen != 0 && nc->authc_addr.buf == NULL) { kmem_free(nc, sizeof (*nc)); goto retrieve; @@ -972,8 +971,7 @@ nfsauth_cache_get(struct exportinfo *exi, struct svc_req *req, int flavor, rw_exit(&c->authc_lock); - np = kmem_cache_alloc(exi_cache_handle, - KM_NOSLEEP | KM_NORMALPRI); + np = kmem_cache_alloc(exi_cache_handle, KM_NOSLEEP_LAZY); if (np == NULL) { rw_exit(&exi->exi_cache_lock); goto retrieve; @@ -1071,7 +1069,7 @@ nfsauth_cache_get(struct exportinfo *exi, struct svc_req *req, int flavor, * auth_cache entry */ tmpgids = kmem_alloc(tmpngids * sizeof (gid_t), - KM_NOSLEEP | KM_NORMALPRI); + KM_NOSLEEP_LAZY); if (tmpgids != NULL) bcopy(*gids, tmpgids, tmpngids * sizeof (gid_t)); diff --git a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c index 4a657bbf19..930bd353c4 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_copychunk.c @@ -204,7 +204,7 @@ smb2_fsctl_copychunk(smb_request_t *sr, smb_fsctl_t *fsctl) * The client should then fall back to normal copy. */ args->bufsize = smb2_copychunk_max_seg; - args->buffer = kmem_alloc(args->bufsize, KM_NOSLEEP | KM_NORMALPRI); + args->buffer = kmem_alloc(args->bufsize, KM_NOSLEEP_LAZY); if (args->buffer == NULL) { status = NT_STATUS_INSUFF_SERVER_RESOURCES; goto out; diff --git a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c index 0452cddb39..fe748bbd62 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_fsctl_odx.c @@ -667,7 +667,7 @@ smb2_fsctl_odx_write_native1(smb_request_t *sr, * allow the allocation to fail and return an error. * The client should then fall back to normal copy. */ - buffer = kmem_alloc(bufsize, KM_NOSLEEP | KM_NORMALPRI); + buffer = kmem_alloc(bufsize, KM_NOSLEEP_LAZY); if (buffer == NULL) { status = NT_STATUS_INSUFF_SERVER_RESOURCES; goto out; diff --git a/usr/src/uts/common/fs/zfs/zcp.c b/usr/src/uts/common/fs/zfs/zcp.c index 61ce60a233..45ffa37e2a 100644 --- a/usr/src/uts/common/fs/zfs/zcp.c +++ b/usr/src/uts/common/fs/zfs/zcp.c @@ -718,8 +718,7 @@ static void * zcp_lua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) { zcp_alloc_arg_t *allocargs = ud; - int flags = (allocargs->aa_must_succeed) ? - KM_SLEEP : (KM_NOSLEEP | KM_NORMALPRI); + int flags = (allocargs->aa_must_succeed) ? KM_SLEEP : KM_NOSLEEP_LAZY; if (nsize == 0) { if (ptr != NULL) { diff --git a/usr/src/uts/common/inet/ip/ip_attr.c b/usr/src/uts/common/inet/ip/ip_attr.c index 6dfbc53d77..0aa969d971 100644 --- a/usr/src/uts/common/inet/ip/ip_attr.c +++ b/usr/src/uts/common/inet/ip/ip_attr.c @@ -862,7 +862,7 @@ conn_get_ixa_exclusive(conn_t *connp) ip_xmit_attr_t *oldixa; ip_xmit_attr_t *ixa; - ixa = kmem_alloc(sizeof (*ixa), KM_NOSLEEP | KM_NORMALPRI); + ixa = kmem_alloc(sizeof (*ixa), KM_NOSLEEP_LAZY); if (ixa == NULL) return (NULL); diff --git a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c index 4ab032e354..d39f1954b1 100644 --- a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c +++ b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd_scsi.c @@ -2389,7 +2389,7 @@ sbd_write_same_data(struct scsi_task *task, sbd_cmd_t *scmd) * Don't sleep for the allocation, and don't make the system * reclaim memory. Trade higher I/Os if in a low-memory situation. */ - big_buf = kmem_alloc(big_buf_size, KM_NOSLEEP | KM_NORMALPRI); + big_buf = kmem_alloc(big_buf_size, KM_NOSLEEP_LAZY); if (big_buf == NULL) { /* diff --git a/usr/src/uts/common/io/dld/dld_drv.c b/usr/src/uts/common/io/dld/dld_drv.c index 00b5f0e3de..676fca1249 100644 --- a/usr/src/uts/common/io/dld/dld_drv.c +++ b/usr/src/uts/common/io/dld/dld_drv.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015, Joyent Inc. * Copyright (c) 2017, Joyent, Inc. */ @@ -630,7 +631,7 @@ drv_ioc_prop_common(dld_ioc_macprop_t *prop, intptr_t arg, boolean_t set, cred_t *cred, int mode) { int err = EINVAL; - dls_dl_handle_t dlh = NULL; + dls_dl_handle_t dlh = NULL; dls_link_t *dlp = NULL; mac_perim_handle_t mph = NULL; dld_ioc_macprop_t *kprop; @@ -1327,7 +1328,7 @@ drv_ioc_gettran(void *karg, intptr_t arg, int mode, cred_t *cred, { int ret = 0; mac_perim_handle_t mph = NULL; - dls_dl_handle_t dlh = NULL; + dls_dl_handle_t dlh = NULL; dls_link_t *dlp = NULL; dld_ioc_gettran_t *dgt = karg; @@ -1375,7 +1376,7 @@ drv_ioc_readtran(void *karg, intptr_t arg, int mode, cred_t *cred, { int ret = 0; mac_perim_handle_t mph = NULL; - dls_dl_handle_t dlh = NULL; + dls_dl_handle_t dlh = NULL; dls_link_t *dlp = NULL; dld_ioc_tranio_t *dti = karg; uint8_t buf[256]; @@ -1432,7 +1433,7 @@ drv_ioc_getled(void *karg, intptr_t arg, int mode, cred_t *cred, { int ret = 0; mac_perim_handle_t mph = NULL; - dls_dl_handle_t dlh = NULL; + dls_dl_handle_t dlh = NULL; dls_link_t *dlp = NULL; dld_ioc_led_t *dil = karg; @@ -1478,7 +1479,7 @@ drv_ioc_setled(void *karg, intptr_t arg, int mode, cred_t *cred, { int ret = 0; mac_perim_handle_t mph = NULL; - dls_dl_handle_t dlh = NULL; + dls_dl_handle_t dlh = NULL; dls_link_t *dlp = NULL; dld_ioc_led_t *dil = karg; diff --git a/usr/src/uts/common/io/mac/mac_protect.c b/usr/src/uts/common/io/mac/mac_protect.c index ee493bbca1..cff1f884b9 100644 --- a/usr/src/uts/common/io/mac/mac_protect.c +++ b/usr/src/uts/common/io/mac/mac_protect.c @@ -1467,8 +1467,8 @@ insert_slaac_prefix(mac_client_impl_t *mcip, nd_opt_prefix_info_t *po) return; } - if ((addr = kmem_zalloc(sizeof (slaac_addr_t), - KM_NOSLEEP | KM_NORMALPRI)) == NULL) + if ((addr = kmem_zalloc(sizeof (slaac_addr_t), KM_NOSLEEP_LAZY)) == + NULL) return; bcopy(&po->nd_opt_pi_prefix, &addr->sla_prefix, diff --git a/usr/src/uts/common/io/nvme/nvme.c b/usr/src/uts/common/io/nvme/nvme.c index e9c779e323..77117adda0 100644 --- a/usr/src/uts/common/io/nvme/nvme.c +++ b/usr/src/uts/common/io/nvme/nvme.c @@ -10,14 +10,12 @@ */ /* - * Copyright 2018 Nexenta Systems, Inc. - * Copyright 2016 Tegile Systems, Inc. All rights reserved. * Copyright (c) 2016 The MathWorks, Inc. All rights reserved. * Copyright 2020 Joyent, Inc. - * Copyright 2019 Western Digital Corporation. * Copyright 2020 Racktop Systems. * Copyright 2022 Oxide Computer Company. * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2022 Tintri by DDN, Inc. All rights reserved. */ /* @@ -4902,6 +4900,7 @@ nvme_ioctl_firmware_download(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, size_t len, copylen; offset_t offset; uintptr_t buf; + nvme_cqe_t cqe = { 0 }; nvme_sqe_t sqe = { .sqe_opc = NVME_OPC_FW_IMAGE_LOAD }; @@ -4927,6 +4926,9 @@ nvme_ioctl_firmware_download(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, len = nioc->n_len; offset = nioc->n_arg; buf = (uintptr_t)nioc->n_buf; + + nioc->n_arg = 0; + while (len > 0 && rv == 0) { /* * nvme_ioc_cmd() does not use SGLs or PRP lists. @@ -4939,7 +4941,22 @@ nvme_ioctl_firmware_download(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, sqe.sqe_cdw11 = (uint32_t)(offset >> NVME_DWORD_SHIFT); rv = nvme_ioc_cmd(nvme, &sqe, B_TRUE, (void *)buf, copylen, - FWRITE, NULL, nvme_admin_cmd_timeout); + FWRITE, &cqe, nvme_admin_cmd_timeout); + + /* + * Regardless of whether the command succeeded or not, whether + * there's an errno in rv to be returned, we'll return any + * command-specific status code in n_arg. + * + * As n_arg isn't cleared in all other possible code paths + * returning an error, we return the status code as a negative + * value so it can be distinguished easily from whatever value + * was passed in n_arg originally. This of course only works as + * long as arguments passed in n_arg are less than INT64_MAX, + * which they currently are. + */ + if (cqe.cqe_sf.sf_sct == NVME_CQE_SCT_SPECIFIC) + nioc->n_arg = (uint64_t)-cqe.cqe_sf.sf_sc; buf += copylen; offset += copylen; @@ -4983,6 +5000,8 @@ nvme_ioctl_firmware_commit(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, case NVME_FWC_SAVE: case NVME_FWC_SAVE_ACTIVATE: timeout = nvme_commit_save_cmd_timeout; + if (slot == 1 && nvme->n_idctl->id_frmw.fw_readonly) + return (EROFS); break; case NVME_FWC_ACTIVATE: case NVME_FWC_ACTIVATE_IMMED: @@ -4996,9 +5015,23 @@ nvme_ioctl_firmware_commit(nvme_t *nvme, int nsid, nvme_ioctl_t *nioc, fc_dw10.b.fc_action = action; sqe.sqe_cdw10 = fc_dw10.r; + nioc->n_arg = 0; rv = nvme_ioc_cmd(nvme, &sqe, B_TRUE, NULL, 0, 0, &cqe, timeout); - nioc->n_arg = ((uint64_t)cqe.cqe_sf.sf_sct << 16) | cqe.cqe_sf.sf_sc; + /* + * Regardless of whether the command succeeded or not, whether + * there's an errno in rv to be returned, we'll return any + * command-specific status code in n_arg. + * + * As n_arg isn't cleared in all other possible code paths + * returning an error, we return the status code as a negative + * value so it can be distinguished easily from whatever value + * was passed in n_arg originally. This of course only works as + * long as arguments passed in n_arg are less than INT64_MAX, + * which they currently are. + */ + if (cqe.cqe_sf.sf_sct == NVME_CQE_SCT_SPECIFIC) + nioc->n_arg = (uint64_t)-cqe.cqe_sf.sf_sc; /* * Let the DDI UFM subsystem know that the firmware information for diff --git a/usr/src/uts/common/io/overlay/overlay.c b/usr/src/uts/common/io/overlay/overlay.c index e837b15c93..3016d88b13 100644 --- a/usr/src/uts/common/io/overlay/overlay.c +++ b/usr/src/uts/common/io/overlay/overlay.c @@ -185,46 +185,46 @@ * * The following are the supported types of properties: * - * OVERLAY_PROP_T_INT + * OVERLAY_PROP_T_INT * - * A signed integer, its length is 8 bytes, corresponding to a - * int64_t. + * A signed integer, its length is 8 bytes, corresponding to a + * int64_t. * - * OVERLAY_PROP_T_UINT + * OVERLAY_PROP_T_UINT * - * An unsigned integer, its length is 8 bytes, corresponding to a - * uint64_t. + * An unsigned integer, its length is 8 bytes, corresponding to a + * uint64_t. * - * OVERLAY_PROP_T_IP + * OVERLAY_PROP_T_IP * - * A struct in6_addr, it has a fixed size. + * A struct in6_addr, it has a fixed size. * - * OVERLAY_PROP_T_STRING + * OVERLAY_PROP_T_STRING * - * A null-terminated character string encoded in either ASCII or - * UTF-8. Note that the size of the string includes the null - * terminator. + * A null-terminated character string encoded in either ASCII or + * UTF-8. Note that the size of the string includes the null + * terminator. * * The next thing that we apply to a property is its permission. The permissions * are put together by the bitwise or of the following flags and values. * - * OVERLAY_PROP_PERM_REQ + * OVERLAY_PROP_PERM_REQ * - * This indicates a required property. A property that is required - * must be set by a consumer before the device can be created. If a - * required property has a default property, this constraint is - * loosened because the default property defines the value. + * This indicates a required property. A property that is required + * must be set by a consumer before the device can be created. If a + * required property has a default property, this constraint is + * loosened because the default property defines the value. * - * OVERLAY_PORP_PERM_READ + * OVERLAY_PORP_PERM_READ * - * This indicates that a property can be read. All properties will - * have this value set. + * This indicates that a property can be read. All properties will + * have this value set. * - * OVERLAY_PROP_PERM_WRITE + * OVERLAY_PROP_PERM_WRITE * - * This indicates that a property can be written to and thus - * updated by userland. Properties that are only intended to - * display information, will not have OVERLAY_PROP_PERM_WRITE set. + * This indicates that a property can be written to and thus + * updated by userland. Properties that are only intended to + * display information, will not have OVERLAY_PROP_PERM_WRITE set. * * In addition, a few additional values are defined as a convenience to * consumers. The first, OVERLAY_PROP_PERM_RW, is a combination of @@ -260,19 +260,19 @@ * summarized in the type overlay_point_t. Any combination of these is * supported. * - * OVERLAY_PLUGIN_D_ETHERNET + * OVERLAY_PLUGIN_D_ETHERNET * - * An Ethernet MAC address is required. + * An Ethernet MAC address is required. * - * OVERLAY_PLUGIN_D_IP + * OVERLAY_PLUGIN_D_IP * - * An IP address is required. All IP addresses used by the overlay - * system are transmitted as IPv6 addresses. IPv4 addresses can be - * represented by using IPv4-mapped IPv6 addresses. + * An IP address is required. All IP addresses used by the overlay + * system are transmitted as IPv6 addresses. IPv4 addresses can be + * represented by using IPv4-mapped IPv6 addresses. * - * OVERLAY_PLUGIN_D_PORT + * OVERLAY_PLUGIN_D_PORT * - * A TCP/UDP port is required. + * A TCP/UDP port is required. * * A kernel encapsulation plugin declares which of these that it requires, it's * a static set. On the other hand, a userland lookup plugin can be built to @@ -287,20 +287,20 @@ * determines how they interact with the broader system and how look ups are * performed. These types are: * - * OVERLAY_TARGET_POINT + * OVERLAY_TARGET_POINT * - * A point to point plugin has a single static definition for where - * to send all traffic. Every packet in the system always gets sent - * to the exact same destination which is programmed into the - * kernel when the general device is activated. + * A point to point plugin has a single static definition for where + * to send all traffic. Every packet in the system always gets sent + * to the exact same destination which is programmed into the + * kernel when the general device is activated. * - * OVERLAY_TARGET_DYNAMIC + * OVERLAY_TARGET_DYNAMIC * - * A dynamic plugin does not have a single static definition. - * Instead, for each destination, the kernel makes an asynchronous - * request to varpd to determine where the packet should be routed, - * and if a specific destination is found, then that destination is - * cached in the overlay device's target cache. + * A dynamic plugin does not have a single static definition. + * Instead, for each destination, the kernel makes an asynchronous + * request to varpd to determine where the packet should be routed, + * and if a specific destination is found, then that destination is + * cached in the overlay device's target cache. * * This distinction, while important for the general overlay device's operation, * is not important to the encapsulation plugins. They don't need to know about @@ -339,7 +339,7 @@ * | mac_handle_t -----+---> GLDv3 handle to MAC * | datalink_id_t -----+---> Datalink ID used by DLS * | overlay_dev_flag_t ---+---> Device state - * | uint_t -----+---> Curent device MTU + * | uint_t -----+---> Current device MTU * | uint_t -----+---> In-progress RX operations * | uint_t -----+---> In-progress TX operations * | char[] -----+---> FMA degraded message @@ -442,7 +442,7 @@ * a call to mac_rx(). * * Today, we don't do too much that's special with the ksocket; however, as - * hardware is gaining understanding for these encapuslation protocols, we'll + * hardware is gaining understanding for these encapsulation protocols, we'll * probably want to think of better ways to get those capabilities passed down * and potentially better ways to program receive filters so they get directly * to us. Though, that's all fantasy future land. @@ -492,7 +492,7 @@ * * Every kernel overlay device keeps track of its FMA state. Today in FMA we * cannot represent partitions between resources nor can we represent that a - * given minor node of a psuedo device has failed -- if we degrade the overlay + * given minor node of a pseudo device has failed -- if we degrade the overlay * device, then the entire dev_info_t is degraded. However, we still want to be * able to indicate to administrators that things may go wrong. * @@ -583,7 +583,7 @@ * | de:ad:be:ef:00:00 | and only exists in the target cache. * +-------------------+ * - * ~~~~ + * ~~~~ * * +---------------------+ * | Global list_t | A mblk_t comes in for an entry. We @@ -596,7 +596,7 @@ * | 42:5e:1a:10:d6:2d | | de:ad:be:ef:00:00 | * +-------------------+ +-------------------+ * - * ~~~~ + * ~~~~ * * +--------------------------+ * | /dev/overlay minor state | User land said that it would look up an @@ -610,7 +610,7 @@ * | 90:b8:d0:79:02:dd | | de:ad:be:ef:00:00 | * +-------------------+ +-------------------+ * - * ~~~~ + * ~~~~ * * +-------------------+ * | Valid Entry | varpd returned an answer with @@ -620,7 +620,7 @@ * * * The lookup mechanism is performed via a series of operations on the character - * psuedo-device /dev/overlay. The only thing that uses this device is the + * pseudo-device /dev/overlay. The only thing that uses this device is the * userland daemon varpd. /dev/overlay is a cloneable device, each open of it * granting a new minor number which maintains its own state. We maintain this * state so that way if an outstanding lookup was queued to something that @@ -994,7 +994,7 @@ overlay_m_stop(void *arg) /* * The MAC Perimeter is held here, so we don't have to worry about - * synchornizing this with respect to metadata operations. + * synchronizing this with respect to metadata operations. */ mutex_enter(&odd->odd_lock); VERIFY(odd->odd_flags & OVERLAY_F_IN_MUX); diff --git a/usr/src/uts/common/io/overlay/overlay_mux.c b/usr/src/uts/common/io/overlay/overlay_mux.c index 882f350060..69098ed10e 100644 --- a/usr/src/uts/common/io/overlay/overlay_mux.c +++ b/usr/src/uts/common/io/overlay/overlay_mux.c @@ -37,7 +37,7 @@ #include <sys/sdt.h> #define OVERLAY_FREEMSG(mp, reason) \ - DTRACE_PROBE2(overlay__fremsg, mblk_t *, mp, char *, reason) + DTRACE_PROBE2(overlay__freemsg, mblk_t *, mp, char *, reason) static list_t overlay_mux_list; static kmutex_t overlay_mux_lock; @@ -84,7 +84,7 @@ overlay_mux_recv(ksocket_t ks, mblk_t *mpchain, size_t msgsize, int oob, overlay_mux_t *mux = arg; /* - * We may have a received a chain of messages. Each messsage in the + * We may have a received a chain of messages. Each message in the * chain will likely have a T_unitdata_ind attached to it as an M_PROTO. * If we aren't getting that, we should probably drop that for the * moment. diff --git a/usr/src/uts/common/io/overlay/overlay_target.c b/usr/src/uts/common/io/overlay/overlay_target.c index f4147b56d1..3f2167620a 100644 --- a/usr/src/uts/common/io/overlay/overlay_target.c +++ b/usr/src/uts/common/io/overlay/overlay_target.c @@ -69,7 +69,7 @@ typedef int (*overlay_target_copyin_f)(const void *, void **, size_t *, int); typedef int (*overlay_target_ioctl_f)(overlay_target_hdl_t *, void *); typedef int (*overlay_target_copyout_f)(void *, void *, size_t, int); -typedef struct overaly_target_ioctl { +typedef struct overlay_target_ioctl { int oti_cmd; /* ioctl id */ boolean_t oti_write; /* ioctl requires FWRITE */ boolean_t oti_ncopyout; /* copyout data? */ @@ -354,8 +354,7 @@ overlay_target_lookup(overlay_dev_t *odd, mblk_t *mp, struct sockaddr *sock, entry = refhash_lookup(ott->ott_u.ott_dyn.ott_dhash, mhi.mhi_daddr); if (entry == NULL) { - entry = kmem_cache_alloc(overlay_entry_cache, - KM_NOSLEEP | KM_NORMALPRI); + entry = kmem_cache_alloc(overlay_entry_cache, KM_NOSLEEP_LAZY); if (entry == NULL) { mutex_exit(&ott->ott_lock); return (OVERLAY_TARGET_DROP); diff --git a/usr/src/uts/common/io/ptem.c b/usr/src/uts/common/io/ptem.c index 6497465b61..3be1f9d777 100644 --- a/usr/src/uts/common/io/ptem.c +++ b/usr/src/uts/common/io/ptem.c @@ -401,7 +401,7 @@ ptemrput(queue_t *q, mblk_t *mp) case M_IOCACK: case M_IOCNAK: /* - * We only pass write-side ioctls through to the master that + * We only pass write-side ioctls through to the manager that * we've already ACKed or NAKed to the stream head. Thus, we * discard ones arriving from below, since they're redundant * from the point of view of modules above us. @@ -626,7 +626,7 @@ ptemwmsg(queue_t *q, mblk_t *mp) * of the M_IOCTL message is made and passed * downstream. Eventually the PCKT module, if * it has been pushed, should pick up this message. - * If the PCKT module has not been pushed the master + * If the PCKT module has not been pushed the manager * side stream head will free it. */ iocp = (struct iocblk *)mp->b_rptr; @@ -843,8 +843,9 @@ out: default: /* - * End of the line. The slave driver doesn't see any - * ioctls that we don't explicitly pass along to it. + * End of the line. The subsidiary driver doesn't see + * any ioctls that we don't explicitly pass along to + * it. */ miocnak(q, mp, 0, EINVAL); break; @@ -983,14 +984,14 @@ ptioc(queue_t *q, mblk_t *mp, int qside) (void) putnextctl1(q, M_SIG, SIGWINCH); /* * Message may have come in as an M_IOCDATA; pass it - * to the master side as an M_IOCTL. + * to the manager side as an M_IOCTL. */ mp->b_datap->db_type = M_IOCTL; if (qside == WRSIDE) { /* * Need a copy of this message to pass on to * the PCKT module, only if the M_IOCTL - * orginated from the slave side. + * orginated from the subsidiary side. */ if ((pckt_msgp = copymsg(mp)) == NULL) { miocnak(q, mp, 0, EAGAIN); @@ -1010,7 +1011,7 @@ ptioc(queue_t *q, mblk_t *mp, int qside) case TIOCSIGNAL: { /* - * This ioctl can emanate from the master side in remote + * This ioctl can emanate from the manager side in remote * mode only. */ int sig; @@ -1034,8 +1035,8 @@ ptioc(queue_t *q, mblk_t *mp, int qside) } /* - * Send an M_PCSIG message up the slave's read side and - * respond back to the master with an ACK or NAK as + * Send an M_PCSIG message up the subsidiary's read side and + * respond back to the manager with an ACK or NAK as * appropriate. */ if (putnextctl1(q, M_PCSIG, sig) == 0) { diff --git a/usr/src/uts/common/io/ptm.c b/usr/src/uts/common/io/ptm.c index d4dfe83766..21d641992f 100644 --- a/usr/src/uts/common/io/ptm.c +++ b/usr/src/uts/common/io/ptm.c @@ -26,97 +26,107 @@ /* * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2021 Oxide Computer Company */ /* - * Pseudo Terminal Master Driver. + * PSEUDO-TERMINAL MANAGER DRIVER (PTM) * - * The pseudo-tty subsystem simulates a terminal connection, where the master - * side represents the terminal and the slave represents the user process's - * special device end point. The master device is set up as a cloned device - * where its major device number is the major for the clone device and its minor - * device number is the major for the ptm driver. There are no nodes in the file - * system for master devices. The master pseudo driver is opened using the - * open(2) system call with /dev/ptmx as the device parameter. The clone open - * finds the next available minor device for the ptm major device. + * The pseudo-terminal subsystem simulates a terminal connection, where the + * manager side represents the terminal and the subsidiary represents the user + * process's special device end point. The manager device is set up as a + * cloned device where its major device number is the major for the clone + * device and its minor device number is the major for the ptm driver. There + * are no nodes in the file system for manager devices. The manager pseudo + * driver is opened using the open(2) system call with /dev/ptmx as the device + * parameter. The clone open finds the next available minor device for the ptm + * major device. * - * A master device is available only if it and its corresponding slave device - * are not already open. When the master device is opened, the corresponding - * slave device is automatically locked out. Only one open is allowed on a - * master device. Multiple opens are allowed on the slave device. After both - * the master and slave have been opened, the user has two file descriptors - * which are the end points of a full duplex connection composed of two streams - * which are automatically connected at the master and slave drivers. The user - * may then push modules onto either side of the stream pair. + * A manager device is available only if it and its corresponding subsidiary + * device are not already open. When the manager device is opened, the + * corresponding subsidiary device is automatically locked out. Only one open + * is allowed on a manager device. Multiple opens are allowed on the + * subsidiary device. After both the manager and subsidiary have been opened, + * the user has two file descriptors which are the end points of a full duplex + * connection composed of two streams which are automatically connected at the + * manager and subsidiary drivers. The user may then push modules onto either + * side of the stream pair. * - * The master and slave drivers pass all messages to their adjacent queues. - * Only the M_FLUSH needs some processing. Because the read queue of one side - * is connected to the write queue of the other, the FLUSHR flag is changed to - * the FLUSHW flag and vice versa. When the master device is closed an M_HANGUP - * message is sent to the slave device which will render the device - * unusable. The process on the slave side gets the EIO when attempting to write - * on that stream but it will be able to read any data remaining on the stream - * head read queue. When all the data has been read, read() returns 0 - * indicating that the stream can no longer be used. On the last close of the - * slave device, a 0-length message is sent to the master device. When the - * application on the master side issues a read() or getmsg() and 0 is returned, - * the user of the master device decides whether to issue a close() that - * dismantles the pseudo-terminal subsystem. If the master device is not closed, - * the pseudo-tty subsystem will be available to another user to open the slave - * device. + * The manager and subsidiary drivers pass all messages to their adjacent + * queues. Only the M_FLUSH needs some processing. Because the read queue of + * one side is connected to the write queue of the other, the FLUSHR flag is + * changed to the FLUSHW flag and vice versa. When the manager device is + * closed an M_HANGUP message is sent to the subsidiary device which will + * render the device unusable. The process on the subsidiary side gets an EIO + * error when attempting to write on that stream but it will be able to read + * any data remaining on the stream head read queue. When all the data has + * been read, read() returns 0 indicating that the stream can no longer be + * used. On the last close of the subsidiary device, a 0-length message is + * sent to the manager device. When the application on the manager side issues + * a read() or getmsg() and 0 is returned, the user of the manager device + * decides whether to issue a close() that dismantles the pseudo-terminal + * subsystem. If the manager device is not closed, the pseudo-terminal + * subsystem will be available to another user to open the subsidiary device. * - * If O_NONBLOCK or O_NDELAY is set, read on the master side returns -1 with + * If O_NONBLOCK or O_NDELAY is set, read on the manager side returns -1 with * errno set to EAGAIN if no data is available, and write returns -1 with errno * set to EAGAIN if there is internal flow control. * - * IOCTLS: * - * ISPTM: determines whether the file descriptor is that of an open master - * device. Return code of zero indicates that the file descriptor - * represents master device. + * IOCTLS * - * UNLKPT: unlocks the master and slave devices. It returns 0 on success. On - * failure, the errno is set to EINVAL indicating that the master - * device is not open. + * ISPTM + * Determines whether the file descriptor is that of an open + * manager device. Return code of zero indicates that the file + * descriptor represents a manager device. * - * ZONEPT: sets the zone membership of the associated pts device. + * UNLKPT + * Unlocks the manager and subsidiary devices. It returns 0 on + * success. On failure, the errno is set to EINVAL indicating that + * the manager device is not open. * - * GRPPT: sets the group owner of the associated pts device. + * ZONEPT + * Sets the zone membership of the associated subsidiary device. * - * Synchronization: + * GRPPT + * Sets the group owner of the associated subsidiary device. * - * All global data synchronization between ptm/pts is done via global - * ptms_lock mutex which is initialized at system boot time from - * ptms_initspace (called from space.c). * - * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and - * pt_nullmsg) are protected by pt_ttys.pt_lock mutex. + * SYNCHRONIZATION * - * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks - * which allow reader locks to be reacquired by the same thread (usual - * reader/writer locks can't be used for that purpose since it is illegal for - * a thread to acquire a lock it already holds, even as a reader). The sole - * purpose of these macros is to guarantee that the peer queue will not - * disappear (due to closing peer) while it is used. It is safe to use - * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since - * they are not real locks but reference counts). + * All global data synchronization between ptm/pts is done via global ptms_lock + * mutex which is initialized at system boot time from ptms_initspace (called + * from space.c). * - * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in master/slave - * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should - * be set to appropriate queues *after* qprocson() is called during open (to - * prevent peer from accessing the queue with incomplete plumbing) and set to - * NULL before qprocsoff() is called during close. + * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and + * pt_nullmsg) are protected by pt_ttys.pt_lock mutex. * - * The pt_nullmsg field is only used in open/close routines and it is also - * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex - * holds. + * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks + * which allow reader locks to be reacquired by the same thread (usual + * reader/writer locks can't be used for that purpose since it is illegal for a + * thread to acquire a lock it already holds, even as a reader). The sole + * purpose of these macros is to guarantee that the peer queue will not + * disappear (due to closing peer) while it is used. It is safe to use + * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since + * they are not real locks but reference counts). * - * Lock Ordering: + * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in manager/subsidiary + * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should + * be set to appropriate queues *after* qprocson() is called during open (to + * prevent peer from accessing the queue with incomplete plumbing) and set to + * NULL before qprocsoff() is called during close. * - * If both ptms_lock and per-pty lock should be held, ptms_lock should always - * be entered first, followed by per-pty lock. + * The pt_nullmsg field is only used in open/close routines and it is also + * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex + * holds. * - * See ptms.h, pts.c and ptms_conf.c for more information. + * + * LOCK ORDERING + * + * If both ptms_lock and per-pty lock should be held, ptms_lock should always + * be entered first, followed by per-pty lock. + * + * See ptms.h, pts.c, and ptms_conf.c for more information. */ #include <sys/types.h> @@ -152,10 +162,6 @@ static int ptmwput(queue_t *, mblk_t *); static int ptmrsrv(queue_t *); static int ptmwsrv(queue_t *); -/* - * Master Stream Pseudo Terminal Module: stream data structure definitions - */ - static struct module_info ptm_info = { 0xdead, "ptm", @@ -209,9 +215,9 @@ DDI_DEFINE_STREAM_OPS(ptm_ops, nulldev, nulldev, ptm_attach, ptm_detach, */ static struct modldrv modldrv = { - &mod_driverops, /* Type of module. This one is a pseudo driver */ - "Master streams driver 'ptm'", - &ptm_ops, /* driver ops */ + &mod_driverops, + "Pseudo-Terminal Manager Driver", + &ptm_ops, }; static struct modlinkage modlinkage = { @@ -273,7 +279,6 @@ ptm_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) return (DDI_SUCCESS); } -/*ARGSUSED*/ static int ptm_devinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) @@ -300,12 +305,11 @@ ptm_devinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, } -/* ARGSUSED */ /* - * Open a minor of the master device. Store the write queue pointer and set the - * pt_state field to (PTMOPEN | PTLOCK). + * Open a minor of the manager device. Store the write queue pointer and set + * the pt_state field to (PTMOPEN | PTLOCK). * This code will work properly with both clone opens and direct opens of the - * master device. + * manager device. */ static int ptmopen( @@ -329,19 +333,18 @@ ptmopen( if (!(sflag & CLONEOPEN) && dminor != 0) { /* - * This is a direct open to specific master device through an + * This is a direct open to specific manager device through an * artificially created entry with specific minor in - * /dev/directory. Such behavior is not supported. + * /dev/directory. Such behavior is not supported. */ return (ENXIO); } /* - * The master open requires that the slave be attached - * before it returns so that attempts to open the slave will - * succeeed + * The manager open requires that the subsidiary be attached before it + * returns so that attempts to open the subsidiary will succeeed */ - if (ptms_attach_slave() != 0) { + if (ptms_attach_subsidiary() != 0) { return (ENXIO); } @@ -366,7 +369,7 @@ ptmopen( qprocson(rqp); - /* Allow slave to send messages to master */ + /* Allow subsidiary to send messages to manager */ PT_ENTER_WRITE(ptmp); ptmp->ptm_rdq = rqp; PT_EXIT_WRITE(ptmp); @@ -397,13 +400,12 @@ ptmopen( /* - * Find the address to private data identifying the slave's write queue. - * Send a hang-up message up the slave's read queue to designate the - * master/slave pair is tearing down. Uattach the master and slave by - * nulling out the write queue fields in the private data structure. - * Finally, unlock the master/slave pair and mark the master as closed. + * Find the address to private data identifying the subsidiary's write queue. + * Send a hang-up message up the subsidiary's read queue to designate the + * manager/subsidiary pair is tearing down. Uattach the manager and subsidiary + * by nulling out the write queue fields in the private data structure. + * Finally, unlock the manager/subsidiary pair and mark the manager as closed. */ -/*ARGSUSED1*/ static int ptmclose(queue_t *rqp, int flag, cred_t *credp) { @@ -417,7 +419,7 @@ ptmclose(queue_t *rqp, int flag, cred_t *credp) if (ptmp->pts_rdq) { pts_rdq = ptmp->pts_rdq; if (pts_rdq->q_next) { - DBG(("send hangup message to slave\n")); + DBG(("send hangup message to subsidiary\n")); (void) putnextctl(pts_rdq, M_HANGUP); } } @@ -431,8 +433,8 @@ ptmclose(queue_t *rqp, int flag, cred_t *credp) freemsg(ptmp->pt_nullmsg); ptmp->pt_nullmsg = NULL; /* - * qenable slave side write queue so that it can flush - * its messages as master's read queue is going away + * qenable subsidiary side write queue so that it can flush + * its messages as manager's read queue is going away */ if (ptmp->pts_rdq) qenable(WR(ptmp->pts_rdq)); @@ -478,9 +480,9 @@ ptmwput(queue_t *qp, mblk_t *mp) switch (mp->b_datap->db_type) { /* - * if write queue request, flush master's write - * queue and send FLUSHR up slave side. If read - * queue request, convert to FLUSHW and putnext(). + * If this is a write queue request, flush manager's write queue and + * send FLUSHR up subsidiary side. If it is a read queue request, + * convert to FLUSHW and putnext(). */ case M_FLUSH: { @@ -489,14 +491,15 @@ ptmwput(queue_t *qp, mblk_t *mp) DBG(("ptm got flush request\n")); if (*mp->b_rptr & FLUSHW) { DBG(("got FLUSHW, flush ptm write Q\n")); - if (*mp->b_rptr & FLUSHBAND) + if (*mp->b_rptr & FLUSHBAND) { /* * if it is a FLUSHBAND, do flushband. */ flushband(qp, *(mp->b_rptr + 1), FLUSHDATA); - else + } else { flushq(qp, FLUSHDATA); + } flush_flg = (*mp->b_rptr & ~FLUSHW) | FLUSHR; } if (*mp->b_rptr & FLUSHR) { @@ -508,8 +511,9 @@ ptmwput(queue_t *qp, mblk_t *mp) DBG(("putnext to pts\n")); *mp->b_rptr = flush_flg; putnext(ptmp->pts_rdq, mp); - } else + } else { freemsg(mp); + } break; } @@ -519,7 +523,7 @@ ptmwput(queue_t *qp, mblk_t *mp) default: if ((ptmp->pt_state & PTLOCK) || (ptmp->pts_rdq == NULL)) { - DBG(("got M_IOCTL but no slave\n")); + DBG(("got M_IOCTL but no subsidiary\n")); miocnak(qp, mp, 0, EINVAL); PT_EXIT_READ(ptmp); return (0); @@ -634,16 +638,16 @@ ptmwput(queue_t *qp, mblk_t *mp) break; case M_READ: - /* Caused by ldterm - can not pass to slave */ + /* Caused by ldterm - can not pass to subsidiary */ freemsg(mp); break; /* - * send other messages to slave + * Send other messages to the subsidiary: */ default: - if ((ptmp->pt_state & PTLOCK) || (ptmp->pts_rdq == NULL)) { - DBG(("got msg. but no slave\n")); + if ((ptmp->pt_state & PTLOCK) || (ptmp->pts_rdq == NULL)) { + DBG(("got msg. but no subsidiary\n")); mp = mexchange(NULL, mp, 2, M_ERROR, -1); if (mp != NULL) { mp->b_rptr[0] = NOERROR; @@ -653,7 +657,7 @@ ptmwput(queue_t *qp, mblk_t *mp) PT_EXIT_READ(ptmp); return (0); } - DBG(("put msg on master's write queue\n")); + DBG(("put msg on manager's write queue\n")); (void) putq(qp, mp); break; } @@ -664,9 +668,8 @@ ptmwput(queue_t *qp, mblk_t *mp) /* - * enable the write side of the slave. This triggers the - * slave to send any messages queued on its write side to - * the read side of this master. + * Enable the write side of the subsidiary. This triggers the subsidiary to + * send any messages queued on its write side to the read side of this manager. */ static int ptmrsrv(queue_t *qp) @@ -688,10 +691,10 @@ ptmrsrv(queue_t *qp) /* - * If there are messages on this queue that can be sent to - * slave, send them via putnext(). Else, if queued messages - * cannot be sent, leave them on this queue. If priority - * messages on this queue, send them to slave no matter what. + * If there are messages on this queue that can be sent to subsidiary, send + * them via putnext(). Otherwise, if queued messages cannot be sent, leave + * them on this queue. If priority messages on this queue, send them to the + * subsidiary no matter what. */ static int ptmwsrv(queue_t *qp) @@ -712,7 +715,7 @@ ptmwsrv(queue_t *qp) PT_ENTER_READ(ptmp); if ((ptmp->pt_state & PTLOCK) || (ptmp->pts_rdq == NULL)) { - DBG(("in master write srv proc but no slave\n")); + DBG(("in manager write srv proc but no subsidiary\n")); /* * Free messages on the write queue and send * NAK for any M_IOCTL type messages to wakeup @@ -737,13 +740,12 @@ ptmwsrv(queue_t *qp) return (0); } /* - * while there are messages on this write queue... + * While there are messages on this write queue... */ do { /* - * if don't have control message and cannot put - * msg. on slave's read queue, put it back on - * this queue. + * If this is not a control message, and we cannot put messages + * on the subsidiary's read queue, put it back on this queue. */ if (mp->b_datap->db_type <= QPCTL && !bcanputnext(ptmp->pts_rdq, mp->b_band)) { @@ -752,9 +754,9 @@ ptmwsrv(queue_t *qp) break; } /* - * else send the message up slave's stream + * Otherwise send the message up subsidiary's stream */ - DBG(("send message to slave\n")); + DBG(("send message to subsidiary\n")); putnext(ptmp->pts_rdq, mp); } while ((mp = getq(qp)) != NULL); DBG(("leaving ptmwsrv\n")); diff --git a/usr/src/uts/common/io/ptms_conf.c b/usr/src/uts/common/io/ptms_conf.c index d5d4383d5c..b032b093ed 100644 --- a/usr/src/uts/common/io/ptms_conf.c +++ b/usr/src/uts/common/io/ptms_conf.c @@ -21,79 +21,86 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2021 Oxide Computer Company */ /* - * This file contains global data and code shared between master and slave parts - * of the pseudo-terminal driver. + * PSEUDO-TERMINAL COMMON DATA AND ROUTINES (PTM, PTS) * - * Pseudo terminals (or pt's for short) are allocated dynamically. - * pt's are put in the global ptms_slots array indexed by minor numbers. + * This file contains global data and code shared between manager and + * subsidiary parts of the pseudo-terminal driver. * - * The slots array is initially small (of the size NPTY_MIN). When more pt's are + * Pseudo-terminals (or ptys for short) are allocated dynamically. + * ptys are put in the global ptms_slots array indexed by minor numbers. + * + * The slots array is initially small (of the size NPTY_MIN). When more ptys are * needed than the slot array size, the larger slot array is allocated and all - * opened pt's move to the new one. + * opened ptys move to the new one. + * + * + * RESOURCE ALLOCATION + * + * - pt_ttys structures are allocated via pt_ttys_alloc, which uses + * kmem_cache_alloc(). + * - Minor number space is allocated via vmem_alloc() interface. + * - ptms_slots arrays are allocated via kmem_alloc(). * - * Resource allocation: + * Minors start from 1 instead of 0, because vmem_alloc() returns 0 in case of + * failure. Also, in anticipation of removing the clone device interface to + * pseudo-terminal subsystem, minor 0 should not be used. (Potential future + * development). * - * pt_ttys structures are allocated via pt_ttys_alloc, which uses - * kmem_cache_alloc(). - * Minor number space is allocated via vmem_alloc() interface. - * ptms_slots arrays are allocated via kmem_alloc(). + * After the table slot size reaches pt_maxdelta, we stop 2^N extension + * algorithm and start extending the slot table size by pt_maxdelta. * - * Minors are started from 1 instead of 0 because vmem_alloc returns 0 in case - * of failure. Also, in anticipation of removing clone device interface to - * pseudo-terminal subsystem, minor 0 should not be used. (Potential future - * development). + * Device entries /dev/pts directory are created dynamically by the /dev + * filesystem. We no longer call ddi_create_minor_node() on behalf of the + * subsidiary driver. The /dev filesystem creates /dev/pts nodes based on the + * pt_ttys array. * - * After the table slot size reaches pt_maxdelta, we stop 2^N extension - * algorithm and start extending the slot table size by pt_maxdelta. * - * Device entries /dev/pts directory are created dynamically by the - * /dev filesystem. We no longer call ddi_create_minor_node() on - * behalf of the slave driver. The /dev filesystem creates /dev/pts - * nodes based on the pt_ttys array. + * SYNCHRONIZATION * - * Synchronization: + * All global data synchronization between ptm/pts is done via global ptms_lock + * mutex which is implicitly initialized by declaring it global. * - * All global data synchronization between ptm/pts is done via global - * ptms_lock mutex which is implicitly initialized by declaring it global. + * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and + * pt_nullmsg) are protected by pt_ttys.pt_lock mutex. * - * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and - * pt_nullmsg) are protected by pt_ttys.pt_lock mutex. + * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks + * which allow reader locks to be reacquired by the same thread (usual + * reader/writer locks can't be used for that purpose since it is illegal for a + * thread to acquire a lock it already holds, even as a reader). The sole + * purpose of these macros is to guarantee that the peer queue will not + * disappear (due to closing peer) while it is used. It is safe to use + * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since + * they are not real locks but reference counts). * - * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks - * which allow reader locks to be reacquired by the same thread (usual - * reader/writer locks can't be used for that purpose since it is illegal for - * a thread to acquire a lock it already holds, even as a reader). The sole - * purpose of these macros is to guarantee that the peer queue will not - * disappear (due to closing peer) while it is used. It is safe to use - * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since - * they are not real locks but reference counts). + * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in manager/subsidiary + * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should + * be set to appropriate queues *after* qprocson() is called during open (to + * prevent peer from accessing the queue with incomplete plumbing) and set to + * NULL before qprocsoff() is called during close. Put and service procedures + * use PT_ENTER_READ/PT_EXIT_READ to prevent peer closes. * - * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in master/slave - * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should - * be set to appropriate queues *after* qprocson() is called during open (to - * prevent peer from accessing the queue with incomplete plumbing) and set to - * NULL before qprocsoff() is called during close. Put and service procedures - * use PT_ENTER_READ/PT_EXIT_READ to prevent peer closes. + * The pt_nullmsg field is only used in open/close routines and is also + * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex + * holds. * - * The pt_nullmsg field is only used in open/close routines and is also - * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex - * holds. * - * Lock Ordering: + * LOCK ORDERING * - * If both ptms_lock and per-pty lock should be held, ptms_lock should always - * be entered first, followed by per-pty lock. + * If both ptms_lock and per-pty lock should be held, ptms_lock should always + * be entered first, followed by per-pty lock. * - * Global functions: + * + * GLOBAL FUNCTIONS * * void ptms_init(void); * * Called by pts/ptm _init entry points. It performes one-time - * initialization needed for both pts and ptm. This initialization is done - * here and not in ptms_initspace because all these data structures are not + * initialization needed for both pts and ptm. This initialization is done + * here and not in ptms_initspace because all these data structures are not * needed if pseudo-terminals are not used in the system. * * struct pt_ttys *pt_ttys_alloc(void); @@ -117,6 +124,7 @@ * Also returns owner of pty. * * int ptms_minor_exists(minor_t minor) + * * Check if minor refers to an allocated pty (in any zone) * Returns * 0 if not an allocated pty @@ -129,32 +137,33 @@ * void ptms_close(struct pt_ttys *pt, uint_t flags_to_clear); * * Clear flags_to_clear in pt and if no one owns it (PTMOPEN/PTSOPEN not - * set) free pt entry and corresponding slot. + * set) free pt entry and corresponding slot. + * * - * Tuneables and configuration: + * TUNEABLES AND CONFIGURATION * * pt_cnt: minimum number of pseudo-terminals in the system. The system * should provide at least this number of ptys (provided sufficient - * memory is available). It is different from the older semantics + * memory is available). It is different from the older semantics * of pt_cnt meaning maximum number of ptys. * Set to 0 by default. * * pt_max_pty: Maximum number of pseudo-terminals in the system. The system * should not allocate more ptys than pt_max_pty (although, it may - * impose stricter maximum). Zero value means no user-defined - * maximum. This is intended to be used as "denial-of-service" + * impose stricter maximum). Zero value means no user-defined + * maximum. This is intended to be used as "denial-of-service" * protection. * Set to 0 by default. * - * Both pt_cnt and pt_max_pty may be modified during system lifetime - * with their semantics preserved. + * Both pt_cnt and pt_max_pty may be modified during system + * lifetime with their semantics preserved. * * pt_init_cnt: Initial size of ptms_slots array. Set to NPTY_INITIAL. * * pt_ptyofmem: Approximate percentage of system memory that may be * occupied by pty data structures. Initially set to NPTY_PERCENT. * This variable is used once during initialization to estimate - * maximum number of ptys in the system. The actual maximum is + * maximum number of ptys in the system. The actual maximum is * determined as minimum of pt_max_pty and calculated value. * * pt_maxdelta: Maximum extension chunk of the slot table. @@ -193,7 +202,7 @@ * Tuneable variables. */ uint_t pt_cnt = 0; /* Minimum number of ptys */ -size_t pt_max_pty = 0; /* Maximum number of ptys */ +size_t pt_max_pty = 0; /* Maximum number of ptys */ uint_t pt_init_cnt = NPTY_INITIAL; /* Initial number of ptms slots */ uint_t pt_pctofmem = NPTY_PERCENT; /* Percent of memory to use for ptys */ uint_t pt_maxdelta = PTY_MAXDELTA; /* Max increment for slot table size */ @@ -210,7 +219,7 @@ static size_t ptms_nslots = 0; /* Size of slot array */ static size_t ptms_ptymax = 0; /* Maximum number of ptys */ static size_t ptms_inuse = 0; /* # of ptys currently allocated */ -dev_info_t *pts_dip = NULL; /* set if slave is attached */ +dev_info_t *pts_dip = NULL; /* Set if subsidiary is attached */ static struct kmem_cache *ptms_cache = NULL; /* pty cache */ @@ -222,9 +231,9 @@ static void ptms_destructor(void *, void *); static minor_t ptms_grow(void); /* - * Total size occupied by one pty. Each pty master/slave pair consumes one - * pointer for ptms_slots array, one pt_ttys structure and one empty message - * preallocated for pts close. + * Total size occupied by one pty. Each pty manager/subsidiary pair consumes + * one pointer for ptms_slots array, one pt_ttys structure, and one empty + * message preallocated for pts close. */ #define PTY_SIZE (sizeof (struct pt_ttys) + \ @@ -239,7 +248,7 @@ int ptms_debug = 0; /* * Clear all bits of x except the highest bit */ -#define truncate(x) ((x) <= 2 ? (x) : (1 << (highbit(x) - 1))) +#define truncate(x) ((x) <= 2 ? (x) : (1 << (highbit(x) - 1))) /* * Roundup the number to the nearest power of 2 @@ -295,7 +304,7 @@ ptms_init(void) * This routine attaches the pts dip. */ int -ptms_attach_slave(void) +ptms_attach_subsidiary(void) { if (pts_dip == NULL && i_ddi_attach_pseudo_node("pts") == NULL) return (-1); @@ -309,7 +318,7 @@ ptms_attach_slave(void) * and if it is, returns its major number. */ major_t -ptms_slave_attached(void) +ptms_subsidiary_attached(void) { major_t maj = DDI_MAJOR_T_NONE; diff --git a/usr/src/uts/common/io/pts.c b/usr/src/uts/common/io/pts.c index ff2d91f566..046a2bc76b 100644 --- a/usr/src/uts/common/io/pts.c +++ b/usr/src/uts/common/io/pts.c @@ -27,80 +27,84 @@ /* * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2021 Oxide Computer Company */ /* - * Pseudo Terminal Slave Driver. + * PSEUDO-TERMINAL SUBSIDIARY DRIVER (PTS) * - * The pseudo-tty subsystem simulates a terminal connection, where the master - * side represents the terminal and the slave represents the user process's - * special device end point. The master device is set up as a cloned device - * where its major device number is the major for the clone device and its minor - * device number is the major for the ptm driver. There are no nodes in the file - * system for master devices. The master pseudo driver is opened using the - * open(2) system call with /dev/ptmx as the device parameter. The clone open - * finds the next available minor device for the ptm major device. + * The pseudo-terminal subsystem simulates a terminal connection, where the + * manager side represents the terminal and the subsidiary represents the user + * process's special device end point. The manager device is set up as a + * cloned device where its major device number is the major for the clone + * device and its minor device number is the major for the ptm driver. There + * are no nodes in the file system for manager devices. The manager pseudo + * driver is opened using the open(2) system call with /dev/ptmx as the device + * parameter. The clone open finds the next available minor device for the ptm + * major device. * - * A master device is available only if it and its corresponding slave device - * are not already open. When the master device is opened, the corresponding - * slave device is automatically locked out. Only one open is allowed on a - * master device. Multiple opens are allowed on the slave device. After both - * the master and slave have been opened, the user has two file descriptors - * which are the end points of a full duplex connection composed of two streams - * which are automatically connected at the master and slave drivers. The user - * may then push modules onto either side of the stream pair. + * A manager device is available only if it and its corresponding subsidiary + * device are not already open. When the manager device is opened, the + * corresponding subsidiary device is automatically locked out. Only one open + * is allowed on a manager device. Multiple opens are allowed on the + * subsidiary device. After both the manager and subsidiary have been opened, + * the user has two file descriptors which are the end points of a full duplex + * connection composed of two streams which are automatically connected at the + * manager and subsidiary drivers. The user may then push modules onto either + * side of the stream pair. * - * The master and slave drivers pass all messages to their adjacent queues. - * Only the M_FLUSH needs some processing. Because the read queue of one side - * is connected to the write queue of the other, the FLUSHR flag is changed to - * the FLUSHW flag and vice versa. When the master device is closed an M_HANGUP - * message is sent to the slave device which will render the device - * unusable. The process on the slave side gets the EIO when attempting to write - * on that stream but it will be able to read any data remaining on the stream - * head read queue. When all the data has been read, read() returns 0 - * indicating that the stream can no longer be used. On the last close of the - * slave device, a 0-length message is sent to the master device. When the - * application on the master side issues a read() or getmsg() and 0 is returned, - * the user of the master device decides whether to issue a close() that - * dismantles the pseudo-terminal subsystem. If the master device is not closed, - * the pseudo-tty subsystem will be available to another user to open the slave - * device. + * The manager and subsidiary drivers pass all messages to their adjacent + * queues. Only the M_FLUSH needs some processing. Because the read queue of + * one side is connected to the write queue of the other, the FLUSHR flag is + * changed to the FLUSHW flag and vice versa. When the manager device is + * closed an M_HANGUP message is sent to the subsidiary device which will + * render the device unusable. The process on the subsidiary side gets the EIO + * when attempting to write on that stream but it will be able to read any data + * remaining on the stream head read queue. When all the data has been read, + * read() returns 0 indicating that the stream can no longer be used. On the + * last close of the subsidiary device, a 0-length message is sent to the + * manager device. When the application on the manager side issues a read() or + * getmsg() and 0 is returned, the user of the manager device decides whether + * to issue a close() that dismantles the pseudo-terminal subsystem. If the + * manager device is not closed, the pseudo-tty subsystem will be available to + * another user to open the subsidiary device. * - * Synchronization: * - * All global data synchronization between ptm/pts is done via global - * ptms_lock mutex which is initialized at system boot time from - * ptms_initspace (called from space.c). + * SYNCHRONIZATION * - * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and - * pt_nullmsg) are protected by pt_ttys.pt_lock mutex. + * All global data synchronization between ptm/pts is done via global ptms_lock + * mutex which is initialized at system boot time from ptms_initspace (called + * from space.c). * - * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks - * which allow reader locks to be reacquired by the same thread (usual - * reader/writer locks can't be used for that purpose since it is illegal for - * a thread to acquire a lock it already holds, even as a reader). The sole - * purpose of these macros is to guarantee that the peer queue will not - * disappear (due to closing peer) while it is used. It is safe to use - * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since - * they are not real locks but reference counts). + * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and + * pt_nullmsg) are protected by pt_ttys.pt_lock mutex. * - * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in master/slave - * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should - * be set to appropriate queues *after* qprocson() is called during open (to - * prevent peer from accessing the queue with incomplete plumbing) and set to - * NULL before qprocsoff() is called during close. + * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks + * which allow reader locks to be reacquired by the same thread (usual + * reader/writer locks can't be used for that purpose since it is illegal for a + * thread to acquire a lock it already holds, even as a reader). The sole + * purpose of these macros is to guarantee that the peer queue will not + * disappear (due to closing peer) while it is used. It is safe to use + * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since + * they are not real locks but reference counts). * - * The pt_nullmsg field is only used in open/close routines and it is also - * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex - * holds. + * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in manager/subsidiary + * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should + * be set to appropriate queues *after* qprocson() is called during open (to + * prevent peer from accessing the queue with incomplete plumbing) and set to + * NULL before qprocsoff() is called during close. * - * Lock Ordering: + * The pt_nullmsg field is only used in open/close routines and it is also + * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex + * holds. * - * If both ptms_lock and per-pty lock should be held, ptms_lock should always - * be entered first, followed by per-pty lock. * - * See ptms.h, ptm.c and ptms_conf.c fore more information. + * LOCK ORDERING + * + * If both ptms_lock and per-pty lock should be held, ptms_lock should always + * be entered first, followed by per-pty lock. * + * See ptms.h, ptm.c and ptms_conf.c fore more information. */ #include <sys/types.h> @@ -135,9 +139,6 @@ static int ptswput(queue_t *, mblk_t *); static int ptsrsrv(queue_t *); static int ptswsrv(queue_t *); -/* - * Slave Stream Pseudo Terminal Module: stream data structure definitions - */ static struct module_info pts_info = { 0xface, "pts", @@ -192,9 +193,9 @@ DDI_DEFINE_STREAM_OPS(pts_ops, nulldev, nulldev, \ */ static struct modldrv modldrv = { - &mod_driverops, /* Type of module. This one is a pseudo driver */ - "Slave Stream Pseudo Terminal driver 'pts'", - &pts_ops, /* driver ops */ + &mod_driverops, + "Pseudo-Terminal Subsidiary Driver", + &pts_ops, }; static struct modlinkage modlinkage = { @@ -239,7 +240,6 @@ pts_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) return (DDI_SUCCESS); } -/*ARGSUSED*/ static int pts_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) { @@ -252,7 +252,6 @@ pts_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) return (DDI_FAILURE); } -/*ARGSUSED*/ static int pts_devinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) @@ -280,9 +279,9 @@ pts_devinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, /* ARGSUSED */ /* - * Open the slave device. Reject a clone open and do not allow the - * driver to be pushed. If the slave/master pair is locked or if - * the master is not open, return EACCESS. + * Open the subsidiary device. Reject a clone open and do not allow the + * driver to be pushed. If the subsidiary/manager pair is locked or if + * the manager is not open, return EACCESS. * Upon success, store the write queue pointer in private data and * set the PTSOPEN bit in the pt_state field. */ @@ -369,10 +368,10 @@ ptsopen( } /* - * Slave should send zero-length message to a master when it is - * closing. If memory is low at that time, master will not detect slave - * closes, this pty will not be deallocated. So, preallocate this - * zero-length message block early. + * Subsidiary should send zero-length message to a manager when it is + * closing. If memory is low at that time, manager will not detect + * subsidiary closes, this pty will not be deallocated. So, + * preallocate this zero-length message block early. */ if ((mp = allocb(0, BPRI_MED)) == NULL) { mutex_exit(&ptsp->pt_lock); @@ -395,9 +394,10 @@ ptsopen( /* * After qprocson pts driver is fully plumbed into the stream and can - * send/receive messages. Setting pts_rdq will allow master side to send - * messages to the slave. This setting can't occur before qprocson() is - * finished because slave is not ready to process them. + * send/receive messages. Setting pts_rdq will allow manager side to + * send messages to the subsidiary. This setting can't occur before + * qprocson() is finished because subsidiary is not ready to process + * them. */ PT_ENTER_WRITE(ptsp); ptsp->pts_rdq = rqp; @@ -422,12 +422,11 @@ ptsopen( } /* - * Find the address to private data identifying the slave's write - * queue. Send a 0-length msg up the slave's read queue to designate - * the master is closing. Uattach the master from the slave by nulling - * out master's write queue field in private data. + * Find the address to private data identifying the subsidiary's write queue. + * Send a 0-length msg up the subsidiary's read queue to designate the manager + * is closing. Uattach the manager from the subsidiary by nulling out + * manager's write queue field in private data. */ -/*ARGSUSED1*/ static int ptsclose(queue_t *rqp, int flag, cred_t *credp) { @@ -450,10 +449,10 @@ ptsclose(queue_t *rqp, int flag, cred_t *credp) ptsp = (struct pt_ttys *)rqp->q_ptr; /* - * Slave is going to close and doesn't want any new messages coming - * from the master side, so set pts_rdq to NULL. This should be done - * before call to qprocsoff() since slave can't process additional - * messages from the master after qprocsoff is called. + * Subsidiary is going to close and doesn't want any new messages + * coming from the manager side, so set pts_rdq to NULL. This should + * be done before call to qprocsoff() since subsidiary can't process + * additional messages from the manager after qprocsoff is called. */ PT_ENTER_WRITE(ptsp); mp = ptsp->pt_nullmsg; @@ -479,8 +478,8 @@ ptsclose(queue_t *rqp, int flag, cred_t *credp) } } /* - * qenable master side write queue so that it can flush - * its messages as slaves's read queue is going away + * qenable manager side write queue so that it can flush its messages + * as subsidiarys's read queue is going away: */ if (ptsp->ptm_rdq) { if (mp) @@ -503,9 +502,9 @@ ptsclose(queue_t *rqp, int flag, cred_t *credp) /* - * The wput procedure will only handle flush messages. - * All other messages are queued and the write side - * service procedure sends them off to the master side. + * The wput procedure will only handle flush messages. All other messages are + * queued and the write side service procedure sends them off to the manager + * side. */ static int ptswput(queue_t *qp, mblk_t *mp) @@ -520,9 +519,9 @@ ptswput(queue_t *qp, mblk_t *mp) ptsp = (struct pt_ttys *)qp->q_ptr; PT_ENTER_READ(ptsp); if (ptsp->ptm_rdq == NULL) { - DBG(("in write put proc but no master\n")); + DBG(("in write put proc but no manager\n")); /* - * NAK ioctl as slave side read queue is gone. + * NAK ioctl as subsidiary side read queue is gone. * Or else free the message. */ if (mp->b_datap->db_type == M_IOCTL) { @@ -540,7 +539,7 @@ ptswput(queue_t *qp, mblk_t *mp) switch (type) { /* - * if write queue request, flush slave's write + * if write queue request, flush subsidiary's write * queue and send FLUSHR to ptm. If read queue * request, send FLUSHR to ptm. */ @@ -585,9 +584,9 @@ ptswput(queue_t *qp, mblk_t *mp) } } /* - * Since the packet module will toss any - * M_FLUSHES sent to the master's stream head - * read queue, we simply turn it around here. + * Since the packet module will toss any M_FLUSHES sent to the + * manager's stream head read queue, we simply turn it around + * here. */ if (*mp->b_rptr & FLUSHR) { ASSERT(RD(qp)->q_first == NULL); @@ -599,7 +598,7 @@ ptswput(queue_t *qp, mblk_t *mp) break; case M_READ: - /* Caused by ldterm - can not pass to master */ + /* Caused by ldterm - can not pass to manager */ freemsg(mp); break; @@ -645,9 +644,9 @@ ptswput(queue_t *qp, mblk_t *mp) /* FALLTHROUGH */ default: /* - * send other messages to the master + * send other messages to the manager */ - DBG(("put msg on slave's write queue\n")); + DBG(("put msg on subsidiary's write queue\n")); (void) putq(qp, mp); break; } @@ -659,9 +658,8 @@ ptswput(queue_t *qp, mblk_t *mp) /* - * enable the write side of the master. This triggers the - * master to send any messages queued on its write side to - * the read side of this slave. + * Enable the write side of the manager. This triggers the manager to send any + * messages queued on its write side to the read side of this subsidiary. */ static int ptsrsrv(queue_t *qp) @@ -674,7 +672,7 @@ ptsrsrv(queue_t *qp) ptsp = (struct pt_ttys *)qp->q_ptr; PT_ENTER_READ(ptsp); if (ptsp->ptm_rdq == NULL) { - DBG(("in read srv proc but no master\n")); + DBG(("in read srv proc but no manager\n")); PT_EXIT_READ(ptsp); return (0); } @@ -685,10 +683,10 @@ ptsrsrv(queue_t *qp) } /* - * If there are messages on this queue that can be sent to - * master, send them via putnext(). Else, if queued messages - * cannot be sent, leave them on this queue. If priority - * messages on this queue, send them to master no matter what. + * If there are messages on this queue that can be sent to manager, send them + * via putnext(). Otherwise, if queued messages cannot be sent, leave them on + * this queue. If priority messages on this queue, send them to manager no + * matter what. */ static int ptswsrv(queue_t *qp) @@ -703,12 +701,11 @@ ptswsrv(queue_t *qp) ptsp = (struct pt_ttys *)qp->q_ptr; PT_ENTER_READ(ptsp); if (ptsp->ptm_rdq == NULL) { - DBG(("in write srv proc but no master\n")); + DBG(("in write srv proc but no manager\n")); /* - * Free messages on the write queue and send - * NAK for any M_IOCTL type messages to wakeup - * the user process waiting for ACK/NAK from - * the ioctl invocation + * Free messages on the write queue and send NAK for any + * M_IOCTL type messages to wakeup the user process waiting for + * ACK/NAK from the ioctl invocation */ while ((mp = getq(qp)) != NULL) { if (mp->b_datap->db_type == M_IOCTL) { @@ -726,13 +723,12 @@ ptswsrv(queue_t *qp) } /* - * while there are messages on this write queue... + * While there are messages on this write queue... */ while ((mp = getq(qp)) != NULL) { /* - * if don't have control message and cannot put - * msg. on master's read queue, put it back on - * this queue. + * If this is not a control message and we cannot put messages + * on the manager's read queue, put it back on this queue. */ if (mp->b_datap->db_type <= QPCTL && !bcanputnext(ptm_rdq, mp->b_band)) { @@ -741,9 +737,9 @@ ptswsrv(queue_t *qp) break; } /* - * else send the message up master's stream + * Otherwise, send the message up manager's stream: */ - DBG(("send message to master\n")); + DBG(("send message to manager\n")); putnext(ptm_rdq, mp); } DBG(("leaving ptswsrv\n")); diff --git a/usr/src/uts/common/io/sata/adapters/ahci/ahci.c b/usr/src/uts/common/io/sata/adapters/ahci/ahci.c index 721aead599..7f2100ba41 100644 --- a/usr/src/uts/common/io/sata/adapters/ahci/ahci.c +++ b/usr/src/uts/common/io/sata/adapters/ahci/ahci.c @@ -10766,7 +10766,7 @@ ahci_em_ioctl_set(ahci_ctl_t *ahci_ctlp, intptr_t arg) return (ENOTSUP); } - task = kmem_alloc(sizeof (*task), KM_NOSLEEP | KM_NORMALPRI); + task = kmem_alloc(sizeof (*task), KM_NOSLEEP_LAZY); if (task == NULL) { return (ENOMEM); } diff --git a/usr/src/uts/common/io/tty_pts.c b/usr/src/uts/common/io/tty_pts.c index 2e69280908..65a4669259 100644 --- a/usr/src/uts/common/io/tty_pts.c +++ b/usr/src/uts/common/io/tty_pts.c @@ -12,7 +12,7 @@ /* * PTY - Stream "pseudo-tty" device. - * This is the "slave" side. + * This is the "subsidiary" side. */ @@ -30,7 +30,7 @@ #include <sys/user.h> #include <sys/conf.h> #include <sys/file.h> -#include <sys/vnode.h> /* 1/0 on the vomit meter */ +#include <sys/vnode.h> #include <sys/proc.h> #include <sys/uio.h> #include <sys/errno.h> @@ -65,7 +65,7 @@ extern struct pollhead ptcph; /* poll head for ptcpoll() use */ */ /* - * Slave side. This is a streams device. + * Subsidiary side. This is a streams device. */ static int ptslopen(queue_t *, dev_t *, int flag, int, cred_t *); static int ptslclose(queue_t *, int, cred_t *); @@ -141,7 +141,7 @@ DDI_DEFINE_STREAM_OPS(ptsl_ops, nulldev, nulldev, static struct modldrv modldrv = { &mod_driverops, /* Type of module. This one is a pseudo driver */ - "tty pseudo driver slave 'ptsl'", + "tty pseudo driver subsidiary 'ptsl'", &ptsl_ops, /* driver ops */ }; @@ -226,7 +226,7 @@ ptsl_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, /* - * Open the slave side of a pty. + * Open the subsidiary side of a pty. */ /*ARGSUSED*/ static int @@ -277,13 +277,13 @@ again: pty->pt_sdev = dev; q->q_ptr = WR(q)->q_ptr = pty; - pty->pt_flags &= ~PF_SLAVEGONE; + pty->pt_flags &= ~PF_SUBSIDGONE; pty->pt_ttycommon.t_readq = pty->pt_ttycommon.t_writeq = NULL; /* - * Slave is ready to accept messages but master still can't send - * messages to the slave queue since it is not plumbed - * yet. So do qprocson() and finish slave initialization. + * Subsidiary is ready to accept messages but manager still can't send + * messages to the subsidiary queue since it is not plumbed + * yet. So do qprocson() and finish subsidiary initialization. */ mutex_exit(&pty->ptc_lock); @@ -291,8 +291,8 @@ again: qprocson(q); /* - * Now it is safe to send messages to q, so wakeup master possibly - * waiting for slave queue to finish open. + * Now it is safe to send messages to q, so wakeup manager possibly + * waiting for subsidiary queue to finish open. */ mutex_enter(&pty->ptc_lock); /* @@ -303,7 +303,7 @@ again: VN_RELE(pty->pt_vnode); pty->pt_ttycommon.t_readq = q; pty->pt_ttycommon.t_writeq = WR(q); - /* tell master device that slave is ready for writing */ + /* tell manager device that subsidiary is ready for writing */ if (pty->pt_flags & PF_CARR_ON) cv_broadcast(&pty->pt_cv_readq); mutex_exit(&pty->ptc_lock); @@ -326,10 +326,10 @@ ptslclose(queue_t *q, int flag, cred_t *cred) return (ENODEV); /* already been closed once */ /* - * Prevent the queues from being uses by master device. - * This should be done before qprocsoff or writer may attempt - * to use the slave queue after qprocsoff removed it from the stream and - * before entering mutex_enter(). + * Prevent the queues from being uses by manager device. This should + * be done before qprocsoff or writer may attempt to use the subsidiary + * queue after qprocsoff removed it from the stream and before entering + * mutex_enter(). */ mutex_enter(&pty->ptc_lock); pty->pt_ttycommon.t_readq = NULL; @@ -359,11 +359,11 @@ ptslclose(queue_t *q, int flag, cred_t *cred) } /* - * Clear out all the slave-side state. + * Clear out all the subsidiary-side state. */ pty->pt_flags &= ~(PF_WOPEN|PF_STOPPED|PF_NOSTOP); if (pty->pt_flags & PF_CARR_ON) { - pty->pt_flags |= PF_SLAVEGONE; /* let the controller know */ + pty->pt_flags |= PF_SUBSIDGONE; /* let the controller know */ ptcpollwakeup(pty, 0); /* wake up readers/selectors */ ptcpollwakeup(pty, FWRITE); /* wake up writers/selectors */ cv_broadcast(&pty->pt_cv_flags); @@ -942,10 +942,10 @@ pt_sendstop(struct pty *pty) if ((pty->pt_ttycommon.t_cflag&CBAUD) == 0) { if (pty->pt_flags & PF_CARR_ON) { /* - * Let the controller know, then wake up + * Let the manager know, then wake up * readers/selectors and writers/selectors. */ - pty->pt_flags |= PF_SLAVEGONE; + pty->pt_flags |= PF_SUBSIDGONE; ptcpollwakeup(pty, 0); ptcpollwakeup(pty, FWRITE); } @@ -977,7 +977,7 @@ pt_sendstop(struct pty *pty) * user control mode message has been queued up (this data is readable, * so we also treat it as a regular data event; should we send SIGIO, * though?), FREAD if regular data has been queued up, or FWRITE if - * the slave's read queue has drained sufficiently to allow writing. + * the subsidiary's read queue has drained sufficiently to allow writing. */ static void ptcpollwakeup(struct pty *pty, int flag) @@ -997,7 +997,7 @@ ptcpollwakeup(struct pty *pty, int flag) if (flag & FREAD) { /* * Wake up the parent process as there is regular - * data to read from slave's write queue + * data to read from subsidiary's write queue */ pollwakeup(&ptcph, POLLIN | POLLRDNORM); cv_broadcast(&pty->pt_cv_writeq); @@ -1007,7 +1007,7 @@ ptcpollwakeup(struct pty *pty, int flag) if (flag & FWRITE) { /* * Wake up the parent process to write - * data into slave's read queue as the + * data into subsidiary's read queue as the * read queue has drained enough */ pollwakeup(&ptcph, POLLOUT | POLLWRNORM); diff --git a/usr/src/uts/common/io/tty_pty.c b/usr/src/uts/common/io/tty_pty.c index c1e15de161..d6bbda6626 100644 --- a/usr/src/uts/common/io/tty_pty.c +++ b/usr/src/uts/common/io/tty_pty.c @@ -11,8 +11,8 @@ */ /* - * PTY - Stream "pseudo-tty" device. For each "controller" side - * it connects to a "slave" side. + * PTY - Stream "pseudo-terminal" device. For each "manager" side it connects + * to a "subsidiary" side. */ @@ -29,7 +29,7 @@ #include <sys/user.h> #include <sys/conf.h> #include <sys/file.h> -#include <sys/vnode.h> /* 1/0 on the vomit meter */ +#include <sys/vnode.h> #include <sys/proc.h> #include <sys/uio.h> #include <sys/errno.h> @@ -116,9 +116,9 @@ extern struct dev_ops ptc_ops; */ static struct modldrv modldrv = { - &mod_driverops, /* Type of module. This one is a pseudo driver */ + &mod_driverops, "tty pseudo driver control 'ptc'", - &ptc_ops, /* driver ops */ + &ptc_ops, }; static struct modlinkage modlinkage = { @@ -236,12 +236,11 @@ ptc_uninit(void) } /* - * Controller side. This is not, alas, a streams device; there are too + * Manager side. This is not, alas, a streams device; there are too * many old features that we must support and that don't work well * with streams. */ -/*ARGSUSED*/ int ptcopen(dev_t *devp, int flag, int otyp, struct cred *cred) { @@ -256,7 +255,7 @@ ptcopen(dev_t *devp, int flag, int otyp, struct cred *cred) mutex_enter(&pty->ptc_lock); if (pty->pt_flags & PF_CARR_ON) { mutex_exit(&pty->ptc_lock); - return (EIO); /* controller is exclusive use */ + return (EIO); /* manager is exclusive use */ /* XXX - should be EBUSY! */ } if (pty->pt_flags & PF_WOPEN) { @@ -266,7 +265,7 @@ ptcopen(dev_t *devp, int flag, int otyp, struct cred *cred) if ((q = pty->pt_ttycommon.t_readq) != NULL) { /* - * Send an un-hangup to the slave, since "carrier" is + * Send an un-hangup to the subsidiary, since "carrier" is * coming back up. Make sure we're doing canonicalization. */ (void) putctl(q, M_UNHANGUP); @@ -280,7 +279,6 @@ ptcopen(dev_t *devp, int flag, int otyp, struct cred *cred) return (0); } -/*ARGSUSED1*/ int ptcclose(dev_t dev, int flag, int otyp, struct cred *cred) { @@ -293,15 +291,15 @@ ptcclose(dev_t dev, int flag, int otyp, struct cred *cred) mutex_enter(&pty->ptc_lock); if ((q = pty->pt_ttycommon.t_readq) != NULL) { /* - * Send a hangup to the slave, since "carrier" is dropping. + * Send a hangup to the subsidiary, since "carrier" is dropping. */ (void) putctl(q, M_HANGUP); } /* - * Clear out all the controller-side state. This also + * Clear out all the manager-side state. This also * clears PF_CARR_ON, which is correct because the - * "carrier" is dropping since the controller process + * "carrier" is dropping since the manager process * is going away. */ pty->pt_flags &= (PF_WOPEN|PF_STOPPED|PF_NOSTOP); @@ -329,10 +327,6 @@ ptcread(dev_t dev, struct uio *uio, struct cred *cred) int error; off_t off; -#ifdef lint - cred = cred; -#endif - off = uio->uio_offset; mutex_enter(&pty->ptc_lock); @@ -475,14 +469,14 @@ ptcread(dev_t dev, struct uio *uio, struct cred *cred) /* * There's no data available. - * We want to block until the slave is open, and there's - * something to read; but if we lost the slave or we're NBIO, - * then return the appropriate error instead. POSIX-style - * non-block has top billing and gives -1 with errno = EAGAIN, - * BSD-style comes next and gives -1 with errno = EWOULDBLOCK, - * SVID-style comes last and gives 0. + * We want to block until the subsidiary is open, and there's + * something to read; but if we lost the subsidiary or we're + * NBIO, then return the appropriate error instead. + * POSIX-style non-block has top billing and gives -1 with + * errno = EAGAIN, BSD-style comes next and gives -1 with + * errno = EWOULDBLOCK, SVID-style comes last and gives 0. */ - if (pty->pt_flags & PF_SLAVEGONE) { + if (pty->pt_flags & PF_SUBSIDGONE) { error = EIO; goto out; } @@ -532,11 +526,6 @@ ptcwrite(dev_t dev, struct uio *uio, struct cred *cred) off_t off; off = uio->uio_offset; -#ifdef lint - cred = cred; -#endif - - mutex_enter(&pty->ptc_lock); again: @@ -550,9 +539,9 @@ again: if ((q = pty->pt_ttycommon.t_readq) == NULL) { /* - * Wait for slave to open. + * Wait for subsidiary to open. */ - if (pty->pt_flags & PF_SLAVEGONE) { + if (pty->pt_flags & PF_SUBSIDGONE) { error = EIO; goto out; } @@ -588,9 +577,9 @@ again: do { while (!canput(q)) { /* - * Wait for slave's read queue to unclog. + * Wait for subsidiary's read queue to unclog. */ - if (pty->pt_flags & PF_SLAVEGONE) { + if (pty->pt_flags & PF_SUBSIDGONE) { error = EIO; goto out; } @@ -763,7 +752,7 @@ ptcioctl(dev_t dev, int cmd, intptr_t data, int flag, struct cred *cred, case TIOCSIGNAL: /* - * Blast a M_PCSIG message up the slave stream; the + * Blast a M_PCSIG message up the subsidiary stream; the * signal number is the argument to the "ioctl". */ copy_in(data, d_arg); @@ -794,7 +783,7 @@ ptcioctl(dev_t dev, int cmd, intptr_t data, int flag, struct cred *cred, break; /* - * These, at least, can work on the controller-side process + * These, at least, can work on the manager-side process * group. */ case FIOGETOWN: @@ -813,9 +802,9 @@ ptcioctl(dev_t dev, int cmd, intptr_t data, int flag, struct cred *cred, case FIONREAD: { /* - * Return the total number of bytes of data in all messages - * in slave write queue, which is master read queue, unless a - * special message would be read. + * Return the total number of bytes of data in all messages in + * subsidiary write queue, which is manager read queue, unless + * a special message would be read. */ mblk_t *mp; size_t count = 0; @@ -916,13 +905,13 @@ ptcioctl(dev_t dev, int cmd, intptr_t data, int flag, struct cred *cred, /* * XXX These should not be here. The only reason why an - * "ioctl" on the controller side should get the - * slave side's process group is so that the process on - * the controller side can send a signal to the slave + * "ioctl" on the manager side should get the + * subsidiary side's process group is so that the process on + * the manager side can send a signal to the subsidiary * side's process group; however, this is better done * with TIOCSIGNAL, both because it doesn't require us - * to know about the slave side's process group and because - * the controller side process may not have permission to + * to know about the subsidiary side's process group and because + * the manager side process may not have permission to * send that signal to the entire process group. * * However, since vanilla 4BSD doesn't provide TIOCSIGNAL, @@ -933,9 +922,9 @@ ptcioctl(dev_t dev, int cmd, intptr_t data, int flag, struct cred *cred, /* * This is amazingly disgusting, but the stupid semantics of * 4BSD pseudo-ttys makes us do it. If we do one of these guys - * on the controller side, it really applies to the slave-side + * on the manager side, it really applies to the subsidiary-side * stream. It should NEVER have been possible to do ANY sort - * of tty operations on the controller side, but it's too late + * of tty operations on the manager side, but it's too late * to fix that now. However, we won't waste our time implementing * anything that the original pseudo-tty driver didn't handle. */ @@ -983,9 +972,6 @@ ptcpoll(dev_t dev, short events, int anyyet, short *reventsp, queue_t *q; int pos = 0; -#ifdef lint - anyyet = anyyet; -#endif if (polllock(php, &pty->ptc_lock) != 0) { *reventsp = POLLNVAL; return (0); @@ -994,7 +980,7 @@ ptcpoll(dev_t dev, short events, int anyyet, short *reventsp, ASSERT(MUTEX_HELD(&pty->ptc_lock)); *reventsp = 0; - if (pty->pt_flags & PF_SLAVEGONE) { + if (pty->pt_flags & PF_SUBSIDGONE) { if (events & (POLLIN|POLLRDNORM)) *reventsp |= (events & (POLLIN|POLLRDNORM)); if (events & (POLLOUT|POLLWRNORM)) diff --git a/usr/src/uts/common/io/ufmtest.c b/usr/src/uts/common/io/ufmtest.c index 25c4af8fee..241d71d5c5 100644 --- a/usr/src/uts/common/io/ufmtest.c +++ b/usr/src/uts/common/io/ufmtest.c @@ -256,7 +256,7 @@ ufmtest_do_setfw(intptr_t data, int mode) ufmt.ufmt_nvl = NULL; } - nvlbuf = kmem_zalloc(setfw.utsw_bufsz, KM_NOSLEEP | KM_NORMALPRI); + nvlbuf = kmem_zalloc(setfw.utsw_bufsz, KM_NOSLEEP_LAZY); if (nvlbuf == NULL) return (ENOMEM); diff --git a/usr/src/uts/common/io/usb/clients/ccid/ccid.c b/usr/src/uts/common/io/usb/clients/ccid/ccid.c index 9631a99283..60574f8aa1 100644 --- a/usr/src/uts/common/io/usb/clients/ccid/ccid.c +++ b/usr/src/uts/common/io/usb/clients/ccid/ccid.c @@ -1636,7 +1636,7 @@ ccid_command_alloc(ccid_t *ccid, ccid_slot_t *slot, boolean_t block, kmflag = KM_SLEEP; usbflag = USB_FLAGS_SLEEP; } else { - kmflag = KM_NOSLEEP | KM_NORMALPRI; + kmflag = KM_NOSLEEP_LAZY; usbflag = 0; } diff --git a/usr/src/uts/common/io/zcons.c b/usr/src/uts/common/io/zcons.c index 8430e3e8cb..eb74c3a039 100644 --- a/usr/src/uts/common/io/zcons.c +++ b/usr/src/uts/common/io/zcons.c @@ -30,18 +30,18 @@ * This driver, derived from the pts/ptm drivers, is the pseudo console driver * for system zones. Its implementation is straightforward. Each instance * of the driver represents a global-zone/local-zone pair (this maps in a - * straightforward way to the commonly used terminal notion of "master side" - * and "slave side", and we use that terminology throughout). + * straightforward way to the commonly used terminal notion of "manager side" + * and "subsidiary side", and we use that terminology throughout). * * Instances of zcons are onlined as children of /pseudo/zconsnex@1/ * by zoneadmd in userland, using the devctl framework; thus the driver * does not need to maintain any sort of "admin" node. * - * The driver shuttles I/O from master side to slave side and back. In a break - * from the pts/ptm semantics, if one side is not open, I/O directed towards - * it will simply be discarded. This is so that if zoneadmd is not holding - * the master side console open (i.e. it has died somehow), processes in - * the zone do not experience any errors and I/O to the console does not + * The driver shuttles I/O from manager side to subsidiary side and back. In a + * break from the pts/ptm semantics, if one side is not open, I/O directed + * towards it will simply be discarded. This is so that if zoneadmd is not + * holding the manager side console open (i.e. it has died somehow), processes + * in the zone do not experience any errors and I/O to the console does not * hang. * * TODO: we may want to revisit the other direction; i.e. we may want @@ -50,64 +50,67 @@ * * * - * MASTER SIDE IOCTLS + * MANAGER SIDE IOCTLS * - * The ZC_HOLDSLAVE and ZC_RELEASESLAVE ioctls instruct the master side of the - * console to hold and release a reference to the slave side's vnode. They are - * meant to be issued by zoneadmd after the console device node is created and - * before it is destroyed so that the slave's STREAMS anchor, ptem, is - * preserved when ttymon starts popping STREAMS modules from within the - * associated zone. This guarantees that the zone console will always have + * The ZC_HOLDSUBSID and ZC_RELEASESUBSID ioctls instruct the manager side of + * the console to hold and release a reference to the subsidiary side's vnode. + * They are meant to be issued by zoneadmd after the console device node is + * created and before it is destroyed so that the subsidiary's STREAMS anchor, + * ptem, is preserved when ttymon starts popping STREAMS modules from within + * the associated zone. This guarantees that the zone console will always have * terminal semantics while the zone is running. * * Here is the issue: the ptem module is anchored in the zone console - * (slave side) so that processes within the associated non-global zone will - * fail to pop it off, thus ensuring that the slave will retain terminal - * semantics. When a process attempts to pop the anchor off of a stream, the - * STREAMS subsystem checks whether the calling process' zone is the same as - * that of the process that pushed the anchor onto the stream and cancels the - * pop if they differ. zoneadmd used to hold an open file descriptor for the - * slave while the associated non-global zone ran, thus ensuring that the - * slave's STREAMS anchor would never be popped from within the non-global zone - * (because zoneadmd runs in the global zone). However, this file descriptor - * was removed to make zone console management more robust. sad(7D) is now - * used to automatically set up the slave's STREAMS modules when the zone - * console is freshly opened within the associated non-global zone. However, - * when a process within the non-global zone freshly opens the zone console, the - * anchor is pushed from within the non-global zone, making it possible for - * processes within the non-global zone (e.g., ttymon) to pop the anchor and - * destroy the zone console's terminal semantics. + * (subsidiary side) so that processes within the associated non-global zone + * will fail to pop it off, thus ensuring that the subsidiary will retain + * terminal semantics. When a process attempts to pop the anchor off of a + * stream, the STREAMS subsystem checks whether the calling process' zone is + * the same as that of the process that pushed the anchor onto the stream and + * cancels the pop if they differ. zoneadmd used to hold an open file + * descriptor for the subsidiary while the associated non-global zone ran, thus + * ensuring that the subsidiary's STREAMS anchor would never be popped from + * within the non-global zone (because zoneadmd runs in the global zone). + * However, this file descriptor was removed to make zone console management + * more robust. sad(7D) is now used to automatically set up the subsidiary's + * STREAMS modules when the zone console is freshly opened within the + * associated non-global zone. However, when a process within the non-global + * zone freshly opens the zone console, the anchor is pushed from within the + * non-global zone, making it possible for processes within the non-global zone + * (e.g., ttymon) to pop the anchor and destroy the zone console's terminal + * semantics. * - * One solution is to make the zcons device hold the slave open while the + * One solution is to make the zcons device hold the subsidiary open while the * associated non-global zone runs so that the STREAMS anchor will always be - * associated with the global zone. Unfortunately, the slave cannot be opened - * from within the zcons driver because the driver is not reentrant: it has - * an outer STREAMS perimeter. Therefore, the next best option is for zcons to - * provide an ioctl interface to zoneadmd to manage holding and releasing - * the slave side of the console. It is sufficient to hold the slave side's - * vnode and bump the associated snode's reference count to preserve the slave's - * STREAMS configuration while the associated zone runs, so that's what the - * ioctls do. + * associated with the global zone. Unfortunately, the subsidiary cannot be + * opened from within the zcons driver because the driver is not reentrant: it + * has an outer STREAMS perimeter. Therefore, the next best option is for + * zcons to provide an ioctl interface to zoneadmd to manage holding and + * releasing the subsidiary side of the console. It is sufficient to hold the + * subsidiary side's vnode and bump the associated snode's reference count to + * preserve the subsidiary's STREAMS configuration while the associated zone + * runs, so that's what the ioctls do. * * - * ZC_HOLDSLAVE + * ZC_HOLDSUBSID * * This ioctl takes a file descriptor as an argument. It effectively gets a - * reference to the slave side's minor node's vnode and bumps the associated - * snode's reference count. The vnode reference is stored in the zcons device - * node's soft state. This ioctl succeeds if the given file descriptor refers - * to the slave side's minor node or if there is already a reference to the - * slave side's minor node's vnode in the device's soft state. + * reference to the subsidiary side's minor node's vnode and bumps the + * associated snode's reference count. The vnode reference is stored in the + * zcons device node's soft state. This ioctl succeeds if the given file + * descriptor refers to the subsidiary side's minor node or if there is already + * a reference to the subsidiary side's minor node's vnode in the device's soft + * state. * * - * ZC_RELEASESLAVE + * ZC_RELEASESUBSID * * This ioctl takes a file descriptor as an argument. It effectively releases * the vnode reference stored in the zcons device node's soft state (which was - * previously acquired via ZC_HOLDSLAVE) and decrements the reference count of + * previously acquired via ZC_HOLDSUBSID) and decrements the reference count of * the snode associated with the vnode. This ioctl succeeds if the given file - * descriptor refers to the slave side's minor node or if no reference to the - * slave side's minor node's vnode is stored in the device's soft state. + * descriptor refers to the subsidiary side's minor node or if no reference to + * the subsidiary side's minor node's vnode is stored in the device's soft + * state. * * * Note that the file descriptor arguments for both ioctls must be cast to @@ -117,35 +120,36 @@ * * Zone boot: * 1. While booting the zone, zoneadmd creates an instance of zcons. - * 2. zoneadmd opens the master and slave sides of the new zone console - * and issues the ZC_HOLDSLAVE ioctl on the master side, passing its - * file descriptor for the slave side as the ioctl argument. - * 3. zcons holds the slave side's vnode, bumps the snode's reference + * 2. zoneadmd opens the manager and subsidiary sides of the new zone + * console and issues the ZC_HOLDSUBSID ioctl on the manager side, + * passing its file descriptor for the subsidiary side as the ioctl + * argument. + * 3. zcons holds the subsidiary side's vnode, bumps the snode's reference * count, and stores a pointer to the vnode in the device's soft * state. - * 4. zoneadmd closes the master and slave sides and continues to boot - * the zone. + * 4. zoneadmd closes the manager and subsidiary sides and continues to + * boot the zone. * * Zone halt: - * 1. While halting the zone, zoneadmd opens the master and slave sides - * of the zone's console and issues the ZC_RELEASESLAVE ioctl on the - * master side, passing its file descriptor for the slave side as the - * ioctl argument. - * 2. zcons decrements the slave side's snode's reference count, releases - * the slave's vnode, and eliminates its reference to the vnode in the - * device's soft state. - * 3. zoneadmd closes the master and slave sides. + * 1. While halting the zone, zoneadmd opens the manager and subsidiary + * sides of the zone's console and issues the ZC_RELEASESUBSID ioctl on + * the manager side, passing its file descriptor for the subsidiary + * side as the ioctl argument. + * 2. zcons decrements the subsidiary side's snode's reference count, + * releases the subsidiary's vnode, and eliminates its reference to the + * vnode in the device's soft state. + * 3. zoneadmd closes the manager and subsidiary sides. * 4. zoneadmd destroys the zcons device and continues to halt the zone. * - * It is necessary for zoneadmd to hold the slave open while issuing - * ZC_RELEASESLAVE because zcons might otherwise release the last reference to - * the slave's vnode. If it does, then specfs will panic because it will expect - * that the STREAMS configuration for the vnode was destroyed, which VN_RELE - * doesn't do. Forcing zoneadmd to hold the slave open guarantees that zcons - * won't release the vnode's last reference. zoneadmd will properly destroy the - * vnode and the snode when it closes the file descriptor. + * It is necessary for zoneadmd to hold the subsidiary open while issuing + * ZC_RELEASESUBSID because zcons might otherwise release the last reference to + * the subsidiary's vnode. If it does, then specfs will panic because it will + * expect that the STREAMS configuration for the vnode was destroyed, which + * VN_RELE doesn't do. Forcing zoneadmd to hold the subsidiary open guarantees + * that zcons won't release the vnode's last reference. zoneadmd will properly + * destroy the vnode and the snode when it closes the file descriptor. * - * Technically, any process that can access the master side can issue these + * Technically, any process that can access the manager side can issue these * ioctls, but they should be treated as private interfaces for zoneadmd. */ @@ -186,21 +190,22 @@ static int zc_wsrv(queue_t *); /* * The instance number is encoded in the dev_t in the minor number; the lowest - * bit of the minor number is used to track the master vs. slave side of the - * virtual console. The rest of the bits in the minor number are the instance. + * bit of the minor number is used to track the manager vs. subsidiary side of + * the virtual console. The rest of the bits in the minor number are the + * instance. */ -#define ZC_MASTER_MINOR 0 -#define ZC_SLAVE_MINOR 1 +#define ZC_MANAGER_MINOR 0 +#define ZC_SUBSID_MINOR 1 #define ZC_INSTANCE(x) (getminor((x)) >> 1) #define ZC_NODE(x) (getminor((x)) & 0x01) /* - * This macro converts a zc_state_t pointer to the associated slave minor node's - * dev_t. + * This macro converts a zc_state_t pointer to the associated subsidiary minor + * node's dev_t. */ -#define ZC_STATE_TO_SLAVEDEV(x) (makedevice(ddi_driver_major((x)->zc_devinfo), \ - (minor_t)(ddi_get_instance((x)->zc_devinfo) << 1 | ZC_SLAVE_MINOR))) +#define ZC_STATE_TO_SUBDEV(x) (makedevice(ddi_driver_major((x)->zc_devinfo), \ + (minor_t)(ddi_get_instance((x)->zc_devinfo) << 1 | ZC_SUBSID_MINOR))) int zcons_debug = 0; #define DBG(a) if (zcons_debug) cmn_err(CE_NOTE, a) @@ -272,9 +277,9 @@ static struct modlinkage modlinkage = { typedef struct zc_state { dev_info_t *zc_devinfo; - queue_t *zc_master_rdq; - queue_t *zc_slave_rdq; - vnode_t *zc_slave_vnode; + queue_t *zc_manager_rdq; + queue_t *zc_subsid_rdq; + vnode_t *zc_subsid_vnode; int zc_state; } zc_state_t; @@ -284,7 +289,7 @@ typedef struct zc_state { static void *zc_soft_state; /* - * List of STREAMS modules that should be pushed onto every slave instance. + * List of STREAMS modules that should be pushed onto every subsidiary instance. */ static char *zcons_mods[] = { "ptem", @@ -343,12 +348,12 @@ zc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) return (DDI_FAILURE); /* - * Create the master and slave minor nodes. + * Create the manager and subsidiary minor nodes. */ - if ((ddi_create_minor_node(dip, ZCONS_SLAVE_NAME, S_IFCHR, - instance << 1 | ZC_SLAVE_MINOR, DDI_PSEUDO, 0) == DDI_FAILURE) || - (ddi_create_minor_node(dip, ZCONS_MASTER_NAME, S_IFCHR, - instance << 1 | ZC_MASTER_MINOR, DDI_PSEUDO, 0) == DDI_FAILURE)) { + if ((ddi_create_minor_node(dip, ZCONS_SUBSIDIARY_NAME, S_IFCHR, + instance << 1 | ZC_SUBSID_MINOR, DDI_PSEUDO, 0) == DDI_FAILURE) || + (ddi_create_minor_node(dip, ZCONS_MANAGER_NAME, S_IFCHR, + instance << 1 | ZC_MANAGER_MINOR, DDI_PSEUDO, 0) == DDI_FAILURE)) { ddi_remove_minor_node(dip, NULL); ddi_soft_state_free(zc_soft_state, instance); return (DDI_FAILURE); @@ -388,7 +393,6 @@ zc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) * zc_getinfo() * getinfo(9e) entrypoint. */ -/*ARGSUSED*/ static int zc_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) { @@ -410,7 +414,7 @@ zc_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result) /* * Return the equivalent queue from the other side of the relationship. - * e.g.: given the slave's write queue, return the master's write queue. + * e.g.: given the subsidiary's write queue, return the manager's write queue. */ static queue_t * zc_switch(queue_t *qp) @@ -418,16 +422,19 @@ zc_switch(queue_t *qp) zc_state_t *zcs = qp->q_ptr; ASSERT(zcs != NULL); - if (qp == zcs->zc_master_rdq) - return (zcs->zc_slave_rdq); - else if (OTHERQ(qp) == zcs->zc_master_rdq && zcs->zc_slave_rdq != NULL) - return (OTHERQ(zcs->zc_slave_rdq)); - else if (qp == zcs->zc_slave_rdq) - return (zcs->zc_master_rdq); - else if (OTHERQ(qp) == zcs->zc_slave_rdq && zcs->zc_master_rdq != NULL) - return (OTHERQ(zcs->zc_master_rdq)); - else + if (qp == zcs->zc_manager_rdq) { + return (zcs->zc_subsid_rdq); + } else if (OTHERQ(qp) == zcs->zc_manager_rdq && + zcs->zc_subsid_rdq != NULL) { + return (OTHERQ(zcs->zc_subsid_rdq)); + } else if (qp == zcs->zc_subsid_rdq) { + return (zcs->zc_manager_rdq); + } else if (OTHERQ(qp) == zcs->zc_subsid_rdq && + zcs->zc_manager_rdq != NULL) { + return (OTHERQ(zcs->zc_manager_rdq)); + } else { return (NULL); + } } /* @@ -440,17 +447,16 @@ zc_side(queue_t *qp) zc_state_t *zcs = qp->q_ptr; ASSERT(zcs != NULL); - if (qp == zcs->zc_master_rdq || - OTHERQ(qp) == zcs->zc_master_rdq) { - return ("master"); + if (qp == zcs->zc_manager_rdq || + OTHERQ(qp) == zcs->zc_manager_rdq) { + return ("manager"); } - ASSERT(qp == zcs->zc_slave_rdq || OTHERQ(qp) == zcs->zc_slave_rdq); - return ("slave"); + ASSERT(qp == zcs->zc_subsid_rdq || OTHERQ(qp) == zcs->zc_subsid_rdq); + return ("subsidiary"); } -/*ARGSUSED*/ static int -zc_master_open(zc_state_t *zcs, +zc_manager_open(zc_state_t *zcs, queue_t *rqp, /* pointer to the read side queue */ dev_t *devp, /* pointer to stream tail's dev */ int oflag, /* the user open(2) supplied flags */ @@ -461,14 +467,14 @@ zc_master_open(zc_state_t *zcs, struct stroptions *sop; /* - * Enforce exclusivity on the master side; the only consumer should + * Enforce exclusivity on the manager side; the only consumer should * be the zoneadmd for the zone. */ if ((zcs->zc_state & ZC_STATE_MOPEN) != 0) return (EBUSY); if ((mop = allocb(sizeof (struct stroptions), BPRI_MED)) == NULL) { - DBG("zc_master_open(): mop allocation failed\n"); + DBG("zc_manager_open(): mop allocation failed\n"); return (ENOMEM); } @@ -482,13 +488,13 @@ zc_master_open(zc_state_t *zcs, qprocson(rqp); /* - * Following qprocson(), the master side is fully plumbed into the - * STREAM and may send/receive messages. Setting zcs->zc_master_rdq - * will allow the slave to send messages to us (the master). - * This cannot occur before qprocson() because the master is not + * Following qprocson(), the manager side is fully plumbed into the + * STREAM and may send/receive messages. Setting zcs->zc_manager_rdq + * will allow the subsidiary to send messages to us (the manager). + * This cannot occur before qprocson() because the manager is not * ready to process them until that point. */ - zcs->zc_master_rdq = rqp; + zcs->zc_manager_rdq = rqp; /* * set up hi/lo water marks on stream head read queue and add @@ -508,9 +514,8 @@ zc_master_open(zc_state_t *zcs, return (0); } -/*ARGSUSED*/ static int -zc_slave_open(zc_state_t *zcs, +zc_subsidiary_open(zc_state_t *zcs, queue_t *rqp, /* pointer to the read side queue */ dev_t *devp, /* pointer to stream tail's dev */ int oflag, /* the user open(2) supplied flags */ @@ -525,7 +530,7 @@ zc_slave_open(zc_state_t *zcs, uint_t anchorindex; /* - * The slave side can be opened as many times as needed. + * The subsidiary side can be opened as many times as needed. */ if ((zcs->zc_state & ZC_STATE_SOPEN) != 0) { ASSERT((rqp != NULL) && (WR(rqp)->q_ptr == zcs)); @@ -538,18 +543,18 @@ zc_slave_open(zc_state_t *zcs, * in place (see streamio(7i)) because we always want the console to * have terminal semantics. */ - minor = ddi_get_instance(zcs->zc_devinfo) << 1 | ZC_SLAVE_MINOR; + minor = ddi_get_instance(zcs->zc_devinfo) << 1 | ZC_SUBSID_MINOR; major = ddi_driver_major(zcs->zc_devinfo); lastminor = 0; anchorindex = 1; if (kstr_autopush(SET_AUTOPUSH, &major, &minor, &lastminor, &anchorindex, zcons_mods) != 0) { - DBG("zc_slave_open(): kstr_autopush() failed\n"); + DBG("zc_subsidiary_open(): kstr_autopush() failed\n"); return (EIO); } if ((mop = allocb(sizeof (struct stroptions), BPRI_MED)) == NULL) { - DBG("zc_slave_open(): mop allocation failed\n"); + DBG("zc_subsidiary_open(): mop allocation failed\n"); return (ENOMEM); } @@ -566,7 +571,7 @@ zc_slave_open(zc_state_t *zcs, /* * Must follow qprocson(), since we aren't ready to process until then. */ - zcs->zc_slave_rdq = rqp; + zcs->zc_subsid_rdq = rqp; /* * set up hi/lo water marks on stream head read queue and add @@ -604,11 +609,11 @@ zc_open(queue_t *rqp, /* pointer to the read side queue */ return (ENXIO); switch (ZC_NODE(*devp)) { - case ZC_MASTER_MINOR: - ret = zc_master_open(zcs, rqp, devp, oflag, sflag, credp); + case ZC_MANAGER_MINOR: + ret = zc_manager_open(zcs, rqp, devp, oflag, sflag, credp); break; - case ZC_SLAVE_MINOR: - ret = zc_slave_open(zcs, rqp, devp, oflag, sflag, credp); + case ZC_SUBSID_MINOR: + ret = zc_subsidiary_open(zcs, rqp, devp, oflag, sflag, credp); break; default: ret = ENXIO; @@ -621,7 +626,6 @@ zc_open(queue_t *rqp, /* pointer to the read side queue */ /* * close(9e) entrypoint. */ -/*ARGSUSED1*/ static int zc_close(queue_t *rqp, int flag, cred_t *credp) { @@ -633,33 +637,33 @@ zc_close(queue_t *rqp, int flag, cred_t *credp) zcs = (zc_state_t *)rqp->q_ptr; - if (rqp == zcs->zc_master_rdq) { - DBG("Closing master side"); + if (rqp == zcs->zc_manager_rdq) { + DBG("Closing manager side"); - zcs->zc_master_rdq = NULL; + zcs->zc_manager_rdq = NULL; zcs->zc_state &= ~ZC_STATE_MOPEN; /* - * qenable slave side write queue so that it can flush - * its messages as master's read queue is going away + * qenable subsidiary side write queue so that it can flush + * its messages as manager's read queue is going away */ - if (zcs->zc_slave_rdq != NULL) { - qenable(WR(zcs->zc_slave_rdq)); + if (zcs->zc_subsid_rdq != NULL) { + qenable(WR(zcs->zc_subsid_rdq)); } qprocsoff(rqp); WR(rqp)->q_ptr = rqp->q_ptr = NULL; - } else if (rqp == zcs->zc_slave_rdq) { + } else if (rqp == zcs->zc_subsid_rdq) { - DBG("Closing slave side"); + DBG("Closing subsidiary side"); zcs->zc_state &= ~ZC_STATE_SOPEN; - zcs->zc_slave_rdq = NULL; + zcs->zc_subsid_rdq = NULL; wqp = WR(rqp); while ((bp = getq(wqp)) != NULL) { - if (zcs->zc_master_rdq != NULL) - putnext(zcs->zc_master_rdq, bp); + if (zcs->zc_manager_rdq != NULL) + putnext(zcs->zc_manager_rdq, bp); else if (bp->b_datap->db_type == M_IOCTL) miocnak(wqp, bp, 0, 0); else @@ -667,11 +671,11 @@ zc_close(queue_t *rqp, int flag, cred_t *credp) } /* - * Qenable master side write queue so that it can flush its - * messages as slaves's read queue is going away. + * Qenable manager side write queue so that it can flush its + * messages as subsidiarys's read queue is going away. */ - if (zcs->zc_master_rdq != NULL) - qenable(WR(zcs->zc_master_rdq)); + if (zcs->zc_manager_rdq != NULL) + qenable(WR(zcs->zc_manager_rdq)); qprocsoff(rqp); WR(rqp)->q_ptr = rqp->q_ptr = NULL; @@ -681,7 +685,8 @@ zc_close(queue_t *rqp, int flag, cred_t *credp) * to set up sad configuration. */ major = ddi_driver_major(zcs->zc_devinfo); - minor = ddi_get_instance(zcs->zc_devinfo) << 1 | ZC_SLAVE_MINOR; + minor = ddi_get_instance(zcs->zc_devinfo) << 1 | + ZC_SUBSID_MINOR; (void) kstr_autopush(CLR_AUTOPUSH, &major, &minor, NULL, NULL, NULL); } @@ -729,9 +734,9 @@ handle_mflush(queue_t *qp, mblk_t *mp) } /* - * wput(9E) is symmetric for master and slave sides, so this handles both + * wput(9E) is symmetric for manager and subsidiary sides, so this handles both * without splitting the codepath. (The only exception to this is the - * processing of zcons ioctls, which is restricted to the master side.) + * processing of zcons ioctls, which is restricted to the manager side.) * * zc_wput() looks at the other side; if there is no process holding that * side open, it frees the message. This prevents processes from hanging @@ -746,34 +751,34 @@ zc_wput(queue_t *qp, mblk_t *mp) unsigned char type = mp->b_datap->db_type; zc_state_t *zcs; struct iocblk *iocbp; - file_t *slave_filep; - struct snode *slave_snodep; - int slave_fd; + file_t *subsidiary_filep; + struct snode *subsidiary_snodep; + int subsidiary_fd; ASSERT(qp->q_ptr); DBG1("entering zc_wput, %s side", zc_side(qp)); /* - * Process zcons ioctl messages if qp is the master console's write + * Process zcons ioctl messages if qp is the manager console's write * queue. */ zcs = (zc_state_t *)qp->q_ptr; - if (zcs->zc_master_rdq != NULL && qp == WR(zcs->zc_master_rdq) && + if (zcs->zc_manager_rdq != NULL && qp == WR(zcs->zc_manager_rdq) && type == M_IOCTL) { iocbp = (struct iocblk *)(void *)mp->b_rptr; switch (iocbp->ioc_cmd) { - case ZC_HOLDSLAVE: + case ZC_HOLDSUBSID: /* - * Hold the slave's vnode and increment the refcount - * of the snode. If the vnode is already held, then - * indicate success. + * Hold the subsidiary's vnode and increment the + * refcount of the snode. If the vnode is already + * held, then indicate success. */ if (iocbp->ioc_count != TRANSPARENT) { miocack(qp, mp, 0, EINVAL); return (0); } - if (zcs->zc_slave_vnode != NULL) { + if (zcs->zc_subsid_vnode != NULL) { miocack(qp, mp, 0, 0); return (0); } @@ -789,49 +794,49 @@ zc_wput(queue_t *qp, mblk_t *mp) /* * The calling process must pass a file descriptor for - * the slave device. + * the subsidiary device. */ - slave_fd = + subsidiary_fd = (int)(intptr_t)*(caddr_t *)(void *)mp->b_cont-> b_rptr; - slave_filep = getf(slave_fd); - if (slave_filep == NULL) { + subsidiary_filep = getf(subsidiary_fd); + if (subsidiary_filep == NULL) { miocack(qp, mp, 0, EINVAL); return (0); } - if (ZC_STATE_TO_SLAVEDEV(zcs) != - slave_filep->f_vnode->v_rdev) { - releasef(slave_fd); + if (ZC_STATE_TO_SUBDEV(zcs) != + subsidiary_filep->f_vnode->v_rdev) { + releasef(subsidiary_fd); miocack(qp, mp, 0, EINVAL); return (0); } /* - * Get a reference to the slave's vnode. Also bump the - * reference count on the associated snode. + * Get a reference to the subsidiary's vnode. Also + * bump the reference count on the associated snode. */ - ASSERT(vn_matchops(slave_filep->f_vnode, + ASSERT(vn_matchops(subsidiary_filep->f_vnode, spec_getvnodeops())); - zcs->zc_slave_vnode = slave_filep->f_vnode; - VN_HOLD(zcs->zc_slave_vnode); - slave_snodep = VTOCS(zcs->zc_slave_vnode); - mutex_enter(&slave_snodep->s_lock); - ++slave_snodep->s_count; - mutex_exit(&slave_snodep->s_lock); - releasef(slave_fd); + zcs->zc_subsid_vnode = subsidiary_filep->f_vnode; + VN_HOLD(zcs->zc_subsid_vnode); + subsidiary_snodep = VTOCS(zcs->zc_subsid_vnode); + mutex_enter(&subsidiary_snodep->s_lock); + ++subsidiary_snodep->s_count; + mutex_exit(&subsidiary_snodep->s_lock); + releasef(subsidiary_fd); miocack(qp, mp, 0, 0); return (0); - case ZC_RELEASESLAVE: + case ZC_RELEASESUBSID: /* - * Release the master's handle on the slave's vnode. - * If there isn't a handle for the vnode, then indicate - * success. + * Release the manager's handle on the subsidiary's + * vnode. If there isn't a handle for the vnode, then + * indicate success. */ if (iocbp->ioc_count != TRANSPARENT) { miocack(qp, mp, 0, EINVAL); return (0); } - if (zcs->zc_slave_vnode == NULL) { + if (zcs->zc_subsid_vnode == NULL) { miocack(qp, mp, 0, 0); return (0); } @@ -847,20 +852,20 @@ zc_wput(queue_t *qp, mblk_t *mp) /* * The process that passed the ioctl must have provided - * a file descriptor for the slave device. Make sure - * this is correct. + * a file descriptor for the subsidiary device. Make + * sure this is correct. */ - slave_fd = + subsidiary_fd = (int)(intptr_t)*(caddr_t *)(void *)mp->b_cont-> b_rptr; - slave_filep = getf(slave_fd); - if (slave_filep == NULL) { + subsidiary_filep = getf(subsidiary_fd); + if (subsidiary_filep == NULL) { miocack(qp, mp, 0, EINVAL); return (0); } - if (zcs->zc_slave_vnode->v_rdev != - slave_filep->f_vnode->v_rdev) { - releasef(slave_fd); + if (zcs->zc_subsid_vnode->v_rdev != + subsidiary_filep->f_vnode->v_rdev) { + releasef(subsidiary_fd); miocack(qp, mp, 0, EINVAL); return (0); } @@ -869,15 +874,15 @@ zc_wput(queue_t *qp, mblk_t *mp) * Decrement the snode's reference count and release the * vnode. */ - ASSERT(vn_matchops(slave_filep->f_vnode, + ASSERT(vn_matchops(subsidiary_filep->f_vnode, spec_getvnodeops())); - slave_snodep = VTOCS(zcs->zc_slave_vnode); - mutex_enter(&slave_snodep->s_lock); - --slave_snodep->s_count; - mutex_exit(&slave_snodep->s_lock); - VN_RELE(zcs->zc_slave_vnode); - zcs->zc_slave_vnode = NULL; - releasef(slave_fd); + subsidiary_snodep = VTOCS(zcs->zc_subsid_vnode); + mutex_enter(&subsidiary_snodep->s_lock); + --subsidiary_snodep->s_count; + mutex_exit(&subsidiary_snodep->s_lock); + VN_RELE(zcs->zc_subsid_vnode); + zcs->zc_subsid_vnode = NULL; + releasef(subsidiary_fd); miocack(qp, mp, 0, 0); return (0); default: @@ -939,7 +944,7 @@ zc_wput(queue_t *qp, mblk_t *mp) } /* - * rsrv(9E) is symmetric for master and slave, so zc_rsrv() handles both + * rsrv(9E) is symmetric for manager and subsidiary, so zc_rsrv() handles both * without splitting up the codepath. * * Enable the write side of the partner. This triggers the partner to send @@ -952,10 +957,10 @@ zc_rsrv(queue_t *qp) zcs = (zc_state_t *)qp->q_ptr; /* - * Care must be taken here, as either of the master or slave side + * Care must be taken here, as either of the manager or subsidiary side * qptr could be NULL. */ - ASSERT(qp == zcs->zc_master_rdq || qp == zcs->zc_slave_rdq); + ASSERT(qp == zcs->zc_manager_rdq || qp == zcs->zc_subsid_rdq); if (zc_switch(qp) == NULL) { DBG("zc_rsrv: other side isn't listening\n"); return (0); @@ -965,8 +970,8 @@ zc_rsrv(queue_t *qp) } /* - * This routine is symmetric for master and slave, so it handles both without - * splitting up the codepath. + * This routine is symmetric for manager and subsidiary, so it handles both + * without splitting up the codepath. * * If there are messages on this queue that can be sent to the other, send * them via putnext(). Else, if queued messages cannot be sent, leave them @@ -977,7 +982,7 @@ zc_wsrv(queue_t *qp) { mblk_t *mp; - DBG1("zc_wsrv master (%s) side", zc_side(qp)); + DBG1("zc_wsrv manager (%s) side", zc_side(qp)); /* * Partner has no read queue, so take the data, and throw it away. diff --git a/usr/src/uts/common/os/ddi_ufm.c b/usr/src/uts/common/os/ddi_ufm.c index 7e863bdac2..3610df8bac 100644 --- a/usr/src/uts/common/os/ddi_ufm.c +++ b/usr/src/uts/common/os/ddi_ufm.c @@ -181,7 +181,7 @@ ufm_cache_fill(ddi_ufm_handle_t *ufmh) */ ufmh->ufmh_images = kmem_zalloc((sizeof (ddi_ufm_image_t) * ufmh->ufmh_nimages), - KM_NOSLEEP | KM_NORMALPRI); + KM_NOSLEEP_LAZY); if (ufmh->ufmh_images == NULL) return (ENOMEM); @@ -201,7 +201,7 @@ ufm_cache_fill(ddi_ufm_handle_t *ufmh) img->ufmi_slots = kmem_zalloc((sizeof (ddi_ufm_slot_t) * img->ufmi_nslots), - KM_NOSLEEP | KM_NORMALPRI); + KM_NOSLEEP_LAZY); if (img->ufmi_slots == NULL) { ret = ENOMEM; goto cache_fail; diff --git a/usr/src/uts/common/os/vm_pageout.c b/usr/src/uts/common/os/vm_pageout.c index c675a4dfb8..1df2f479a5 100644 --- a/usr/src/uts/common/os/vm_pageout.c +++ b/usr/src/uts/common/os/vm_pageout.c @@ -135,7 +135,7 @@ * v allocations (e.g., KM_SLEEP) are held here while we wait for * | more memory. Non-sleeping allocations are generally allowed to * | proceed, unless their priority is explicitly lowered with - * | KM_NORMALPRI. + * | KM_NORMALPRI (Note: KM_NOSLEEP_LAZY == (KM_NOSLEEP | KM_NORMALPRI).). * | * +------- pageout_reserve (3/4 of throttlefree, 0.44% of physmem, min. 4MB) * | diff --git a/usr/src/uts/common/sys/kmem.h b/usr/src/uts/common/sys/kmem.h index aac2eafa3c..bfc301a521 100644 --- a/usr/src/uts/common/sys/kmem.h +++ b/usr/src/uts/common/sys/kmem.h @@ -23,7 +23,7 @@ * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. - * Copyright 2018, Joyent, Inc. + * Copyright 2022 Joyent, Inc. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ @@ -49,6 +49,7 @@ extern "C" { #define KM_PANIC 0x0002 /* if memory cannot be allocated, panic */ #define KM_PUSHPAGE 0x0004 /* can block for memory; may use reserve */ #define KM_NORMALPRI 0x0008 /* with KM_NOSLEEP, lower priority allocation */ +#define KM_NOSLEEP_LAZY (KM_NOSLEEP | KM_NORMALPRI) /* Syntactic sugar. */ #define KM_VMFLAGS 0x00ff /* flags that must match VM_* flags */ #define KM_FLAGS 0xffff /* all settable kmem flags */ diff --git a/usr/src/uts/common/sys/mac_provider.h b/usr/src/uts/common/sys/mac_provider.h index fc0866f2d1..431de67ff5 100644 --- a/usr/src/uts/common/sys/mac_provider.h +++ b/usr/src/uts/common/sys/mac_provider.h @@ -110,7 +110,7 @@ typedef enum { MAC_CAPAB_LEGACY = 0x00200000, /* data is mac_capab_legacy_t */ MAC_CAPAB_VRRP = 0x00400000, /* data is mac_capab_vrrp_t */ MAC_CAPAB_OVERLAY = 0x00800000, /* boolean only, no data */ - MAC_CAPAB_TRANSCEIVER = 0x01000000, /* mac_capab_transciever_t */ + MAC_CAPAB_TRANSCEIVER = 0x01000000, /* mac_capab_transceiver_t */ MAC_CAPAB_LED = 0x02000000 /* data is mac_capab_led_t */ } mac_capab_t; diff --git a/usr/src/uts/common/sys/overlay_common.h b/usr/src/uts/common/sys/overlay_common.h index d638096006..5c4b651f2c 100644 --- a/usr/src/uts/common/sys/overlay_common.h +++ b/usr/src/uts/common/sys/overlay_common.h @@ -34,7 +34,7 @@ typedef enum overlay_plugin_dest { OVERLAY_PLUGIN_D_INVALID = 0x0, OVERLAY_PLUGIN_D_ETHERNET = 0x1, OVERLAY_PLUGIN_D_IP = 0x2, - OVERLAY_PLUGIN_D_PORT = 0x4, + OVERLAY_PLUGIN_D_PORT = 0x4, OVERLAY_PLUGIN_D_MASK = 0x7 } overlay_plugin_dest_t; @@ -49,7 +49,7 @@ typedef enum overlay_prop_prot { OVERLAY_PROP_PERM_REQ = 0x1, OVERLAY_PROP_PERM_READ = 0x2, OVERLAY_PROP_PERM_WRITE = 0x4, - OVERLAY_PROP_PERM_RW = 0x6, + OVERLAY_PROP_PERM_RW = 0x6, OVERLAY_PROP_PERM_RRW = 0x7, OVERLAY_PROP_PERM_MASK = 0x7 } overlay_prop_prot_t; diff --git a/usr/src/uts/common/sys/overlay_impl.h b/usr/src/uts/common/sys/overlay_impl.h index 7fb8b8da1d..0095c75eeb 100644 --- a/usr/src/uts/common/sys/overlay_impl.h +++ b/usr/src/uts/common/sys/overlay_impl.h @@ -59,7 +59,7 @@ typedef struct overlay_mux { int omux_domain; /* RO: socket domain */ int omux_family; /* RO: socket family */ int omux_protocol; /* RO: socket protocol */ - struct sockaddr *omux_addr; /* RO: socket address */ + struct sockaddr *omux_addr; /* RO: socket address */ socklen_t omux_alen; /* RO: sockaddr len */ kmutex_t omux_lock; /* Protects everything below */ uint_t omux_count; /* Active instances */ diff --git a/usr/src/uts/common/sys/overlay_plugin.h b/usr/src/uts/common/sys/overlay_plugin.h index 07efaa05df..3392973562 100644 --- a/usr/src/uts/common/sys/overlay_plugin.h +++ b/usr/src/uts/common/sys/overlay_plugin.h @@ -54,30 +54,30 @@ * * overlay_plugin_init_t * - * This interface is used to create a new instance of a plugin. An instance - * of a plugin will be created for each overlay device that is created. For - * example, if a device is created with VXLAN ID 23 and ID 42, then there - * will be two different calls to this function. + * This interface is used to create a new instance of a plugin. An instance + * of a plugin will be created for each overlay device that is created. For + * example, if a device is created with VXLAN ID 23 and ID 42, then there + * will be two different calls to this function. * - * This function gives the plugin a chance to create a private data - * structure that will be returned on subsequent calls to the system. + * This function gives the plugin a chance to create a private data + * structure that will be returned on subsequent calls to the system. * * overlay_plugin_fini_t * - * This is the opposite of overlay_plugin_init_t. It will be called when it - * is safe to remove any private data that is associated with this instance - * of the plugin. + * This is the opposite of overlay_plugin_init_t. It will be called when it + * is safe to remove any private data that is associated with this instance + * of the plugin. * * overlay_plugin_propinfo_t * - * This is called with the name of a property that is registered when the - * plugin is created. This function will be called with the name of the - * property that information is being requested about. The plugin is - * responsible for filling out information such as setting the name, the - * type of property it is, the protection of the property (can a user - * update it?), whether the property is required, an optional default value - * for the property, and an optional set of values or ranges that are - * allowed. + * This is called with the name of a property that is registered when the + * plugin is created. This function will be called with the name of the + * property that information is being requested about. The plugin is + * responsible for filling out information such as setting the name, the + * type of property it is, the protection of the property (can a user + * update it?), whether the property is required, an optional default value + * for the property, and an optional set of values or ranges that are + * allowed. * * overlay_plugin_getprop_t * @@ -93,103 +93,103 @@ * * overlay_plugin_socket_t * - * Every overlay device has a corresponding socket that it uses to send and - * receive traffic. This routine is used to get the parameters that should - * be used to define such a socket. The actual socket may be multiplexed - * with other uses of it. + * Every overlay device has a corresponding socket that it uses to send and + * receive traffic. This routine is used to get the parameters that should + * be used to define such a socket. The actual socket may be multiplexed + * with other uses of it. * * overlay_plugin_sockopt_t * - * Allow a plugin to set any necessary socket options that it needs on the - * kernel socket that is being used by a mux. This will only be called once - * for a given mux, if additional devices are added to a mux, it will not - * be called additional times. + * Allow a plugin to set any necessary socket options that it needs on the + * kernel socket that is being used by a mux. This will only be called once + * for a given mux, if additional devices are added to a mux, it will not + * be called additional times. * * overlay_plugin_encap_t * - * In this routine you're given a message block and information about the - * packet, such as the identifier and are asked to fill out a message block - * that represents the encapsulation header and optionally manipulate the - * input message if required. + * In this routine you're given a message block and information about the + * packet, such as the identifier and are asked to fill out a message block + * that represents the encapsulation header and optionally manipulate the + * input message if required. * * overlay_plugin_decap_t * - * In this routine, you're given the encapsulated message block. The - * requirement is to decapsulate it and determine what is the correct - * overlay identifier for this network and to fill in the header size so - * the broader system knows how much of this data should be considered - * consumed. + * In this routine, you're given the encapsulated message block. The + * requirement is to decapsulate it and determine what is the correct + * overlay identifier for this network and to fill in the header size so + * the broader system knows how much of this data should be considered + * consumed. * * ovpo_callbacks * - * This should be set to zero, it's reserved for future use. + * This should be set to zero, it's reserved for future use. * * Once these properties are defined, the module should define the following * members in the overlay_plugin_register_t. * * ovep_version * - * Should be set to the value of the macro OVEP_VERSION. + * Should be set to the value of the macro OVEP_VERSION. * * ovep_name * - * Should be set to a character string that has the name of the module. - * Generally this should match the name of the kernel module; however, this - * is the name that users will use to refer to this module when creating - * devices. + * Should be set to a character string that has the name of the module. + * Generally this should match the name of the kernel module; however, this + * is the name that users will use to refer to this module when creating + * devices. * * overlay_plugin_ops_t * - * Should be set to the functions as described above. + * Should be set to the functions as described above. * * ovep_props * - * This is an array of character strings that holds the names of the - * properties of the encapsulation plugin. + * This is an array of character strings that holds the names of the + * properties of the encapsulation plugin. * * * ovep_id_size * - * This is the size in bytes of the valid range for the identifier. The - * valid identifier range is considered a ovep_id_size byte unsigned - * integer, [ 0, 1 << (ovep_id_size * 8) ). + * This is the size in bytes of the valid range for the identifier. The + * valid identifier range is considered a ovep_id_size byte unsigned + * integer, [ 0, 1 << (ovep_id_size * 8) ). * * ovep_flags * - * A series of flags that indicate optional features that are supported. - * Valid flags include: + * A series of flags that indicate optional features that are supported. + * Valid flags include: * - * OVEP_F_VLAN_TAG + * OVEP_F_VLAN_TAG * - * The encapsulation format allows for the encapsulated - * packet to maintain a VLAN tag. + * The encapsulation format allows for the encapsulated + * packet to maintain a VLAN tag. * * ovep_dest * - * Describes the kind of destination that the overlay plugin supports for - * sending traffic. For example, vxlan uses UDP, therefore it requires both - * an IP address and a port; however, nvgre uses the gre header and - * therefore only requires an IP address. The following flags may be - * combined: + * Describes the kind of destination that the overlay plugin supports for + * sending traffic. For example, vxlan uses UDP, therefore it requires both + * an IP address and a port; however, nvgre uses the gre header and + * therefore only requires an IP address. The following flags may be + * combined: * - * OVERLAY_PLUGIN_D_ETHERNET + * OVERLAY_PLUGIN_D_ETHERNET * - * Indicates that to send a packet to its destination, we - * require a link-layer ethernet address. + * Indicates that to send a packet to its destination, we + * require a link-layer ethernet address. * - * OVERLAY_PLUGIN_D_IP + * OVERLAY_PLUGIN_D_IP * - * Indicates that to send a packet to its destination, we - * require an IP address. Note, all IP addresses are - * transmitted as IPv6 addresses and for an IPv4 - * destination, using an IPv4-mapped IPv6 address is the - * expected way to transmit that. + * Indicates that to send a packet to its destination, we + * require an IP address. Note, all IP addresses are + * transmitted as IPv6 addresses and for an IPv4 + * destination, using an IPv4-mapped IPv6 address is the + * expected way to transmit that. * - * OVERLAY_PLUGIN_D_PORT + * OVERLAY_PLUGIN_D_PORT * - * Indicates that to send a packet to its destination, a - * port is required, this usually indicates that the - * protocol uses something like TCP or UDP. + * Indicates that to send a packet to its destination, a + * port is required, this usually indicates that the + * protocol uses something like TCP or UDP. * * * ------------------------------------------------- @@ -209,7 +209,7 @@ * * While servicing a downcall from the general overlay device framework, a * kernel module should not make any upcalls, excepting those functions that are - * defined in this header file, eg. the property related callbacks. Improtantly, + * defined in this header file, eg. the property related callbacks. Importantly, * it cannot make any assumptions about what locks may or may not be held by the * broader system. The only thing that it is safe for it to use are its own * locks. @@ -291,7 +291,7 @@ typedef struct overlay_plugin_register { uint_t ovep_version; const char *ovep_name; const overlay_plugin_ops_t *ovep_ops; - const char **ovep_props; + const char **ovep_props; uint_t ovep_id_size; uint_t ovep_flags; uint_t ovep_dest; diff --git a/usr/src/uts/common/sys/overlay_target.h b/usr/src/uts/common/sys/overlay_target.h index db9f4b67a9..775c7d27b8 100644 --- a/usr/src/uts/common/sys/overlay_target.h +++ b/usr/src/uts/common/sys/overlay_target.h @@ -120,30 +120,30 @@ typedef struct overlay_targ_id { * drop a packet. * * - * OVERLAY_TARG_INJECT - overlay_targ_pkt_t + * OVERLAY_TARG_INJECT - overlay_targ_pkt_t * - * The overlay_targ_pkt_t injects a fully formed packet into the - * virtual network. It may either be identified by its data link id - * or by the request id. If both are specified, the - * datalink id will be used. Note, that an injection is not - * considered a reply and if this corresponds to a requeset, then - * that individual packet must still be dropped. + * The overlay_targ_pkt_t injects a fully formed packet into the + * virtual network. It may either be identified by its data link id + * or by the request id. If both are specified, the + * datalink id will be used. Note, that an injection is not + * considered a reply and if this corresponds to a request, then + * that individual packet must still be dropped. * * - * OVERLAY_TARG_PKT - overlay_targ_pkt_t + * OVERLAY_TARG_PKT - overlay_targ_pkt_t * - * This ioctl can be used to copy data from a given request into a - * user buffer. This can be used in combination with - * OVERLAY_TARG_INJECT to implemnt services such as a proxy-arp. + * This ioctl can be used to copy data from a given request into a + * user buffer. This can be used in combination with + * OVERLAY_TARG_INJECT to implement services such as a proxy-arp. * * - * OVERLAY_TARG_RESEND - overlay_targ_pkt_t + * OVERLAY_TARG_RESEND - overlay_targ_pkt_t * - * This ioctl is similar to the OVERLAY_TARG_INJECT, except instead - * of receiving it on the local mac handle, it queues it for - * retransmission again. This is useful if you have a packet that - * was originally destined for some broadcast or multicast address - * that you now want to send to a unicast address. + * This ioctl is similar to the OVERLAY_TARG_INJECT, except instead + * of receiving it on the local mac handle, it queues it for + * retransmission again. This is useful if you have a packet that + * was originally destined for some broadcast or multicast address + * that you now want to send to a unicast address. */ #define OVERLAY_TARG_LOOKUP (OVERLAY_TARG_IOCTL | 0x10) #define OVERLAY_TARG_RESPOND (OVERLAY_TARG_IOCTL | 0x11) @@ -210,46 +210,46 @@ typedef struct overlay_targ_list { * The following family of ioctls all manipulate the target cache of a given * device. * - * OVERLAY_TARG_CACHE_GET - overlay_targ_cache_t + * OVERLAY_TARG_CACHE_GET - overlay_targ_cache_t * - * The overlay_targ_cache_t should be have its link identifier and - * the desired mac address filled in. On return, it will fill in - * the otc_dest member, if the entry exists in the table. + * The overlay_targ_cache_t should be have its link identifier and + * the desired mac address filled in. On return, it will fill in + * the otc_dest member, if the entry exists in the table. * * - * OVERLAY_TARG_CACHE_SET - overlay_targ_cache_t + * OVERLAY_TARG_CACHE_SET - overlay_targ_cache_t * - * The cache table entry of the mac address referred to by otc_mac - * and otd_linkid will be filled in with the details provided by in - * the otc_dest member. + * The cache table entry of the mac address referred to by otc_mac + * and otd_linkid will be filled in with the details provided by in + * the otc_dest member. * - * OVERLAY_TARG_CACHE_REMOVE - overlay_targ_cache_t + * OVERLAY_TARG_CACHE_REMOVE - overlay_targ_cache_t * - * Removes the cache entry identified by otc_mac from the table. - * Note that this does not stop any in-flight lookups or deal with - * any data that is awaiting a lookup. + * Removes the cache entry identified by otc_mac from the table. + * Note that this does not stop any in-flight lookups or deal with + * any data that is awaiting a lookup. * * - * OVERLAY_TARG_CACHE_FLUSH - overlay_targ_cache_t + * OVERLAY_TARG_CACHE_FLUSH - overlay_targ_cache_t * - * Similar to OVERLAY_TARG_CACHE_REMOVE, but functions on the - * entire table identified by otc_linkid. All other parameters are - * ignored. + * Similar to OVERLAY_TARG_CACHE_REMOVE, but functions on the + * entire table identified by otc_linkid. All other parameters are + * ignored. * * - * OVERLAY_TARG_CACHE_ITER - overlay_targ_cache_iter_t + * OVERLAY_TARG_CACHE_ITER - overlay_targ_cache_iter_t * - * Iterates over the contents of a target cache identified by - * otci_linkid. Iteration is guaranteed to be exactly once for - * items which are in the hashtable at the beginning and end of - * iteration. For items which are added or removed after iteration - * has begun, only at most once semantics are guaranteed. Consumers - * should ensure that otci_marker is zeroed before starting - * iteration and should preserve its contents across calls. + * Iterates over the contents of a target cache identified by + * otci_linkid. Iteration is guaranteed to be exactly once for + * items which are in the hashtable at the beginning and end of + * iteration. For items which are added or removed after iteration + * has begun, only at most once semantics are guaranteed. Consumers + * should ensure that otci_marker is zeroed before starting + * iteration and should preserve its contents across calls. * - * Before calling in, otci_count should be set to the number of - * entries that space has been allocated for in otci_ents. The - * value will be updated to indicate the total number written out. + * Before calling in, otci_count should be set to the number of + * entries that space has been allocated for in otci_ents. The + * value will be updated to indicate the total number written out. */ #define OVERLAY_TARG_CACHE_GET (OVERLAY_TARG_IOCTL | 0x30) diff --git a/usr/src/uts/common/sys/ptms.h b/usr/src/uts/common/sys/ptms.h index 8b97fd7e3b..52d69b3416 100644 --- a/usr/src/uts/common/sys/ptms.h +++ b/usr/src/uts/common/sys/ptms.h @@ -35,18 +35,17 @@ extern "C" { #ifdef _KERNEL /* - * Structures and definitions supporting the pseudo terminal - * drivers. This structure is private and should not be used by any - * applications. + * Structures and definitions supporting the pseudo-terminal drivers. This + * structure is private and should not be used by any applications. */ struct pt_ttys { - queue_t *ptm_rdq; /* master's read queue pointer */ - queue_t *pts_rdq; /* slave's read queue pointer */ + queue_t *ptm_rdq; /* manager's read queue pointer */ + queue_t *pts_rdq; /* subsidiary's read queue pointer */ mblk_t *pt_nullmsg; /* 0-bytes message block for pts close */ pid_t pt_pid; /* process id (for debugging) */ minor_t pt_minor; /* Minor number of this pty */ int pt_refcnt; /* reference count for ptm_rdq/pts_rdq uses */ - ushort_t pt_state; /* state of master/slave pair */ + ushort_t pt_state; /* state of manager/subsidiary pair */ kcondvar_t pt_cv; /* condition variable for exclusive access */ kmutex_t pt_lock; /* Per-element lock */ zoneid_t pt_zoneid; /* Zone membership for this pty */ @@ -57,10 +56,10 @@ struct pt_ttys { /* * pt_state values */ -#define PTLOCK 0x01 /* master/slave pair is locked */ -#define PTMOPEN 0x02 /* master side is open */ -#define PTSOPEN 0x04 /* slave side is open */ -#define PTSTTY 0x08 /* slave side is tty */ +#define PTLOCK 0x01 /* manager/subsidiary pair is locked */ +#define PTMOPEN 0x02 /* manager side is open */ +#define PTSOPEN 0x04 /* subsidiary side is open */ +#define PTSTTY 0x08 /* subsidiary side is tty */ /* * Multi-threading primitives. @@ -104,17 +103,17 @@ struct pt_ttys { * ptms_lock and pt_cnt are defined in ptms_conf.c */ extern kmutex_t ptms_lock; -extern dev_info_t *pts_dip; /* private copy of devinfo ptr */ +extern dev_info_t *pts_dip; /* private copy of devinfo ptr */ extern void ptms_init(void); extern struct pt_ttys *pt_ttys_alloc(void); extern void ptms_close(struct pt_ttys *, uint_t); extern struct pt_ttys *ptms_minor2ptty(minor_t); -extern int ptms_attach_slave(void); +extern int ptms_attach_subsidiary(void); extern int ptms_minor_valid(minor_t ptmin, uid_t *uid, gid_t *gid); extern int ptms_minor_exists(minor_t ptmin); extern void ptms_set_owner(minor_t ptmin, uid_t uid, gid_t gid); -extern major_t ptms_slave_attached(void); +extern major_t ptms_subsidiary_attached(void); #ifdef DEBUG extern void ptms_log(char *, uint_t); @@ -140,28 +139,32 @@ typedef struct pt_own { } pt_own_t; /* - * ioctl commands + * IOCTL COMMANDS * - * ISPTM: Determines whether the file descriptor is that of an open master - * device. Return code of zero indicates that the file descriptor - * represents master device. + * ISPTM + * Determines whether the file descriptor is that of an open + * manager device. Return code of zero indicates that the file + * descriptor represents a manager device. * - * UNLKPT: Unlocks the master and slave devices. It returns 0 on success. On - * failure, the errno is set to EINVAL indicating that the master - * device is not open. + * UNLKPT + * Unlocks the manager and subsidiary devices. It returns 0 on + * success. On failure, the errno is set to EINVAL indicating + * that the manager device is not open. * - * ZONEPT: Sets the zoneid of the pair of master and slave devices. It - * returns 0 upon success. Used to force a pty 'into' a zone upon - * zone entry. - * - * PT_OWNER: Sets uid and gid for slave device. It returns 0 on success. + * ZONEPT + * Sets the zoneid of the pair of manager and subsidiary devices. + * It returns 0 upon success. Used to force a pty 'into' a zone + * upon zone entry. * + * PT_OWNER + * Sets uid and gid for subsidiary device. It returns 0 on + * success. */ -#define ISPTM (('P'<<8)|1) /* query for master */ -#define UNLKPT (('P'<<8)|2) /* unlock master/slave pair */ -#define PTSSTTY (('P'<<8)|3) /* set tty flag */ -#define ZONEPT (('P'<<8)|4) /* set zone of master/slave pair */ -#define OWNERPT (('P'<<8)|5) /* set owner/group for slave device */ +#define ISPTM (('P'<<8)|1) /* query for manager */ +#define UNLKPT (('P'<<8)|2) /* unlock manager/subsidiary pair */ +#define PTSSTTY (('P'<<8)|3) /* set tty flag */ +#define ZONEPT (('P'<<8)|4) /* set zone of manager/subsidiary pair */ +#define OWNERPT (('P'<<8)|5) /* set owner/group for subsidiary */ #ifdef _KERNEL /* diff --git a/usr/src/uts/common/sys/ptyvar.h b/usr/src/uts/common/sys/ptyvar.h index 76bc74c36a..ee00379fd8 100644 --- a/usr/src/uts/common/sys/ptyvar.h +++ b/usr/src/uts/common/sys/ptyvar.h @@ -25,14 +25,12 @@ */ /* - * Pseudo-tty driver data structures. + * Pseudo-terminal driver data structures. */ #ifndef _SYS_PTYVAR_H #define _SYS_PTYVAR_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/tty.h> #ifdef __cplusplus @@ -49,8 +47,8 @@ struct pty { struct proc *pt_selr; /* proc selecting on controller read */ struct proc *pt_selw; /* proc selecting on controller write */ struct proc *pt_sele; /* proc selecting on exception */ - dev_t pt_sdev; /* XXX dev no for the slave */ - struct vnode *pt_vnode; /* XXX vnode for the slave */ + dev_t pt_sdev; /* XXX dev no for the subsidiary */ + struct vnode *pt_vnode; /* XXX vnode for the subsidiary */ short pt_pgrp; /* controller side process group */ uchar_t pt_send; /* pending message to controller */ uchar_t pt_ucntl; /* pending iocontrol for controller */ @@ -67,11 +65,11 @@ struct pty { #define PF_ASYNC 0x00000010 /* asynchronous I/O on controller */ #define PF_WOPEN 0x00000020 /* waiting for open to complete */ #define PF_CARR_ON 0x00000040 /* "carrier" is on (cntlr. is open) */ -#define PF_SLAVEGONE 0x00000080 /* slave was open, but is now closed */ +#define PF_SUBSIDGONE 0x00000080 /* subsidiary was open, now closed */ #define PF_PKT 0x00000100 /* packet mode */ #define PF_STOPPED 0x00000200 /* user told stopped */ #define PF_REMOTE 0x00000400 /* remote and flow controlled input */ -#define PF_NOSTOP 0x00000800 /* slave is doing XON/XOFF */ +#define PF_NOSTOP 0x00000800 /* subsidiary is doing XON/XOFF */ #define PF_UCNTL 0x00001000 /* user control mode */ #define PF_43UCNTL 0x00002000 /* real 4.3 user control mode */ #define PF_IOCTL 0x00004000 /* ioctl call in progress */ diff --git a/usr/src/uts/common/sys/termios.h b/usr/src/uts/common/sys/termios.h index 3e653dae87..4edeb7a41c 100644 --- a/usr/src/uts/common/sys/termios.h +++ b/usr/src/uts/common/sys/termios.h @@ -496,7 +496,7 @@ struct ppsclockev32 { /* pseudo-tty */ #define TIOCREMOTE (tIOC|30) /* remote input editing */ -#define TIOCSIGNAL (tIOC|31) /* pty: send signal to slave */ +#define TIOCSIGNAL (tIOC|31) /* pty: send signal to subsidiary */ /* Some more 386 xenix stuff */ diff --git a/usr/src/uts/common/sys/zcons.h b/usr/src/uts/common/sys/zcons.h index 218d1a67ad..84abdc12fb 100644 --- a/usr/src/uts/common/sys/zcons.h +++ b/usr/src/uts/common/sys/zcons.h @@ -33,19 +33,19 @@ extern "C" { #endif /* - * Minor node name of the global zone side (often called the "master" side) + * Minor node name of the global zone side (often called the "manager" side) * of the zcons driver. */ -#define ZCONS_MASTER_NAME "masterconsole" +#define ZCONS_MANAGER_NAME "globalconsole" /* - * Minor node name of the non-global zone side (often called the "slave" - * side) of the zcons driver. We name it "zoneconsole" since that nameo + * Minor node name of the non-global zone side (often called the "subsidiary" + * side) of the zcons driver. We name it "zoneconsole" since that name * will show up in 'ps' output, and will make some sense to the global zone * user. Inside the zone, it will simply show up as "console" due to the * links we create. */ -#define ZCONS_SLAVE_NAME "zoneconsole" +#define ZCONS_SUBSIDIARY_NAME "zoneconsole" /* * ZC_IOC forms the base for all zcons ioctls. @@ -53,18 +53,18 @@ extern "C" { #define ZC_IOC (('Z' << 24) | ('o' << 16) | ('n' << 8)) /* - * These ioctls instruct the master side of the console to hold or release - * a reference to the slave side's vnode. They are meant to be issued by + * These ioctls instruct the manager side of the console to hold or release + * a reference to the subsidiary side's vnode. They are meant to be issued by * zoneadmd after the console device node is created and before it is destroyed - * so that the slave's STREAMS anchor, ptem, is preserved when ttymon starts - * popping STREAMS modules from within the associated zone. This guarantees - * that the zone slave console will always have terminal semantics while the - * zone is running. + * so that the subsidiary's STREAMS anchor, ptem, is preserved when ttymon + * starts popping STREAMS modules from within the associated zone. This + * guarantees that the zone subsidiary console will always have terminal + * semantics while the zone is running. * * A more detailed description can be found in uts/common/io/zcons.c. */ -#define ZC_HOLDSLAVE (ZC_IOC | 0) /* get and save slave side reference */ -#define ZC_RELEASESLAVE (ZC_IOC | 1) /* release slave side reference */ +#define ZC_HOLDSUBSID (ZC_IOC | 0) +#define ZC_RELEASESUBSID (ZC_IOC | 1) #ifdef __cplusplus } diff --git a/usr/src/uts/intel/io/imc/imc.c b/usr/src/uts/intel/io/imc/imc.c index e1dbfbfc2e..67a14528f0 100644 --- a/usr/src/uts/intel/io/imc/imc.c +++ b/usr/src/uts/intel/io/imc/imc.c @@ -1405,7 +1405,7 @@ imc_nvl_pack(imc_socket_t *sock, boolean_t sleep) if (sleep) { kmflag = KM_SLEEP; } else { - kmflag = KM_NOSLEEP | KM_NORMALPRI; + kmflag = KM_NOSLEEP_LAZY; } if (nvlist_pack(sock->isock_nvl, &buf, &len, NV_ENCODE_XDR, @@ -1432,7 +1432,7 @@ imc_decoder_pack(imc_t *imc) } if (nvlist_pack(imc->imc_decoder_dump, &buf, &len, NV_ENCODE_XDR, - KM_NOSLEEP | KM_NORMALPRI) != 0) { + KM_NOSLEEP_LAZY) != 0) { return; } |