From patchwork Fri Mar 20 20:41:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 132104 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 3F1364C3185E for ; Fri, 20 Mar 2026 20:42:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F1364C3185E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VENLPwjQ X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id ECD554C515F9 for ; Fri, 20 Mar 2026 20:41:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECD554C515F9 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ECD554C515F9 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774039283; cv=none; b=J1vQXh3wHzt5ckInjBI6l2jKgxdG5tRwPRCCLUqnMkgJhlbgPtAMNF1ZUhySs4EEJ18QHpPSjq/VR3f68gsZzCcIRrfvxcVU6YrIi5LaBAI+GyRfCJyRD8F05bwKanu78c/h5/1kL+pl6+45jRL1nRz+8omqMxmfh6bMDkBQgL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774039283; c=relaxed/simple; bh=bwFr4PqMqezvmMIxH8HrDcyYkYxf0PNTmhmEvNtHsRY=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=xTP9NSNUZMthWEOFQ5ob6qkNE6ccFzjNX6MIJwpvCVLLj9GnUW8gB/k0HxFv6iBkpNab4KOF9XqhcL/NEIsJBT/URBAKuy3DpqpUuxNd1i/XfuLfFrgwuYMWFlbN4bmtV9ZXV0jytzRcGSKwfBMb4C6KlaS7Xi8wYRvMMgdaK0E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECD554C515F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774039282; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aRvWolzjRkB9bG5Gf32hifYKrrtR4jvoEQx3TzX4N9k=; b=VENLPwjQIJcxm+OZZ1zCwt0z0J1NStJtx+/LfNphR4saR8HuHeX5MTuJxEkX8BzFmifuGA X99wP+PF58S5c/tWo/4OoMi8qiocCpa4AgF3a+8SeST3QqWjbk/+RNav6ZeX9WnSNCLOf5 +l7R9mzUd7Cld2nhzc8niDeLoiGKjx4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-wiXeR_WdNjqCPVQpg9g23w-1; Fri, 20 Mar 2026 16:41:21 -0400 X-MC-Unique: wiXeR_WdNjqCPVQpg9g23w-1 X-Mimecast-MFC-AGG-ID: wiXeR_WdNjqCPVQpg9g23w_1774039280 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A5AFA195609F for ; Fri, 20 Mar 2026 20:41:20 +0000 (UTC) Received: from fweimer-oldenburg.csb.redhat.com (unknown [10.45.224.63]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F001C30001A1 for ; Fri, 20 Mar 2026 20:41:19 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2 02/23] nscd: Extract dbtype and struct statdata types to separate headers In-Reply-To: Message-ID: <46558f4181ad5c04f7e7d2439a88a0a37018b0dc.1774037705.git.fweimer@redhat.com> References: X-From-Line: 46558f4181ad5c04f7e7d2439a88a0a37018b0dc Mon Sep 17 00:00:00 2001 Date: Fri, 20 Mar 2026 21:41:17 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MDN6YydZVPu3x60UNOrZYa-YKMrrWMC_MmhnXOlP93M_1774039280 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_HOSTKARMA_W, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org So that they can be used in test code which uses _ISOMAC (so not in internal tests). Reviewed-by: Carlos O'Donell --- nscd/nscd-dbtype.h | 32 ++++++++++++++ nscd/nscd-statdata.h | 99 ++++++++++++++++++++++++++++++++++++++++++++ nscd/nscd.h | 14 +------ nscd/nscd_stat.c | 73 +------------------------------- 4 files changed, 133 insertions(+), 85 deletions(-) create mode 100644 nscd/nscd-dbtype.h create mode 100644 nscd/nscd-statdata.h diff --git a/nscd/nscd-dbtype.h b/nscd/nscd-dbtype.h new file mode 100644 index 0000000000..7d553d020a --- /dev/null +++ b/nscd/nscd-dbtype.h @@ -0,0 +1,32 @@ +/* Database types handled by nscd. + Copyright (c) 1998-2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef NSCD_DBTYPE_H +#define NSCD_DBTYPE_H + +typedef enum +{ + pwddb, + grpdb, + hstdb, + servdb, + netgrdb, + lastdb +} dbtype; + +#endif /* NSCD_DBTYPE_H */ diff --git a/nscd/nscd-statdata.h b/nscd/nscd-statdata.h new file mode 100644 index 0000000000..255dcdfc54 --- /dev/null +++ b/nscd/nscd-statdata.h @@ -0,0 +1,99 @@ +/* Statistics data for nscd. + Copyright (c) 1998-2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef NSCD_STATDATA_H +#define NSCD_STATDATA_H + +#include +#include + +#ifdef HAVE_SELINUX +# include +# include +#endif /* HAVE_SELINUX */ + +#include "nscd-dbtype.h" + +/* We use this to make sure the receiver is the same. The lower 16 + bits are reserved for flags indicating compilation variants. This + version needs to be updated if the definition of struct statdata + changes. */ +#define STATDATA_VERSION 0x01020000U + +#ifdef HAVE_SELINUX +# define STATDATA_VERSION_SELINUX_FLAG 0x0001U +#else +# define STATDATA_VERSION_SELINUX_FLAG 0x0000U +#endif + +/* All flags affecting the struct statdata layout. */ +#define STATDATA_VERSION_FLAGS STATDATA_VERSION_SELINUX_FLAG + +/* The full version number for struct statdata. */ +#define STATDATA_VERSION_FULL (STATDATA_VERSION | STATDATA_VERSION_FLAGS) + +/* Statistic data for one database. */ +struct dbstat +{ + int enabled; + int check_file; + int shared; + int persistent; + size_t module; + + unsigned long int postimeout; + unsigned long int negtimeout; + + size_t nentries; + size_t maxnentries; + size_t maxnsearched; + size_t datasize; + size_t dataused; + + uintmax_t poshit; + uintmax_t neghit; + uintmax_t posmiss; + uintmax_t negmiss; + + uintmax_t rdlockdelayed; + uintmax_t wrlockdelayed; + + uintmax_t addfailed; +}; + +/* Record for transmitting statistics. If this definition changes, + update STATDATA_VERSION above. */ +struct statdata +{ + unsigned int version; /* Must be STATDATA_VERSION_FULL. */ + int debug_level; + time_t runtime; + unsigned long int client_queued; + int nthreads; + int max_nthreads; + int paranoia; + time_t restart_interval; + unsigned int reload_count; + int ndbs; + struct dbstat dbs[lastdb]; +#ifdef HAVE_SELINUX + struct avc_cache_stats cstats; +#endif /* HAVE_SELINUX */ +}; + +#endif /* NSCD_STATDATA_H */ diff --git a/nscd/nscd.h b/nscd/nscd.h index 7d1bac2dc1..fffcb7a719 100644 --- a/nscd/nscd.h +++ b/nscd/nscd.h @@ -27,19 +27,7 @@ "nscd-client.h", which should contain everything needed by client functions. */ #include "nscd-client.h" - - -/* Handle databases. */ -typedef enum -{ - pwddb, - grpdb, - hstdb, - servdb, - netgrdb, - lastdb -} dbtype; - +#include "nscd-dbtype.h" /* Default limit on the number of times a value gets reloaded without being used in the meantime. NSCD does not throw a value out as diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c index 3a0ed54617..d67910cd9e 100644 --- a/nscd/nscd_stat.c +++ b/nscd/nscd_stat.c @@ -29,78 +29,7 @@ #include "nscd.h" #include "dbg_log.h" #include "selinux.h" -#ifdef HAVE_SELINUX -# include -# include -#endif /* HAVE_SELINUX */ - -/* We use this to make sure the receiver is the same. The lower 16 - bits are reserved for flags indicating compilation variants. This - version needs to be updated if the definition of struct statdata - changes. */ -#define STATDATA_VERSION 0x01020000U - -#ifdef HAVE_SELINUX -# define STATDATA_VERSION_SELINUX_FLAG 0x0001U -#else -# define STATDATA_VERSION_SELINUX_FLAG 0x0000U -#endif - -/* All flags affecting the struct statdata layout. */ -#define STATDATA_VERSION_FLAGS STATDATA_VERSION_SELINUX_FLAG - -/* The full version number for struct statdata. */ -#define STATDATA_VERSION_FULL (STATDATA_VERSION | STATDATA_VERSION_FLAGS) - -/* Statistic data for one database. */ -struct dbstat -{ - int enabled; - int check_file; - int shared; - int persistent; - size_t module; - - unsigned long int postimeout; - unsigned long int negtimeout; - - size_t nentries; - size_t maxnentries; - size_t maxnsearched; - size_t datasize; - size_t dataused; - - uintmax_t poshit; - uintmax_t neghit; - uintmax_t posmiss; - uintmax_t negmiss; - - uintmax_t rdlockdelayed; - uintmax_t wrlockdelayed; - - uintmax_t addfailed; -}; - -/* Record for transmitting statistics. If this definition changes, - update STATDATA_VERSION above. */ -struct statdata -{ - unsigned int version; /* Must be STATDATA_VERSION_FULL. */ - int debug_level; - time_t runtime; - unsigned long int client_queued; - int nthreads; - int max_nthreads; - int paranoia; - time_t restart_interval; - unsigned int reload_count; - int ndbs; - struct dbstat dbs[lastdb]; -#ifdef HAVE_SELINUX - struct avc_cache_stats cstats; -#endif /* HAVE_SELINUX */ -}; - +#include "nscd-statdata.h" void send_stats (int fd, struct database_dyn dbs[lastdb])