From c8907381b10259bed3a871a2881c0f3b7287ab3c Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 7 May 2020 05:16:27 -0700 Subject: 12705 remove __builtin_alloca() declaration from string.h Reviewed by: Toomas Soome Reviewed by: Andy Stormont Approved by: Gordon Ross --- usr/src/head/string.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'usr/src') diff --git a/usr/src/head/string.h b/usr/src/head/string.h index 2194b70bd8..f75c14c59c 100644 --- a/usr/src/head/string.h +++ b/usr/src/head/string.h @@ -22,6 +22,7 @@ /* * Copyright 2014 Garrett D'Amore * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2020 Joyent, Inc. */ /* Copyright (c) 1988 AT&T */ @@ -139,13 +140,8 @@ extern char *strdup(const char *); #if defined(__EXTENSIONS__) || \ (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) -#if defined(__GNUC__) -/* - * gcc provides this inlining facility but Studio C does not. - * We should use it exclusively once Studio C also provides it. - */ -extern void *__builtin_alloca(size_t); +#if defined(__GNUC__) #define strdupa(s) \ (__extension__( \ -- cgit v1.2.3 From 8124b8119d8ab7f80f1bd8b094cd96356f531b54 Mon Sep 17 00:00:00 2001 From: Yuri Pankov Date: Fri, 8 May 2020 16:25:59 +0300 Subject: 12597 want libutempter Reviewed by: Robert Mustacchi Reviewed by: Toomas Soome Reviewed by: GergÅ‘ Doma Approved by: Gordon Ross MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/src/cmd/mandoc/lib.in | 1 + usr/src/cmd/mandoc/msec.in | 1 + usr/src/lib/Makefile | 2 + usr/src/lib/libutempter/Makefile | 37 ++++++ usr/src/lib/libutempter/Makefile.com | 30 +++++ usr/src/lib/libutempter/THIRDPARTYLICENSE | 23 ++++ usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip | 1 + usr/src/lib/libutempter/amd64/Makefile | 15 +++ usr/src/lib/libutempter/common/mapfile-vers | 38 ++++++ usr/src/lib/libutempter/common/utempter.c | 132 ++++++++++++++++++++ usr/src/lib/libutempter/common/utempter.h | 47 ++++++++ usr/src/lib/libutempter/i386/Makefile | 14 +++ usr/src/lib/libutempter/sparc/Makefile | 14 +++ usr/src/lib/libutempter/sparcv9/Makefile | 15 +++ usr/src/man/Makefile | 1 + usr/src/man/man3utempter/Makefile | 35 ++++++ .../man/man3utempter/utempter_add_record.3utempter | 134 +++++++++++++++++++++ .../pkg/manifests/system-library-libutempter.mf | 44 +++++++ 18 files changed, 584 insertions(+) create mode 100644 usr/src/lib/libutempter/Makefile create mode 100644 usr/src/lib/libutempter/Makefile.com create mode 100644 usr/src/lib/libutempter/THIRDPARTYLICENSE create mode 100644 usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip create mode 100644 usr/src/lib/libutempter/amd64/Makefile create mode 100644 usr/src/lib/libutempter/common/mapfile-vers create mode 100644 usr/src/lib/libutempter/common/utempter.c create mode 100644 usr/src/lib/libutempter/common/utempter.h create mode 100644 usr/src/lib/libutempter/i386/Makefile create mode 100644 usr/src/lib/libutempter/sparc/Makefile create mode 100644 usr/src/lib/libutempter/sparcv9/Makefile create mode 100644 usr/src/man/man3utempter/Makefile create mode 100644 usr/src/man/man3utempter/utempter_add_record.3utempter create mode 100644 usr/src/pkg/manifests/system-library-libutempter.mf (limited to 'usr/src') diff --git a/usr/src/cmd/mandoc/lib.in b/usr/src/cmd/mandoc/lib.in index 0d65eeb086..9e42725de5 100644 --- a/usr/src/cmd/mandoc/lib.in +++ b/usr/src/cmd/mandoc/lib.in @@ -77,6 +77,7 @@ LINE("libtecla", "Interactive Command Line Input Library (libtecla, \\-ltecla)") LINE("libtnfctl", "TNF Probe Control Library (libtnfctl, \\-ltnfctl)") LINE("libtsol", "Trusted Extensions Library (libtsol, \\-ltsol)") LINE("libumem", "Object-Caching Memory Allocation Library (libumem, \\-lumem") +LINE("libutempter", "UTEMPTER Library (libutempter, \\-lutempter)") LINE("libuuid", "UUID Library (libuuid, \\-luuid)") LINE("libvolmgt", "Volume Management Library (libvolmgt, \\-lvolmgt)") LINE("libxcurses", "X/Open Curses Library (libxcurses, \\-lxcurses)") diff --git a/usr/src/cmd/mandoc/msec.in b/usr/src/cmd/mandoc/msec.in index 10861ddd07..09069603b7 100644 --- a/usr/src/cmd/mandoc/msec.in +++ b/usr/src/cmd/mandoc/msec.in @@ -88,6 +88,7 @@ LINE("3SYSEVENT", "System Event Library Functions") LINE("3TECLA", "Interactive Command-line Input Library Functions") LINE("3TNF", "TNF Library Functions") LINE("3TSOL", "Trusted Extensions Library Functions") +LINE("3UTEMPTER", "UTEMPTER Library Functions") LINE("3UUID", "Universally Unique Identifier Library Functions") LINE("3VOLMGT", "Volume Management Library Functions") LINE("3XCURSES", "X/Open Curses Library Functions") diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 4023cf6290..e2bbd9a8c0 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -232,6 +232,7 @@ SUBDIRS += \ libtsnet \ libtsol \ libumem \ + libutempter \ libuuid \ libuutil \ libvolmgt \ @@ -479,6 +480,7 @@ HDRSUBDIRS= \ libtsnet \ libtsol \ libumem \ + libutempter \ libuutil \ libvolmgt \ libvrrpadm \ diff --git a/usr/src/lib/libutempter/Makefile b/usr/src/lib/libutempter/Makefile new file mode 100644 index 0000000000..50a91bef6b --- /dev/null +++ b/usr/src/lib/libutempter/Makefile @@ -0,0 +1,37 @@ +# +# 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. +# + +include $(SRC)/lib/Makefile.lib + +SUBDIRS= $(MACH) $(BUILD64) $(MACH64) + +all:= TARGET= all +clean:= TARGET= clean +clobber:= TARGET= clobber +install:= TARGET= install + +HDRDIR= common +HDRS= utempter.h + +.KEEP_STATE: + +all clean clobber install: $(SUBDIRS) + +check: $(CHECKHDRS) + +install_h: $(ROOTHDRS) + +$(SUBDIRS): FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libutempter/Makefile.com b/usr/src/lib/libutempter/Makefile.com new file mode 100644 index 0000000000..6e0332e4e0 --- /dev/null +++ b/usr/src/lib/libutempter/Makefile.com @@ -0,0 +1,30 @@ +# +# 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. +# + +LIBRARY= libutempter.a +VERS= .1 + +OBJECTS= utempter.o + +include $(SRC)/lib/Makefile.lib + +SRCDIR= ../common + +LDLIBS += -lc +LIBS= $(DYNLIB) + +CSTD= $(CSTD_GNU99) + +.KEEP_STATE: + +all: $(LIBS) + +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libutempter/THIRDPARTYLICENSE b/usr/src/lib/libutempter/THIRDPARTYLICENSE new file mode 100644 index 0000000000..aa2de14939 --- /dev/null +++ b/usr/src/lib/libutempter/THIRDPARTYLICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2009 Ed Schouten +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip b/usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip new file mode 100644 index 0000000000..a5add467b7 --- /dev/null +++ b/usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip @@ -0,0 +1 @@ +UTEMPTER LIBRARY diff --git a/usr/src/lib/libutempter/amd64/Makefile b/usr/src/lib/libutempter/amd64/Makefile new file mode 100644 index 0000000000..c876c91740 --- /dev/null +++ b/usr/src/lib/libutempter/amd64/Makefile @@ -0,0 +1,15 @@ +# +# 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. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/libutempter/common/mapfile-vers b/usr/src/lib/libutempter/common/mapfile-vers new file mode 100644 index 0000000000..c2c0249afd --- /dev/null +++ b/usr/src/lib/libutempter/common/mapfile-vers @@ -0,0 +1,38 @@ +# +# 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. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION ILLUMOS_0.1 { + global: + addToUtmp; + removeFromUtmp; + removeLineFromUtmp; + utempter_add_record; + utempter_remove_added_record; + utempter_remove_record; + local: + *; +}; diff --git a/usr/src/lib/libutempter/common/utempter.c b/usr/src/lib/libutempter/common/utempter.c new file mode 100644 index 0000000000..63e6b24ba1 --- /dev/null +++ b/usr/src/lib/libutempter/common/utempter.c @@ -0,0 +1,132 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2009 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#include +#include +#include +#include +#include + +static int last_fd = -1; + +static void +utempter_update_utmpx(int type, int fd, const char *host) +{ + struct utmpx ut; + struct passwd *pw; + uid_t uid; + + (void) memset(&ut, 0, sizeof (ut)); + ut.ut_type = type; + ut.ut_pid = getpid(); + ut.ut_session = getsid(0); + (void) gettimeofday(&ut.ut_tv, NULL); + if (snprintf(ut.ut_id, sizeof (ut.ut_id), "f%d", fd) >= + sizeof (ut.ut_id)) + return; + uid = getuid(); + if ((pw = getpwuid(uid)) == NULL) + return; + (void) strlcpy(ut.ut_user, pw->pw_name, sizeof (ut.ut_user)); + + if (type == DEAD_PROCESS) { + struct utmpx *ut1; + struct utmpx ut2; + + (void) memset(&ut2, 0, sizeof (ut2)); + ut2.ut_type = USER_PROCESS; + if (snprintf(ut2.ut_id, sizeof (ut2.ut_id), "f%d", fd) >= + sizeof (ut2.ut_id)) + return; + if ((ut1 = getutxid(&ut2)) == NULL) + return; + (void) strlcpy(ut.ut_line, ut1->ut_line, sizeof (ut.ut_line)); + } else { + char *line = ptsname(fd); + if (line == NULL) + return; + (void) strlcpy(ut.ut_line, line + strlen("/dev/"), + sizeof (ut.ut_line)); + } + + if (host != NULL) { + (void) strlcpy(ut.ut_host, host, sizeof (ut.ut_host)); + ut.ut_syslen = strlen(ut.ut_host) + 1; + } + + setutxent(); + (void) pututxline(&ut); + endutxent(); +} + +int +utempter_add_record(int fd, const char *host) +{ + utempter_update_utmpx(USER_PROCESS, fd, host); + last_fd = fd; + return (0); +} + +int +utempter_remove_record(int fd) +{ + utempter_update_utmpx(DEAD_PROCESS, fd, NULL); + if (last_fd == fd) + last_fd = -1; + return (0); +} + +int +utempter_remove_added_record(void) +{ + if (last_fd < 0) + return (0); + utempter_update_utmpx(DEAD_PROCESS, last_fd, NULL); + last_fd = -1; + return (0); +} + +void +addToUtmp(const char *pty __unused, const char *host, int fd) +{ + (void) utempter_add_record(fd, host); +} + +void +removeFromUtmp(void) +{ + (void) utempter_remove_added_record(); +} + +void +removeLineFromUtmp(const char *pty __unused, int fd) +{ + (void) utempter_remove_record(fd); +} diff --git a/usr/src/lib/libutempter/common/utempter.h b/usr/src/lib/libutempter/common/utempter.h new file mode 100644 index 0000000000..fab58d9422 --- /dev/null +++ b/usr/src/lib/libutempter/common/utempter.h @@ -0,0 +1,47 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2009 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _UTEMPTER_H +#define _UTEMPTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +int utempter_add_record(int, const char *); +int utempter_remove_added_record(void); +int utempter_remove_record(int); +void addToUtmp(const char *, const char *, int); +void removeFromUtmp(void); +void removeLineFromUtmp(const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* !_UTEMPTER_H */ diff --git a/usr/src/lib/libutempter/i386/Makefile b/usr/src/lib/libutempter/i386/Makefile new file mode 100644 index 0000000000..f4a0a208fd --- /dev/null +++ b/usr/src/lib/libutempter/i386/Makefile @@ -0,0 +1,14 @@ +# +# 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. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libutempter/sparc/Makefile b/usr/src/lib/libutempter/sparc/Makefile new file mode 100644 index 0000000000..f4a0a208fd --- /dev/null +++ b/usr/src/lib/libutempter/sparc/Makefile @@ -0,0 +1,14 @@ +# +# 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. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libutempter/sparcv9/Makefile b/usr/src/lib/libutempter/sparcv9/Makefile new file mode 100644 index 0000000000..c876c91740 --- /dev/null +++ b/usr/src/lib/libutempter/sparcv9/Makefile @@ -0,0 +1,15 @@ +# +# 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. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/man/Makefile b/usr/src/man/Makefile index 7bfd356b32..f3e553ecf6 100644 --- a/usr/src/man/Makefile +++ b/usr/src/man/Makefile @@ -83,6 +83,7 @@ SUBDIRS= man1 \ man3tecla \ man3tnf \ man3tsol \ + man3utempter \ man3uuid \ man3volmgt \ man3xcurses \ diff --git a/usr/src/man/man3utempter/Makefile b/usr/src/man/man3utempter/Makefile new file mode 100644 index 0000000000..a61f7696e6 --- /dev/null +++ b/usr/src/man/man3utempter/Makefile @@ -0,0 +1,35 @@ +# +# 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. +# + +include $(SRC)/Makefile.master + +MANSECT= 3utempter + +MANFILES= utempter_add_record.3utempter + +MANLINKS= addToUtmp.3utempter \ + removeFromUtmp.3utempter \ + removeLineFromUtmp.3utempter \ + utempter_remove_added_record.3utempter \ + utempter_remove_record.3utempter + + +addToUtmp.3utempter := LINKSRC = utempter_add_record.3utempter +removeFromUtmp.3utempter := LINKSRC = utempter_add_record.3utempter +removeLineFromUtmp.3utempter := LINKSRC = utempter_add_record.3utempter +utempter_remove_added_record.3utempter := LINKSRC = utempter_add_record.3utempter +utempter_remove_record.3utempter := LINKSRC = utempter_add_record.3utempter + +.KEEP_STATE: + +include $(SRC)/man/Makefile.man + +install: $(ROOTMANFILES) $(ROOTMANLINKS) diff --git a/usr/src/man/man3utempter/utempter_add_record.3utempter b/usr/src/man/man3utempter/utempter_add_record.3utempter new file mode 100644 index 0000000000..da6cbb7211 --- /dev/null +++ b/usr/src/man/man3utempter/utempter_add_record.3utempter @@ -0,0 +1,134 @@ +.\" Copyright (c) 2009 Ed Schouten +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd May 5, 2020 +.Dt UTEMPTER_ADD_RECORD 3UTEMPTER +.Os +.Sh NAME +.Nm utempter_add_record , +.Nm utempter_remove_added_record , +.Nm utempter_remove_record , +.Nm addToUtmp , +.Nm removeFromUtmp , +.Nm removeLineFromUtmp +.Nd utempter compatibility interface +.Sh LIBRARY +.Lb libutempter +.Sh SYNOPSIS +.In utempter.h +.Ft int +.Fn utempter_add_record "int fd" "const char *host" +.Ft int +.Fn utempter_remove_added_record "void" +.Ft int +.Fn utempter_remove_record "int fd" +.Ft void +.Fn addToUtmp "const char *pty" "const char *host" "int fd" +.Ft void +.Fn removeFromUtmp "void" +.Ft void +.Fn removeLineFromUtmp "const char *pty" "int fd" +.Sh DESCRIPTION +These functions provide an interface for terminal emulators such as tmux, +screen, and xterm to record user sessions to +.Xr utmpx 4 +database. +Note that they are best effort and may not succeed. +If consumers need to know for certain that they have successfully updated the +.Xr utmpx 4 +database, these functions should not be used because they cannot communicate +that for compatibility reasons. +.Pp +The +.Fn utempter_add_record +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 +.Fa fd , +using the username corresponding with the real user ID of the calling +process and the optional hostname +.Fa host , +limited to 256 characters, that is the size of +.Va ut_host +member of +.Vt struct utmpx +minus terminating NUL character. +.Pp +The +.Fn utempter_remove_record +and +.Fn removeLineFromUtmp +functions mark the login session as being closed for the TTY belonging +to the pseudo-terminal master file descriptor +.Fa fd . +.Pp +The +.Fn utempter_remove_added_record +and +.Fn removeFromUtmp +functions have the same properties as the previously mentioned +functions, except that they use an internally cached value of the file +descriptor passed to +.Fn utempter_add_record +and +.Fn addToUtmp . +.Pp +In this implementation, the +.Fa pty +arguments of +.Fn addToUtmp +and +.Fn removeLineFromUtmp +are ignored, and database entries are driven entirely by the +.Fa fd +argument. +.Sh RETURN VALUES +The +.Fn utempter_add_record , +.Fn utempter_remove_added_record +and +.Fn utempter_remove_record +functions always return a value of 0. +.Sh INTERFACE STABILITY +.Fn utempter_add_record , +.Fn utempter_remove_added_record , +and +.Fn utempter_remove_record +are +.Sy Committed . +.Fn addToUtmp , +.Fn removeFromUtmp , +and +.Fn removeLineFromUtmp +are +.Sy Obsolete Committed . +.Sh MT-LEVEL +.Sy Unsafe +.Sh SEE ALSO +.Xr pututxline 3c , +.Xr utmpx 3head , +.Xr utmpx 4 diff --git a/usr/src/pkg/manifests/system-library-libutempter.mf b/usr/src/pkg/manifests/system-library-libutempter.mf new file mode 100644 index 0000000000..e883545383 --- /dev/null +++ b/usr/src/pkg/manifests/system-library-libutempter.mf @@ -0,0 +1,44 @@ +# +# 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. +# + +set name=pkg.fmri value=pkg:/system/library/libutempter@$(PKGVERS) +set name=pkg.description \ + value="Interface to record user sessions in utmpx database" +set name=pkg.summary \ + value="Interface to record user sessions in utmpx database" +set name=info.classification \ + value=org.opensolaris.category.2008:System/Library +set name=variant.arch value=$(ARCH) +dir path=usr group=sys +dir path=usr/include +dir path=usr/lib +dir path=usr/lib/$(ARCH64) +dir path=usr/share +dir path=usr/share/man +dir path=usr/share/man/man3utempter +file path=usr/include/utempter.h +file path=usr/lib/$(ARCH64)/libutempter.so.1 +file path=usr/lib/libutempter.so.1 +file path=usr/share/man/man3utempter/utempter_add_record.3utempter +license usr/src/lib/libutempter/THIRDPARTYLICENSE \ + license=usr/src/lib/libutempter/THIRDPARTYLICENSE +link path=usr/lib/$(ARCH64)/libutempter.so target=libutempter.so.1 +link path=usr/lib/libutempter.so target=libutempter.so.1 +link path=usr/share/man/man3utempter/addToUtmp.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/removeFromUtmp.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/removeLineFromUtmp.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/utempter_remove_added_record.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/utempter_remove_record.3utempter \ + target=utempter_add_record.3utempter -- cgit v1.2.3 From 59b05390e07c3b0e69288f9a732dc5b90d464721 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 7 Feb 2020 20:17:24 +0200 Subject: 12539 mdb: NULL pointer errors Reviewed by: Gary Mills Approved by: Dan McDonald --- usr/src/cmd/mdb/common/mdb/mdb_cmds.c | 4 +- usr/src/cmd/mdb/common/modules/sd/sd.c | 74 ++++++++++----------- usr/src/cmd/mdb/sparc/kmdb/kaif.c | 18 ++--- usr/src/cmd/mdb/sparc/kmdb/kmdb_kdi_isadep.c | 7 +- usr/src/cmd/mdb/sparc/kmdb/kmdb_makecontext.c | 6 +- usr/src/cmd/mdb/sparc/kmdb/kmdb_promif_isadep.c | 2 +- usr/src/cmd/mdb/sparc/modules/intr/intr.c | 2 +- usr/src/cmd/mdb/sun4u/modules/opl/oplhwd/oplhwd.c | 77 +++++++++++----------- usr/src/cmd/mdb/sun4u/modules/unix/sfmmu.c | 80 +++++++++++------------ usr/src/cmd/mdb/sun4u/modules/unix/unix.c | 19 +++--- usr/src/cmd/mdb/sun4v/modules/errh/errh.c | 11 +--- usr/src/cmd/mdb/sun4v/modules/ldc/ldc.c | 12 ++-- usr/src/cmd/mdb/sun4v/modules/mdesc/mdesc.c | 2 +- usr/src/cmd/mdb/sun4v/modules/vdsk/vdsk.c | 4 +- 14 files changed, 152 insertions(+), 166 deletions(-) (limited to 'usr/src') diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c index aa706c690d..b7b15aa507 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c @@ -1956,14 +1956,14 @@ cmd_findsym(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) } else value = argv[i].a_un.a_val; - if (value != NULL) + if (value != (uintptr_t)NULL) symlist[len++] = value; } if (flags & DCMD_ADDRSPEC) symlist[len++] = addr; - symlist[len] = NULL; + symlist[len] = (uintptr_t)NULL; if (optg) type = MDB_TGT_BIND_GLOBAL | MDB_TGT_TYPE_FUNC; diff --git a/usr/src/cmd/mdb/common/modules/sd/sd.c b/usr/src/cmd/mdb/common/modules/sd/sd.c index 3de82ff809..7e87cf005b 100644 --- a/usr/src/cmd/mdb/common/modules/sd/sd.c +++ b/usr/src/cmd/mdb/common/modules/sd/sd.c @@ -139,7 +139,7 @@ buf_avforw_walk_step(mdb_walk_state_t *wsp) } status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, - wsp->walk_cbdata); + wsp->walk_cbdata); wsp->walk_addr = (uintptr_t)(((buf_t *)wsp->walk_data)->av_forw); return (status); @@ -221,37 +221,37 @@ static void dump_xbuf_attr(struct __ddi_xbuf_attr *xba_ptr, uintptr_t mem_addr) { mdb_printf("0x%8lx:\tmutex\t\tallocsize\tpending\n", - mem_addr + offsetof(struct __ddi_xbuf_attr, xa_mutex)); + mem_addr + offsetof(struct __ddi_xbuf_attr, xa_mutex)); mdb_printf(" \t%lx\t\t%d\t\t%d\n", - xba_ptr->xa_mutex._opaque[0], xba_ptr->xa_allocsize, - xba_ptr->xa_pending); + xba_ptr->xa_mutex._opaque[0], xba_ptr->xa_allocsize, + xba_ptr->xa_pending); mdb_printf("0x%8lx:\tactive_limit\tactive_count\tactive_lowater\n", - mem_addr + offsetof(struct __ddi_xbuf_attr, xa_active_limit)); + mem_addr + offsetof(struct __ddi_xbuf_attr, xa_active_limit)); mdb_printf(" \t%lx\t\t%lx\t\t%lx\n", - xba_ptr->xa_active_limit, xba_ptr->xa_active_count, - xba_ptr->xa_active_lowater); + xba_ptr->xa_active_limit, xba_ptr->xa_active_count, + xba_ptr->xa_active_lowater); mdb_printf("0x%8lx:\theadp\t\ttailp\n", - mem_addr + offsetof(struct __ddi_xbuf_attr, xa_headp)); + mem_addr + offsetof(struct __ddi_xbuf_attr, xa_headp)); mdb_printf(" \t%lx%c\t%lx\n", - xba_ptr->xa_headp, (xba_ptr->xa_headp == 0?'\t':' '), - xba_ptr->xa_tailp); + xba_ptr->xa_headp, (xba_ptr->xa_headp == 0?'\t':' '), + xba_ptr->xa_tailp); mdb_printf( "0x%8lx:\treserve_mutex\treserve_limit\treserve_count\treserve_headp\n", - mem_addr + offsetof(struct __ddi_xbuf_attr, xa_reserve_mutex)); + mem_addr + offsetof(struct __ddi_xbuf_attr, xa_reserve_mutex)); mdb_printf(" \t%lx\t\t%lx\t\t%lx\t\t%lx\n", - xba_ptr->xa_reserve_mutex._opaque[0], xba_ptr->xa_reserve_limit, - xba_ptr->xa_reserve_count, xba_ptr->xa_reserve_headp); + xba_ptr->xa_reserve_mutex._opaque[0], xba_ptr->xa_reserve_limit, + xba_ptr->xa_reserve_count, xba_ptr->xa_reserve_headp); mdb_printf("0x%8lx:\ttimeid\t\ttq\n", - mem_addr + offsetof(struct __ddi_xbuf_attr, xa_timeid)); + mem_addr + offsetof(struct __ddi_xbuf_attr, xa_timeid)); mdb_printf(" \t%lx%c\t%lx\n", - xba_ptr->xa_timeid, (xba_ptr->xa_timeid == 0?'\t':' '), - xba_ptr->xa_tq); + xba_ptr->xa_timeid, (xba_ptr->xa_timeid == 0?'\t':' '), + xba_ptr->xa_tq); } /* @@ -278,7 +278,7 @@ init_softstate_members(mdb_walk_state_t *wsp) SD_DATA(valid_root_count) = 0; if (mdb_vread((void *)&SD_DATA(sd_state_data), - sizeof (sd_state_str_t), wsp->walk_addr) == -1) { + sizeof (sd_state_str_t), wsp->walk_addr) == -1) { mdb_warn("failed to sd_state at %p", wsp->walk_addr); return (WALK_ERR); } @@ -333,7 +333,7 @@ sd_state_walk_init(mdb_walk_state_t *wsp) static int ssd_state_walk_init(mdb_walk_state_t *wsp) { - if (wsp->walk_addr == NULL && + if (wsp->walk_addr == (uintptr_t)NULL && mdb_readvar(&wsp->walk_addr, "ssd_state") == -1) { mdb_warn("failed to read 'ssd_state'"); return (WALK_ERR); @@ -381,7 +381,7 @@ sd_state_walk_step(mdb_walk_state_t *wsp) } status = wsp->walk_callback((uintptr_t)tp, wsp->walk_data, - wsp->walk_cbdata); + wsp->walk_cbdata); if (tp != 0) { /* Count the number of non-zero un entries. */ SD_DATA(valid_root_count++); @@ -442,7 +442,7 @@ process_semo_sleepq(uintptr_t walk_addr, int silent) } if (mdb_vread((void *)¤tBuf, sizeof (buf_t), - rootBuf) == -1) { + rootBuf) == -1) { mdb_warn("failed to read buf at %p", rootBuf); return (FAIL); } @@ -459,7 +459,7 @@ process_semo_sleepq(uintptr_t walk_addr, int silent) if (rootBuf == 0) { mdb_printf("------------------------------\n"); mdb_printf("Processed %d SEMOCLOSE SLEEP Q entries\n", - semo_sleepq_count); + semo_sleepq_count); mdb_printf("------------------------------\n"); } @@ -498,9 +498,9 @@ process_sdlun_waitq(uintptr_t walk_addr, int silent) } if (mdb_vread(¤tBuf, sizeof (buf_t), - (uintptr_t)rootBuf) == -1) { + (uintptr_t)rootBuf) == -1) { mdb_warn("failed to read buf at %p", - (uintptr_t)rootBuf); + (uintptr_t)rootBuf); return (FAIL); } @@ -550,7 +550,7 @@ process_xbuf(uintptr_t xbuf_attr, int silent) /* Process the Xbuf Attr struct for a device. */ if (mdb_vread((void *)&xba, sizeof (struct __ddi_xbuf_attr), - xbuf_attr) == -1) { + xbuf_attr) == -1) { mdb_warn("failed to read xbuf_attr at %p", xbuf_attr); return (FAIL); } @@ -578,9 +578,9 @@ process_xbuf(uintptr_t xbuf_attr, int silent) } if (mdb_vread((void *)&xba_current, sizeof (buf_t), - (uintptr_t)xba_root) == -1) { + (uintptr_t)xba_root) == -1) { mdb_warn("failed to read buf at %p", - (uintptr_t)xba_root); + (uintptr_t)xba_root); return (FAIL); } if (!silent) { @@ -612,10 +612,10 @@ static void print_footer(const void *walk_data) { if (SD_DATA_IN_CBACK(current_list_count) >= - (SD_DATA_IN_CBACK(sd_state_data.n_items) - 1)) { + (SD_DATA_IN_CBACK(sd_state_data.n_items) - 1)) { mdb_printf("---------------------------\n"); mdb_printf("Processed %d UN softstate entries\n", - SD_DATA_IN_CBACK(valid_root_count)); + SD_DATA_IN_CBACK(valid_root_count)); mdb_printf("---------------------------\n"); } } @@ -651,13 +651,13 @@ sd_callback(uintptr_t addr, const void *walk_data, void *flg_silent) if (SD_DATA_IN_CBACK(current_list_count) == 0) { mdb_printf("walk_addr = %lx\n", SD_DATA_IN_CBACK(sd_state)); mdb_printf("walking sd_state units via ptr: %lx\n", - SD_DATA_IN_CBACK(current_root)); + SD_DATA_IN_CBACK(current_root)); mdb_printf("%d entries in sd_state table\n", - SD_DATA_IN_CBACK(sd_state_data.n_items)); + SD_DATA_IN_CBACK(sd_state_data.n_items)); } mdb_printf("\nun %d: %lx\n", SD_DATA_IN_CBACK(current_list_count), - addr); + addr); mdb_printf("--------------\n"); @@ -691,7 +691,7 @@ sd_callback(uintptr_t addr, const void *walk_data, void *flg_silent) /* process device semoclose wait Q */ if (sdLun.un_semoclose._opaque[1] == 0) { process_semo_sleepq((uintptr_t)sdLun.un_semoclose._opaque[0], - silent); + silent); } /* print the actual number of soft state processed */ @@ -725,7 +725,7 @@ dcmd_sd_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) /* Enable the silent mode if '-s' option specified the user */ if (mdb_getopts(argc, argv, 's', MDB_OPT_SETBITS, TRUE, &silent, NULL) - != argc) { + != argc) { return (DCMD_USAGE); } @@ -764,7 +764,7 @@ dcmd_sd_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) /* process device's semoclose wait Q */ if (sdLun.un_semoclose._opaque[1] == 0) { process_semo_sleepq( - (uintptr_t)sdLun.un_semoclose._opaque[0], silent); + (uintptr_t)sdLun.un_semoclose._opaque[0], silent); } } return (DCMD_OK); @@ -797,7 +797,7 @@ dcmd_ssd_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) /* Enable the silent mode if '-s' option specified the user */ if (mdb_getopts(argc, argv, 's', MDB_OPT_SETBITS, TRUE, &silent, NULL) - != argc) { + != argc) { return (DCMD_USAGE); } @@ -835,7 +835,7 @@ dcmd_ssd_state(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) /* process device's semoclose wait Q */ if (sdLun.un_semoclose._opaque[1] == 0) { process_semo_sleepq( - (uintptr_t)sdLun.un_semoclose._opaque[0], silent); + (uintptr_t)sdLun.un_semoclose._opaque[0], silent); } } return (DCMD_OK); @@ -872,7 +872,7 @@ dcmd_buf_avforw(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) */ if ((flags & DCMD_ADDRSPEC)) { mdb_pwalk("buf_avforw", buf_callback, (void *)&buf_entries, - addr); + addr); return (DCMD_OK); } else { mdb_printf("buffer address required with the command\n"); diff --git a/usr/src/cmd/mdb/sparc/kmdb/kaif.c b/usr/src/cmd/mdb/sparc/kmdb/kaif.c index b8a8565b16..6251b2e30e 100644 --- a/usr/src/cmd/mdb/sparc/kmdb/kaif.c +++ b/usr/src/cmd/mdb/sparc/kmdb/kaif.c @@ -397,7 +397,7 @@ kaif_wapt_reserve(kmdb_wapt_t *wp) else addrp = &kaif_vwapt_addr; - if (*addrp != NULL) + if (*addrp != 0) return (set_errno(EMDB_WPTOOMANY)); *addrp = wp->wp_addr; @@ -412,8 +412,8 @@ kaif_wapt_release(kmdb_wapt_t *wp) uint64_t *addrp = (wp->wp_type == DPI_WAPT_TYPE_PHYS ? &kaif_pwapt_addr : &kaif_vwapt_addr); - ASSERT(*addrp != NULL); - *addrp = NULL; + ASSERT(*addrp != 0); + *addrp = 0; } /*ARGSUSED*/ @@ -487,10 +487,10 @@ kaif_wapt_set_regs(void) ASSERT((kaif_lsuctl & ~KAIF_LSUCTL_WAPT_MASK) == NULL); - lsu = rdasi(ASI_LSU, NULL); + lsu = rdasi(ASI_LSU, (uintptr_t)NULL); lsu &= ~KAIF_LSUCTL_WAPT_MASK; lsu |= kaif_lsuctl; - wrasi(ASI_LSU, NULL, lsu); + wrasi(ASI_LSU, (uintptr_t)NULL, lsu); #endif /* sun4v */ } @@ -501,9 +501,9 @@ kaif_wapt_clear_regs(void) * Sun4v doesn't have watch point regs */ #ifndef sun4v - uint64_t lsu = rdasi(ASI_LSU, NULL); + uint64_t lsu = rdasi(ASI_LSU, (uintptr_t)NULL); lsu &= ~KAIF_LSUCTL_WAPT_MASK; - wrasi(ASI_LSU, NULL, lsu); + wrasi(ASI_LSU, (uintptr_t)NULL, lsu); #endif /* sun4v */ } @@ -742,7 +742,7 @@ static const mdb_bitmask_t krm_flag_bits[] = { { "M_PE", KAIF_CRUMB_F_MAIN_OBPPENT, KAIF_CRUMB_F_MAIN_OBPPENT }, { "M_NRM", KAIF_CRUMB_F_MAIN_NORMAL, KAIF_CRUMB_F_MAIN_NORMAL }, { "I_RE", KAIF_CRUMB_F_IVEC_REENTER, KAIF_CRUMB_F_IVEC_REENTER }, - { "I_OBP", KAIF_CRUMB_F_IVEC_INOBP, KAIF_CRUMB_F_IVEC_INOBP }, + { "I_OBP", KAIF_CRUMB_F_IVEC_INOBP, KAIF_CRUMB_F_IVEC_INOBP }, { "I_NRM", KAIF_CRUMB_F_IVEC_NORMAL, KAIF_CRUMB_F_IVEC_NORMAL }, { "O_NRM", KAIF_CRUMB_F_OBP_NORMAL, KAIF_CRUMB_F_OBP_NORMAL }, { "O_REVEC", KAIF_CRUMB_F_OBP_REVECT, KAIF_CRUMB_F_OBP_REVECT }, @@ -798,7 +798,7 @@ kaif_dump_crumbs(uintptr_t addr, int cpuid) { int i; - if (addr != NULL) { + if (addr != (uintptr_t)NULL) { /* dump_crumb will protect us from bogus addresses */ dump_crumb((kaif_crumb_t *)addr); diff --git a/usr/src/cmd/mdb/sparc/kmdb/kmdb_kdi_isadep.c b/usr/src/cmd/mdb/sparc/kmdb/kmdb_kdi_isadep.c index b7cc077dee..0b7b150c40 100644 --- a/usr/src/cmd/mdb/sparc/kmdb/kmdb_kdi_isadep.c +++ b/usr/src/cmd/mdb/sparc/kmdb/kmdb_kdi_isadep.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * SPARC-specific portions of the KDI */ @@ -66,7 +64,8 @@ kdi_cpu_ready_iter(int (*cb)(int, void *), void *arg) static int kdi_xc_one(int cpuid, void (*cb)(void)) { - return (mdb.m_kdi->mkdi_xc_one(cpuid, (void (*)())cb, NULL, NULL)); + return (mdb.m_kdi->mkdi_xc_one(cpuid, (void (*)())cb, (uintptr_t)NULL, + (uintptr_t)NULL)); } /*ARGSUSED1*/ @@ -157,7 +156,7 @@ kdi_halt_cpu(int cpuid, void *state_saverp) if (state != DPI_CPU_STATE_MASTER && state != DPI_CPU_STATE_SLAVE) { res = kdi_xc_one(cpuid, state_saver); - rc = 1; + rc = 1; if (res == KDI_XC_RES_OK) msg = "accepted the"; diff --git a/usr/src/cmd/mdb/sparc/kmdb/kmdb_makecontext.c b/usr/src/cmd/mdb/sparc/kmdb/kmdb_makecontext.c index 1d3781f1e9..3b233209de 100644 --- a/usr/src/cmd/mdb/sparc/kmdb/kmdb_makecontext.c +++ b/usr/src/cmd/mdb/sparc/kmdb/kmdb_makecontext.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Context-saving routine used for pipelines. Designed for use only * with kmdb_setcontext, and with the assumption that func() will never @@ -59,6 +57,6 @@ kmdb_makecontext(ucontext_t *ucp, void (*func)(void *), void *arg, caddr_t stk, ucp->uc_mcontext.gregs[REG_nPC] = (greg_t)func + 4; ucp->uc_mcontext.gregs[REG_O0] = (greg_t)arg; ucp->uc_mcontext.gregs[REG_SP] = (greg_t)(stack - STACK_BIAS); - ucp->uc_mcontext.gregs[REG_O7] = NULL; - ucp->uc_mcontext.gregs[REG_G7] = NULL; + ucp->uc_mcontext.gregs[REG_O7] = 0; + ucp->uc_mcontext.gregs[REG_G7] = 0; } diff --git a/usr/src/cmd/mdb/sparc/kmdb/kmdb_promif_isadep.c b/usr/src/cmd/mdb/sparc/kmdb/kmdb_promif_isadep.c index 6db4861bd7..ff7aa494a0 100644 --- a/usr/src/cmd/mdb/sparc/kmdb/kmdb_promif_isadep.c +++ b/usr/src/cmd/mdb/sparc/kmdb/kmdb_promif_isadep.c @@ -75,7 +75,7 @@ kmdb_prom_get_ddi_prop(kmdb_auxv_t *kav, char *propname) ssize_t len; char *val; - if ((node = prom_finddevice("/options")) == NULL) + if ((node = prom_finddevice("/options")) == 0) return (NULL); if ((len = prom_getproplen(node, propname)) < 0) diff --git a/usr/src/cmd/mdb/sparc/modules/intr/intr.c b/usr/src/cmd/mdb/sparc/modules/intr/intr.c index cdfbf1c4ce..1ffb7edcce 100644 --- a/usr/src/cmd/mdb/sparc/modules/intr/intr.c +++ b/usr/src/cmd/mdb/sparc/modules/intr/intr.c @@ -64,7 +64,7 @@ static int detailed = 0; /* Print detailed view */ static int intr_walk_init(mdb_walk_state_t *wsp) { - wsp->walk_addr = NULL; + wsp->walk_addr = (uintptr_t)NULL; return (WALK_NEXT); } diff --git a/usr/src/cmd/mdb/sun4u/modules/opl/oplhwd/oplhwd.c b/usr/src/cmd/mdb/sun4u/modules/opl/oplhwd/oplhwd.c index 48aed6c313..5bdea9bc81 100644 --- a/usr/src/cmd/mdb/sun4u/modules/opl/oplhwd/oplhwd.c +++ b/usr/src/cmd/mdb/sun4u/modules/opl/oplhwd/oplhwd.c @@ -23,7 +23,6 @@ * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include #include @@ -151,7 +150,7 @@ dumpmemhwd(hwd_memory_t *memp, int v, int mv) mdb_printf("\tDIMM %d\tstatus\t0x%x (%s)\n", i, memp->mem_dimms[i].dimm_status, hwd_stat_decode( - memp->mem_dimms[i].dimm_status)); + memp->mem_dimms[i].dimm_status)); continue; } mdb_printf("\tDIMM %d\tstatus\t0x%x (%s)\tcapacity\t0x%llx\n", @@ -241,16 +240,16 @@ dumpchiphwd(hwd_cpu_chip_t *chipp, int ch, int v, int mv) mdb_printf("\tsharing\t%x\n", corep->core_l2_cache_sharing); mdb_printf("\t\tITLB entries\t0x%x\tDTLB entries " - "0x%x\n", corep->core_num_itlb_entries, + "0x%x\n", corep->core_num_itlb_entries, corep->core_num_dtlb_entries); } for (cp = 0; cp < HWD_CPUS_PER_CORE; cp++) { cpup = &corep->core_cpus[cp]; mdb_printf("\t\tCPU %d:\tstatus\t0x%x (%s)\tcpuid" - " = 0x%x\n", cp, cpup->cpu_status, - hwd_stat_decode(cpup->cpu_status), - cpup->cpu_cpuid); + " = 0x%x\n", cp, cpup->cpu_status, + hwd_stat_decode(cpup->cpu_status), + cpup->cpu_cpuid); if (v & DUMP_COMP_NAME) mdb_printf("\t\t\tcomponent name:%s\n", cpup->cpu_component_name); @@ -320,10 +319,10 @@ dumpahwd(int bd, int v) if (mdb_vread(&boardcfg, sizeof (opl_board_cfg_t), - tmptr + (bd * sizeof (opl_board_cfg_t))) == -1) { + tmptr + (bd * sizeof (opl_board_cfg_t))) == -1) { mdb_warn("failed to read opl_board_cfg at %p", - (tmptr + (bd * sizeof (opl_board_cfg_t)))); - return; + (tmptr + (bd * sizeof (opl_board_cfg_t)))); + return; } if (boardcfg.cfg_hwd == NULL) { @@ -335,9 +334,9 @@ dumpahwd(int bd, int v) /* We always need the header, for offsets */ if (mdb_vread(&hwd_hdr, sizeof (hwd_header_t), - (uintptr_t)boardcfg.cfg_hwd) == -1) { + (uintptr_t)boardcfg.cfg_hwd) == -1) { mdb_warn("failed to read hwd_header_t at %p\n", - boardcfg.cfg_hwd); + boardcfg.cfg_hwd); return; } @@ -370,7 +369,7 @@ dumpahwd(int bd, int v) if (mdb_vread(&hwd_sb_status, sizeof (hwd_sb_status_t), (uintptr_t)statusp) == -1) { mdb_warn("failed to read hwd_sb_status_t at %p\n", - statusp); + statusp); return; } mdb_printf("\nSTATUS:\tBoard\tStatus\n"); @@ -388,7 +387,7 @@ dumpahwd(int bd, int v) if (mdb_vread(&hwd_dinfo, sizeof (hwd_domain_info_t), (uintptr_t)dinfop) == -1) { mdb_warn("failed to read hwd_domain_info_t at %p\n", - dinfop); + dinfop); return; } mdb_printf("\nDomain info:\tReset reason\t0x%x", @@ -445,7 +444,7 @@ dumpahwd(int bd, int v) cmup = &hwd_sb.sb_cmu.cmu_ch; mdb_printf("\nCMU CH: status\t0x%x (%s)\tportid=0x%x" - " LSB = 0x%x\n", + " LSB = 0x%x\n", cmup->chan_status, hwd_stat_decode(cmup->chan_status), cmup->chan_portid, ((cmup->chan_portid) >> 4)); @@ -504,16 +503,16 @@ dumpahwd(int bd, int v) scp = &hwd_sb.sb_cmu.cmu_scs[sc]; - if (DONT_BOTHER(scp->sc_status, mv)) - mdb_printf("\nSC %d:\tstatus\t0x%x (%s)\n", - sc, scp->sc_status, - hwd_stat_decode(scp->sc_status)); - else { - mdb_printf("\nSC %d:\tstatus\t0x%x (%s)\t", - sc, scp->sc_status, - hwd_stat_decode(scp->sc_status)); - mdb_printf("register addr\t0x%llx\n", - scp->sc_register_address); + if (DONT_BOTHER(scp->sc_status, mv)) { + mdb_printf("\nSC %d:\tstatus\t0x%x (%s)\n", + sc, scp->sc_status, + hwd_stat_decode(scp->sc_status)); + } else { + mdb_printf("\nSC %d:\tstatus\t0x%x (%s)\t", + sc, scp->sc_status, + hwd_stat_decode(scp->sc_status)); + mdb_printf("register addr\t0x%llx\n", + scp->sc_register_address); } } @@ -607,7 +606,7 @@ oplhwd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) if (bdi < 0) { /* get active boards */ for (bdi = 0; bdi < OPL_MAX_BOARDS; bdi++) - dumpahwd(bdi, v_mode); + dumpahwd(bdi, v_mode); } else { dumpahwd(bdi, v_mode); } @@ -621,22 +620,22 @@ static void oplhwd_help(void) { mdb_printf("oplhwd will dump HWD only for a particular board" - " on which,"); + " on which,"); mdb_printf("an earlier DR operation has been executed.\n"); mdb_printf("-b NUM \tlist oplhwd entry for a board\n" - "-s \t\tlist oplhwd entry with SB status\n" - "-d \t\tlist oplhwd entry with Domain info.\n" - "-i \t\tlist oplhwd entry with SB info.\n" - "-h \t\tlist oplhwd entry with Chips details\n" - "-o \t\tlist oplhwd entry with Core details\n" - "-m \t\tlist oplhwd entry with Memory info.\n" - "-k \t\tlist oplhwd entry with Memory Bank info.\n" - "-r \t\tlist oplhwd entry with SC info.\n" - "-c \t\tlist oplhwd entry with CMU channels\n" - "-p \t\tlist oplhwd entry with PCI channels\n" - "-a \t\tlist oplhwd entry with all possible info.\n" - "-C \t\tlist oplhwd entry with component names\n" - "-v \t\tlist oplhwd entry in verbose mode\n"); + "-s \t\tlist oplhwd entry with SB status\n" + "-d \t\tlist oplhwd entry with Domain info.\n" + "-i \t\tlist oplhwd entry with SB info.\n" + "-h \t\tlist oplhwd entry with Chips details\n" + "-o \t\tlist oplhwd entry with Core details\n" + "-m \t\tlist oplhwd entry with Memory info.\n" + "-k \t\tlist oplhwd entry with Memory Bank info.\n" + "-r \t\tlist oplhwd entry with SC info.\n" + "-c \t\tlist oplhwd entry with CMU channels\n" + "-p \t\tlist oplhwd entry with PCI channels\n" + "-a \t\tlist oplhwd entry with all possible info.\n" + "-C \t\tlist oplhwd entry with component names\n" + "-v \t\tlist oplhwd entry in verbose mode\n"); } /* diff --git a/usr/src/cmd/mdb/sun4u/modules/unix/sfmmu.c b/usr/src/cmd/mdb/sun4u/modules/unix/sfmmu.c index 20b59d7e56..ce4a1035f1 100644 --- a/usr/src/cmd/mdb/sun4u/modules/unix/sfmmu.c +++ b/usr/src/cmd/mdb/sun4u/modules/unix/sfmmu.c @@ -131,7 +131,7 @@ sfmmu_vtop(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) if (ret == 0) { mdb_printf("address space %p: virtual %lr mapped to physical " - "%llr", asp, addr, paddr); + "%llr", asp, addr, paddr); } else { return (DCMD_ERR); } @@ -174,7 +174,7 @@ sfmmu_vtop_common(struct as *asp, uintptr_t addr, physaddr_t *pap) static int sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, - physaddr_t *pap) + physaddr_t *pap) { struct hmehash_bucket *uhme_hash; struct hmehash_bucket *khme_hash; @@ -225,7 +225,7 @@ sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, } ism_blkp = &mism_blk; ism_map = ism_blkp->iblk_maps; - for (i = 0; ism_map[i].imap_ismhat && i < ISM_MAP_SLOTS; i++) { + for (i = 0; i < ISM_MAP_SLOTS && ism_map[i].imap_ismhat; i++) { if ((caddr_t)addr >= ism_start(ism_map[i]) && (caddr_t)addr < ism_end(ism_map[i])) { sfmmup = ism_hatid = ism_map[i].imap_ismhat; @@ -252,18 +252,18 @@ sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, #ifdef __sparcv9 SFMMU_VTOP_DBG_DBG("hblktag=%lx %lx\n", - (uint64_t)hblktag.htag_tag[0], - (uint64_t)hblktag.htag_tag[1]); + (uint64_t)hblktag.htag_tag[0], + (uint64_t)hblktag.htag_tag[1]); #else SFMMU_VTOP_DBG_DBG("hblktag=%llx\n", - (uint64_t)hblktag.htag_tag); + (uint64_t)hblktag.htag_tag); #endif hmebp = shmebp = HME_HASH_FUNCTION(sfmmup, addr, hmeshift); SFMMU_VTOP_DBG_DBG("hmebp=%p\n", hmebp); if (mdb_vread(&mbucket, sizeof (mbucket), - (uintptr_t)hmebp) == -1) { + (uintptr_t)hmebp) == -1) { mdb_warn("couldn't read mbucket at %p\n", hmebp); return (DCMD_ERR); } @@ -271,7 +271,7 @@ sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, hmebp = &mbucket; for (hmeblkp = hmebp->hmeblkp; hmeblkp; - hmeblkp = hmeblkp->hblk_next) { + hmeblkp = hmeblkp->hblk_next) { SFMMU_VTOP_DBG_DBG("hmeblkp=%p\n", hmeblkp); @@ -279,9 +279,9 @@ sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, break; if (mdb_vread(&mhmeblkmax, sizeof (struct hme_blk), - (uintptr_t)hmeblkp) == -1) { + (uintptr_t)hmeblkp) == -1) { mdb_warn("couldn't read hme_blk at %p\n", - hmeblkp); + hmeblkp); return (DCMD_ERR); } @@ -298,7 +298,7 @@ sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, sfmmu_vtop_print_hmeblk(hmeblkp); sfhmep = mdb_sfmmu_hblktohme(hmeblkp, (caddr_t)addr, - &sfhmeinx); + &sfhmeinx); SFMMU_VTOP_DBG_DBG("sfhmeinx=%d ", sfhmeinx); @@ -307,28 +307,26 @@ sfmmu_vtop_impl(uintptr_t addr, sfmmu_t *sfmmup, sfmmu_t *msfmmup, sizeof (struct sf_hment) * (sfhmeinx - 1); if (mdb_vread(sfhmep, sizeof (struct sf_hment), - thmeblkp) == -1) { + thmeblkp) == -1) { mdb_warn("couldn't read msfhme at %p\n", - sfhmep); + sfhmep); return (DCMD_ERR); } } SFMMU_VTOP_DBG_VRB("sfmmup=%p hmebp=%p hmeblkp=%p\n", - sfmmup, shmebp, thmeblkp); + sfmmup, shmebp, thmeblkp); tte = sfhmep->hme_tte; SFMMU_VTOP_DBG_VRB("tte=%llx ", tte.ll); if (TTE_IS_VALID(&tte)) { start_pfn = TTE_TO_TTEPFN(&tte); *pap = (start_pfn << MMU_PAGESHIFT) + - (addr & TTE_PAGE_OFFSET(tte.tte_size)); + (addr & TTE_PAGE_OFFSET(tte.tte_size)); pfn = *pap >> MMU_PAGESHIFT; pp = (sfhmep->hme_page != 0) ? - sfhmep->hme_page + (pfn - start_pfn) : - 0; - SFMMU_VTOP_DBG_VRB("pfn=%lx pp=%p\n", - pfn, pp); + sfhmep->hme_page + (pfn - start_pfn) : 0; + SFMMU_VTOP_DBG_VRB("pfn=%lx pp=%p\n", pfn, pp); ret = 0; } break; @@ -345,13 +343,13 @@ static void sfmmu_vtop_print_hmeblk(struct hme_blk *hmeblkp) { - if ((sfmmu_vtop_dbg & SFMMU_VTOP_DBG_DEBUG) == NULL) + if ((sfmmu_vtop_dbg & SFMMU_VTOP_DBG_DEBUG) == 0) return; mdb_printf(" hblk_nextpa=%llx\n", hmeblkp->hblk_nextpa); #ifdef __sparcv9 mdb_printf(" hblktag=%lx %lx\n", hmeblkp->hblk_tag.htag_tag[0], - hmeblkp->hblk_tag.htag_tag[1]); + hmeblkp->hblk_tag.htag_tag[1]); #else mdb_printf(" hblktag=%llx\n", hmeblkp->hblk_tag.htag_tag); #endif @@ -403,7 +401,7 @@ memseg_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) if (DCMD_HDRSPEC(flags)) mdb_printf("%%?s %?s %?s %?s %?s%\n", "ADDR", - "PAGES", "EPAGES", "BASE", "END"); + "PAGES", "EPAGES", "BASE", "END"); if (mdb_vread(&ms, sizeof (struct memseg), addr) == -1) { mdb_warn("can't read memseg at %#lx", addr); @@ -411,7 +409,7 @@ memseg_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) } mdb_printf("%0?lx %0?lx %0?lx %0?lx %0?lx\n", addr, - ms.pages, ms.epages, ms.pages_base, ms.pages_end); + ms.pages, ms.epages, ms.pages_base, ms.pages_end); return (DCMD_OK); } @@ -422,7 +420,7 @@ memseg_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) int memseg_walk_init(mdb_walk_state_t *wsp) { - if (wsp->walk_addr != NULL) { + if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("memseg only supports global walks\n"); return (WALK_ERR); } @@ -535,9 +533,9 @@ tsbinfo_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) } if (mdb_getopts(argc, argv, - 'l', MDB_OPT_SETBITS, TRUE, &lflag, - 'a', MDB_OPT_SETBITS, TRUE, &aflag, - NULL) != argc) { + 'l', MDB_OPT_SETBITS, TRUE, &lflag, + 'a', MDB_OPT_SETBITS, TRUE, &aflag, + NULL) != argc) { return (DCMD_USAGE); } @@ -600,24 +598,24 @@ tsbinfo_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) UM_SLEEP); if (mdb_vread(tsbp, sizeof (struct tsbe) * entries, - (uintptr_t)tsbinfo.tsb_va) == -1) { + (uintptr_t)tsbinfo.tsb_va) == -1) { mdb_warn("failed to read TSB at %p", tsbinfo.tsb_va); return (DCMD_ERR); } mdb_printf( - "TSB @ %lx (%d entries)\n" - "%-?s %-17s %s\n" - "%%-?s %1s %1s %-11s " - "%1s %1s %1s %1s %1s %1s %8s " - "%1s %1s %1s %1s %1s %1s %1s " - "%1s %1s %1s %1s %1s %1s%\n", - tsbinfo.tsb_va, entries, "", "TAG", "TTE", - "ADDR", "I", "L", "VA 63:22", - "V", "S", "N", "I", "H", "S", "PA 42:13", - "N", "U", "R", "W", "E", "X", "L", - "P", "V", "E", "P", "W", "G"); + "TSB @ %lx (%d entries)\n" + "%-?s %-17s %s\n" + "%%-?s %1s %1s %-11s " + "%1s %1s %1s %1s %1s %1s %8s " + "%1s %1s %1s %1s %1s %1s %1s " + "%1s %1s %1s %1s %1s %1s%\n", + tsbinfo.tsb_va, entries, "", "TAG", "TTE", + "ADDR", "I", "L", "VA 63:22", + "V", "S", "N", "I", "H", "S", "PA 42:13", + "N", "U", "R", "W", "E", "X", "L", + "P", "V", "E", "P", "W", "G"); tsbend = tsbp + entries; for (tsbstart = tsbp; tsbp < tsbend; tsbp++) { @@ -626,8 +624,8 @@ tsbinfo_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) va = (caddr_t) (((uint64_t)tsbp->tte_tag.tag_vahi - << 32) + - tsbp->tte_tag.tag_valo); + << 32) + + tsbp->tte_tag.tag_valo); pa = (tsbp->tte_data.tte_pahi << 19) + tsbp->tte_data.tte_palo; mdb_printf("%0?lx %-1u %-1u %011lx " diff --git a/usr/src/cmd/mdb/sun4u/modules/unix/unix.c b/usr/src/cmd/mdb/sun4u/modules/unix/unix.c index 09303f5345..e43449f9db 100644 --- a/usr/src/cmd/mdb/sun4u/modules/unix/unix.c +++ b/usr/src/cmd/mdb/sun4u/modules/unix/unix.c @@ -676,7 +676,7 @@ ttrace_walk_init(mdb_walk_state_t *wsp) ttrace_cpu_data_t *tc; struct trap_trace_record *buf; - if (wsp->walk_addr != NULL) { + if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("ttrace only supports global walks\n"); return (WALK_ERR); } @@ -965,7 +965,7 @@ httrace_walk_init(mdb_walk_state_t *wsp) struct htrap_trace_record *buf; htrap_trace_hdr_t *hdr; - if (wsp->walk_addr != NULL) { + if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("httrace only supports global walks\n"); return (WALK_ERR); } @@ -1347,7 +1347,7 @@ vecint_walk_init(mdb_walk_state_t *wsp) { vecint_walk_data_t *vecint; - if (wsp->walk_addr != NULL) { + if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("vecint walk only supports global walks\n"); return (WALK_ERR); } @@ -1378,13 +1378,14 @@ vecint_walk_step(mdb_walk_state_t *wsp) intr_vec_t iv; int status; - if (wsp->walk_addr == NULL) { + if (wsp->walk_addr == (uintptr_t)NULL) { while ((vecint->vec_idx < max) && ((wsp->walk_addr = - (uintptr_t)vecint->vec_table[vecint->vec_idx++]) == NULL)) + (uintptr_t)vecint->vec_table[vecint->vec_idx++]) == + (uintptr_t)NULL)) continue; } - if (wsp->walk_addr == NULL) + if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, @@ -1443,7 +1444,7 @@ softint_walk_init(mdb_walk_state_t *wsp) { intr_vec_t *list; - if (wsp->walk_addr != NULL) { + if (wsp->walk_addr != (uintptr_t)NULL) { mdb_warn("softint walk only supports global walks\n"); return (WALK_ERR); } @@ -1471,7 +1472,7 @@ softint_walk_step(mdb_walk_state_t *wsp) intr_vec_t iv; int status; - if (wsp->walk_addr == NULL) + if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, @@ -1568,7 +1569,7 @@ mutex_owner_step(mdb_walk_state_t *wsp) if (!MUTEX_TYPE_ADAPTIVE(&mtx)) return (WALK_DONE); - if ((owner = (uintptr_t)MUTEX_OWNER(&mtx)) == NULL) + if ((owner = (uintptr_t)MUTEX_OWNER(&mtx)) == (uintptr_t)NULL) return (WALK_DONE); if (mdb_vread(&thr, sizeof (thr), owner) != -1) diff --git a/usr/src/cmd/mdb/sun4v/modules/errh/errh.c b/usr/src/cmd/mdb/sun4v/modules/errh/errh.c index 6525746f3b..3554e1d559 100644 --- a/usr/src/cmd/mdb/sun4v/modules/errh/errh.c +++ b/usr/src/cmd/mdb/sun4v/modules/errh/errh.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -208,14 +206,13 @@ errh_prtaddr(uintptr_t addr, const void *data, void *private) return (WALK_NEXT); } -/*ARGSUSED*/ int rq_walk_init(mdb_walk_state_t *wsp) { cpu_t cpu; uintptr_t *ao, *lower, *upper; - if (wsp->walk_addr == NULL) { + if (wsp->walk_addr == (uintptr_t)NULL) { mdb_warn("address of struct cpu_t is required\n"); return (WALK_ERR); } @@ -245,14 +242,13 @@ rq_walk_init(mdb_walk_state_t *wsp) return (WALK_NEXT); } -/*ARGSUSED*/ int nrq_walk_init(mdb_walk_state_t *wsp) { cpu_t cpu; uintptr_t *ao, *lower, *upper; - if (wsp->walk_addr == NULL) { + if (wsp->walk_addr == (uintptr_t)NULL) { mdb_warn("address of struct cpu_t is required\n"); return (WALK_ERR); } @@ -282,14 +278,13 @@ nrq_walk_init(mdb_walk_state_t *wsp) return (WALK_NEXT); } -/*ARGSUSED*/ int errh_walk_step(mdb_walk_state_t *wsp) { int status; uintptr_t *ao, *lower, *upper; - if (wsp->walk_addr == NULL) + if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data, diff --git a/usr/src/cmd/mdb/sun4v/modules/ldc/ldc.c b/usr/src/cmd/mdb/sun4v/modules/ldc/ldc.c index 8cd92bc435..766f799e6e 100644 --- a/usr/src/cmd/mdb/sun4v/modules/ldc/ldc.c +++ b/usr/src/cmd/mdb/sun4v/modules/ldc/ldc.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This module provides debugging tools for the LDoms channels (ldc) */ @@ -233,13 +231,13 @@ ldc_walk_init(mdb_walk_state_t *wsp) ldc_soft_state_t softstate; /* Must have a start addr. */ - if (wsp->walk_addr == NULL) { + if (wsp->walk_addr == (uintptr_t)NULL) { if (mdb_readvar(&wsp->walk_addr, "ldcssp") == -1) { mdb_warn("failed to read 'ldcssp'"); return (WALK_ERR); } - if (wsp->walk_addr == NULL) + if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); if (mdb_vread(&softstate, sizeof (softstate), wsp->walk_addr) @@ -263,7 +261,7 @@ ldc_walk_step(mdb_walk_state_t *wsp) int status; ldc_chan_t ldcp; - if (wsp->walk_addr == NULL) + if (wsp->walk_addr == (uintptr_t)NULL) return (WALK_DONE); if (mdb_vread(&ldcp, sizeof (ldc_chan_t), wsp->walk_addr) == -1) { @@ -289,7 +287,7 @@ int ldcmsg(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { ldc_msg_t msg; - uint64_t count = 1; + uint64_t count = 1; int i; /* @@ -476,7 +474,7 @@ ldcmhdl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) mdb_printf("\n"); } - if ((addr = (uintptr_t)mhdl.next) == NULL) + if ((addr = (uintptr_t)mhdl.next) == (uintptr_t)NULL) break; } diff --git a/usr/src/cmd/mdb/sun4v/modules/mdesc/mdesc.c b/usr/src/cmd/mdb/sun4v/modules/mdesc/mdesc.c index d0184bc7c8..b2c791690e 100644 --- a/usr/src/cmd/mdb/sun4v/modules/mdesc/mdesc.c +++ b/usr/src/cmd/mdb/sun4v/modules/mdesc/mdesc.c @@ -68,7 +68,7 @@ mdhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) else mdb_printf("%p\n", mdp); - } while ((mdp = (uintptr_t)md.next) != NULL); + } while ((mdp = (uintptr_t)md.next) != (uintptr_t)NULL); return (DCMD_OK); } diff --git a/usr/src/cmd/mdb/sun4v/modules/vdsk/vdsk.c b/usr/src/cmd/mdb/sun4v/modules/vdsk/vdsk.c index b43c3f9d95..c404a3fb98 100644 --- a/usr/src/cmd/mdb/sun4v/modules/vdsk/vdsk.c +++ b/usr/src/cmd/mdb/sun4v/modules/vdsk/vdsk.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * This module provides debugging tools for the LDoms vDisk drivers * (vds and vdc). @@ -41,7 +39,7 @@ int vd_dring_entry_walk_init(mdb_walk_state_t *wsp) { /* Must have a start addr. */ - if (wsp->walk_addr == NULL) { + if (wsp->walk_addr == (uintptr_t)NULL) { mdb_warn("Descriptor Ring base address required\n"); return (WALK_ERR); -- cgit v1.2.3 From 29368e865707707ba77989693d34358ebfa08757 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 30 Jan 2020 14:09:14 +0200 Subject: 12644 vdc: NULL pointer errors Reviewed by: Peter Tribble Reviewed by: John Levon Approved by: Dan McDonald --- usr/src/uts/sun4v/io/vdc.c | 81 +++++++++++++++++++++--------------------- usr/src/uts/sun4v/vdc/Makefile | 8 ----- 2 files changed, 41 insertions(+), 48 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/sun4v/io/vdc.c b/usr/src/uts/sun4v/io/vdc.c index ccea7403ea..6f55fcc6e6 100644 --- a/usr/src/uts/sun4v/io/vdc.c +++ b/usr/src/uts/sun4v/io/vdc.c @@ -173,14 +173,14 @@ static int vdc_process_data_msg(vdc_t *vdc, vio_msg_t *msg); static int vdc_handle_ver_msg(vdc_t *vdc, vio_ver_msg_t *ver_msg); static int vdc_handle_attr_msg(vdc_t *vdc, vd_attr_msg_t *attr_msg); static int vdc_handle_dring_reg_msg(vdc_t *vdc, vio_dring_reg_msg_t *msg); -static int vdc_send_request(vdc_t *vdcp, int operation, +static int vdc_send_request(vdc_t *vdcp, int operation, caddr_t addr, size_t nbytes, int slice, diskaddr_t offset, buf_t *bufp, vio_desc_direction_t dir, int flags); static int vdc_map_to_shared_dring(vdc_t *vdcp, int idx); -static int vdc_populate_descriptor(vdc_t *vdcp, int operation, +static int vdc_populate_descriptor(vdc_t *vdcp, int operation, caddr_t addr, size_t nbytes, int slice, diskaddr_t offset, buf_t *bufp, vio_desc_direction_t dir, int flags); -static int vdc_do_sync_op(vdc_t *vdcp, int operation, caddr_t addr, +static int vdc_do_sync_op(vdc_t *vdcp, int operation, caddr_t addr, size_t nbytes, int slice, diskaddr_t offset, vio_desc_direction_t dir, boolean_t); static int vdc_do_op(vdc_t *vdc, int op, caddr_t addr, size_t nbytes, @@ -224,7 +224,7 @@ static int vdc_get_efi_convert(vdc_t *vdc, void *from, void *to, static int vdc_set_efi_convert(vdc_t *vdc, void *from, void *to, int mode, int dir); -static void vdc_ownership_update(vdc_t *vdc, int ownership_flags); +static void vdc_ownership_update(vdc_t *vdc, int ownership_flags); static int vdc_access_set(vdc_t *vdc, uint64_t flags); static vdc_io_t *vdc_eio_queue(vdc_t *vdc, int index); static void vdc_eio_unqueue(vdc_t *vdc, clock_t deadline, @@ -284,7 +284,7 @@ static uint_t vdc_hattr_min = VDC_HATTR_MIN; * various operations */ static int vdc_timeout = 0; /* units: seconds */ -static int vdc_ldcup_timeout = 1; /* units: seconds */ +static int vdc_ldcup_timeout = 1; /* units: seconds */ static uint64_t vdc_hz_min_ldc_delay; static uint64_t vdc_min_timeout_ldc = 1 * MILLISEC; @@ -1074,7 +1074,7 @@ vdc_create_device_nodes_vtoc(vdc_t *vdc) * refers to a whole disk. Slices start at 'a' * * Parameters: - * vdc - soft state pointer + * vdc - soft state pointer * * Return Values * 0 - Success @@ -1192,7 +1192,7 @@ vdc_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags, * currently opened. * * Parameters: - * vdc - soft state pointer + * vdc - soft state pointer * * Return Values * B_TRUE - at least one slice is opened. @@ -2576,7 +2576,7 @@ vdc_terminate_ldc(vdc_t *vdc, vdc_server_t *srvr) if (srvr->state & VDC_LDC_INIT) { DMSG(vdc, 0, "[%d] ldc_fini()\n", instance); (void) ldc_fini(srvr->ldc_handle); - srvr->ldc_handle = NULL; + srvr->ldc_handle = 0; } srvr->state &= ~(VDC_LDC_INIT | VDC_LDC_CB | VDC_LDC_OPEN); @@ -2682,7 +2682,7 @@ vdc_init_descriptor_ring(vdc_t *vdc) status = ldc_mem_dring_create(vdc->dring_len, vdc->dring_entry_size, &vdc->dring_hdl); - if ((vdc->dring_hdl == NULL) || (status != 0)) { + if ((vdc->dring_hdl == 0) || (status != 0)) { DMSG(vdc, 0, "[%d] Descriptor ring creation failed", vdc->instance); return (status); @@ -2773,7 +2773,7 @@ static void vdc_destroy_descriptor_ring(vdc_t *vdc) { vdc_local_desc_t *ldep = NULL; /* Local Dring Entry Pointer */ - ldc_mem_handle_t mhdl = NULL; + ldc_mem_handle_t mhdl = 0; ldc_mem_info_t minfo; int status = -1; int i; /* loop */ @@ -2790,7 +2790,7 @@ vdc_destroy_descriptor_ring(vdc_t *vdc) ldep = &vdc->local_dring[i]; mhdl = ldep->desc_mhdl; - if (mhdl == NULL) + if (mhdl == 0) continue; if ((status = ldc_mem_info(mhdl, &minfo)) != 0) { @@ -2803,7 +2803,7 @@ vdc_destroy_descriptor_ring(vdc_t *vdc) * is not valid. Clear it out so that * no one tries to use it. */ - ldep->desc_mhdl = NULL; + ldep->desc_mhdl = 0; continue; } @@ -2813,7 +2813,7 @@ vdc_destroy_descriptor_ring(vdc_t *vdc) (void) ldc_mem_free_handle(mhdl); - ldep->desc_mhdl = NULL; + ldep->desc_mhdl = 0; } vdc->initialized &= ~VDC_DRING_ENTRY; } @@ -2841,7 +2841,7 @@ vdc_destroy_descriptor_ring(vdc_t *vdc) DMSG(vdc, 0, "[%d] Destroying DRing\n", vdc->instance); status = ldc_mem_dring_destroy(vdc->dring_hdl); if (status == 0) { - vdc->dring_hdl = NULL; + vdc->dring_hdl = 0; bzero(&vdc->dring_mem_info, sizeof (ldc_mem_info_t)); vdc->initialized &= ~VDC_DRING_INIT; } else { @@ -3197,7 +3197,7 @@ loop: * vdc_do_op * * Description: - * Wrapper around vdc_submit_request(). Each request is associated with a + * Wrapper around vdc_submit_request(). Each request is associated with a * buf structure. If a buf structure is provided (bufp != NULL) then the * request will be submitted with that buf, and the caller can wait for * completion of the request with biowait(). If a buf structure is not @@ -3321,7 +3321,7 @@ done: * vdc_do_sync_op * * Description: - * Wrapper around vdc_do_op that serializes requests. + * Wrapper around vdc_do_op that serializes requests. * * Arguments: * vdcp - the soft state pointer @@ -3411,9 +3411,9 @@ vdc_do_sync_op(vdc_t *vdcp, int operation, caddr_t addr, size_t nbytes, * vdc_drain_response() * * Description: - * When a guest is panicking, the completion of requests needs to be - * handled differently because interrupts are disabled and vdc - * will not get messages. We have to poll for the messages instead. + * When a guest is panicking, the completion of requests needs to be + * handled differently because interrupts are disabled and vdc + * will not get messages. We have to poll for the messages instead. * * Note: since we are panicking we don't implement the io:::done * DTrace probe or update the I/O statistics kstats. @@ -3431,9 +3431,9 @@ vdc_do_sync_op(vdc_t *vdcp, int operation, caddr_t addr, size_t nbytes, static int vdc_drain_response(vdc_t *vdc, struct buf *buf) { - int rv, idx, retries; + int rv, idx, retries; size_t msglen; - vdc_local_desc_t *ldep = NULL; /* Local Dring Entry Pointer */ + vdc_local_desc_t *ldep = NULL; /* Local Dring Entry Pointer */ vio_dring_msg_t dmsg; struct buf *mbuf; boolean_t ack; @@ -3926,7 +3926,7 @@ vdc_wait_for_response(vdc_t *vdcp, vio_msg_t *msgp) * * Description: * Resubmit each descriptor in the backed up dring to - * vDisk server. The Dring was backed up during connection + * vDisk server. The Dring was backed up during connection * reset. * * Arguments: @@ -4030,7 +4030,7 @@ void vdc_cancel_backup_dring(vdc_t *vdcp) { vdc_local_desc_t *ldep; - struct buf *bufp; + struct buf *bufp; int count; int b_idx; int dring_size; @@ -4118,7 +4118,7 @@ vdc_cancel_backup_dring(vdc_t *vdcp) void vdc_connection_timeout(void *arg) { - vdc_t *vdcp = (vdc_t *)arg; + vdc_t *vdcp = (vdc_t *)arg; mutex_enter(&vdcp->lock); @@ -4213,7 +4213,7 @@ static void vdc_switch_server(vdc_t *vdcp) { int rv; - vdc_server_t *curr_server, *new_server; + vdc_server_t *curr_server, *new_server; ASSERT(MUTEX_HELD(&vdcp->lock)); @@ -4410,9 +4410,9 @@ vdc_handshake_retry(vdc_t *vdcp, int hshake_cnt, int hattr_cnt) * Description: * * Main VDC message processing thread. Each vDisk instance - * consists of a copy of this thread. This thread triggers - * all the handshakes and data exchange with the server. It - * also handles all channel resets + * consists of a copy of this thread. This thread triggers + * all the handshakes and data exchange with the server. It + * also handles all channel resets * * Arguments: * vdc - soft state pointer for this instance of the device driver. @@ -5516,7 +5516,7 @@ typedef struct vdc_dk_arg { /* * Function: - * vdc_dkio_flush_cb() + * vdc_dkio_flush_cb() * * Description: * This routine is a callback for DKIOCFLUSHWRITECACHE which can be called @@ -5572,7 +5572,7 @@ vdc_dkio_flush_cb(void *arg) /* * Function: - * vdc_dkio_gapart() + * vdc_dkio_gapart() * * Description: * This function implements the DKIOCGAPART ioctl. @@ -5638,7 +5638,7 @@ vdc_dkio_gapart(vdc_t *vdc, caddr_t arg, int flag) /* * Function: - * vdc_dkio_partition() + * vdc_dkio_partition() * * Description: * This function implements the DKIOCPARTITION ioctl. @@ -5691,7 +5691,7 @@ vdc_dkio_partition(vdc_t *vdc, caddr_t arg, int flag) /* * Function: - * vdc_dioctl_rwcmd() + * vdc_dioctl_rwcmd() * * Description: * This function implements the DIOCTL_RWCMD ioctl. This ioctl is used @@ -5934,15 +5934,15 @@ vdc_scsi_status(vdc_t *vdc, vd_scsi_t *vd_scsi, boolean_t log_error) static int vdc_uscsi_cmd(vdc_t *vdc, caddr_t arg, int mode) { - struct uscsi_cmd uscsi; + struct uscsi_cmd uscsi; struct uscsi_cmd32 uscsi32; - vd_scsi_t *vd_scsi; - int vd_scsi_len; + vd_scsi_t *vd_scsi; + int vd_scsi_len; union scsi_cdb *cdb; struct scsi_extended_sense *sense; - char *datain, *dataout; + char *datain, *dataout; size_t cdb_len, datain_len, dataout_len, sense_len; - int rv; + int rv; if (ddi_model_convert_from(mode & FMODELS) == DDI_MODEL_ILP32) { if (ddi_copyin(arg, &uscsi32, sizeof (struct uscsi_cmd32), @@ -7200,7 +7200,7 @@ static vdc_dk_ioctl_t dk_ioctl[] = { vdc_get_geom_convert}, {VD_OP_GET_DISKGEOM, DKIOCG_PHYGEOM, sizeof (vd_geom_t), vdc_get_geom_convert}, - {VD_OP_GET_DISKGEOM, DKIOCG_VIRTGEOM, sizeof (vd_geom_t), + {VD_OP_GET_DISKGEOM, DKIOCG_VIRTGEOM, sizeof (vd_geom_t), vdc_get_geom_convert}, {VD_OP_SET_DISKGEOM, DKIOCSGEOM, sizeof (vd_geom_t), vdc_set_geom_convert}, @@ -7222,7 +7222,7 @@ static vdc_dk_ioctl_t dk_ioctl[] = { {0, MHIOCGRP_INKEYS, 0, vdc_null_copy_func}, {0, MHIOCGRP_INRESV, 0, vdc_null_copy_func}, {0, MHIOCGRP_REGISTER, 0, vdc_null_copy_func}, - {0, MHIOCGRP_RESERVE, 0, vdc_null_copy_func}, + {0, MHIOCGRP_RESERVE, 0, vdc_null_copy_func}, {0, MHIOCGRP_PREEMPTANDABORT, 0, vdc_null_copy_func}, {0, MHIOCGRP_REGISTERANDIGNOREKEY, 0, vdc_null_copy_func}, @@ -7578,9 +7578,10 @@ vd_process_ioctl(dev_t dev, int cmd, caddr_t arg, int mode, int *rvalp) vdc->dkio_flush_pending--; mutex_exit(&vdc->lock); kmem_free(dkarg, sizeof (vdc_dk_arg_t)); + return (ENOMEM); } - return (rv == NULL ? ENOMEM : 0); + return (0); } } diff --git a/usr/src/uts/sun4v/vdc/Makefile b/usr/src/uts/sun4v/vdc/Makefile index 9877103746..d9bf73ea19 100644 --- a/usr/src/uts/sun4v/vdc/Makefile +++ b/usr/src/uts/sun4v/vdc/Makefile @@ -40,7 +40,6 @@ UTSBASE = ../.. # MODULE = vdc OBJECTS = $(VDC_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(VDC_OBJS:%.o=$(LINTS_DIR)/%.ln) ROOTMODULE = $(ROOT_PSM_DRV_DIR)/$(MODULE) # @@ -59,7 +58,6 @@ CLEANFILES += $(MODSTUBS_O) # Define targets # ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint INSTALL_TARGET = $(BINARY) $(ROOTMODULE) CFLAGS += $(CCVERBOSE) @@ -83,12 +81,6 @@ clean: $(CLEAN_DEPS) clobber: $(CLOBBER_DEPS) -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - install: $(INSTALL_DEPS) # -- cgit v1.2.3 From cb453c7ae4b42ac7a2d7ce155181572a96d69b33 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Sat, 1 Feb 2020 09:50:38 +0200 Subject: 12650 ds: smatch and NULL pointer errors Reviewed by: C Fraire Approved by: Dan McDonald --- usr/src/uts/sun4v/ds/Makefile | 20 -------------------- usr/src/uts/sun4v/io/ds_common.c | 4 ++-- usr/src/uts/sun4v/io/ds_drv.c | 8 +++----- usr/src/uts/sun4v/sys/ds_impl.h | 8 ++++---- 4 files changed, 9 insertions(+), 31 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/sun4v/ds/Makefile b/usr/src/uts/sun4v/ds/Makefile index ed43f2f58e..f119b7138f 100644 --- a/usr/src/uts/sun4v/ds/Makefile +++ b/usr/src/uts/sun4v/ds/Makefile @@ -40,7 +40,6 @@ UTSBASE = ../.. # MODULE = ds OBJECTS = $(DS_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(DS_OBJS:%.o=$(LINTS_DIR)/%.ln) ROOTMODULE = $(ROOT_PSM_MISC_DIR)/$(MODULE) # @@ -52,14 +51,8 @@ include $(UTSBASE)/sun4v/Makefile.sun4v # Define targets # ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint INSTALL_TARGET = $(BINARY) $(ROOTMODULE) -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) - # # Turn on doubleword alignment for 64 bit registers # @@ -70,13 +63,6 @@ CFLAGS += -dalign # LDFLAGS += -dy -Nmisc/ldc -# -# For now, disable these lint checks; maintainers should endeavor -# to investigate and remove these for maximum lint coverage. -# Please do not carry these forward to new Makefiles. -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN - CERRWARN += $(CNOWARN_UNINIT) # @@ -92,12 +78,6 @@ clean: $(CLEAN_DEPS) clobber: $(CLOBBER_DEPS) -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - install: $(INSTALL_DEPS) # diff --git a/usr/src/uts/sun4v/io/ds_common.c b/usr/src/uts/sun4v/io/ds_common.c index 54876ac3bc..fad3014d2b 100644 --- a/usr/src/uts/sun4v/io/ds_common.c +++ b/usr/src/uts/sun4v/io/ds_common.c @@ -431,7 +431,7 @@ ds_ldc_fini(ds_port_t *port) } port->ldc.id = (uint64_t)-1; - port->ldc.hdl = NULL; + port->ldc.hdl = 0; port->ldc.state = 0; return (rv); @@ -2492,7 +2492,7 @@ ds_ucap_init(ds_capability_t *cap, ds_clnt_ops_t *ops, uint32_t flags, ds_vers_check_t status; ds_svc_t *svc; int rv = 0; - ds_svc_hdl_t lb_hdl, hdl; + ds_svc_hdl_t lb_hdl, hdl; int is_loopback; int is_client; diff --git a/usr/src/uts/sun4v/io/ds_drv.c b/usr/src/uts/sun4v/io/ds_drv.c index 2b2ba29e52..b812999005 100644 --- a/usr/src/uts/sun4v/io/ds_drv.c +++ b/usr/src/uts/sun4v/io/ds_drv.c @@ -493,8 +493,6 @@ static ds_log_entry_t ds_log_entry_pool[DS_LOG_NPOOL]; static void ds_log_init(void) { - ds_log_entry_t *new; - /* initialize global lock */ mutex_init(&ds_log.lock, NULL, MUTEX_DRIVER, NULL); @@ -506,9 +504,9 @@ ds_log_init(void) ds_log.nentry = 0; /* initialize the free list */ - for (new = ds_log_entry_pool; new < DS_LOG_POOL_END; new++) { - new->next = ds_log.freelist; - ds_log.freelist = new; + for (int i = 0; i < DS_LOG_NPOOL; i++) { + ds_log_entry_pool[i].next = ds_log.freelist; + ds_log.freelist = &ds_log_entry_pool[i]; } mutex_exit(&ds_log.lock); diff --git a/usr/src/uts/sun4v/sys/ds_impl.h b/usr/src/uts/sun4v/sys/ds_impl.h index a2a06d21a3..00e8ba7680 100644 --- a/usr/src/uts/sun4v/sys/ds_impl.h +++ b/usr/src/uts/sun4v/sys/ds_impl.h @@ -196,7 +196,7 @@ typedef struct ds_port { uint32_t ver_idx; /* index of version during handshake */ ds_ldc_t ldc; /* LDC for this port */ ds_domain_hdl_t domain_hdl; /* LDOMs domain hdl assoc. with port */ - char *domain_name; /* LDOMs domain name assoc. with port */ + char *domain_name; /* LDOMs domain name assoc. with port */ } ds_port_t; #define IS_DS_PORT(port) 1 /* VBSC code compatability */ @@ -404,7 +404,7 @@ typedef struct ds_log_entry { #define DS_LOG_POOL_END (ds_log_entry_pool + DS_LOG_NPOOL) #define DS_IS_POOL_ENTRY(ep) (((ep) >= ds_log_entry_pool) && \ - ((ep) <= &(ds_log_entry_pool[DS_LOG_NPOOL]))) + ((ep) < &(ds_log_entry_pool[DS_LOG_NPOOL]))) /* VBSC code compatability related defines */ @@ -554,8 +554,8 @@ void ds_dump_msg(void *buf, size_t len); #define DS_DUMP_MSG(flags, buf, len) #define DS_DUMP_LDC_MSG(buf, len) -#define DS_BADHDL1 NULL -#define DS_BADHDL2 NULL +#define DS_BADHDL1 (ds_svc_hdl_t)0 +#define DS_BADHDL2 (ds_svc_hdl_t)0 #endif /* DEBUG */ -- cgit v1.2.3 From 725953abcc30bcf6f15d7b8a313ab0749275d95f Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 31 Jan 2020 10:06:12 +0200 Subject: 12610 rmcadm: NULL pointer errors Reviewed by: GergÅ‘ Doma Reviewed by: Peter Tribble Approved by: Dan McDonald MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/src/uts/sun4u/io/rmcadm.c | 2 +- usr/src/uts/sun4u/rmcadm/Makefile | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/sun4u/io/rmcadm.c b/usr/src/uts/sun4u/io/rmcadm.c index 2ad9a87c23..ed4da3a286 100644 --- a/usr/src/uts/sun4u/io/rmcadm.c +++ b/usr/src/uts/sun4u/io/rmcadm.c @@ -233,7 +233,7 @@ rmcadm_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) return (DDI_FAILURE); err = ddi_create_minor_node(dip, "rmcadm", S_IFCHR, - instance, DDI_PSEUDO, NULL); + instance, DDI_PSEUDO, 0); if (err != DDI_SUCCESS) return (DDI_FAILURE); diff --git a/usr/src/uts/sun4u/rmcadm/Makefile b/usr/src/uts/sun4u/rmcadm/Makefile index baa1fb4883..4ef75a6149 100644 --- a/usr/src/uts/sun4u/rmcadm/Makefile +++ b/usr/src/uts/sun4u/rmcadm/Makefile @@ -23,8 +23,6 @@ # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -#ident "%Z%%M% %I% %E% SMI" -# # This makefile drives the production of the rmcadm driver kernel # module in the sun4u systems # @@ -39,7 +37,6 @@ UTSBASE = ../.. # MODULE = rmcadm OBJECTS = $(RMCADM_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(RMCADM_OBJS:%.o=$(LINTS_DIR)/%.ln) ROOTMODULE = $(ROOT_PSM_DRV_DIR)/$(MODULE) CONF_SRCDIR = $(UTSBASE)/sun4u/io @@ -52,13 +49,8 @@ include $(UTSBASE)/sun4u/Makefile.sun4u # Define targets # ALL_TARGET = $(BINARY) $(SRC_CONFILE) -LINT_TARGET = $(MODULE).lint INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) -# -# lint pass one enforcement -# -CFLAGS += $(CCVERBOSE) LDFLAGS += -dy -Ndrv/rmc_comm -Ndrv/pmugpio # @@ -79,12 +71,6 @@ clean: $(CLEAN_DEPS) clobber: $(CLOBBER_DEPS) -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - install: $(INSTALL_DEPS) # -- cgit v1.2.3 From f8927fa6636832af96f657f29571bdbd213c6247 Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Sun, 19 Apr 2020 17:04:03 +0000 Subject: 12554 want sdev plugin framework Portions contributed by: John Levon Portions contributed by: Mike Gerdts Reviewed by: Jerry Jelinek Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/uts/common/Makefile.files | 3 +- usr/src/uts/common/fs/dev/sdev_plugin.c | 948 ++++++++++++++++++++++++++++++++ usr/src/uts/common/fs/dev/sdev_subr.c | 209 +------ usr/src/uts/common/fs/dev/sdev_vfsops.c | 23 +- usr/src/uts/common/fs/dev/sdev_vnops.c | 38 +- usr/src/uts/common/sys/fs/sdev_impl.h | 61 +- usr/src/uts/common/sys/fs/sdev_plugin.h | 106 ++++ usr/src/uts/intel/dev/Makefile | 1 + 8 files changed, 1153 insertions(+), 236 deletions(-) create mode 100644 usr/src/uts/common/fs/dev/sdev_plugin.c create mode 100644 usr/src/uts/common/sys/fs/sdev_plugin.h (limited to 'usr/src') diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index 36b2c49d67..dbed5ea9cc 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -1067,8 +1067,7 @@ DEVFS_OBJS += devfs_subr.o devfs_vfsops.o devfs_vnops.o DEV_OBJS += sdev_subr.o sdev_vfsops.o sdev_vnops.o \ sdev_ptsops.o sdev_zvolops.o sdev_comm.o \ sdev_profile.o sdev_ncache.o sdev_netops.o \ - sdev_ipnetops.o \ - sdev_vtops.o + sdev_ipnetops.o sdev_vtops.o sdev_plugin.o CTFS_OBJS += ctfs_all.o ctfs_cdir.o ctfs_ctl.o ctfs_event.o \ ctfs_latest.o ctfs_root.o ctfs_sym.o ctfs_tdir.o ctfs_tmpl.o diff --git a/usr/src/uts/common/fs/dev/sdev_plugin.c b/usr/src/uts/common/fs/dev/sdev_plugin.c new file mode 100644 index 0000000000..8f825eccff --- /dev/null +++ b/usr/src/uts/common/fs/dev/sdev_plugin.c @@ -0,0 +1,948 @@ +/* + * 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 2019 Joyent, Inc. + */ + +/* + * Dynamic directory plugin interface for sdev. + * + * The sdev plugin interfaces provides a means for a dynamic directory based on + * in-kernel state to be simply created. Traditionally, dynamic directories were + * built into sdev itself. While these legacy plugins are useful, it makes more + * sense for these pieces of functionality to live with the individual drivers. + * + * The plugin interface requires folks to implement three interfaces and + * provides a series of callbacks that can be made in the context of those + * interfaces to interrogate the sdev_node_t without having to leak + * implementation details of the sdev_node_t. These interfaces are: + * + * o spo_validate + * + * Given a particular node, answer the question as to whether or not this + * entry is still valid. Here, plugins should use the name and the dev_t + * associated with the node to verify that it matches something that still + * exists. + * + * o spo_filldir + * + * Fill all the entries inside of a directory. Note that some of these entries + * may already exist. + * + * o spo_inactive + * + * The given node is no longer being used. This allows the consumer to + * potentially tear down anything that was being held open related to this. + * Note that this only fires when the given sdev_node_t becomes a zombie. + * + * During these callbacks a consumer is not allowed to register or unregister a + * plugin, especially their own. They may call the sdev_ctx style functions. All + * callbacks fire in a context where blocking is allowed (eg. the spl is below + * LOCK_LEVEL). + * + * When a plugin is added, we create its directory in the global zone. By doing + * that, we ensure that something isn't already there and that nothing else can + * come along and try and create something without our knowledge. We only have + * to create it in the GZ and not for all other instances of sdev because an + * instance of sdev that isn't at /dev does not have dynamic directories, and + * second, any instance of sdev present in a non-global zone cannot create + * anything, therefore we know that by it not being in the global zone's + * instance of sdev that we're good to go. + * + * Lock Ordering + * ------------- + * + * The global sdev_plugin_lock must be held before any of the individual + * sdev_plugin_t`sp_lock. Further, once any plugin related lock has been held, + * it is not legal to take any holds on any sdev_node_t or to grab the + * sdev_node_t`contents_lock in any way. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +kmutex_t sdev_plugin_lock; +list_t sdev_plugin_list; +kmem_cache_t *sdev_plugin_cache; +struct vnodeops *sdev_plugin_vnops; + +#define SDEV_PLUGIN_NAMELEN 64 + +typedef struct sdev_plugin { + list_node_t sp_link; + char sp_name[SDEV_PLUGIN_NAMELEN]; /* E */ + int sp_nflags; /* E */ + struct vnodeops *sp_vnops; /* E */ + sdev_plugin_ops_t *sp_pops; /* E */ + boolean_t sp_islegacy; /* E */ + int (*sp_lvtor)(sdev_node_t *); /* E */ + kmutex_t sp_lock; /* Protects everything below */ + kcondvar_t sp_nodecv; + size_t sp_nnodes; +} sdev_plugin_t; + +/* ARGSUSED */ +static int +sdev_plugin_cache_constructor(void *buf, void *arg, int tags) +{ + sdev_plugin_t *spp = buf; + mutex_init(&spp->sp_lock, NULL, MUTEX_DRIVER, 0); + cv_init(&spp->sp_nodecv, NULL, CV_DRIVER, NULL); + return (0); +} + +/* ARGSUSED */ +static void +sdev_plugin_cache_destructor(void *buf, void *arg) +{ + sdev_plugin_t *spp = buf; + cv_destroy(&spp->sp_nodecv); + mutex_destroy(&spp->sp_lock); +} + +enum vtype +sdev_ctx_vtype(sdev_ctx_t ctx) +{ + sdev_node_t *sdp = (sdev_node_t *)ctx; + + ASSERT(RW_LOCK_HELD(&sdp->sdev_contents)); + return (sdp->sdev_vnode->v_type); +} + +const char * +sdev_ctx_path(sdev_ctx_t ctx) +{ + sdev_node_t *sdp = (sdev_node_t *)ctx; + + ASSERT(RW_LOCK_HELD(&sdp->sdev_contents)); + return (sdp->sdev_path); +} + +const char * +sdev_ctx_name(sdev_ctx_t ctx) +{ + sdev_node_t *sdp = (sdev_node_t *)ctx; + + ASSERT(RW_LOCK_HELD(&sdp->sdev_contents)); + return (sdp->sdev_name); +} + +int +sdev_ctx_minor(sdev_ctx_t ctx, minor_t *minorp) +{ + sdev_node_t *sdp = (sdev_node_t *)ctx; + + ASSERT(RW_LOCK_HELD(&sdp->sdev_contents)); + ASSERT(minorp != NULL); + if (sdp->sdev_vnode->v_type == VCHR || + sdp->sdev_vnode->v_type == VBLK) { + *minorp = getminor(sdp->sdev_vnode->v_rdev); + return (0); + } + + return (ENODEV); +} + +/* + * Currently we only support psasing through a single flag -- SDEV_IS_GLOBAL. + */ +sdev_ctx_flags_t +sdev_ctx_flags(sdev_ctx_t ctx) +{ + sdev_node_t *sdp = (sdev_node_t *)ctx; + + ASSERT(RW_LOCK_HELD(&sdp->sdev_contents)); + return (sdp->sdev_flags & SDEV_GLOBAL); +} + +/* + * Use the same rules as zones for a name. isalphanum + '-', '_', and '.'. + */ +static int +sdev_plugin_name_isvalid(const char *c, int buflen) +{ + int i; + + for (i = 0; i < buflen; i++, c++) { + if (*c == '\0') + return (1); + + if (!isalnum(*c) && *c != '-' && *c != '_' && *c != '.') + return (0); + } + /* Never found a null terminator */ + return (0); +} + +static int +sdev_plugin_mknode(sdev_plugin_t *spp, sdev_node_t *sdvp, char *name, + vattr_t *vap) +{ + int ret; + sdev_node_t *svp; + + ASSERT(RW_WRITE_HELD(&sdvp->sdev_contents)); + ASSERT(spp != NULL); + svp = sdev_cache_lookup(sdvp, name); + if (svp != NULL) { + SDEV_SIMPLE_RELE(svp); + return (EEXIST); + } + + ret = sdev_mknode(sdvp, name, &svp, vap, NULL, NULL, kcred, + SDEV_READY); + if (ret != 0) + return (ret); + SDEV_SIMPLE_RELE(svp); + + return (0); +} + +/* + * Plugin node creation callbacks + */ +int +sdev_plugin_mkdir(sdev_ctx_t ctx, char *name) +{ + sdev_node_t *sdvp; + timestruc_t now; + struct vattr vap; + + if (sdev_plugin_name_isvalid(name, SDEV_PLUGIN_NAMELEN) == 0) + return (EINVAL); + + sdvp = (sdev_node_t *)ctx; + ASSERT(sdvp->sdev_private != NULL); + ASSERT(RW_WRITE_HELD(&sdvp->sdev_contents)); + + vap = *sdev_getdefault_attr(VDIR); + gethrestime(&now); + vap.va_atime = now; + vap.va_mtime = now; + vap.va_ctime = now; + + return (sdev_plugin_mknode(sdvp->sdev_private, sdvp, name, &vap)); +} + +int +sdev_plugin_mknod(sdev_ctx_t ctx, char *name, mode_t mode, dev_t dev) +{ + sdev_node_t *sdvp; + timestruc_t now; + struct vattr vap; + mode_t type = mode & S_IFMT; + mode_t access = mode & S_IAMB; + + if (sdev_plugin_name_isvalid(name, SDEV_PLUGIN_NAMELEN) == 0) + return (EINVAL); + + sdvp = (sdev_node_t *)ctx; + ASSERT(RW_WRITE_HELD(&sdvp->sdev_contents)); + + /* + * Ensure only type and user/group/other permission bits are present. + * Do not allow setuid, setgid, etc. + */ + if ((mode & ~(S_IFMT | S_IAMB)) != 0) + return (EINVAL); + + /* Disallow types other than character and block devices */ + if (type != S_IFCHR && type != S_IFBLK) + return (EINVAL); + + /* Disallow execute bits */ + if ((access & (S_IXUSR | S_IXGRP | S_IXOTH)) != 0) + return (EINVAL); + + /* No bits other than 0666 in access */ + ASSERT((access & + ~(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == 0); + + /* Default to relatively safe access bits if none specified. */ + if (access == 0) + access = 0600; + + ASSERT(sdvp->sdev_private != NULL); + + vap = *sdev_getdefault_attr(type == S_IFCHR ? VCHR : VBLK); + gethrestime(&now); + vap.va_atime = now; + vap.va_mtime = now; + vap.va_ctime = now; + vap.va_rdev = dev; + vap.va_mode = type | access; + + /* Despite the similar name, this is in fact a different function */ + return (sdev_plugin_mknode(sdvp->sdev_private, sdvp, name, &vap)); +} + +static int +sdev_plugin_validate(sdev_node_t *sdp) +{ + int ret; + sdev_plugin_t *spp; + + ASSERT(sdp->sdev_private != NULL); + spp = sdp->sdev_private; + ASSERT(spp->sp_islegacy == B_FALSE); + ASSERT(spp->sp_pops != NULL); + rw_enter(&sdp->sdev_contents, RW_READER); + ret = spp->sp_pops->spo_validate((uintptr_t)sdp); + rw_exit(&sdp->sdev_contents); + return (ret); +} + +static void +sdev_plugin_validate_dir(sdev_node_t *sdvp) +{ + int ret; + sdev_node_t *svp, *next; + + ASSERT(RW_WRITE_HELD(&sdvp->sdev_contents)); + + for (svp = SDEV_FIRST_ENTRY(sdvp); svp != NULL; svp = next) { + + next = SDEV_NEXT_ENTRY(sdvp, svp); + ASSERT(svp->sdev_state != SDEV_ZOMBIE); + /* skip nodes that aren't ready */ + if (svp->sdev_state == SDEV_INIT) + continue; + + switch (sdev_plugin_validate(svp)) { + case SDEV_VTOR_VALID: + case SDEV_VTOR_SKIP: + continue; + case SDEV_VTOR_INVALID: + case SDEV_VTOR_STALE: + break; + } + + SDEV_HOLD(svp); + + /* + * Clean out everything underneath this node before we + * remove it. + */ + if (svp->sdev_vnode->v_type == VDIR) { + ret = sdev_cleandir(svp, NULL, 0); + ASSERT(ret == 0); + } + /* remove the cache node */ + (void) sdev_cache_update(sdvp, &svp, svp->sdev_name, + SDEV_CACHE_DELETE); + SDEV_RELE(svp); + } +} + +/* ARGSUSED */ +static int +sdev_plugin_vop_readdir(struct vnode *dvp, struct uio *uiop, struct cred *cred, + int *eofp, caller_context_t *ct_unused, int flags_unused) +{ + int ret; + sdev_node_t *sdvp = VTOSDEV(dvp); + sdev_plugin_t *spp; + + ASSERT(RW_READ_HELD(&sdvp->sdev_contents)); + + /* Sanity check we're not a zombie before we do anyting else */ + if (sdvp->sdev_state == SDEV_ZOMBIE) + return (ENOENT); + + spp = sdvp->sdev_private; + ASSERT(spp != NULL); + ASSERT(spp->sp_islegacy == B_FALSE); + ASSERT(spp->sp_pops != NULL); + + if (crgetzoneid(cred) == GLOBAL_ZONEID && !SDEV_IS_GLOBAL(sdvp)) + return (EPERM); + + if (uiop->uio_offset == 0) { + /* + * We upgrade to a write lock and grab the plugin's lock along + * the way. We're almost certainly going to get creation + * callbacks, so this is the only safe way to go. + */ + if (rw_tryupgrade(&sdvp->sdev_contents) == 0) { + rw_exit(&sdvp->sdev_contents); + rw_enter(&sdvp->sdev_contents, RW_WRITER); + if (sdvp->sdev_state == SDEV_ZOMBIE) { + rw_downgrade(&sdvp->sdev_contents); + return (ENOENT); + } + } + + sdev_plugin_validate_dir(sdvp); + ret = spp->sp_pops->spo_filldir((uintptr_t)sdvp); + rw_downgrade(&sdvp->sdev_contents); + if (ret != 0) + return (ret); + } + + return (devname_readdir_func(dvp, uiop, cred, eofp, 0)); +} + +/* + * If we don't have a callback function that returns a failure, then sdev will + * try to create a node for us which violates all of our basic assertions. To + * work around that we create our own callback for devname_lookup_func which + * always returns ENOENT as at this point either it was created with the filldir + * callback or it was not. + */ +/*ARGSUSED*/ +static int +sdev_plugin_vop_lookup_cb(sdev_node_t *ddv, char *nm, void **arg, cred_t *cred, + void *unused, char *unused2) +{ + return (ENOENT); +} + +/* ARGSUSED */ +static int +sdev_plugin_vop_lookup(struct vnode *dvp, char *nm, struct vnode **vpp, + struct pathname *pnp, int flags, struct vnode *rdir, struct cred *cred, + caller_context_t *ct, int *direntflags, pathname_t *realpnp) +{ + int ret; + sdev_node_t *sdvp; + sdev_plugin_t *spp; + + /* execute access is required to search the directory */ + if ((ret = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0) + return (ret); + + sdvp = VTOSDEV(dvp); + spp = sdvp->sdev_private; + ASSERT(spp != NULL); + ASSERT(spp->sp_islegacy == B_FALSE); + ASSERT(spp->sp_pops != NULL); + + if (crgetzoneid(cred) == GLOBAL_ZONEID && !SDEV_IS_GLOBAL(sdvp)) + return (EPERM); + + /* + * Go straight for the write lock. + */ + rw_enter(&sdvp->sdev_contents, RW_WRITER); + if (sdvp->sdev_state == SDEV_ZOMBIE) { + rw_exit(&sdvp->sdev_contents); + return (ENOENT); + } + sdev_plugin_validate_dir(sdvp); + ret = spp->sp_pops->spo_filldir((uintptr_t)sdvp); + rw_exit(&sdvp->sdev_contents); + if (ret != 0) + return (ret); + + return (devname_lookup_func(sdvp, nm, vpp, cred, + sdev_plugin_vop_lookup_cb, SDEV_VATTR)); +} + +/* + * sdev is not a good citizen. We get inactive callbacks whenever a vnode goes + * to zero, but isn't necessairily a zombie yet. As such, to make things easier + * for users, we only fire the inactive callback when the node becomes a zombie + * and thus will be torn down here. + */ +static void +sdev_plugin_vop_inactive_cb(struct vnode *dvp) +{ + sdev_node_t *sdp = VTOSDEV(dvp); + sdev_plugin_t *spp = sdp->sdev_private; + + rw_enter(&sdp->sdev_contents, RW_READER); + if (sdp->sdev_state != SDEV_ZOMBIE) { + rw_exit(&sdp->sdev_contents); + return; + } + spp->sp_pops->spo_inactive((uintptr_t)sdp); + mutex_enter(&spp->sp_lock); + VERIFY(spp->sp_nnodes > 0); + spp->sp_nnodes--; + cv_signal(&spp->sp_nodecv); + mutex_exit(&spp->sp_lock); + rw_exit(&sdp->sdev_contents); +} + +/*ARGSUSED*/ +static void +sdev_plugin_vop_inactive(struct vnode *dvp, struct cred *cred, + caller_context_t *ct) +{ + sdev_node_t *sdp = VTOSDEV(dvp); + sdev_plugin_t *spp = sdp->sdev_private; + ASSERT(sdp->sdev_private != NULL); + ASSERT(spp->sp_islegacy == B_FALSE); + devname_inactive_func(dvp, cred, sdev_plugin_vop_inactive_cb); +} + +const fs_operation_def_t sdev_plugin_vnodeops_tbl[] = { + VOPNAME_READDIR, { .vop_readdir = sdev_plugin_vop_readdir }, + VOPNAME_LOOKUP, { .vop_lookup = sdev_plugin_vop_lookup }, + VOPNAME_INACTIVE, { .vop_inactive = sdev_plugin_vop_inactive }, + VOPNAME_CREATE, { .error = fs_nosys }, + VOPNAME_REMOVE, { .error = fs_nosys }, + VOPNAME_MKDIR, { .error = fs_nosys }, + VOPNAME_RMDIR, { .error = fs_nosys }, + VOPNAME_SYMLINK, { .error = fs_nosys }, + VOPNAME_SETSECATTR, { .error = fs_nosys }, + NULL, NULL +}; + +/* + * construct a new template with overrides from vtab + */ +static fs_operation_def_t * +sdev_merge_vtab(const fs_operation_def_t tab[]) +{ + fs_operation_def_t *new; + const fs_operation_def_t *tab_entry; + + /* make a copy of standard vnode ops table */ + new = kmem_alloc(sdev_vnodeops_tbl_size, KM_SLEEP); + bcopy((void *)sdev_vnodeops_tbl, new, sdev_vnodeops_tbl_size); + + /* replace the overrides from tab */ + for (tab_entry = tab; tab_entry->name != NULL; tab_entry++) { + fs_operation_def_t *std_entry = new; + while (std_entry->name) { + if (strcmp(tab_entry->name, std_entry->name) == 0) { + std_entry->func = tab_entry->func; + break; + } + std_entry++; + } + } + + return (new); +} + +/* free memory allocated by sdev_merge_vtab */ +static void +sdev_free_vtab(fs_operation_def_t *new) +{ + kmem_free(new, sdev_vnodeops_tbl_size); +} + +/* + * Register a new plugin. + */ +sdev_plugin_hdl_t +sdev_plugin_register(const char *name, sdev_plugin_ops_t *ops, int *errp) +{ + char buf[sizeof ("dev")] = ""; + struct pathname pn = { 0 }; + sdev_plugin_t *spp, *iter; + vnode_t *vp, *nvp; + sdev_node_t *sdp, *slp; + timestruc_t now; + struct vattr vap; + int ret, err; + + /* + * Some consumers don't care about why they failed. To keep the code + * simple, we'll just pretend they gave us something. + */ + if (errp == NULL) + errp = &err; + + if (sdev_plugin_name_isvalid(name, SDEV_PLUGIN_NAMELEN) == 0) { + *errp = EINVAL; + return ((sdev_plugin_hdl_t)NULL); + } + + if (ops->spo_version != 1) { + *errp = EINVAL; + return ((sdev_plugin_hdl_t)NULL); + } + + if (ops->spo_validate == NULL || ops->spo_filldir == NULL || + ops->spo_inactive == NULL) { + *errp = EINVAL; + return ((sdev_plugin_hdl_t)NULL); + } + + if ((ops->spo_flags & ~SDEV_PLUGIN_FLAGS_MASK) != 0) { + *errp = EINVAL; + return ((sdev_plugin_hdl_t)NULL); + } + + spp = kmem_cache_alloc(sdev_plugin_cache, KM_SLEEP); + (void) strlcpy(spp->sp_name, name, SDEV_PLUGIN_NAMELEN); + + spp->sp_pops = ops; + spp->sp_nflags = SDEV_DYNAMIC | SDEV_VTOR; + if (ops->spo_flags & SDEV_PLUGIN_NO_NCACHE) + spp->sp_nflags |= SDEV_NO_NCACHE; + if (ops->spo_flags & SDEV_PLUGIN_SUBDIR) + spp->sp_nflags |= SDEV_SUBDIR; + spp->sp_vnops = sdev_plugin_vnops; + spp->sp_islegacy = B_FALSE; + spp->sp_lvtor = NULL; + spp->sp_nnodes = 0; + + /* + * Make sure our /dev entry is unique and install it. We also need to + * go through and grab the sdev root node as we cannot grab any sdev + * node locks once we've grabbed the sdev_plugin_lock. We effectively + * assert that if a directory is not present in the GZ's /dev, then it + * doesn't exist in any of the local zones. + * + * Note that we may be in NGZ context: during a prof_filldir(".../dev/") + * enumeration, for example. So we have to dig as deep as lookuppnvp() + * to make sure we really get to the global /dev (i.e. escape both + * CRED() and ->u_rdir). + */ + (void) pn_get_buf("dev", UIO_SYSSPACE, &pn, buf, sizeof (buf)); + VN_HOLD(rootdir); + ret = lookuppnvp(&pn, NULL, NO_FOLLOW, NULLVPP, + &vp, rootdir, rootdir, kcred); + + if (ret != 0) { + *errp = ret; + kmem_cache_free(sdev_plugin_cache, spp); + return ((sdev_plugin_hdl_t)NULL); + } + /* Make sure we have the real vnode */ + if (VOP_REALVP(vp, &nvp, NULL) == 0) { + VN_HOLD(nvp); + VN_RELE(vp); + vp = nvp; + nvp = NULL; + } + VERIFY(vp->v_op == sdev_vnodeops); + sdp = VTOSDEV(vp); + rw_enter(&sdp->sdev_contents, RW_WRITER); + slp = sdev_cache_lookup(sdp, spp->sp_name); + if (slp != NULL) { + SDEV_RELE(slp); + rw_exit(&sdp->sdev_contents); + VN_RELE(vp); + *errp = EEXIST; + kmem_cache_free(sdev_plugin_cache, spp); + return ((sdev_plugin_hdl_t)NULL); + } + + mutex_enter(&sdev_plugin_lock); + for (iter = list_head(&sdev_plugin_list); iter != NULL; + iter = list_next(&sdev_plugin_list, iter)) { + if (strcmp(spp->sp_name, iter->sp_name) == 0) { + mutex_exit(&sdev_plugin_lock); + rw_exit(&sdp->sdev_contents); + VN_RELE(vp); + *errp = EEXIST; + kmem_cache_free(sdev_plugin_cache, spp); + return ((sdev_plugin_hdl_t)NULL); + } + } + + list_insert_tail(&sdev_plugin_list, spp); + mutex_exit(&sdev_plugin_lock); + + /* + * Now go ahead and create the top level directory for the global zone. + */ + vap = *sdev_getdefault_attr(VDIR); + gethrestime(&now); + vap.va_atime = now; + vap.va_mtime = now; + vap.va_ctime = now; + + (void) sdev_plugin_mknode(spp, sdp, spp->sp_name, &vap); + + rw_exit(&sdp->sdev_contents); + VN_RELE(vp); + + *errp = 0; + + return ((sdev_plugin_hdl_t)spp); +} + +static void +sdev_plugin_unregister_cb(sdev_node_t *rdp, void *arg) +{ + sdev_plugin_t *spp = arg; + sdev_node_t *sdp; + + rw_enter(&rdp->sdev_contents, RW_WRITER); + sdp = sdev_cache_lookup(rdp, spp->sp_name); + /* If it doesn't exist, we're done here */ + if (sdp == NULL) { + rw_exit(&rdp->sdev_contents); + return; + } + + /* + * We first delete the directory before recursively marking everything + * else stale. This ordering should ensure that we don't accidentally + * miss anything. + */ + sdev_cache_update(rdp, &sdp, spp->sp_name, SDEV_CACHE_DELETE); + sdev_stale(sdp); + SDEV_RELE(sdp); + rw_exit(&rdp->sdev_contents); +} + +int sdev_plugin_unregister_allowed; + +/* + * Remove a plugin. This will block until everything has become a zombie, thus + * guaranteeing the caller that nothing will call into them again once this call + * returns. While the call is ongoing, it could be called into. Note that while + * this is ongoing, it will block other mounts. + * + * NB: this is not safe when used from detach() context - we will be DEVI_BUSY, + * and other sdev threads may be waiting for this. Only use the over-ride if + * willing to risk it. + */ +int +sdev_plugin_unregister(sdev_plugin_hdl_t hdl) +{ + sdev_plugin_t *spp = (sdev_plugin_t *)hdl; + if (spp->sp_islegacy) + return (EINVAL); + + if (!sdev_plugin_unregister_allowed) + return (EBUSY); + + mutex_enter(&sdev_plugin_lock); + list_remove(&sdev_plugin_list, spp); + mutex_exit(&sdev_plugin_lock); + + sdev_mnt_walk(sdev_plugin_unregister_cb, spp); + mutex_enter(&spp->sp_lock); + while (spp->sp_nnodes > 0) + cv_wait(&spp->sp_nodecv, &spp->sp_lock); + mutex_exit(&spp->sp_lock); + kmem_cache_free(sdev_plugin_cache, spp); + return (0); +} + +/* + * Register an old sdev style plugin to deal with what used to be in the vtab. + */ +static int +sdev_plugin_register_legacy(struct sdev_vop_table *vtp) +{ + sdev_plugin_t *spp; + + spp = kmem_cache_alloc(sdev_plugin_cache, KM_SLEEP); + (void) strlcpy(spp->sp_name, vtp->vt_name, SDEV_PLUGIN_NAMELEN); + spp->sp_islegacy = B_TRUE; + spp->sp_pops = NULL; + spp->sp_nflags = vtp->vt_flags; + spp->sp_lvtor = vtp->vt_vtor; + spp->sp_nnodes = 0; + + if (vtp->vt_service != NULL) { + fs_operation_def_t *templ; + templ = sdev_merge_vtab(vtp->vt_service); + if (vn_make_ops(vtp->vt_name, + (const fs_operation_def_t *)templ, + &spp->sp_vnops) != 0) { + cmn_err(CE_WARN, "%s: malformed vnode ops\n", + vtp->vt_name); + sdev_free_vtab(templ); + kmem_cache_free(sdev_plugin_cache, spp); + return (1); + } + + if (vtp->vt_global_vops) { + *(vtp->vt_global_vops) = spp->sp_vnops; + } + + sdev_free_vtab(templ); + } else { + spp->sp_vnops = sdev_vnodeops; + } + + /* + * No need to check for EEXIST here. These are loaded as a part of the + * sdev's initialization function. Further, we don't have to create them + * as that's taken care of in sdev's mount for the GZ. + */ + mutex_enter(&sdev_plugin_lock); + list_insert_tail(&sdev_plugin_list, spp); + mutex_exit(&sdev_plugin_lock); + + return (0); +} + +/* + * We need to match off of the sdev_path, not the sdev_name. We are only allowed + * to exist directly under /dev. + */ +static sdev_plugin_t * +sdev_match(sdev_node_t *dv) +{ + int vlen; + const char *path; + sdev_plugin_t *spp; + + if (strlen(dv->sdev_path) <= 5) + return (NULL); + + if (strncmp(dv->sdev_path, "/dev/", 5) != 0) + return (NULL); + path = dv->sdev_path + 5; + + mutex_enter(&sdev_plugin_lock); + + for (spp = list_head(&sdev_plugin_list); spp != NULL; + spp = list_next(&sdev_plugin_list, spp)) { + if (strcmp(spp->sp_name, path) == 0) { + mutex_exit(&sdev_plugin_lock); + return (spp); + } + + if (spp->sp_nflags & SDEV_SUBDIR) { + vlen = strlen(spp->sp_name); + if ((strncmp(spp->sp_name, path, + vlen - 1) == 0) && path[vlen] == '/') { + mutex_exit(&sdev_plugin_lock); + return (spp); + } + + } + } + + mutex_exit(&sdev_plugin_lock); + return (NULL); +} + +void +sdev_set_no_negcache(sdev_node_t *dv) +{ + char *path; + sdev_plugin_t *spp; + + ASSERT(dv->sdev_path); + path = dv->sdev_path + strlen("/dev/"); + + mutex_enter(&sdev_plugin_lock); + for (spp = list_head(&sdev_plugin_list); spp != NULL; + spp = list_next(&sdev_plugin_list, spp)) { + if (strcmp(spp->sp_name, path) == 0) { + if (spp->sp_nflags & SDEV_NO_NCACHE) + dv->sdev_flags |= SDEV_NO_NCACHE; + break; + } + } + mutex_exit(&sdev_plugin_lock); +} + +struct vnodeops * +sdev_get_vop(sdev_node_t *dv) +{ + char *path; + sdev_plugin_t *spp; + + path = dv->sdev_path; + ASSERT(path); + + /* gets the relative path to /dev/ */ + path += 5; + + if ((spp = sdev_match(dv)) != NULL) { + dv->sdev_flags |= spp->sp_nflags; + if (SDEV_IS_PERSIST(dv->sdev_dotdot) && + (SDEV_IS_PERSIST(dv) || !SDEV_IS_DYNAMIC(dv))) + dv->sdev_flags |= SDEV_PERSIST; + return (spp->sp_vnops); + } + + /* child inherits the persistence of the parent */ + if (SDEV_IS_PERSIST(dv->sdev_dotdot)) + dv->sdev_flags |= SDEV_PERSIST; + return (sdev_vnodeops); +} + +void * +sdev_get_vtor(sdev_node_t *dv) +{ + sdev_plugin_t *spp; + + if (dv->sdev_private == NULL) { + spp = sdev_match(dv); + if (spp == NULL) + return (NULL); + } else { + spp = dv->sdev_private; + } + + if (spp->sp_islegacy) + return ((void *)spp->sp_lvtor); + else + return ((void *)sdev_plugin_validate); +} + +void +sdev_plugin_nodeready(sdev_node_t *sdp) +{ + sdev_plugin_t *spp; + + ASSERT(RW_WRITE_HELD(&sdp->sdev_contents)); + ASSERT(sdp->sdev_private == NULL); + + spp = sdev_match(sdp); + if (spp == NULL) + return; + if (spp->sp_islegacy) + return; + sdp->sdev_private = spp; + mutex_enter(&spp->sp_lock); + spp->sp_nnodes++; + mutex_exit(&spp->sp_lock); +} + +int +sdev_plugin_init(void) +{ + sdev_vop_table_t *vtp; + fs_operation_def_t *templ; + + sdev_plugin_cache = kmem_cache_create("sdev_plugin", + sizeof (sdev_plugin_t), 0, sdev_plugin_cache_constructor, + sdev_plugin_cache_destructor, NULL, NULL, NULL, 0); + if (sdev_plugin_cache == NULL) + return (1); + mutex_init(&sdev_plugin_lock, NULL, MUTEX_DRIVER, NULL); + list_create(&sdev_plugin_list, sizeof (sdev_plugin_t), + offsetof(sdev_plugin_t, sp_link)); + + /* + * Register all of the legacy vnops + */ + for (vtp = &vtab[0]; vtp->vt_name != NULL; vtp++) + if (sdev_plugin_register_legacy(vtp) != 0) + return (1); + + templ = sdev_merge_vtab(sdev_plugin_vnodeops_tbl); + if (vn_make_ops("sdev_plugin", + (const fs_operation_def_t *)templ, + &sdev_plugin_vnops) != 0) { + sdev_free_vtab(templ); + return (1); + } + + sdev_free_vtab(templ); + return (0); +} diff --git a/usr/src/uts/common/fs/dev/sdev_subr.c b/usr/src/uts/common/fs/dev/sdev_subr.c index d810dd9a31..42a3874b95 100644 --- a/usr/src/uts/common/fs/dev/sdev_subr.c +++ b/usr/src/uts/common/fs/dev/sdev_subr.c @@ -151,12 +151,6 @@ vattr_t sdev_vattr_chr = { kmem_cache_t *sdev_node_cache; /* sdev_node cache */ int devtype; /* fstype */ -/* static */ -static struct vnodeops *sdev_get_vop(struct sdev_node *); -static void sdev_set_no_negcache(struct sdev_node *); -static fs_operation_def_t *sdev_merge_vtab(const fs_operation_def_t []); -static void sdev_free_vtab(fs_operation_def_t *); - static void sdev_prof_free(struct sdev_node *dv) { @@ -314,6 +308,7 @@ sdev_nodeinit(struct sdev_node *ddv, char *nm, struct sdev_node **newdv, (void) snprintf(dv->sdev_path, len, "%s/%s", ddv->sdev_path, nm); /* overwritten for VLNK nodes */ dv->sdev_symlink = NULL; + list_link_init(&dv->sdev_plist); vp = SDEVTOV(dv); vn_reinit(vp); @@ -402,6 +397,7 @@ sdev_nodeready(struct sdev_node *dv, struct vattr *vap, struct vnode *avp, } else { dv->sdev_nlink = 1; } + sdev_plugin_nodeready(dv); if (!(SDEV_IS_GLOBAL(dv))) { dv->sdev_origin = (struct sdev_node *)args; @@ -498,37 +494,22 @@ sdev_mkroot(struct vfs *vfsp, dev_t devdev, struct vnode *mvp, return (dv); } -/* directory dependent vop table */ -struct sdev_vop_table { - char *vt_name; /* subdirectory name */ - const fs_operation_def_t *vt_service; /* vnodeops table */ - struct vnodeops *vt_vops; /* constructed vop */ - struct vnodeops **vt_global_vops; /* global container for vop */ - int (*vt_vtor)(struct sdev_node *); /* validate sdev_node */ - int vt_flags; -}; - -/* - * A nice improvement would be to provide a plug-in mechanism - * for this table instead of a const table. - */ -static struct sdev_vop_table vtab[] = -{ - { "pts", devpts_vnodeops_tbl, NULL, &devpts_vnodeops, devpts_validate, +struct sdev_vop_table vtab[] = { + { "pts", devpts_vnodeops_tbl, &devpts_vnodeops, devpts_validate, SDEV_DYNAMIC | SDEV_VTOR }, - { "vt", devvt_vnodeops_tbl, NULL, &devvt_vnodeops, devvt_validate, + { "vt", devvt_vnodeops_tbl, &devvt_vnodeops, devvt_validate, SDEV_DYNAMIC | SDEV_VTOR }, - { "zvol", devzvol_vnodeops_tbl, NULL, &devzvol_vnodeops, + { "zvol", devzvol_vnodeops_tbl, &devzvol_vnodeops, devzvol_validate, SDEV_ZONED | SDEV_DYNAMIC | SDEV_VTOR | SDEV_SUBDIR }, - { "zcons", NULL, NULL, NULL, NULL, SDEV_NO_NCACHE }, + { "zcons", NULL, NULL, NULL, SDEV_NO_NCACHE }, - { "net", devnet_vnodeops_tbl, NULL, &devnet_vnodeops, devnet_validate, - SDEV_DYNAMIC | SDEV_VTOR }, + { "net", devnet_vnodeops_tbl, &devnet_vnodeops, devnet_validate, + SDEV_DYNAMIC | SDEV_VTOR | SDEV_SUBDIR }, - { "ipnet", devipnet_vnodeops_tbl, NULL, &devipnet_vnodeops, + { "ipnet", devipnet_vnodeops_tbl, &devipnet_vnodeops, devipnet_validate, SDEV_DYNAMIC | SDEV_VTOR | SDEV_NO_NCACHE }, /* @@ -543,132 +524,14 @@ static struct sdev_vop_table vtab[] = * preventing a mkdir. */ - { "lofi", NULL, NULL, NULL, NULL, + { "lofi", NULL, NULL, NULL, SDEV_ZONED | SDEV_DYNAMIC | SDEV_PERSIST }, - { "rlofi", NULL, NULL, NULL, NULL, + { "rlofi", NULL, NULL, NULL, SDEV_ZONED | SDEV_DYNAMIC | SDEV_PERSIST }, - { NULL, NULL, NULL, NULL, NULL, 0} + { NULL, NULL, NULL, NULL, 0} }; -/* - * We need to match off of the sdev_path, not the sdev_name. We are only allowed - * to exist directly under /dev. - */ -struct sdev_vop_table * -sdev_match(struct sdev_node *dv) -{ - int vlen; - int i; - const char *path; - - if (strlen(dv->sdev_path) <= 5) - return (NULL); - - if (strncmp(dv->sdev_path, "/dev/", 5) != 0) - return (NULL); - path = dv->sdev_path + 5; - - for (i = 0; vtab[i].vt_name; i++) { - if (strcmp(vtab[i].vt_name, path) == 0) - return (&vtab[i]); - if (vtab[i].vt_flags & SDEV_SUBDIR) { - vlen = strlen(vtab[i].vt_name); - if ((strncmp(vtab[i].vt_name, path, - vlen - 1) == 0) && path[vlen] == '/') - return (&vtab[i]); - } - - } - return (NULL); -} - -/* - * sets a directory's vnodeops if the directory is in the vtab; - */ -static struct vnodeops * -sdev_get_vop(struct sdev_node *dv) -{ - struct sdev_vop_table *vtp; - char *path; - - path = dv->sdev_path; - ASSERT(path); - - /* gets the relative path to /dev/ */ - path += 5; - - /* gets the vtab entry it matches */ - if ((vtp = sdev_match(dv)) != NULL) { - dv->sdev_flags |= vtp->vt_flags; - if (SDEV_IS_PERSIST(dv->sdev_dotdot) && - (SDEV_IS_PERSIST(dv) || !SDEV_IS_DYNAMIC(dv))) - dv->sdev_flags |= SDEV_PERSIST; - - if (vtp->vt_vops) { - if (vtp->vt_global_vops) - *(vtp->vt_global_vops) = vtp->vt_vops; - - return (vtp->vt_vops); - } - - if (vtp->vt_service) { - fs_operation_def_t *templ; - templ = sdev_merge_vtab(vtp->vt_service); - if (vn_make_ops(vtp->vt_name, - (const fs_operation_def_t *)templ, - &vtp->vt_vops) != 0) { - cmn_err(CE_PANIC, "%s: malformed vnode ops\n", - vtp->vt_name); - /*NOTREACHED*/ - } - if (vtp->vt_global_vops) { - *(vtp->vt_global_vops) = vtp->vt_vops; - } - sdev_free_vtab(templ); - - return (vtp->vt_vops); - } - - return (sdev_vnodeops); - } - - /* child inherits the persistence of the parent */ - if (SDEV_IS_PERSIST(dv->sdev_dotdot)) - dv->sdev_flags |= SDEV_PERSIST; - - return (sdev_vnodeops); -} - -static void -sdev_set_no_negcache(struct sdev_node *dv) -{ - int i; - char *path; - - ASSERT(dv->sdev_path); - path = dv->sdev_path + strlen("/dev/"); - - for (i = 0; vtab[i].vt_name; i++) { - if (strcmp(vtab[i].vt_name, path) == 0) { - if (vtab[i].vt_flags & SDEV_NO_NCACHE) - dv->sdev_flags |= SDEV_NO_NCACHE; - break; - } - } -} - -void * -sdev_get_vtor(struct sdev_node *dv) -{ - struct sdev_vop_table *vtp; - - vtp = sdev_match(dv); - if (vtp) - return ((void *)vtp->vt_vtor); - else - return (NULL); -} /* * Build the base root inode @@ -948,8 +811,11 @@ sdev_nodedestroy(struct sdev_node *dv, uint_t flags) dv->sdev_path = NULL; } - if (!SDEV_IS_GLOBAL(dv)) + if (!SDEV_IS_GLOBAL(dv)) { sdev_prof_free(dv); + if (dv->sdev_vnode->v_type != VLNK && dv->sdev_origin != NULL) + SDEV_RELE(dv->sdev_origin); + } if (SDEVTOV(dv)->v_type == VDIR) { ASSERT(SDEV_FIRST_ENTRY(dv) == NULL); @@ -963,6 +829,7 @@ sdev_nodedestroy(struct sdev_node *dv, uint_t flags) (void) memset((void *)&dv->sdev_instance_data, 0, sizeof (dv->sdev_instance_data)); vn_invalid(SDEVTOV(dv)); + dv->sdev_private = NULL; kmem_cache_free(sdev_node_cache, dv); } @@ -2945,46 +2812,6 @@ sdev_modctl_devexists(const char *path) return (error); } -extern int sdev_vnodeops_tbl_size; - -/* - * construct a new template with overrides from vtab - */ -static fs_operation_def_t * -sdev_merge_vtab(const fs_operation_def_t tab[]) -{ - fs_operation_def_t *new; - const fs_operation_def_t *tab_entry; - - /* make a copy of standard vnode ops table */ - new = kmem_alloc(sdev_vnodeops_tbl_size, KM_SLEEP); - bcopy((void *)sdev_vnodeops_tbl, new, sdev_vnodeops_tbl_size); - - /* replace the overrides from tab */ - for (tab_entry = tab; tab_entry->name != NULL; tab_entry++) { - fs_operation_def_t *std_entry = new; - while (std_entry->name) { - if (strcmp(tab_entry->name, std_entry->name) == 0) { - std_entry->func = tab_entry->func; - break; - } - std_entry++; - } - if (std_entry->name == NULL) - cmn_err(CE_NOTE, "sdev_merge_vtab: entry %s unused.", - tab_entry->name); - } - - return (new); -} - -/* free memory allocated by sdev_merge_vtab */ -static void -sdev_free_vtab(fs_operation_def_t *new) -{ - kmem_free(new, sdev_vnodeops_tbl_size); -} - /* * a generic setattr() function * diff --git a/usr/src/uts/common/fs/dev/sdev_vfsops.c b/usr/src/uts/common/fs/dev/sdev_vfsops.c index d81702185e..55b388c2d4 100644 --- a/usr/src/uts/common/fs/dev/sdev_vfsops.c +++ b/usr/src/uts/common/fs/dev/sdev_vfsops.c @@ -173,7 +173,13 @@ devinit(int fstype, char *name) if ((devmajor = getudev()) == (major_t)-1) { cmn_err(CE_WARN, "%s: can't get unique dev", sdev_vfssw.name); - return (1); + return (ENXIO); + } + + if (sdev_plugin_init() != 0) { + cmn_err(CE_WARN, "%s: failed to set init plugin subsystem", + sdev_vfssw.name); + return (EIO); } /* initialize negative cache */ @@ -350,6 +356,7 @@ sdev_mount(struct vfs *vfsp, struct vnode *mvp, struct mounta *uap, ASSERT(sdev_origins); dv->sdev_flags &= ~SDEV_GLOBAL; dv->sdev_origin = sdev_origins->sdev_root; + SDEV_HOLD(dv->sdev_origin); } else { sdev_ncache_setup(); rw_enter(&dv->sdev_contents, RW_WRITER); @@ -527,3 +534,17 @@ sdev_mntinfo_rele(struct sdev_data *mntinfo) mutex_exit(&vp->v_lock); mutex_exit(&sdev_lock); } + +void +sdev_mnt_walk(void (*func)(struct sdev_node *, void *), void *arg) +{ + struct sdev_data *mntinfo; + + mutex_enter(&sdev_lock); + mntinfo = sdev_mntinfo; + while (mntinfo != NULL) { + func(mntinfo->sdev_root, arg); + mntinfo = mntinfo->sdev_next; + } + mutex_exit(&sdev_lock); +} diff --git a/usr/src/uts/common/fs/dev/sdev_vnops.c b/usr/src/uts/common/fs/dev/sdev_vnops.c index 79ebd8b2e5..8fe926f6fb 100644 --- a/usr/src/uts/common/fs/dev/sdev_vnops.c +++ b/usr/src/uts/common/fs/dev/sdev_vnops.c @@ -22,7 +22,7 @@ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright (c) 2013, Joyent, Inc. All rights reserved. + * Copyright 2018, Joyent, Inc. */ /* @@ -372,7 +372,7 @@ sdev_close(struct vnode *vp, int flag, int count, /*ARGSUSED*/ static int sdev_read(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred, - struct caller_context *ct) + struct caller_context *ct) { struct sdev_node *dv = (struct sdev_node *)VTOSDEV(vp); int error; @@ -399,7 +399,7 @@ sdev_read(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred, /*ARGSUSED*/ static int sdev_write(struct vnode *vp, struct uio *uio, int ioflag, struct cred *cred, - struct caller_context *ct) + struct caller_context *ct) { struct sdev_node *dv = VTOSDEV(vp); int error = 0; @@ -582,7 +582,9 @@ sdev_self_access(sdev_node_t *dv, int mode, int flags, struct cred *cr, { int ret; + ASSERT(RW_READ_HELD(&dv->sdev_contents)); ASSERT(dv->sdev_attr || dv->sdev_attrvp); + if (dv->sdev_attrvp) { ret = VOP_ACCESS(dv->sdev_attrvp, mode, flags, cr, ct); } else if (dv->sdev_attr) { @@ -1438,32 +1440,24 @@ sdev_readlink(struct vnode *vp, struct uio *uiop, struct cred *cred, /*ARGSUSED4*/ static int -sdev_readdir(struct vnode *dvp, struct uio *uiop, struct cred *cred, int *eofp, +sdev_readdir(struct vnode *vp, struct uio *uiop, struct cred *cred, int *eofp, caller_context_t *ct, int flags) { - struct sdev_node *parent = VTOSDEV(dvp); + struct sdev_node *dv = VTOSDEV(vp); int error; + VERIFY(RW_READ_HELD(&dv->sdev_contents)); + /* - * We must check that we have execute access to search the directory -- - * but because our sdev_contents lock is already held as a reader (the - * caller must have done a VOP_RWLOCK()), we call directly into the - * underlying access routine if sdev_attr is non-NULL. + * We can't recursively take ->sdev_contents via an indirect + * VOP_ACCESS(), but we don't need to use that anyway. */ - if (parent->sdev_attr != NULL) { - VERIFY(RW_READ_HELD(&parent->sdev_contents)); - - if (sdev_unlocked_access(parent, VEXEC, cred) != 0) - return (EACCES); - } else { - if ((error = VOP_ACCESS(dvp, VEXEC, 0, cred, ct)) != 0) - return (error); - } + if ((error = sdev_self_access(dv, VEXEC, 0, cred, ct)) != 0) + return (error); - ASSERT(parent); - if (!SDEV_IS_GLOBAL(parent)) - prof_filldir(parent); - return (devname_readdir_func(dvp, uiop, cred, eofp, SDEV_BROWSE)); + if (!SDEV_IS_GLOBAL(dv)) + prof_filldir(dv); + return (devname_readdir_func(vp, uiop, cred, eofp, SDEV_BROWSE)); } /*ARGSUSED1*/ diff --git a/usr/src/uts/common/sys/fs/sdev_impl.h b/usr/src/uts/common/sys/fs/sdev_impl.h index 9f9ce5c8c1..dc6601bb43 100644 --- a/usr/src/uts/common/sys/fs/sdev_impl.h +++ b/usr/src/uts/common/sys/fs/sdev_impl.h @@ -38,6 +38,7 @@ extern "C" { #include #include #include +#include /* * sdev_nodes are the file-system specific part of the @@ -129,6 +130,21 @@ typedef struct sdev_local_data { struct sdev_dprof sdev_lprof; /* profile for multi-inst */ } sdev_local_data_t; +/* sdev_flags */ +typedef enum sdev_flags { + SDEV_BUILD = 0x0001, /* directory cache out-of-date */ + SDEV_GLOBAL = 0x0002, /* global /dev nodes */ + SDEV_PERSIST = 0x0004, /* backing store persisted node */ + SDEV_NO_NCACHE = 0x0008, /* do not include in neg. cache */ + SDEV_DYNAMIC = 0x0010, /* special-purpose vnode ops */ + /* (ex: pts) */ + SDEV_VTOR = 0x0020, /* validate sdev_nodes during search */ + SDEV_ATTR_INVALID = 0x0040, /* invalid node attributes, */ + /* need update */ + SDEV_SUBDIR = 0x0080, /* match all subdirs under here */ + SDEV_ZONED = 0x0100 /* zoned subdir */ +} sdev_flags_t; + /* * /dev filesystem sdev_node defines */ @@ -151,7 +167,7 @@ typedef struct sdev_node { ino64_t sdev_ino; /* inode */ uint_t sdev_nlink; /* link count */ int sdev_state; /* state of this node */ - int sdev_flags; /* flags bit */ + sdev_flags_t sdev_flags; /* flags bit */ kmutex_t sdev_lookup_lock; /* node creation synch lock */ kcondvar_t sdev_lookup_cv; /* node creation sync cv */ @@ -162,7 +178,7 @@ typedef struct sdev_node { struct sdev_global_data sdev_globaldata; struct sdev_local_data sdev_localdata; } sdev_instance_data; - + list_node_t sdev_plist; /* link on plugin list */ void *sdev_private; } sdev_node_t; @@ -193,29 +209,11 @@ typedef enum { SDEV_READY } sdev_node_state_t; -/* sdev_flags */ -#define SDEV_BUILD 0x0001 /* directory cache out-of-date */ -#define SDEV_GLOBAL 0x0002 /* global /dev nodes */ -#define SDEV_PERSIST 0x0004 /* backing store persisted node */ -#define SDEV_NO_NCACHE 0x0008 /* do not include in neg. cache */ -#define SDEV_DYNAMIC 0x0010 /* special-purpose vnode ops */ - /* (ex: pts) */ -#define SDEV_VTOR 0x0020 /* validate sdev_nodes during search */ -#define SDEV_ATTR_INVALID 0x0040 /* invalid node attributes, */ - /* need update */ -#define SDEV_SUBDIR 0x0080 /* match all subdirs under here */ -#define SDEV_ZONED 0x0100 /* zoned subdir */ - /* sdev_lookup_flags */ #define SDEV_LOOKUP 0x0001 /* node creation in progress */ #define SDEV_READDIR 0x0002 /* VDIR readdir in progress */ #define SDEV_LGWAITING 0x0004 /* waiting for devfsadm completion */ -#define SDEV_VTOR_INVALID -1 -#define SDEV_VTOR_SKIP 0 -#define SDEV_VTOR_VALID 1 -#define SDEV_VTOR_STALE 2 - /* convenient macros */ #define SDEV_IS_GLOBAL(dv) \ (dv->sdev_flags & SDEV_GLOBAL) @@ -368,8 +366,13 @@ extern void sdev_devfsadmd_thread(struct sdev_node *, struct sdev_node *, extern int devname_profile_update(char *, size_t); extern struct sdev_data *sdev_find_mntinfo(char *); void sdev_mntinfo_rele(struct sdev_data *); +typedef void (*sdev_mnt_walk_f)(struct sdev_node *, void *); +void sdev_mnt_walk(sdev_mnt_walk_f, void *); extern struct vnodeops *devpts_getvnodeops(void); extern struct vnodeops *devvt_getvnodeops(void); +extern void sdev_plugin_nodeready(struct sdev_node *); +extern int sdev_plugin_init(void); +extern int sdev_plugin_fini(void); /* * boot states - warning, the ordering here is significant @@ -514,6 +517,23 @@ extern void sdev_nc_node_exists(sdev_node_t *); extern void sdev_nc_path_exists(sdev_nc_list_t *, char *); extern void sdev_modctl_dump_files(void); +/* + * plugin and legacy vtab stuff + */ +/* directory dependent vop table */ +typedef struct sdev_vop_table { + char *vt_name; /* subdirectory name */ + const fs_operation_def_t *vt_service; /* vnodeops table */ + struct vnodeops **vt_global_vops; /* global container for vop */ + int (*vt_vtor)(struct sdev_node *); /* validate sdev_node */ + int vt_flags; +} sdev_vop_table_t; + +extern struct sdev_vop_table vtab[]; +extern struct vnodeops *sdev_get_vop(struct sdev_node *); +extern void sdev_set_no_negcache(struct sdev_node *); +extern void *sdev_get_vtor(struct sdev_node *dv); + /* * globals */ @@ -527,6 +547,7 @@ extern struct vnodeops *devipnet_vnodeops; extern struct vnodeops *devvt_vnodeops; extern struct sdev_data *sdev_origins; /* mount info for global /dev instance */ extern struct vnodeops *devzvol_vnodeops; +extern int sdev_vnodeops_tbl_size; extern const fs_operation_def_t sdev_vnodeops_tbl[]; extern const fs_operation_def_t devpts_vnodeops_tbl[]; diff --git a/usr/src/uts/common/sys/fs/sdev_plugin.h b/usr/src/uts/common/sys/fs/sdev_plugin.h new file mode 100644 index 0000000000..f4ed813c1e --- /dev/null +++ b/usr/src/uts/common/sys/fs/sdev_plugin.h @@ -0,0 +1,106 @@ +/* + * 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 (c) 2018, Joyent, Inc. + */ + +#ifndef _SYS_SDEV_PLUGIN_H +#define _SYS_SDEV_PLUGIN_H + +/* + * Kernel sdev plugin interface + */ + +#ifdef _KERNEL + +#include +#include +#include + +#endif /* _KERNEL */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL + +typedef uintptr_t sdev_plugin_hdl_t; +typedef uintptr_t sdev_ctx_t; + +/* + * Valid return values for sdev_plugin_validate_t. + */ +typedef enum sdev_plugin_validate { + SDEV_VTOR_INVALID = -1, + SDEV_VTOR_SKIP = 0, + SDEV_VTOR_VALID = 1, + SDEV_VTOR_STALE = 2 +} sdev_plugin_validate_t; + +/* + * Valid flags + */ +typedef enum sdev_plugin_flags { + SDEV_PLUGIN_NO_NCACHE = 0x1, + SDEV_PLUGIN_SUBDIR = 0x2 +} sdev_plugin_flags_t; + +#define SDEV_PLUGIN_FLAGS_MASK 0x3 + +/* + * Functions a module must implement + */ +typedef sdev_plugin_validate_t (*sp_valid_f)(sdev_ctx_t); +typedef int (*sp_filldir_f)(sdev_ctx_t); +typedef void (*sp_inactive_f)(sdev_ctx_t); + +#define SDEV_PLUGIN_VERSION 1 + +typedef struct sdev_plugin_ops { + int spo_version; + sdev_plugin_flags_t spo_flags; + sp_valid_f spo_validate; + sp_filldir_f spo_filldir; + sp_inactive_f spo_inactive; +} sdev_plugin_ops_t; + +extern sdev_plugin_hdl_t sdev_plugin_register(const char *, sdev_plugin_ops_t *, + int *); +extern int sdev_plugin_unregister(sdev_plugin_hdl_t); + +typedef enum sdev_ctx_flags { + SDEV_CTX_GLOBAL = 0x2 /* node belongs to the GZ */ +} sdev_ctx_flags_t; + +/* + * Context helper functions + */ +extern sdev_ctx_flags_t sdev_ctx_flags(sdev_ctx_t); +extern const char *sdev_ctx_name(sdev_ctx_t); +extern const char *sdev_ctx_path(sdev_ctx_t); +extern int sdev_ctx_minor(sdev_ctx_t, minor_t *); +extern enum vtype sdev_ctx_vtype(sdev_ctx_t); + +/* + * Callbacks to manipulate nodes + */ +extern int sdev_plugin_mkdir(sdev_ctx_t, char *); +extern int sdev_plugin_mknod(sdev_ctx_t, char *, mode_t, dev_t); + +#endif /* _KERNEL */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SDEV_PLUGIN_H */ diff --git a/usr/src/uts/intel/dev/Makefile b/usr/src/uts/intel/dev/Makefile index 6cc3fda6cd..cc100922a0 100644 --- a/usr/src/uts/intel/dev/Makefile +++ b/usr/src/uts/intel/dev/Makefile @@ -71,6 +71,7 @@ LINTTAGS += -erroff=E_STATIC_UNUSED CERRWARN += -_gcc=-Wno-parentheses CERRWARN += -_gcc=-Wno-unused-label CERRWARN += $(CNOWARN_UNINIT) +CERRWARN += -_gcc=-Wno-unused-function # # Default build targets. -- cgit v1.2.3 From b939b187ee16d21b506005807c652e2c7bdfe243 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 30 Jan 2020 13:52:25 +0200 Subject: 12645 vds: smatch and NULL pointer errors Reviewed by: Jorge Schrauwen Reviewed by: John Levon Approved by: Dan McDonald --- usr/src/uts/sun4v/io/vds.c | 103 +++++++++++++++++++++-------------------- usr/src/uts/sun4v/vds/Makefile | 8 ---- 2 files changed, 53 insertions(+), 58 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/sun4v/io/vds.c b/usr/src/uts/sun4v/io/vds.c index 15d263a1b9..1c8ca84ff2 100644 --- a/usr/src/uts/sun4v/io/vds.c +++ b/usr/src/uts/sun4v/io/vds.c @@ -168,7 +168,7 @@ typedef struct vd_driver_type { * The list can be extended by adding a "driver-type-list" entry in vds.conf * with the following syntax: * - * driver-type-list=":", ... ,":"; + * driver-type-list=":", ... ,":"; * * Where: * is the name of a driver (limited to 64 characters) @@ -178,7 +178,7 @@ typedef struct vd_driver_type { * * For example, the following line in vds.conf: * - * driver-type-list="foo:disk","bar:volume"; + * driver-type-list="foo:disk","bar:volume"; * * defines that "foo" is a disk driver, and driver "bar" is a volume driver. * @@ -256,7 +256,7 @@ vd_driver_type_t vds_driver_types[] = { static mdeg_prop_spec_t vds_prop_template[] = { { MDET_PROP_STR, "name", VDS_NAME }, { MDET_PROP_VAL, "cfg-handle", NULL }, - { MDET_LIST_END, NULL, NULL } + { MDET_LIST_END, NULL, NULL } }; #define VDS_SET_MDEG_PROP_INST(specp, val) (specp)[1].ps_val = (val); @@ -290,7 +290,7 @@ typedef struct vd_option { vd_option_t vd_bdev_options[] = { { "ro", VD_OPT_RDONLY }, - { "slice", VD_OPT_SLICE }, + { "slice", VD_OPT_SLICE }, { "excl", VD_OPT_EXCLUSIVE } }; @@ -407,7 +407,7 @@ typedef struct vds { mdeg_node_spec_t *ispecp; /* mdeg node specification */ mdeg_handle_t mdeg; /* handle for MDEG operations */ vd_driver_type_t *driver_types; /* extra driver types (from vds.conf) */ - int num_drivers; /* num of extra driver types */ + int num_drivers; /* num of extra driver types */ } vds_t; /* @@ -595,7 +595,7 @@ static int vd_awflush = VD_AWFLUSH_IMMEDIATE | VD_AWFLUSH_GROUP; * the service domain to panic. In both cases, the reset of the service domain * should trigger a reset SCSI buses and hopefully clear any SCSI-2 reservation. */ -static int vd_reset_access_failure = 0; +static int vd_reset_access_failure = 0; /* * Tunable for backward compatibility. When this variable is set to B_TRUE, @@ -694,8 +694,8 @@ extern int is_pseudo_device(dev_info_t *); * vd_get_readable_size * * Description: - * Convert a given size in bytes to a human readable format in - * kilobytes, megabytes, gigabytes or terabytes. + * Convert a given size in bytes to a human readable format in + * kilobytes, megabytes, gigabytes or terabytes. * * Parameters: * full_size - the size to convert in bytes. @@ -729,7 +729,7 @@ vd_get_readable_size(size_t full_size, size_t *size, char *unit) * vd_dskimg_io_params * * Description: - * Convert virtual disk I/O parameters (slice, block, length) to + * Convert virtual disk I/O parameters (slice, block, length) to * (offset, length) relative to the disk image and according to * the virtual disk partitioning. * @@ -848,7 +848,7 @@ vd_dskimg_io_params(vd_t *vd, int slice, size_t *blkp, size_t *lenp) * vd_dskimg_rw * * Description: - * Read or write to a disk image. It handles the case where the disk + * Read or write to a disk image. It handles the case where the disk * image is a file or a volume exported as a full disk or a file * exported as single-slice disk. Read or write to volumes exported as * single slice disks are done by directly using the ldi interface. @@ -891,7 +891,7 @@ vd_dskimg_rw(vd_t *vd, int slice, int operation, caddr_t data, size_t offset, ((operation == VD_OP_BREAD)? B_READ : B_WRITE); buf.b_bcount = len; buf.b_lblkno = offset; - buf.b_edev = vd->dev[0]; + buf.b_edev = vd->dev[0]; buf.b_un.b_addr = data; /* @@ -986,9 +986,9 @@ vd_build_default_label(size_t disk_size, size_t bsize, struct dk_label *label) * * Other parameters are computed from these values: * - * pcyl = disk_size / (nhead * nsect * 512) - * acyl = (pcyl > 2)? 2 : 0 - * ncyl = pcyl - acyl + * pcyl = disk_size / (nhead * nsect * 512) + * acyl = (pcyl > 2)? 2 : 0 + * ncyl = pcyl - acyl * * The maximum number of cylinder is 65535 so this allows to define a * geometry for a disk size up to 65535 * 96 * 768 * 512 = 2.24 TB @@ -1358,7 +1358,7 @@ vd_dskimg_write_devid(vd_t *vd, ddi_devid_t devid) * vd_do_scsi_rdwr * * Description: - * Read or write to a SCSI disk using an absolute disk offset. + * Read or write to a SCSI disk using an absolute disk offset. * * Parameters: * vd - disk on which the operation is performed. @@ -1482,7 +1482,7 @@ vd_do_scsi_rdwr(vd_t *vd, int operation, caddr_t data, size_t blk, size_t len) * vd_scsi_rdwr * * Description: - * Wrapper function to read or write to a SCSI disk using an absolute + * Wrapper function to read or write to a SCSI disk using an absolute * disk offset. It checks the blocksize of the underlying device and, * if necessary, adjusts the buffers accordingly before calling * vd_do_scsi_rdwr() to do the actual read or write. @@ -1562,7 +1562,7 @@ vd_scsi_rdwr(vd_t *vd, int operation, caddr_t data, size_t vblk, size_t vlen) * ^ ^ * |<--------------------->| * | plen - * pblk + * pblk */ /* END CSTYLED */ pblk = (vblk * vd->vdisk_bsize) / vd->backend_bsize; @@ -1897,7 +1897,7 @@ vd_flush_write(vd_t *vd) status = VOP_FSYNC(vd->file_vnode, FSYNC, kcred, NULL); } else { status = ldi_ioctl(vd->ldi_handle[0], DKIOCFLUSHWRITECACHE, - NULL, vd->open_flags | FKIOCTL, kcred, &rval); + (intptr_t)NULL, vd->open_flags | FKIOCTL, kcred, &rval); } return (status); @@ -1973,7 +1973,7 @@ vd_start_bio(vd_task_t *task) vd_dring_payload_t *request = task->request; struct buf *buf = &task->buf; uint8_t mtype; - int slice; + int slice; char *bufaddr = 0; size_t buflen; size_t offset, length, nbytes; @@ -2116,7 +2116,7 @@ vd_start_bio(vd_task_t *task) buf->b_bcount = length; buf->b_lblkno = offset; buf->b_bufsize = buflen; - buf->b_edev = vd->dev[slice]; + buf->b_edev = vd->dev[slice]; buf->b_un.b_addr = bufaddr; buf->b_iodone = vd_biodone; @@ -2526,7 +2526,7 @@ vd_complete_bio(vd_task_t *task) * message to the client. * * Parameters: - * arg - opaque pointer to structure containing task to be completed + * arg - opaque pointer to structure containing task to be completed * * Return Values * None @@ -2569,7 +2569,7 @@ vd_notify(vd_task_t *task) * the vDisk client * * Parameters: - * task - structure containing the request sent from client + * task - structure containing the request sent from client * * Return Values * None @@ -2624,7 +2624,7 @@ vd_complete_notify(vd_task_t *task) * message to the client that the request is completed. * * Parameters: - * arg - opaque pointer to structure containing task to be completed + * arg - opaque pointer to structure containing task to be completed * * Return Values * None @@ -3578,7 +3578,7 @@ vd_do_ioctl(vd_t *vd, vd_dring_payload_t *request, void* buf, vd_ioctl_t *ioctl) * is passed in as a field in the task pointer. * * Parameters: - * arg - opaque pointer to structure containing task to be completed + * arg - opaque pointer to structure containing task to be completed * * Return Values * None @@ -3688,7 +3688,8 @@ vd_ioctl(vd_task_t *task) break; } } - ASSERT(i < nioctls); /* because "operation" already validated */ + + VERIFY(i < nioctls); /* because "operation" already validated */ if (!(vd->open_flags & FWRITE) && ioctl[i].write) { PR0("%s fails because backend is opened read-only", @@ -3890,7 +3891,7 @@ vd_get_access(vd_task_t *task) } request->status = ldi_ioctl(vd->ldi_handle[request->slice], MHIOCSTATUS, - NULL, (vd->open_flags | FKIOCTL), kcred, &rval); + (intptr_t)NULL, (vd->open_flags | FKIOCTL), kcred, &rval); if (request->status != 0) return (0); @@ -3935,8 +3936,8 @@ vd_set_access(vd_task_t *task) if (flags == VD_ACCESS_SET_CLEAR) { PR0("Performing VD_OP_SET_ACCESS (CLEAR)"); request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCRELEASE, NULL, (vd->open_flags | FKIOCTL), kcred, - &rval); + MHIOCRELEASE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); if (request->status == 0) vd->ownership = B_FALSE; return (0); @@ -3962,7 +3963,8 @@ vd_set_access(vd_task_t *task) */ PR0("Performing VD_OP_SET_ACCESS (EXCLUSIVE|PREEMPT|PRESERVE)"); request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCTKOWN, NULL, (vd->open_flags | FKIOCTL), kcred, &rval); + MHIOCTKOWN, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); break; case VD_ACCESS_SET_PRESERVE: @@ -3977,12 +3979,13 @@ vd_set_access(vd_task_t *task) */ PR0("Performing VD_OP_SET_ACCESS (EXCLUSIVE|PRESERVE)"); request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCQRESERVE, NULL, (vd->open_flags | FKIOCTL), kcred, - &rval); + MHIOCQRESERVE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); if (request->status != 0) break; request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCTKOWN, NULL, (vd->open_flags | FKIOCTL), kcred, &rval); + MHIOCTKOWN, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); break; case VD_ACCESS_SET_PREEMPT: @@ -3994,8 +3997,8 @@ vd_set_access(vd_task_t *task) */ PR0("Performing VD_OP_SET_ACCESS (EXCLUSIVE|PREEMPT)"); request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCQRESERVE, NULL, (vd->open_flags | FKIOCTL), kcred, - &rval); + MHIOCQRESERVE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); if (request->status == 0) break; @@ -4004,16 +4007,16 @@ vd_set_access(vd_task_t *task) /* try again even if the reset has failed */ request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCQRESERVE, NULL, (vd->open_flags | FKIOCTL), kcred, - &rval); + MHIOCQRESERVE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); break; case 0: /* Flag EXCLUSIVE only. Just issue a SCSI reservation */ PR0("Performing VD_OP_SET_ACCESS (EXCLUSIVE)"); request->status = ldi_ioctl(vd->ldi_handle[request->slice], - MHIOCQRESERVE, NULL, (vd->open_flags | FKIOCTL), kcred, - &rval); + MHIOCQRESERVE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), + kcred, &rval); break; } @@ -4034,7 +4037,7 @@ vd_reset_access(vd_t *vd) return; PR0("Releasing disk ownership"); - status = ldi_ioctl(vd->ldi_handle[0], MHIOCRELEASE, NULL, + status = ldi_ioctl(vd->ldi_handle[0], MHIOCRELEASE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), kcred, &rval); /* @@ -4059,7 +4062,7 @@ vd_reset_access(vd_t *vd) PR0("Fail to reset disk, error %d", status); /* whatever the result of the reset is, we try the release again */ - status = ldi_ioctl(vd->ldi_handle[0], MHIOCRELEASE, NULL, + status = ldi_ioctl(vd->ldi_handle[0], MHIOCRELEASE, (intptr_t)NULL, (vd->open_flags | FKIOCTL), kcred, &rval); if (status == 0 || status == EACCES) { @@ -4081,7 +4084,7 @@ vd_reset_access(vd_t *vd) if (vd_reset_access_failure == A_REBOOT) { cmn_err(CE_WARN, VD_RESET_ACCESS_FAILURE_MSG ", rebooting the system", vd->device_path); - (void) uadmin(A_SHUTDOWN, AD_BOOT, NULL); + (void) uadmin(A_SHUTDOWN, AD_BOOT, (uintptr_t)NULL); } else if (vd_reset_access_failure == A_DUMP) { panic(VD_RESET_ACCESS_FAILURE_MSG, vd->device_path); } @@ -4122,7 +4125,7 @@ static const size_t vds_noperations = * Process a task specifying a client I/O request * * Parameters: - * task - structure containing the request sent from client + * task - structure containing the request sent from client * * Return Value * 0 - success @@ -4196,7 +4199,7 @@ vd_do_process_task(vd_task_t *task) * by the completion handler. * * Parameters: - * task - structure containing the request sent from client + * task - structure containing the request sent from client * * Return Value * 0 - successful synchronous request. @@ -5415,7 +5418,7 @@ vds_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) kmem_free(vds->ispecp->specp, sizeof (vds_prop_template)); kmem_free(vds->ispecp, sizeof (mdeg_node_spec_t)); vds->ispecp = NULL; - vds->mdeg = NULL; + vds->mdeg = 0; } vds_driver_types_free(vds); @@ -5884,7 +5887,7 @@ vd_setup_partition_efi(vd_t *vd) static int vd_setup_backend_vnode(vd_t *vd) { - int rval, status; + int rval, status; dev_t dev; char *file_path = vd->device_path; ldi_handle_t lhandle; @@ -6059,7 +6062,7 @@ vd_setup_disk_image(vd_t *vd) */ PR1("creating devid for %s", backend_path); - if (ddi_devid_init(vd->vds->dip, DEVID_FAB, NULL, 0, + if (ddi_devid_init(vd->vds->dip, DEVID_FAB, 0, 0, &vd->dskimg_devid) != DDI_SUCCESS) { PR0("fail to create devid for %s", backend_path); vd->dskimg_devid = NULL; @@ -6088,7 +6091,7 @@ vd_setup_disk_image(vd_t *vd) * Open a device using its device path (supplied by ldm(1m)) * * Parameters: - * vd - pointer to structure containing the vDisk info + * vd - pointer to structure containing the vDisk info * flags - open flags * * Return Value @@ -6491,7 +6494,7 @@ vd_backend_check_size(vd_t *vd) * a disk device or a volume device. * * Parameters: - * vd - pointer to structure containing the vDisk info + * vd - pointer to structure containing the vDisk info * dtype - return the driver type of the device * * Return Value @@ -6565,7 +6568,7 @@ vd_setup_vd(vd_t *vd) { int status, drv_type, pseudo; dev_info_t *dip; - vnode_t *vnp; + vnode_t *vnp; char *path = vd->device_path; char tq_name[TASKQ_NAMELEN]; @@ -7066,7 +7069,7 @@ vds_get_ldc_id(md_t *md, mde_cookie_t vd_node, uint64_t *ldc_id) * vds_get_options * * Description: - * Parse the options of a vds node. Options are defined as an array + * Parse the options of a vds node. Options are defined as an array * of strings in the vds-block-device-opts property of the vds node * in the machine description. Options are returned as a bitmask. The * mapping between the bitmask options and the options strings from the diff --git a/usr/src/uts/sun4v/vds/Makefile b/usr/src/uts/sun4v/vds/Makefile index 664b987d0f..b4df7add5f 100644 --- a/usr/src/uts/sun4v/vds/Makefile +++ b/usr/src/uts/sun4v/vds/Makefile @@ -40,7 +40,6 @@ UTSBASE = ../.. # MODULE = vds OBJECTS = $(VDS_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(VDS_OBJS:%.o=$(LINTS_DIR)/%.ln) ROOTMODULE = $(ROOT_PSM_DRV_DIR)/$(MODULE) # @@ -59,7 +58,6 @@ CLEANFILES += $(MODSTUBS_O) # Define targets # ALL_TARGET = $(BINARY) -LINT_TARGET = $(MODULE).lint INSTALL_TARGET = $(BINARY) $(ROOTMODULE) CFLAGS += $(CCVERBOSE) @@ -85,12 +83,6 @@ clean: $(CLEAN_DEPS) clobber: $(CLOBBER_DEPS) -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - install: $(INSTALL_DEPS) # -- cgit v1.2.3 From b237158d576c3f39f35d97c4dd214c07273ddde4 Mon Sep 17 00:00:00 2001 From: Patrick Mooney Date: Wed, 10 Apr 2019 18:16:49 +0000 Subject: 12674 want mac rx barrier function Reviewed by: Robert Mustacchi Reviewed by: Ryan Zezeski Approved by: Dan McDonald --- usr/src/uts/common/io/mac/mac.c | 156 +++++++++++++++++++++++++-------- usr/src/uts/common/io/mac/mac_client.c | 28 +++++- usr/src/uts/common/sys/mac_client.h | 3 +- usr/src/uts/common/sys/mac_impl.h | 59 ++++--------- 4 files changed, 167 insertions(+), 79 deletions(-) (limited to 'usr/src') diff --git a/usr/src/uts/common/io/mac/mac.c b/usr/src/uts/common/io/mac/mac.c index 79a518a164..76b4765de6 100644 --- a/usr/src/uts/common/io/mac/mac.c +++ b/usr/src/uts/common/io/mac/mac.c @@ -707,12 +707,45 @@ mac_callback_remove_wait(mac_cb_info_t *mcbi) } } +void +mac_callback_barrier(mac_cb_info_t *mcbi) +{ + ASSERT(MUTEX_HELD(mcbi->mcbi_lockp)); + ASSERT3U(mcbi->mcbi_barrier_cnt, <, UINT_MAX); + + if (mcbi->mcbi_walker_cnt == 0) { + return; + } + + mcbi->mcbi_barrier_cnt++; + do { + cv_wait(&mcbi->mcbi_cv, mcbi->mcbi_lockp); + } while (mcbi->mcbi_walker_cnt > 0); + mcbi->mcbi_barrier_cnt--; + cv_broadcast(&mcbi->mcbi_cv); +} + +void +mac_callback_walker_enter(mac_cb_info_t *mcbi) +{ + mutex_enter(mcbi->mcbi_lockp); + /* + * Incoming walkers should give precedence to timely clean-up of + * deleted callback entries and requested barriers. + */ + while (mcbi->mcbi_del_cnt > 0 || mcbi->mcbi_barrier_cnt > 0) { + cv_wait(&mcbi->mcbi_cv, mcbi->mcbi_lockp); + } + mcbi->mcbi_walker_cnt++; + mutex_exit(mcbi->mcbi_lockp); +} + /* * The last mac callback walker does the cleanup. Walk the list and unlik * all the logically deleted entries and construct a temporary list of * removed entries. Return the list of removed entries to the caller. */ -mac_cb_t * +static mac_cb_t * mac_callback_walker_cleanup(mac_cb_info_t *mcbi, mac_cb_t **mcb_head) { mac_cb_t *p; @@ -741,7 +774,90 @@ mac_callback_walker_cleanup(mac_cb_info_t *mcbi, mac_cb_t **mcb_head) return (rmlist); } -boolean_t +void +mac_callback_walker_exit(mac_cb_info_t *mcbi, mac_cb_t **headp, + boolean_t is_promisc) +{ + boolean_t do_wake = B_FALSE; + + mutex_enter(mcbi->mcbi_lockp); + + /* If walkers remain, nothing more can be done for now */ + if (--mcbi->mcbi_walker_cnt != 0) { + mutex_exit(mcbi->mcbi_lockp); + return; + } + + if (mcbi->mcbi_del_cnt != 0) { + mac_cb_t *rmlist; + + rmlist = mac_callback_walker_cleanup(mcbi, headp); + + if (!is_promisc) { + /* The "normal" non-promisc callback clean-up */ + mac_callback_free(rmlist); + } else { + mac_cb_t *mcb, *mcb_next; + + /* + * The promisc callbacks are in 2 lists, one off the + * 'mip' and another off the 'mcip' threaded by + * mpi_mi_link and mpi_mci_link respectively. There + * is, however, only a single shared total walker + * count, and an entry cannot be physically unlinked if + * a walker is active on either list. The last walker + * does this cleanup of logically deleted entries. + * + * With a list of callbacks deleted from above from + * mi_promisc_list (headp), remove the corresponding + * entry from mci_promisc_list (headp_pair) and free + * the structure. + */ + for (mcb = rmlist; mcb != NULL; mcb = mcb_next) { + mac_promisc_impl_t *mpip; + mac_client_impl_t *mcip; + + mcb_next = mcb->mcb_nextp; + mpip = (mac_promisc_impl_t *)mcb->mcb_objp; + mcip = mpip->mpi_mcip; + + ASSERT3P(&mcip->mci_mip->mi_promisc_cb_info, + ==, mcbi); + ASSERT3P(&mcip->mci_mip->mi_promisc_list, + ==, headp); + + VERIFY(mac_callback_remove(mcbi, + &mcip->mci_promisc_list, + &mpip->mpi_mci_link)); + mcb->mcb_flags = 0; + mcb->mcb_nextp = NULL; + kmem_cache_free(mac_promisc_impl_cache, mpip); + } + } + + /* + * Wake any walker threads that could be waiting in + * mac_callback_walker_enter() until deleted items have been + * cleaned from the list. + */ + do_wake = B_TRUE; + } + + if (mcbi->mcbi_barrier_cnt != 0) { + /* + * One or more threads are waiting for all walkers to exit the + * callback list. Notify them, now that the list is clear. + */ + do_wake = B_TRUE; + } + + if (do_wake) { + cv_broadcast(&mcbi->mcbi_cv); + } + mutex_exit(mcbi->mcbi_lockp); +} + +static boolean_t mac_callback_lookup(mac_cb_t **mcb_headp, mac_cb_t *mcb_elem) { mac_cb_t *mcb; @@ -755,7 +871,7 @@ mac_callback_lookup(mac_cb_t **mcb_headp, mac_cb_t *mcb_elem) return (B_FALSE); } -boolean_t +static boolean_t mac_callback_find(mac_cb_info_t *mcbi, mac_cb_t **mcb_headp, mac_cb_t *mcb_elem) { boolean_t found; @@ -780,40 +896,6 @@ mac_callback_free(mac_cb_t *rmlist) } } -/* - * The promisc callbacks are in 2 lists, one off the 'mip' and another off the - * 'mcip' threaded by mpi_mi_link and mpi_mci_link respectively. However there - * is only a single shared total walker count, and an entry can't be physically - * unlinked if a walker is active on either list. The last walker does this - * cleanup of logically deleted entries. - */ -void -i_mac_promisc_walker_cleanup(mac_impl_t *mip) -{ - mac_cb_t *rmlist; - mac_cb_t *mcb; - mac_cb_t *mcb_next; - mac_promisc_impl_t *mpip; - - /* - * Construct a temporary list of deleted callbacks by walking the - * the mi_promisc_list. Then for each entry in the temporary list, - * remove it from the mci_promisc_list and free the entry. - */ - rmlist = mac_callback_walker_cleanup(&mip->mi_promisc_cb_info, - &mip->mi_promisc_list); - - for (mcb = rmlist; mcb != NULL; mcb = mcb_next) { - mcb_next = mcb->mcb_nextp; - mpip = (mac_promisc_impl_t *)mcb->mcb_objp; - VERIFY(mac_callback_remove(&mip->mi_promisc_cb_info, - &mpip->mpi_mcip->mci_promisc_list, &mpip->mpi_mci_link)); - mcb->mcb_flags = 0; - mcb->mcb_nextp = NULL; - kmem_cache_free(mac_promisc_impl_cache, mpip); - } -} - void i_mac_notify(mac_impl_t *mip, mac_notify_type_t type) { diff --git a/usr/src/uts/common/io/mac/mac_client.c b/usr/src/uts/common/io/mac/mac_client.c index 779bdf204a..6563d51069 100644 --- a/usr/src/uts/common/io/mac/mac_client.c +++ b/usr/src/uts/common/io/mac/mac_client.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2018 Joyent, Inc. + * Copyright 2019 Joyent, Inc. * Copyright 2017 RackTop Systems. * Copyright 2020 OmniOS Community Edition (OmniOSce) Association. */ @@ -1632,6 +1632,32 @@ mac_rx_clear(mac_client_handle_t mch) mac_rx_set(mch, mac_pkt_drop, NULL); } +void +mac_rx_barrier(mac_client_handle_t mch) +{ + mac_client_impl_t *mcip = (mac_client_impl_t *)mch; + mac_impl_t *mip = mcip->mci_mip; + + i_mac_perim_enter(mip); + + /* If a RX callback is set, quiesce and restart that datapath */ + if (mcip->mci_rx_fn != mac_pkt_drop) { + mac_rx_client_quiesce(mch); + mac_rx_client_restart(mch); + } + + /* If any promisc callbacks are registered, perform a barrier there */ + if (mcip->mci_promisc_list != NULL || mip->mi_promisc_list != NULL) { + mac_cb_info_t *mcbi = &mip->mi_promisc_cb_info; + + mutex_enter(mcbi->mcbi_lockp); + mac_callback_barrier(mcbi); + mutex_exit(mcbi->mcbi_lockp); + } + + i_mac_perim_exit(mip); +} + void mac_secondary_dup(mac_client_handle_t smch, mac_client_handle_t dmch) { diff --git a/usr/src/uts/common/sys/mac_client.h b/usr/src/uts/common/sys/mac_client.h index 74f4cbb310..88ab5f4756 100644 --- a/usr/src/uts/common/sys/mac_client.h +++ b/usr/src/uts/common/sys/mac_client.h @@ -22,7 +22,7 @@ /* * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright 2018 Joyent, Inc. All rights reserved. + * Copyright 2019 Joyent, Inc. */ /* @@ -137,6 +137,7 @@ extern void mac_multicast_remove(mac_client_handle_t, const uint8_t *); extern void mac_rx_set(mac_client_handle_t, mac_rx_t, void *); extern void mac_rx_clear(mac_client_handle_t); +extern void mac_rx_barrier(mac_client_handle_t); extern void mac_secondary_dup(mac_client_handle_t, mac_client_handle_t); extern void mac_secondary_cleanup(mac_client_handle_t); extern mac_tx_cookie_t mac_tx(mac_client_handle_t, mblk_t *, diff --git a/usr/src/uts/common/sys/mac_impl.h b/usr/src/uts/common/sys/mac_impl.h index df03a76715..4625417828 100644 --- a/usr/src/uts/common/sys/mac_impl.h +++ b/usr/src/uts/common/sys/mac_impl.h @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2018, Joyent, Inc. + * Copyright 2019 Joyent, Inc. */ #ifndef _SYS_MAC_IMPL_H @@ -108,6 +108,7 @@ typedef struct mac_cb_info_s { kcondvar_t mcbi_cv; uint_t mcbi_del_cnt; /* Deleted callback cnt */ uint_t mcbi_walker_cnt; /* List walker count */ + uint_t mcbi_barrier_cnt; /* Barrier waiter count */ } mac_cb_info_t; typedef struct mac_notify_cb_s { @@ -123,40 +124,18 @@ typedef struct mac_notify_cb_s { */ typedef boolean_t (*mcb_func_t)(mac_cb_info_t *, mac_cb_t **, mac_cb_t *); -#define MAC_CALLBACK_WALKER_INC(mcbi) { \ - mutex_enter((mcbi)->mcbi_lockp); \ - (mcbi)->mcbi_walker_cnt++; \ - mutex_exit((mcbi)->mcbi_lockp); \ -} +#define MAC_CALLBACK_WALKER_INC(mcbi) \ + mac_callback_walker_enter(mcbi) -#define MAC_CALLBACK_WALKER_INC_HELD(mcbi) (mcbi)->mcbi_walker_cnt++; - -#define MAC_CALLBACK_WALKER_DCR(mcbi, headp) { \ - mac_cb_t *rmlist; \ - \ - mutex_enter((mcbi)->mcbi_lockp); \ - if (--(mcbi)->mcbi_walker_cnt == 0 && (mcbi)->mcbi_del_cnt != 0) { \ - rmlist = mac_callback_walker_cleanup((mcbi), headp); \ - mac_callback_free(rmlist); \ - cv_broadcast(&(mcbi)->mcbi_cv); \ - } \ - mutex_exit((mcbi)->mcbi_lockp); \ -} +#define MAC_CALLBACK_WALKER_DCR(mcbi, headp) \ + mac_callback_walker_exit(mcbi, headp, B_FALSE) -#define MAC_PROMISC_WALKER_INC(mip) \ - MAC_CALLBACK_WALKER_INC(&(mip)->mi_promisc_cb_info) - -#define MAC_PROMISC_WALKER_DCR(mip) { \ - mac_cb_info_t *mcbi; \ - \ - mcbi = &(mip)->mi_promisc_cb_info; \ - mutex_enter(mcbi->mcbi_lockp); \ - if (--mcbi->mcbi_walker_cnt == 0 && mcbi->mcbi_del_cnt != 0) { \ - i_mac_promisc_walker_cleanup(mip); \ - cv_broadcast(&mcbi->mcbi_cv); \ - } \ - mutex_exit(mcbi->mcbi_lockp); \ -} +#define MAC_PROMISC_WALKER_INC(mip) \ + mac_callback_walker_enter(&(mip)->mi_promisc_cb_info) + +#define MAC_PROMISC_WALKER_DCR(mip) \ + mac_callback_walker_exit(&(mip)->mi_promisc_cb_info, \ + &(mip)->mi_promisc_list, B_TRUE) typedef struct mactype_s { const char *mt_ident; @@ -753,12 +732,13 @@ extern void mac_rx_deliver(void *, mac_resource_handle_t, mblk_t *, mac_header_info_t *); extern void mac_tx_notify(mac_impl_t *); -extern boolean_t mac_callback_find(mac_cb_info_t *, mac_cb_t **, mac_cb_t *); -extern void mac_callback_add(mac_cb_info_t *, mac_cb_t **, mac_cb_t *); -extern boolean_t mac_callback_remove(mac_cb_info_t *, mac_cb_t **, mac_cb_t *); -extern void mac_callback_remove_wait(mac_cb_info_t *); -extern void mac_callback_free(mac_cb_t *); -extern mac_cb_t *mac_callback_walker_cleanup(mac_cb_info_t *, mac_cb_t **); +extern void mac_callback_add(mac_cb_info_t *, mac_cb_t **, mac_cb_t *); +extern boolean_t mac_callback_remove(mac_cb_info_t *, mac_cb_t **, mac_cb_t *); +extern void mac_callback_remove_wait(mac_cb_info_t *); +extern void mac_callback_barrier(mac_cb_info_t *); +extern void mac_callback_free(mac_cb_t *); +extern void mac_callback_walker_enter(mac_cb_info_t *); +extern void mac_callback_walker_exit(mac_cb_info_t *, mac_cb_t **, boolean_t); /* in mac_bcast.c */ extern void mac_bcast_init(void); @@ -872,7 +852,6 @@ extern void mac_tx_client_block(mac_client_impl_t *); extern void mac_tx_client_unblock(mac_client_impl_t *); extern void mac_tx_invoke_callbacks(mac_client_impl_t *, mac_tx_cookie_t); extern int i_mac_promisc_set(mac_impl_t *, boolean_t); -extern void i_mac_promisc_walker_cleanup(mac_impl_t *); extern mactype_t *mactype_getplugin(const char *); extern void mac_addr_factory_init(mac_impl_t *); extern void mac_addr_factory_fini(mac_impl_t *); -- cgit v1.2.3 From 868e1ac07011f1f9626a73a411c31ebbdd462e3d Mon Sep 17 00:00:00 2001 From: Patrick Mooney Date: Mon, 11 May 2020 23:26:58 +0000 Subject: 12554 want sdev plugin framework (fix header issue) Reviewed by: Richard Lowe Approved by: Richard Lowe --- usr/src/pkg/manifests/system-header.mf | 1 + usr/src/uts/common/sys/Makefile | 1 + 2 files changed, 2 insertions(+) (limited to 'usr/src') diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf index 0a3e045e1a..5098ae075a 100644 --- a/usr/src/pkg/manifests/system-header.mf +++ b/usr/src/pkg/manifests/system-header.mf @@ -1026,6 +1026,7 @@ file path=usr/include/sys/fs/pc_label.h file path=usr/include/sys/fs/pc_node.h file path=usr/include/sys/fs/pxfs_ki.h file path=usr/include/sys/fs/sdev_impl.h +file path=usr/include/sys/fs/sdev_plugin.h file path=usr/include/sys/fs/snode.h file path=usr/include/sys/fs/swapnode.h file path=usr/include/sys/fs/tmp.h diff --git a/usr/src/uts/common/sys/Makefile b/usr/src/uts/common/sys/Makefile index 3c24a1e04f..a267953305 100644 --- a/usr/src/uts/common/sys/Makefile +++ b/usr/src/uts/common/sys/Makefile @@ -839,6 +839,7 @@ FSHDRS= \ decomp.h \ dv_node.h \ sdev_impl.h \ + sdev_plugin.h \ fifonode.h \ hsfs_isospec.h \ hsfs_node.h \ -- cgit v1.2.3