From nobody Fri Dec 02 18:08:51 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NP1Cl2NdHz4hqc0; Fri, 2 Dec 2022 18:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NP1Cl1v9jz3ymy; Fri, 2 Dec 2022 18:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670004531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D5pGM4V+u5ZDMMMerNkSg+iSSeOuOdgML0C6C8cN8QI=; b=nHoWA7de/pNCI4N60jXWovQ6uQKeyyCHLfl1pxsePWxtXzl3J/yMF+P4BSLljpr8MoTNKo nl57/SzDMdLWb4OPqFH30XBWsos4YDlhyqAnFBk0sk4PsHAiHdlty/FmF4bnHBhbngX8FC WWlU5tDf0R508qskwZi0xsTITQpRXc8IbRSDdd66pF+KVe+qRqIK26ciOS60H+2tLCqza1 lVWnlZdbYMr3o+8yvy3pwPqh9uCT21LMwi+PZ303v3k1uh3uTpBOpttqcOScWo5S7zFhyN nzDHk7iRXUNtwodrWl8g5okclK9p62DFs+BXJpwr5QyDqZywfQRJeVvkRpviiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670004531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=D5pGM4V+u5ZDMMMerNkSg+iSSeOuOdgML0C6C8cN8QI=; b=Lpy6JTj82Hkx6Y0HeUeJmE0GG9uHFVWXGFfT9ZD1q9sKcYmDj6DYNtspblM6aHT5iEG3vm Qmce2Led51uV+uyVU7Ivd3gUE4GQhvQ69CfXK4tWTg7kw559D/ace3b/UuDhu5LOtkXoMS yJb0Vp/IeeYC1hwIMShnUEk5/ko3CI6Mi5hjEHv5N8Du6e9j9+/4+gCyuVd8MZ+7uULSrH 2SSnDi6PuDyq5u3FpcNnv0ubiX5xqCnn2eAH/fyho1Ti3Xxsr5ZYI55MQ1zEVod/MLKm7L dROFN36cnpJErQjnxMfYMrW/5mrM+IRYNXe2WeV8AVmEqncKUtS/tlvWpKC04g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670004531; a=rsa-sha256; cv=none; b=u0V/fd1EYPJ6yLns61FVX6TszGkmUoW8tIZI1R8psBldejra8LOfUxLwkMs+DCRIrIsQcv g2EzFKjDY2a9N0cucQkaeLKeJCV8tRV/2+fzdG+63r06Mzqq/DUdVYjC/DveZt7quLfEHe J/NHrMY8zgfoFEJkzVrGiKHaCqfxB8oB194iXTsU1c2kX3pVrigDeeQC+ecu2fGf96ndNO iSJh0nHqS3OtfWZfU7BAuhFIbHLli96F4YgSCLDMZ9YXO3o5aliJOCx3LXrSNJHYGbD4rc SOBBC7EtquUeNKZBd79hwAZ/5pu1aVIdLu9HaxBHsBAqYN617qZYjXP7sfaTLg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NP1Cl0y19zQ8N; Fri, 2 Dec 2022 18:08:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2B2I8pVj034814; Fri, 2 Dec 2022 18:08:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B2I8pTx034813; Fri, 2 Dec 2022 18:08:51 GMT (envelope-from git) Date: Fri, 2 Dec 2022 18:08:51 GMT Message-Id: <202212021808.2B2I8pTx034813@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 765274354040 - main - devd: Warn for deprecated 'kern' system type List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7652743540401f0b4dd080fc635031d1822295e8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7652743540401f0b4dd080fc635031d1822295e8 commit 7652743540401f0b4dd080fc635031d1822295e8 Author: Warner Losh AuthorDate: 2022-12-02 17:47:22 +0000 Commit: Warner Losh CommitDate: 2022-12-02 17:48:02 +0000 devd: Warn for deprecated 'kern' system type One year ago, I deprecated 'kern' in favor of 'kernel' for the system name for some power events. I'm about to remove it from the kernel, but realized there's been no warning generated for users. Preserve POLA by converting on the fly here and issuing a warning for 14.x, and an fatal error after we branch 15. Make compiling it an error on 16 to remove the gross hack after we branch. Sponsored by: Netflix Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D37584 --- sbin/devd/devd.cc | 34 ++++++++++++++++++++++++++++++++++ sys/kern/kern_devctl.c | 2 -- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index a1b6ee479921..abce58a1e659 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -173,6 +173,8 @@ delete_and_clear(vector &v) static config cfg; +static const char *curr_cf = NULL; + event_proc::event_proc() : _prio(-1) { _epsvec.reserve(4); @@ -452,17 +454,28 @@ config::reset(void) delete_and_clear(_notify_list); } +/* + * Called recursively as new files are included, so current stack of old names + * saved in each instance of 'old' on the call stack. Called single threaded + * so global varaibles curr_cf and lineno (and all of yacc's parser state) + * are safe to access w/o a lock. + */ void config::parse_one_file(const char *fn) { + const char *old; + devdlog(LOG_DEBUG, "Parsing %s\n", fn); yyin = fopen(fn, "r"); + old = curr_cf; + curr_cf = fn; if (yyin == NULL) err(1, "Cannot open config file %s", fn); lineno = 1; if (yyparse() != 0) errx(1, "Cannot parse %s at line %d", fn, lineno); fclose(yyin); + curr_cf = old; } void @@ -1194,6 +1207,27 @@ new_action(const char *cmd) eps * new_match(const char *var, const char *re) { + /* + * In FreeBSD 14, we changed the system=kern to system=kernel for the + * resume message to match all the other 'kernel' messages. Generate a + * warning for the life of 14.x that we've 'fixed' the file on the fly, + * but make it a fatal error in 15.x and newer. + */ + if (strcmp(var, "kern") == 0) { +#if __FreeBSD_version < 1500000 + devdlog(LOG_WARNING, + "Changing deprecated system='kern' to new name 'kernel' in %s line %d.", + curr_cf, lineno); + free(const_cast(var)); + var = strdup("kernel"); +#elif __FreeBSD_version < 1600000 + errx(1, "Encountered deprecated system=\"kern\" rule in %s line %d", + curr_cf, lineno); +#else +#error "Remove this gross hack" +#endif + } + eps *e = new match(cfg, var, re); free(const_cast(var)); free(const_cast(re)); diff --git a/sys/kern/kern_devctl.c b/sys/kern/kern_devctl.c index 414a2b74cbc7..d40559bba8f1 100644 --- a/sys/kern/kern_devctl.c +++ b/sys/kern/kern_devctl.c @@ -568,5 +568,3 @@ devctl_safe_quote_sb(struct sbuf *sb, const char *src) sbuf_putc(sb, *src++); } } - -