2002-03-01 01:20:23 +00:00
|
|
|
#!/usr/bin/awk -f
|
1999-09-26 18:31:51 +00:00
|
|
|
|
2005-01-07 02:29:27 +00:00
|
|
|
#-
|
2017-11-20 19:43:44 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#
|
1994-05-24 10:09:53 +00:00
|
|
|
# Copyright (c) 1992, 1993
|
|
|
|
# The Regents of the University of California. 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.
|
2017-02-28 23:42:47 +00:00
|
|
|
# 3. Neither the name of the University nor the names of its contributors
|
1994-05-24 10:09:53 +00:00
|
|
|
# may be used to endorse or promote products derived from this software
|
|
|
|
# without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
2005-01-07 02:29:27 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#
|
|
|
|
# @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
|
1999-08-28 01:08:13 +00:00
|
|
|
# $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
#
|
|
|
|
# Script to produce VFS front-end sugar.
|
|
|
|
#
|
2006-05-26 07:13:26 +00:00
|
|
|
# usage: vnode_if.awk <srcfile> [-c | -h | -p | -q]
|
2002-03-01 01:20:23 +00:00
|
|
|
# (where <srcfile> is currently /sys/kern/vnode_if.src)
|
2006-05-26 07:13:26 +00:00
|
|
|
# The source file must have a .src extension
|
1994-05-24 10:09:53 +00:00
|
|
|
#
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
function usage()
|
|
|
|
{
|
2004-12-01 23:16:38 +00:00
|
|
|
print "usage: vnode_if.awk <srcfile> [-c|-h|-p|-q]";
|
2002-03-01 01:20:23 +00:00
|
|
|
exit 1;
|
1999-09-26 18:31:51 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
function die(msg, what)
|
|
|
|
{
|
2006-05-30 21:13:28 +00:00
|
|
|
printf srcfile "(" fnr "): " > "/dev/stderr";
|
2002-03-01 01:20:23 +00:00
|
|
|
printf msg "\n", what > "/dev/stderr";
|
|
|
|
exit 1;
|
1999-12-12 16:43:05 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
function t_spc(type)
|
|
|
|
{
|
|
|
|
# Append a space if the type is not a pointer
|
|
|
|
return (type ~ /\*$/) ? type : type " ";
|
1999-12-12 16:43:05 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
# These are just for convenience ...
|
|
|
|
function printc(s) {print s > cfile;}
|
|
|
|
function printh(s) {print s > hfile;}
|
2004-12-01 23:16:38 +00:00
|
|
|
function printp(s) {print s > pfile;}
|
|
|
|
function printq(s) {print s > qfile;}
|
2002-03-01 01:20:23 +00:00
|
|
|
|
2005-01-13 07:53:01 +00:00
|
|
|
function add_debug_code(name, arg, pos, ind)
|
2002-03-01 01:20:23 +00:00
|
|
|
{
|
2003-06-20 12:15:37 +00:00
|
|
|
if (arg == "vpp")
|
2005-01-13 07:53:01 +00:00
|
|
|
star = "*";
|
|
|
|
else
|
|
|
|
star = "";
|
2003-06-22 21:20:06 +00:00
|
|
|
if (lockdata[name, arg, pos] && (lockdata[name, arg, pos] != "-")) {
|
2005-01-13 07:53:01 +00:00
|
|
|
printc(ind"ASSERT_VI_UNLOCKED("star"a->a_"arg", \""uname"\");");
|
2002-03-01 01:20:23 +00:00
|
|
|
# Add assertions for locking
|
2002-07-30 08:52:00 +00:00
|
|
|
if (lockdata[name, arg, pos] == "L")
|
2005-01-13 07:53:01 +00:00
|
|
|
printc(ind"ASSERT_VOP_LOCKED(" star "a->a_"arg", \""uname"\");");
|
2002-07-30 08:52:00 +00:00
|
|
|
else if (lockdata[name, arg, pos] == "U")
|
2005-01-13 07:53:01 +00:00
|
|
|
printc(ind"ASSERT_VOP_UNLOCKED(" star "a->a_"arg", \""uname"\");");
|
2005-04-11 15:15:03 +00:00
|
|
|
else if (lockdata[name, arg, pos] == "E")
|
|
|
|
printc(ind"ASSERT_VOP_ELOCKED(" star "a->a_"arg", \""uname"\");");
|
2002-03-01 01:20:23 +00:00
|
|
|
else if (0) {
|
|
|
|
# XXX More checks!
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2002-03-01 01:20:23 +00:00
|
|
|
}
|
1999-09-26 18:31:51 +00:00
|
|
|
|
2020-07-30 15:50:51 +00:00
|
|
|
function add_debugpre(name)
|
|
|
|
{
|
|
|
|
if (lockdata[name, "debugpre"]) {
|
|
|
|
printc("#ifdef DEBUG_VFS_LOCKS");
|
|
|
|
printc("\t"lockdata[name, "debugpre"]"(a);");
|
|
|
|
printc("#endif");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function add_debugpost(name)
|
|
|
|
{
|
|
|
|
if (lockdata[name, "debugpost"]) {
|
|
|
|
printc("#ifdef DEBUG_VFS_LOCKS");
|
|
|
|
printc("\t"lockdata[name, "debugpost"]"(a, rc);");
|
|
|
|
printc("#endif");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-09 20:20:31 +00:00
|
|
|
function add_pre(name)
|
2002-07-06 03:46:36 +00:00
|
|
|
{
|
2002-07-07 06:39:36 +00:00
|
|
|
if (lockdata[name, "pre"]) {
|
2005-01-13 07:53:01 +00:00
|
|
|
printc("\t"lockdata[name, "pre"]"(a);");
|
2002-07-06 03:46:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-09 20:20:31 +00:00
|
|
|
function add_post(name)
|
2002-07-06 03:46:36 +00:00
|
|
|
{
|
2002-07-07 06:39:36 +00:00
|
|
|
if (lockdata[name, "post"]) {
|
2005-01-13 07:53:01 +00:00
|
|
|
printc("\t"lockdata[name, "post"]"(a, rc);");
|
2002-07-06 03:46:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-30 15:50:51 +00:00
|
|
|
function can_inline(name)
|
|
|
|
{
|
|
|
|
if (lockdata[name, "pre"])
|
|
|
|
return 0;
|
|
|
|
if (lockdata[name, "post"])
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
function find_arg_with_type (type)
|
|
|
|
{
|
|
|
|
for (jj = 0; jj < numargs; jj++) {
|
|
|
|
if (types[jj] == type) {
|
|
|
|
return "VOPARG_OFFSETOF(struct " \
|
|
|
|
name "_args,a_" args[jj] ")";
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
return "VDESC_NO_OFFSET";
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
BEGIN{
|
1999-09-26 18:31:51 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
# Process the command line
|
|
|
|
for (i = 1; i < ARGC; i++) {
|
|
|
|
arg = ARGV[i];
|
2004-12-01 23:16:38 +00:00
|
|
|
if (arg !~ /^-[chpq]+$/ && arg !~ /\.src$/)
|
2002-03-01 01:20:23 +00:00
|
|
|
usage();
|
|
|
|
if (arg ~ /^-.*c/)
|
|
|
|
cfile = "vnode_if.c";
|
|
|
|
if (arg ~ /^-.*h/)
|
|
|
|
hfile = "vnode_if.h";
|
2004-12-01 23:16:38 +00:00
|
|
|
if (arg ~ /^-.*p/)
|
|
|
|
pfile = "vnode_if_newproto.h";
|
|
|
|
if (arg ~ /^-.*q/)
|
|
|
|
qfile = "vnode_if_typedef.h";
|
2002-03-01 01:20:23 +00:00
|
|
|
if (arg ~ /\.src$/)
|
|
|
|
srcfile = arg;
|
|
|
|
}
|
|
|
|
ARGC = 1;
|
|
|
|
|
2004-12-01 23:16:38 +00:00
|
|
|
if (!cfile && !hfile && !pfile && !qfile)
|
2002-03-01 01:20:23 +00:00
|
|
|
exit 0;
|
|
|
|
|
|
|
|
if (!srcfile)
|
|
|
|
usage();
|
|
|
|
|
2019-05-08 13:35:51 +00:00
|
|
|
# Avoid a literal generated file tag here.
|
|
|
|
generated = "@" "generated";
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
common_head = \
|
|
|
|
"/*\n" \
|
2019-05-08 13:35:51 +00:00
|
|
|
" * This file is " generated " automatically.\n" \
|
2002-03-01 01:20:23 +00:00
|
|
|
" * Do not modify anything in here by hand.\n" \
|
|
|
|
" *\n" \
|
|
|
|
" * Created from $FreeBSD$\n" \
|
|
|
|
" */\n" \
|
|
|
|
"\n";
|
|
|
|
|
2004-12-01 23:16:38 +00:00
|
|
|
if (pfile) {
|
|
|
|
printp(common_head)
|
|
|
|
printp("struct vop_vector {")
|
|
|
|
printp("\tstruct vop_vector\t*vop_default;")
|
|
|
|
printp("\tvop_bypass_t\t*vop_bypass;")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qfile) {
|
|
|
|
printq(common_head)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hfile) {
|
2002-03-01 01:20:23 +00:00
|
|
|
printh(common_head "extern struct vnodeop_desc vop_default_desc;");
|
2004-12-01 23:16:38 +00:00
|
|
|
printh("#include \"vnode_if_typedef.h\"")
|
|
|
|
printh("#include \"vnode_if_newproto.h\"")
|
|
|
|
}
|
2002-03-01 01:20:23 +00:00
|
|
|
|
|
|
|
if (cfile) {
|
|
|
|
printc(common_head \
|
|
|
|
"#include <sys/param.h>\n" \
|
2005-06-09 20:20:31 +00:00
|
|
|
"#include <sys/event.h>\n" \
|
2009-03-29 03:30:15 +00:00
|
|
|
"#include <sys/kernel.h>\n" \
|
2005-06-09 20:20:31 +00:00
|
|
|
"#include <sys/mount.h>\n" \
|
2009-03-29 03:30:15 +00:00
|
|
|
"#include <sys/sdt.h>\n" \
|
2013-02-21 19:02:50 +00:00
|
|
|
"#include <sys/signalvar.h>\n" \
|
2002-05-04 02:35:13 +00:00
|
|
|
"#include <sys/systm.h>\n" \
|
2002-03-01 01:20:23 +00:00
|
|
|
"#include <sys/vnode.h>\n" \
|
|
|
|
"\n" \
|
2009-03-29 03:30:15 +00:00
|
|
|
"SDT_PROVIDER_DECLARE(vfs);\n" \
|
|
|
|
"\n" \
|
2002-03-01 01:20:23 +00:00
|
|
|
"struct vnodeop_desc vop_default_desc = {\n" \
|
|
|
|
" \"default\",\n" \
|
|
|
|
" 0,\n" \
|
2018-10-23 21:43:41 +00:00
|
|
|
" 0,\n" \
|
2005-12-14 00:49:52 +00:00
|
|
|
" (vop_bypass_t *)vop_panic,\n" \
|
2002-03-01 01:20:23 +00:00
|
|
|
" NULL,\n" \
|
|
|
|
" VDESC_NO_OFFSET,\n" \
|
|
|
|
" VDESC_NO_OFFSET,\n" \
|
|
|
|
" VDESC_NO_OFFSET,\n" \
|
|
|
|
" VDESC_NO_OFFSET,\n" \
|
|
|
|
"};\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((getline < srcfile) > 0) {
|
2006-05-30 21:13:28 +00:00
|
|
|
fnr++;
|
2002-03-01 01:20:23 +00:00
|
|
|
if (NF == 0)
|
|
|
|
continue;
|
2006-05-30 20:49:54 +00:00
|
|
|
if ($1 ~ /^%%/) {
|
2006-05-30 21:13:28 +00:00
|
|
|
if (NF != 6 ||
|
2012-02-21 19:35:59 +00:00
|
|
|
$2 !~ /^[a-z_]+$/ || $3 !~ /^[a-z]+$/ ||
|
2006-05-30 21:13:28 +00:00
|
|
|
$4 !~ /^.$/ || $5 !~ /^.$/ || $6 !~ /^.$/) {
|
|
|
|
die("Invalid %s construction", "%%");
|
2002-03-01 01:20:23 +00:00
|
|
|
continue;
|
2006-05-30 21:13:28 +00:00
|
|
|
}
|
2002-03-01 01:20:23 +00:00
|
|
|
lockdata["vop_" $2, $3, "Entry"] = $4;
|
|
|
|
lockdata["vop_" $2, $3, "OK"] = $5;
|
|
|
|
lockdata["vop_" $2, $3, "Error"] = $6;
|
|
|
|
continue;
|
1999-09-26 18:31:51 +00:00
|
|
|
}
|
2002-03-01 01:20:23 +00:00
|
|
|
|
2006-05-30 20:49:54 +00:00
|
|
|
if ($1 ~ /^%!/) {
|
2006-05-30 21:13:28 +00:00
|
|
|
if (NF != 4 ||
|
2020-07-30 15:50:51 +00:00
|
|
|
($3 != "pre" && $3 != "post" &&
|
|
|
|
$3 != "debugpre" && $3 != "debugpost")) {
|
2006-05-30 21:13:28 +00:00
|
|
|
die("Invalid %s construction", "%!");
|
2002-07-06 03:46:36 +00:00
|
|
|
continue;
|
2006-05-30 21:13:28 +00:00
|
|
|
}
|
2002-07-06 03:46:36 +00:00
|
|
|
lockdata["vop_" $2, $3] = $4;
|
|
|
|
continue;
|
|
|
|
}
|
2006-05-30 21:13:28 +00:00
|
|
|
if ($1 ~ /^#/)
|
2002-07-06 03:46:36 +00:00
|
|
|
continue;
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
# Get the function name.
|
|
|
|
name = $1;
|
|
|
|
uname = toupper(name);
|
2002-09-23 05:50:07 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
# Get the function arguments.
|
|
|
|
for (numargs = 0; ; ++numargs) {
|
|
|
|
if ((getline < srcfile) <= 0) {
|
|
|
|
die("Unable to read through the arguments for \"%s\"",
|
|
|
|
name);
|
1999-09-26 18:31:51 +00:00
|
|
|
}
|
2006-05-30 21:13:28 +00:00
|
|
|
fnr++;
|
2002-03-01 01:20:23 +00:00
|
|
|
if ($1 ~ /^\};/)
|
|
|
|
break;
|
|
|
|
|
|
|
|
# Delete comments, if any.
|
|
|
|
gsub (/\/\*.*\*\//, "");
|
|
|
|
|
|
|
|
# Condense whitespace and delete leading/trailing space.
|
|
|
|
gsub(/[[:space:]]+/, " ");
|
|
|
|
sub(/^ /, "");
|
|
|
|
sub(/ $/, "");
|
|
|
|
|
|
|
|
# Pick off direction.
|
|
|
|
if ($1 != "INOUT" && $1 != "IN" && $1 != "OUT")
|
|
|
|
die("No IN/OUT direction for \"%s\".", $0);
|
|
|
|
dirs[numargs] = $1;
|
|
|
|
sub(/^[A-Z]* /, "");
|
|
|
|
|
|
|
|
if ((reles[numargs] = $1) == "WILLRELE")
|
|
|
|
sub(/^[A-Z]* /, "");
|
|
|
|
else
|
|
|
|
reles[numargs] = "WONTRELE";
|
|
|
|
|
|
|
|
# kill trailing ;
|
|
|
|
if (sub(/;$/, "") < 1)
|
|
|
|
die("Missing end-of-line ; in \"%s\".", $0);
|
|
|
|
|
|
|
|
# pick off variable name
|
|
|
|
if ((argp = match($0, /[A-Za-z0-9_]+$/)) < 1)
|
|
|
|
die("Missing var name \"a_foo\" in \"%s\".", $0);
|
|
|
|
args[numargs] = substr($0, argp);
|
|
|
|
$0 = substr($0, 1, argp - 1);
|
|
|
|
|
|
|
|
# what is left must be type
|
|
|
|
# remove trailing space (if any)
|
|
|
|
sub(/ $/, "");
|
|
|
|
types[numargs] = $0;
|
1999-09-26 18:31:51 +00:00
|
|
|
}
|
2012-12-19 20:10:00 +00:00
|
|
|
if (numargs > 4)
|
|
|
|
ctrargs = 4;
|
2002-09-23 05:50:07 +00:00
|
|
|
else
|
|
|
|
ctrargs = numargs;
|
2012-12-28 06:52:53 +00:00
|
|
|
ctrstr = ctrargs "(KTR_VOP, \"VOP\", \"" uname "\", (uintptr_t)a,\n\t ";
|
2012-12-19 20:10:00 +00:00
|
|
|
ctrstr = ctrstr "\"" args[0] ":0x%jX\", (uintptr_t)a->a_" args[0];
|
2005-01-13 07:53:01 +00:00
|
|
|
for (i = 1; i < ctrargs; ++i)
|
2012-12-19 20:10:00 +00:00
|
|
|
ctrstr = ctrstr ", \"" args[i] ":0x%jX\", a->a_" args[i];
|
2002-09-23 05:50:07 +00:00
|
|
|
ctrstr = ctrstr ");";
|
1999-12-12 16:43:05 +00:00
|
|
|
|
2004-12-01 23:16:38 +00:00
|
|
|
if (pfile) {
|
|
|
|
printp("\t"name"_t\t*"name";")
|
|
|
|
}
|
|
|
|
if (qfile) {
|
|
|
|
printq("struct "name"_args;")
|
|
|
|
printq("typedef int "name"_t(struct "name"_args *);\n")
|
|
|
|
}
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
if (hfile) {
|
|
|
|
# Print out the vop_F_args structure.
|
2004-12-13 07:23:34 +00:00
|
|
|
printh("struct "name"_args {\n\tstruct vop_generic_args a_gen;");
|
2002-03-01 01:20:23 +00:00
|
|
|
for (i = 0; i < numargs; ++i)
|
|
|
|
printh("\t" t_spc(types[i]) "a_" args[i] ";");
|
|
|
|
printh("};");
|
2005-01-13 07:53:01 +00:00
|
|
|
printh("");
|
2002-03-01 01:20:23 +00:00
|
|
|
|
|
|
|
# Print out extern declaration.
|
|
|
|
printh("extern struct vnodeop_desc " name "_desc;");
|
2005-01-13 07:53:01 +00:00
|
|
|
printh("");
|
2002-03-01 01:20:23 +00:00
|
|
|
|
2005-01-13 07:53:01 +00:00
|
|
|
# Print out function prototypes.
|
|
|
|
printh("int " uname "_AP(struct " name "_args *);");
|
2005-02-08 12:54:32 +00:00
|
|
|
printh("int " uname "_APV(struct vop_vector *vop, struct " name "_args *);");
|
2005-01-13 07:53:01 +00:00
|
|
|
printh("");
|
2002-03-01 01:20:23 +00:00
|
|
|
printh("static __inline int " uname "(");
|
|
|
|
for (i = 0; i < numargs; ++i) {
|
|
|
|
printh("\t" t_spc(types[i]) args[i] \
|
|
|
|
(i < numargs - 1 ? "," : ")"));
|
|
|
|
}
|
2005-01-13 07:53:01 +00:00
|
|
|
printh("{");
|
|
|
|
printh("\tstruct " name "_args a;");
|
|
|
|
printh("");
|
2005-01-13 08:05:20 +00:00
|
|
|
printh("\ta.a_gen.a_desc = &" name "_desc;");
|
2002-03-01 01:20:23 +00:00
|
|
|
for (i = 0; i < numargs; ++i)
|
|
|
|
printh("\ta.a_" args[i] " = " args[i] ";");
|
2020-07-30 15:50:51 +00:00
|
|
|
if (can_inline(name)) {
|
|
|
|
printh("\n#if !defined(DEBUG_VFS_LOCKS) && !defined(INVARIANTS) && !defined(KTR)");
|
|
|
|
printh("\tif (!SDT_PROBES_ENABLED())");
|
|
|
|
printh("\t\treturn (" args[0]"->v_op->"name"(&a));");
|
|
|
|
printh("\telse");
|
|
|
|
printh("\t\treturn (" uname "_APV("args[0]"->v_op, &a));");
|
|
|
|
printh("#else");
|
|
|
|
}
|
2005-02-08 12:54:32 +00:00
|
|
|
printh("\treturn (" uname "_APV("args[0]"->v_op, &a));");
|
2020-07-30 15:50:51 +00:00
|
|
|
if (can_inline(name))
|
|
|
|
printh("#endif");
|
|
|
|
|
2002-07-30 08:52:00 +00:00
|
|
|
printh("}");
|
2005-01-13 07:53:01 +00:00
|
|
|
|
|
|
|
printh("");
|
1999-12-12 16:43:05 +00:00
|
|
|
}
|
1999-09-26 18:31:51 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
if (cfile) {
|
2019-12-16 00:06:22 +00:00
|
|
|
funcarr[name] = 1;
|
2002-03-01 01:20:23 +00:00
|
|
|
# Print out the vop_F_vp_offsets structure. This all depends
|
|
|
|
# on naming conventions and nothing else.
|
|
|
|
printc("static int " name "_vp_offsets[] = {");
|
|
|
|
# as a side effect, figure out the releflags
|
|
|
|
releflags = "";
|
|
|
|
vpnum = 0;
|
|
|
|
for (i = 0; i < numargs; i++) {
|
|
|
|
if (types[i] == "struct vnode *") {
|
|
|
|
printc("\tVOPARG_OFFSETOF(struct " name \
|
|
|
|
"_args,a_" args[i] "),");
|
|
|
|
if (reles[i] == "WILLRELE") {
|
|
|
|
releflags = releflags \
|
|
|
|
"|VDESC_VP" vpnum "_WILLRELE";
|
|
|
|
}
|
|
|
|
vpnum++;
|
|
|
|
}
|
|
|
|
}
|
1999-09-26 18:31:51 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
sub(/^\|/, "", releflags);
|
|
|
|
printc("\tVDESC_NO_OFFSET");
|
|
|
|
printc("};");
|
|
|
|
|
2009-03-29 03:30:15 +00:00
|
|
|
printc("\n");
|
2013-11-26 08:46:27 +00:00
|
|
|
printc("SDT_PROBE_DEFINE2(vfs, vop, " name ", entry, \"struct vnode *\", \"struct " name "_args *\");\n");
|
|
|
|
printc("SDT_PROBE_DEFINE3(vfs, vop, " name ", return, \"struct vnode *\", \"struct " name "_args *\", \"int\");\n");
|
2009-03-29 03:30:15 +00:00
|
|
|
|
2005-01-13 07:53:01 +00:00
|
|
|
# Print out function.
|
|
|
|
printc("\nint\n" uname "_AP(struct " name "_args *a)");
|
|
|
|
printc("{");
|
2005-02-08 12:54:32 +00:00
|
|
|
printc("");
|
|
|
|
printc("\treturn(" uname "_APV(a->a_" args[0] "->v_op, a));");
|
|
|
|
printc("}");
|
|
|
|
printc("\nint\n" uname "_APV(struct vop_vector *vop, struct " name "_args *a)");
|
|
|
|
printc("{");
|
2005-01-13 07:53:01 +00:00
|
|
|
printc("\tint rc;");
|
|
|
|
printc("");
|
2005-02-08 12:54:32 +00:00
|
|
|
printc("\tVNASSERT(a->a_gen.a_desc == &" name "_desc, a->a_" args[0]",");
|
|
|
|
printc("\t (\"Wrong a_desc in " name "(%p, %p)\", a->a_" args[0]", a));");
|
|
|
|
printc("\tVNASSERT(vop != NULL, a->a_" args[0]", (\"No "name"(%p, %p)\", a->a_" args[0]", a));")
|
2012-12-19 20:10:00 +00:00
|
|
|
printc("\tKTR_START" ctrstr);
|
2020-07-30 15:50:51 +00:00
|
|
|
add_debugpre(name);
|
2005-06-09 20:20:31 +00:00
|
|
|
add_pre(name);
|
2019-12-16 00:07:51 +00:00
|
|
|
for (i = 0; i < numargs; ++i)
|
|
|
|
add_debug_code(name, args[i], "Entry", "\t");
|
2020-01-26 00:41:38 +00:00
|
|
|
printc("\tif (!SDT_PROBES_ENABLED()) {");
|
2005-01-13 07:53:01 +00:00
|
|
|
printc("\t\trc = vop->"name"(a);")
|
2019-12-16 00:07:51 +00:00
|
|
|
printc("\t} else {")
|
|
|
|
printc("\t\tSDT_PROBE2(vfs, vop, " name ", entry, a->a_" args[0] ", a);");
|
2020-01-26 00:41:38 +00:00
|
|
|
printc("\t\trc = vop->"name"(a);")
|
2019-12-16 00:07:51 +00:00
|
|
|
printc("\t\tSDT_PROBE3(vfs, vop, " name ", return, a->a_" args[0] ", a, rc);");
|
|
|
|
printc("\t}")
|
2005-01-13 07:53:01 +00:00
|
|
|
printc("\tif (rc == 0) {");
|
|
|
|
for (i = 0; i < numargs; ++i)
|
|
|
|
add_debug_code(name, args[i], "OK", "\t\t");
|
|
|
|
printc("\t} else {");
|
|
|
|
for (i = 0; i < numargs; ++i)
|
|
|
|
add_debug_code(name, args[i], "Error", "\t\t");
|
|
|
|
printc("\t}");
|
2005-06-09 20:20:31 +00:00
|
|
|
add_post(name);
|
2020-07-30 15:50:51 +00:00
|
|
|
add_debugpost(name);
|
2012-12-19 20:10:00 +00:00
|
|
|
printc("\tKTR_STOP" ctrstr);
|
2005-01-13 07:53:01 +00:00
|
|
|
printc("\treturn (rc);");
|
|
|
|
printc("}\n");
|
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
# Print out the vnodeop_desc structure.
|
|
|
|
printc("struct vnodeop_desc " name "_desc = {");
|
|
|
|
# printable name
|
|
|
|
printc("\t\"" name "\",");
|
|
|
|
# flags
|
|
|
|
vppwillrele = "";
|
|
|
|
for (i = 0; i < numargs; i++) {
|
|
|
|
if (types[i] == "struct vnode **" && \
|
|
|
|
reles[i] == "WILLRELE") {
|
|
|
|
vppwillrele = "|VDESC_VPP_WILLRELE";
|
|
|
|
}
|
|
|
|
}
|
1999-09-26 18:31:51 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
if (!releflags)
|
|
|
|
releflags = "0";
|
|
|
|
printc("\t" releflags vppwillrele ",");
|
|
|
|
|
2018-10-23 21:43:41 +00:00
|
|
|
# index in struct vop_vector
|
|
|
|
printc("\t__offsetof(struct vop_vector, " name "),");
|
2005-01-13 07:53:01 +00:00
|
|
|
# function to call
|
2005-12-14 00:49:52 +00:00
|
|
|
printc("\t(vop_bypass_t *)" uname "_AP,");
|
2002-03-01 01:20:23 +00:00
|
|
|
# vp offsets
|
|
|
|
printc("\t" name "_vp_offsets,");
|
|
|
|
# vpp (if any)
|
|
|
|
printc("\t" find_arg_with_type("struct vnode **") ",");
|
|
|
|
# cred (if any)
|
|
|
|
printc("\t" find_arg_with_type("struct ucred *") ",");
|
|
|
|
# thread (if any)
|
|
|
|
printc("\t" find_arg_with_type("struct thread *") ",");
|
|
|
|
# componentname
|
|
|
|
printc("\t" find_arg_with_type("struct componentname *") ",");
|
|
|
|
# transport layer information
|
2005-12-14 00:15:11 +00:00
|
|
|
printc("};\n");
|
2002-03-01 01:20:23 +00:00
|
|
|
}
|
1999-09-26 18:31:51 +00:00
|
|
|
}
|
2019-12-16 00:06:22 +00:00
|
|
|
|
|
|
|
if (cfile) {
|
|
|
|
printc("void");
|
|
|
|
printc("vfs_vector_op_register(struct vop_vector *orig_vop)");
|
|
|
|
printc("{");
|
|
|
|
printc("\tstruct vop_vector *vop;");
|
|
|
|
printc("");
|
|
|
|
printc("\tif (orig_vop->registered)");
|
|
|
|
printc("\t\tpanic(\"%s: vop_vector %p already registered\",")
|
|
|
|
printc("\t\t __func__, orig_vop);");
|
|
|
|
printc("");
|
|
|
|
for (name in funcarr) {
|
|
|
|
printc("\tvop = orig_vop;");
|
|
|
|
printc("\twhile (vop != NULL && \\");
|
|
|
|
printc("\t vop->"name" == NULL && vop->vop_bypass == NULL)")
|
|
|
|
printc("\t\tvop = vop->vop_default;")
|
|
|
|
printc("\tif (vop != NULL)");
|
|
|
|
printc("\t\torig_vop->"name" = vop->"name";");
|
|
|
|
printc("");
|
|
|
|
}
|
|
|
|
printc("\tvop = orig_vop;");
|
|
|
|
printc("\twhile (vop != NULL && vop->vop_bypass == NULL)")
|
|
|
|
printc("\t\tvop = vop->vop_default;")
|
|
|
|
printc("\tif (vop != NULL)");
|
|
|
|
printc("\t\torig_vop->vop_bypass = vop->vop_bypass;");
|
|
|
|
printc("");
|
2020-01-26 00:41:38 +00:00
|
|
|
for (name in funcarr) {
|
|
|
|
printc("\tif (orig_vop->"name" == NULL)");
|
|
|
|
printc("\t\torig_vop->"name" = (void *)orig_vop->vop_bypass;");
|
|
|
|
}
|
|
|
|
printc("");
|
2019-12-16 00:06:22 +00:00
|
|
|
printc("\torig_vop->registered = true;");
|
|
|
|
printc("}")
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hfile) {
|
|
|
|
printh("void vfs_vector_op_register(struct vop_vector *orig_vop);");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pfile) {
|
|
|
|
printp("\tbool\tregistered;")
|
2004-12-01 23:16:38 +00:00
|
|
|
printp("};")
|
2019-12-16 00:06:22 +00:00
|
|
|
}
|
2004-12-01 23:16:38 +00:00
|
|
|
|
2002-03-01 01:20:23 +00:00
|
|
|
if (hfile)
|
|
|
|
close(hfile);
|
|
|
|
if (cfile)
|
|
|
|
close(cfile);
|
2004-12-01 23:16:38 +00:00
|
|
|
if (pfile)
|
|
|
|
close(pfile);
|
2002-03-01 01:20:23 +00:00
|
|
|
close(srcfile);
|
1999-09-26 18:31:51 +00:00
|
|
|
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
}
|