Clean up deleted files.
This commit is contained in:
parent
7999e08c50
commit
025a03852f
@ -1,67 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
/*static char sccsid[] = "from: @(#)daemon.c 5.3 (Berkeley) 12/28/90";*/
|
||||
static char rcsid[] = "$Id: daemon.c,v 1.3 1993/12/19 08:44:42 pk Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <paths.h>
|
||||
|
||||
daemon(nochdir, noclose)
|
||||
int nochdir, noclose;
|
||||
{
|
||||
int cpid;
|
||||
|
||||
if ((cpid = fork()) == -1)
|
||||
return (-1);
|
||||
if (cpid)
|
||||
exit(0);
|
||||
(void) setsid();
|
||||
if (!nochdir)
|
||||
(void) chdir("/");
|
||||
if (!noclose) {
|
||||
int devnull = open(_PATH_DEVNULL, O_RDWR, 0);
|
||||
|
||||
if (devnull != -1) {
|
||||
(void) dup2(devnull, STDIN_FILENO);
|
||||
(void) dup2(devnull, STDOUT_FILENO);
|
||||
(void) dup2(devnull, STDERR_FILENO);
|
||||
if (devnull > 2)
|
||||
(void) close(devnull);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)getbsize.c 5.3 (Berkeley) 3/9/92";*/
|
||||
static char rcsid[] = "$Id: getbsize.c,v 1.3 1994/01/25 21:03:26 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
getbsize(headerlenp, blocksizep)
|
||||
int *headerlenp;
|
||||
long *blocksizep;
|
||||
{
|
||||
static char header[20];
|
||||
long n, max, mul, blocksize;
|
||||
char *ep, *p, *form;
|
||||
|
||||
#define KB (1024L)
|
||||
#define MB (1024L * 1024L)
|
||||
#define GB (1024L * 1024L * 1024L)
|
||||
#define MAXB GB /* No tera, peta, nor exa. */
|
||||
form = "";
|
||||
if ((p = getenv("BLOCKSIZE")) != NULL && *p != '\0') {
|
||||
if ((n = strtol(p, &ep, 10)) < 0)
|
||||
goto underflow;
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
if (*ep && ep[1])
|
||||
goto fmterr;
|
||||
switch (*ep) {
|
||||
case 'G': case 'g':
|
||||
form = "G";
|
||||
max = MAXB / GB;
|
||||
mul = GB;
|
||||
break;
|
||||
case 'K': case 'k':
|
||||
form = "K";
|
||||
max = MAXB / KB;
|
||||
mul = KB;
|
||||
break;
|
||||
case 'M': case 'm':
|
||||
form = "M";
|
||||
max = MAXB / MB;
|
||||
mul = MB;
|
||||
break;
|
||||
case '\0':
|
||||
max = MAXB;
|
||||
mul = 1;
|
||||
break;
|
||||
default:
|
||||
fmterr: warnx("%s: unknown blocksize", p);
|
||||
n = 512;
|
||||
mul = 1;
|
||||
break;
|
||||
}
|
||||
if (n > max) {
|
||||
warnx("maximum blocksize is %dG", MAXB / GB);
|
||||
n = max;
|
||||
}
|
||||
if ((blocksize = n * mul) < 512) {
|
||||
underflow: warnx("%s: minimum blocksize is 512");
|
||||
form = "";
|
||||
blocksize = n = 512;
|
||||
}
|
||||
} else
|
||||
blocksize = n = 512;
|
||||
|
||||
*headerlenp = snprintf(header, sizeof(header), "%d%s-blocks", n, form);
|
||||
*blocksizep = blocksize;
|
||||
return (header);
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
.\" Copyright (c) 1989, 1991 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.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" from: @(#)getloadavg.3 6.3 (Berkeley) 4/19/91
|
||||
.\" $Id: getloadavg.3,v 1.2 1993/08/01 07:40:37 mycroft Exp $
|
||||
.\"
|
||||
.Dd April 19, 1991
|
||||
.Dt GETLOADAVG 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm getloadavg
|
||||
.Nd get system load averages
|
||||
.Sh SYNOPSIS
|
||||
.Fn getloadavg "double loadavg[]" "int nelem"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn getloadavg
|
||||
function
|
||||
returns the number of processes in the system run queue
|
||||
averaged over various periods of time. Up to
|
||||
.Fa nelem
|
||||
samples are retrieved and assigned to successive elements of
|
||||
.Fa loadavg Ns Bq .
|
||||
The system imposes a maximum of 3 samples, representing averages
|
||||
over the last 1, 5, and 15 minutes, respectively.
|
||||
.Sh DIAGNOSTICS
|
||||
If the load average was unobtainable, \-1 is returned; otherwise,
|
||||
the number of samples actually retrieved is returned.
|
||||
.Sh SEE ALSO
|
||||
.Xr uptime 1 ,
|
||||
.Xr nlist 3 ,
|
||||
.Xr kmem 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn getloadavg
|
||||
function is
|
||||
.Ud .
|
||||
.Sh BUGS
|
||||
Programs using this utility must have read permission on
|
||||
.Pa /dev/kmem .
|
||||
This restriction will eventually be lifted.
|
@ -1,94 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1989 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
/*static char sccsid[] = "from: @(#)getloadavg.c 6.2 (Berkeley) 6/29/90";*/
|
||||
static char rcsid[] = "$Id: getloadavg.c,v 1.2 1993/08/01 18:31:55 mycroft Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/file.h>
|
||||
#include <nlist.h>
|
||||
|
||||
static struct nlist nl[] = {
|
||||
{ "_averunnable" },
|
||||
#define X_AVERUNNABLE 0
|
||||
{ "_fscale" },
|
||||
#define X_FSCALE 1
|
||||
{ "" },
|
||||
};
|
||||
|
||||
/*
|
||||
* getloadavg() -- Get system load averages.
|
||||
*
|
||||
* Put `nelem' samples into `loadavg' array.
|
||||
* Return number of samples retrieved, or -1 on error.
|
||||
*/
|
||||
getloadavg(loadavg, nelem)
|
||||
double loadavg[];
|
||||
int nelem;
|
||||
{
|
||||
static int need_nlist = 1;
|
||||
fixpt_t averunnable[3];
|
||||
int fscale, kmemfd, i;
|
||||
int alreadyopen;
|
||||
|
||||
if ((alreadyopen = kvm_openfiles(NULL, NULL, NULL)) == -1)
|
||||
return (-1);
|
||||
/*
|
||||
* cache nlist
|
||||
*/
|
||||
if (need_nlist) {
|
||||
if (kvm_nlist(nl) != 0)
|
||||
goto bad;
|
||||
need_nlist = 0;
|
||||
}
|
||||
if (kvm_read((off_t)nl[X_AVERUNNABLE].n_value, (char *)averunnable,
|
||||
sizeof(averunnable)) != sizeof(averunnable))
|
||||
goto bad;
|
||||
if (kvm_read( (off_t)nl[X_FSCALE].n_value, (char *)&fscale,
|
||||
sizeof(fscale)) != sizeof(fscale))
|
||||
goto bad;
|
||||
nelem = MIN(nelem, sizeof(averunnable) / sizeof(averunnable[0]));
|
||||
for (i = 0; i < nelem; i++)
|
||||
loadavg[i] = (double) averunnable[i] / fscale;
|
||||
if (!alreadyopen)
|
||||
kvm_close();
|
||||
return (nelem);
|
||||
|
||||
bad:
|
||||
if (!alreadyopen)
|
||||
kvm_close();
|
||||
return (-1);
|
||||
}
|
1231
lib/libutil/kvm.c
1231
lib/libutil/kvm.c
File diff suppressed because it is too large
Load Diff
@ -1,101 +0,0 @@
|
||||
.\" Copyright (c) 1989, 1991 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.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" from: @(#)pwcache.3 5.4 (Berkeley) 4/19/91
|
||||
.\" $Id: pwcache.3,v 1.2 1993/08/01 07:40:35 mycroft Exp $
|
||||
.\"
|
||||
.Dd April 19, 1991
|
||||
.Dt PWCACHE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm pwcache
|
||||
.Nd cache password and group entries
|
||||
.Sh SYNOPSIS
|
||||
.Fn user_from_uid "uid_t uid" "int nouser"
|
||||
.Fn group_from_gid "gid_t gid" "int nogroup"
|
||||
.Sh DESCRIPTION
|
||||
.Bf -symbolic
|
||||
This interface is not part of the C library.
|
||||
It has been placed in the Berkeley utility library, libutil, as it is
|
||||
used by several standard utilities.
|
||||
.Ef
|
||||
.Pp
|
||||
The
|
||||
.Fn user_from_uid
|
||||
function returns the user name associated with the argument
|
||||
.Fa uid .
|
||||
The user name is cached so that multiple calls with the same
|
||||
.Fa uid
|
||||
do not require additional calls to
|
||||
.Xr getpwuid 3 .
|
||||
If there is no user associated with the
|
||||
.Fa uid ,
|
||||
a pointer is returned
|
||||
to an
|
||||
.Tn ASCII
|
||||
representation of the
|
||||
.Fa uid ,
|
||||
unless the argument
|
||||
.Fa nouser
|
||||
is non-zero, in which case a
|
||||
.Dv NULL
|
||||
pointer is returned.
|
||||
.Pp
|
||||
The
|
||||
.Fn group_from_gid
|
||||
function returns the group name associated with the argument
|
||||
.Fa gid .
|
||||
The group name is cached so that multiple calls with the same
|
||||
.Fa gid
|
||||
do not require additional calls to
|
||||
.Xr getgrgid 3 .
|
||||
If there is no group associated with the
|
||||
.Fa gid ,
|
||||
a pointer is returned
|
||||
to an
|
||||
.Tn ASCII
|
||||
representation of the
|
||||
.Fa gid ,
|
||||
unless the argument
|
||||
.Fa nogroup
|
||||
is non-zero, in which case a
|
||||
.Dv NULL
|
||||
pointer is returned.
|
||||
.Sh SEE ALSO
|
||||
.Xr getgrgid 3 ,
|
||||
.Xr getpwuid 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Fn user_from_id
|
||||
and
|
||||
.Fn group_from_id
|
||||
functions are
|
||||
.Ud .
|
Loading…
Reference in New Issue
Block a user