xref: /freebsd/sys/fs/procfs/procfs_type.c (revision 95ee2897)
1d167cf6fSWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
432acf9a1SJohn Dyson  * Copyright (c) 1993 Jan-Simon Pendry
532acf9a1SJohn Dyson  * Copyright (c) 1993
632acf9a1SJohn Dyson  *	The Regents of the University of California.  All rights reserved.
732acf9a1SJohn Dyson  *
832acf9a1SJohn Dyson  * This code is derived from software contributed to Berkeley by
932acf9a1SJohn Dyson  * Jan-Simon Pendry.
1032acf9a1SJohn Dyson  *
1132acf9a1SJohn Dyson  * Redistribution and use in source and binary forms, with or without
1232acf9a1SJohn Dyson  * modification, are permitted provided that the following conditions
1332acf9a1SJohn Dyson  * are met:
1432acf9a1SJohn Dyson  * 1. Redistributions of source code must retain the above copyright
1532acf9a1SJohn Dyson  *    notice, this list of conditions and the following disclaimer.
1632acf9a1SJohn Dyson  * 2. Redistributions in binary form must reproduce the above copyright
1732acf9a1SJohn Dyson  *    notice, this list of conditions and the following disclaimer in the
1832acf9a1SJohn Dyson  *    documentation and/or other materials provided with the distribution.
19fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
2032acf9a1SJohn Dyson  *    may be used to endorse or promote products derived from this software
2132acf9a1SJohn Dyson  *    without specific prior written permission.
2232acf9a1SJohn Dyson  *
2332acf9a1SJohn Dyson  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2432acf9a1SJohn Dyson  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2532acf9a1SJohn Dyson  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2632acf9a1SJohn Dyson  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2732acf9a1SJohn Dyson  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2832acf9a1SJohn Dyson  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2932acf9a1SJohn Dyson  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3032acf9a1SJohn Dyson  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3132acf9a1SJohn Dyson  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3232acf9a1SJohn Dyson  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3332acf9a1SJohn Dyson  * SUCH DAMAGE.
3432acf9a1SJohn Dyson  */
3532acf9a1SJohn Dyson 
3632acf9a1SJohn Dyson #include <sys/param.h>
3732acf9a1SJohn Dyson #include <sys/systm.h>
3832acf9a1SJohn Dyson #include <sys/proc.h>
393a669c52SDag-Erling Smørgrav #include <sys/sbuf.h>
4032acf9a1SJohn Dyson #include <sys/sysent.h>
413a669c52SDag-Erling Smørgrav 
423a669c52SDag-Erling Smørgrav #include <fs/pseudofs/pseudofs.h>
4399d300a1SRuslan Ermilov #include <fs/procfs/procfs.h>
4432acf9a1SJohn Dyson 
4532acf9a1SJohn Dyson int
procfs_doproctype(PFS_FILL_ARGS)463a669c52SDag-Erling Smørgrav procfs_doproctype(PFS_FILL_ARGS)
4732acf9a1SJohn Dyson {
483a669c52SDag-Erling Smørgrav 	static const char *none = "Not Available";
4932acf9a1SJohn Dyson 
507caaf6c9SDag-Erling Smørgrav 	if (p != NULL && p->p_sysent && p->p_sysent->sv_name)
511bdfff22SAndriy Gapon 		sbuf_printf(sb, "%s", p->p_sysent->sv_name);
527caaf6c9SDag-Erling Smørgrav 	else
531bdfff22SAndriy Gapon 		sbuf_printf(sb, "%s", none);
543a669c52SDag-Erling Smørgrav 	sbuf_putc(sb, '\n');
553a669c52SDag-Erling Smørgrav 	return (0);
5632acf9a1SJohn Dyson }
57