/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 2009 Konstantin Belousov4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#include <sys/param.h>32#include <sys/proc.h>33#include <sys/sbuf.h>34#include <sys/uio.h>3536#include <fs/pseudofs/pseudofs.h>37#include <fs/procfs/procfs.h>3839int40procfs_doosrel(PFS_FILL_ARGS)41{42const char *pp;43int ov, osrel, i;4445if (uio == NULL)46return (EOPNOTSUPP);47switch (uio->uio_rw) {48case UIO_READ:49sbuf_printf(sb, "%d\n", p->p_osrel);50break;51case UIO_WRITE:52sbuf_trim(sb);53sbuf_finish(sb);54pp = sbuf_data(sb);55osrel = 0;56i = sbuf_len(sb);57while (i--) {58if (*pp < '0' || *pp > '9')59return (EINVAL);60ov = osrel * 10 + *pp++ - '0';61if (ov < osrel)62return (EINVAL);63osrel = ov;64}65p->p_osrel = osrel;66break;67}68return (0);69}707172