Moved timezone, swapon and getdirentries back to libc.

This commit is contained in:
christos 1997-10-20 15:49:39 +00:00
parent 9d0579d2fb
commit 3ecdd3624c
7 changed files with 3 additions and 590 deletions

View File

@ -1,161 +0,0 @@
.\" $NetBSD: getdirentries.3,v 1.9 1997/10/16 23:00:30 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" 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.
.\"
.\" @(#)getdirentries.2 8.1 (Berkeley) 6/9/93
.\"
.Dd June 9, 1993
.Dt GETDIRENTRIES 2
.Os
.Sh NAME
.Nm getdirentries
.Nd "get directory entries in a filesystem independent format"
.Sh SYNOPSIS
.Fd #include <dirent.h>
.Ft int
.Fn getdirentries "int fd" "char *buf" "int nbytes" "long *basep"
.Sh DESCRIPTION
.Sh DESCRIPTION
.Bf -symbolic
This interface is available from the compatibility library, libcompat and
has been obsoleted by
.Xr getdents 2 .
.Ef
.Pp
.Fn Getdirentries
reads directory entries from the directory
referenced by the file descriptor
.Fa fd
into the buffer pointed to by
.Fa buf ,
in a filesystem independent format.
Up to
.Fa nbytes
of data will be transferred.
.Fa Nbytes
must be greater than or equal to the
block size associated with the file,
see
.Xr stat 2 .
Some filesystems may not support
.Fn getdirentries
with buffers smaller than this size.
.Pp
The data in the buffer is a series of
.Em dirent
structures each containing the following entries:
.Bd -literal -offset indent
unsigned long d_fileno;
unsigned short d_reclen;
unsigned short d_namlen;
char d_name[MAXNAMELEN + 1]; /* see below */
.Ed
.Pp
The
.Fa d_fileno
entry is a number which is unique for each
distinct file in the filesystem.
Files that are linked by hard links (see
.Xr link 2 )
have the same
.Fa d_fileno .
The
.Fa d_reclen
entry is the length, in bytes, of the directory record.
The
.Fa d_name
entry contains a null terminated file name.
The
.Fa d_namlen
entry specifies the length of the file name excluding the null byte.
Thus the actual size of
.Fa d_name
may vary from 1 to
.Dv MAXNAMELEN
\&+ 1.
.Pp
Entries may be separated by extra space.
The
.Fa d_reclen
entry may be used as an offset from the start of a
.Fa dirent
structure to the next structure, if any.
.Pp
The actual number of bytes transferred is returned.
The current position pointer associated with
.Fa fd
is set to point to the next block of entries.
The pointer may not advance by the number of bytes returned by
.Fn getdirentries .
A value of zero is returned when
the end of the directory has been reached.
.Pp
.Fn Getdirentries
writes the position of the block read into the location pointed to by
.Fa basep .
Alternatively, the current position pointer may be set and retrieved by
.Xr lseek 2 .
The current position pointer should only be set to a value returned by
.Xr lseek 2 ,
a value returned in the location pointed to by
.Fa basep ,
or zero.
.Sh RETURN VALUES
If successful, the number of bytes actually transferred is returned.
Otherwise, -1 is returned and the global variable
.Va errno
is set to indicate the error.
.Sh ERRORS
.Fn Getdirentries
will fail if:
.Bl -tag -width Er
.It Bq Er EBADF
.Fa fd
is not a valid file descriptor open for reading.
.It Bq Er EFAULT
Either
.Fa buf
or
.Fa basep
point outside the allocated address space.
.It Bq Er EIO
An
.Tn I/O
error occurred while reading from or writing to the file system.
.El
.Sh SEE ALSO
.Xr open 2 ,
.Xr lseek 2
.Sh HISTORY
The
.Fn getdirentries
function first appeared in 4.4BSD.

View File

@ -1,47 +0,0 @@
/* $NetBSD: getdirentries.c,v 1.1 1997/10/10 02:15:56 fvdl Exp $ */
/*
* Copyright (c) 1997 Frank van der Linden
* 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 Frank van der Linden for
* the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
int
getdirentries(fd, buf, nbytes, basep)
int fd, nbytes;
char *buf;
long *basep;
{
*basep = lseek(fd, 0, SEEK_CUR);
return getdents(fd, buf, nbytes);
}

View File

@ -1,124 +0,0 @@
.\" $NetBSD: swapon.3,v 1.9 1997/10/16 23:00:32 christos Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" 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.
.\"
.\" @(#)swapon.2 8.1 (Berkeley) 6/4/93
.\"
.Dd June 4, 1993
.Dt SWAPON 2
.Os BSD 4
.Sh NAME
.Nm swapon
.Nd add a swap device for interleaved paging/swapping
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn swapon "const char *special"
.Sh DESCRIPTION
.Bf -symbolic
This interface is available from the compatibility library, libcompat and
has been obsoleted by
.Xr swapctl 2 .
.Ef
.Pp
.Fn Swapon
makes the block device
.Fa special
available to the system for
allocation for paging and swapping. The names of potentially
available devices are known to the system and defined at system
configuration time. The size of the swap area on
.Fa special
is calculated at the time the device is first made available
for swapping.
.Sh RETURN VALUES
If an error has occurred, a value of -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Fn Swapon
succeeds unless:
.Bl -tag -width Er
.It Bq Er ENOTDIR
A component of the path prefix is not a directory.
.It Bq Er ENAMETOOLONG
A component of a pathname exceeded
.Dv {NAME_MAX}
characters, or an entire path name exceeded
.Dv {PATH_MAX}
characters.
.It Bq Er ENOENT
The named device does not exist.
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
.It Bq Er ELOOP
Too many symbolic links were encountered in translating the pathname.
.It Bq Er EPERM
The caller is not the super-user.
.It Bq Er ENOTBLK
.Fa Special
is not a block device.
.It Bq Er EBUSY
The device specified by
.Fa special
has already
been made available for swapping
.It Bq Er EINVAL
The device configured by
.Fa special
was not
configured into the system as a swap device.
.It Bq Er ENXIO
The major device number of
.Fa special
is out of range (this indicates no device driver exists
for the associated hardware).
.It Bq Er EIO
An I/O error occurred while opening the swap device.
.It Bq Er EFAULT
.Fa Special
points outside the process's allocated address space.
.Sh SEE ALSO
.Xr swapon 8 ,
.Xr config 8
.Sh BUGS
There is no way to stop swapping on a disk so that the pack may be
dismounted.
.Pp
This call will be upgraded in future versions of the system.
.Sh HISTORY
The
.Fn swapon
function call appeared in
.Bx 4.0
and was removed
.Nx 1.3

View File

@ -1,42 +0,0 @@
/* $NetBSD: swapon.c,v 1.3 1997/10/10 05:39:51 mrg Exp $ */
/*
* Copyright (c) 1997 Matthew R. Green
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <vm/vm_swap.h>
#include <unistd.h>
int
swapon(name)
const char *name;
{
return (swapctl(SWAP_ON, name, 0));
}

View File

@ -1,71 +0,0 @@
.\" $NetBSD: timezone.3,v 1.6 1997/10/16 23:00:35 christos Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" 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.
.\"
.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94
.\"
.Dd April 19, 1994
.Dt TIMEZONE 3
.Os
.Sh NAME
.Nm timezone
.Nd return the timezone abbreviation
.Sh SYNOPSIS
.Ft char *
.Fn timezone "int zone" "int dst"
.Sh DESCRIPTION
.Sh DESCRIPTION
.Bf -symbolic
This interface is available from the compatibility library, libcompat;
it is impossible to reliably map timezone's arguments to a time zone
abbreviation.
See ctime(3).
.Ef
.Pp
The
.Fn timezone
function returns a pointer to a time zone abbreviation for the specified
.Ar zone
and
.Ar dst
values.
.Ar Zone
is the number of minutes west of GMT and
.Ar dst
is non-zero if daylight savings time is in effect.
.Sh SEE ALSO
.Xr ctime 3
.Sh HISTORY
A
.Fn timezone
function appeared in
.At v7 .

View File

@ -1,142 +0,0 @@
/* $NetBSD: timezone.c,v 1.9 1997/10/16 23:02:16 christos Exp $ */
/*
* Copyright (c) 1987, 1993
* 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.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: timezone.c,v 1.9 1997/10/16 23:02:16 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tzfile.h>
/*
* timezone --
* The arguments are the number of minutes of time you are westward
* from Greenwich and whether DST is in effect. It returns a string
* giving the name of the local timezone. Should be replaced, in the
* application code, by a call to localtime.
*/
char *_tztab __P((int, int));
static char czone[TZ_MAX_CHARS]; /* space for zone name */
char *
timezone(zone, dst)
int zone,
dst;
{
register char *beg,
*end;
if ((beg = getenv("TZNAME")) != NULL) { /* set in environment */
if ((end = strchr(beg, ',')) != NULL) { /* "PST,PDT" */
if (dst)
return(++end);
*end = '\0';
(void)strncpy(czone,beg,sizeof(czone) - 1);
czone[sizeof(czone) - 1] = '\0';
*end = ',';
return(czone);
}
return(beg);
}
return(_tztab(zone,dst)); /* default: table or created zone */
}
static struct zone {
int offset;
char *stdzone;
char *dlzone;
} zonetab[] = {
{ -1*60, "MET", "MET DST" }, /* Middle European */
{ -2*60, "EET", "EET DST" }, /* Eastern European */
{ 4*60, "AST", "ADT" }, /* Atlantic */
{ 5*60, "EST", "EDT" }, /* Eastern */
{ 6*60, "CST", "CDT" }, /* Central */
{ 7*60, "MST", "MDT" }, /* Mountain */
{ 8*60, "PST", "PDT" }, /* Pacific */
#ifdef notdef
/* there's no way to distinguish this from WET */
{ 0, "GMT", 0 }, /* Greenwich */
#endif
{ 0*60, "WET", "WET DST" }, /* Western European */
{ -10*60, "EST", "EST" }, /* Aust: Eastern */
{ -10*60+30, "CST", "CST" }, /* Aust: Central */
{ -8*60, "WST", 0 }, /* Aust: Western */
{ -1, NULL, NULL }
};
/*
* _tztab --
* check static tables or create a new zone name; broken out so that
* we can make a guess as to what the zone is if the standard tables
* aren't in place in /etc. DO NOT USE THIS ROUTINE OUTSIDE OF THE
* STANDARD LIBRARY.
*/
char *
_tztab(zone,dst)
register int zone;
int dst;
{
register struct zone *zp;
register char sign;
for (zp = zonetab; zp->offset != -1;++zp) /* static tables */
if (zp->offset == zone) {
if (dst && zp->dlzone)
return(zp->dlzone);
if (!dst && zp->stdzone)
return(zp->stdzone);
}
if (zone < 0) { /* create one */
zone = -zone;
sign = '+';
}
else
sign = '-';
(void)snprintf(czone, TZ_MAX_CHARS, "GMT%c%d:%02d", sign, zone / 60,
zone % 60);
return(czone);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.16 1997/10/16 23:02:45 christos Exp $
# $NetBSD: Makefile,v 1.17 1997/10/20 15:49:39 christos Exp $
LIB= compat
CFLAGS+=-DLIBC_SCCS -DSYSLIBC_SCCS
@ -40,8 +40,8 @@ MLINKS+=re_comp.3 re_exec.3
# compat 4.4 sources
SRCS+= cuserid.c getdirentries.c swapon.c timezone.c
MAN+= cuserid.3 getdirentries.3 swapon.3 timezone.3
SRCS+= cuserid.c
MAN+= cuserid.3
# regexp sources