From 41bd4766f68d67a5f8eba60bae8597d1ef7f76eb Mon Sep 17 00:00:00 2001 From: perry Date: Mon, 2 Feb 1998 03:44:25 +0000 Subject: [PATCH] import lite-2 --- lib/libc/sys/getdirentries.3 | 36 ++++++------ lib/libc/sys/swapon.3 | 28 +++------- lib/libc/sys/undelete.2 | 105 +++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 40 deletions(-) create mode 100644 lib/libc/sys/undelete.2 diff --git a/lib/libc/sys/getdirentries.3 b/lib/libc/sys/getdirentries.3 index 75291c1664da..532bec151b7f 100644 --- a/lib/libc/sys/getdirentries.3 +++ b/lib/libc/sys/getdirentries.3 @@ -1,5 +1,3 @@ -.\" $NetBSD: getdirentries.3,v 1.1 1997/10/20 16:04:30 christos Exp $ -.\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,27 +29,19 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)getdirentries.2 8.1 (Berkeley) 6/9/93 +.\" @(#)getdirentries.2 8.2 (Berkeley) 5/3/95 .\" -.Dd June 9, 1993 -.Dt GETDIRENTRIES 3 +.Dd May 3, 1995 +.Dt GETDIRENTRIES 2 .Os .Sh NAME .Nm getdirentries .Nd "get directory entries in a filesystem independent format" .Sh SYNOPSIS -.Fd #include +.Fd #include .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 -This interface is provided for compatibility only and -has been obsoleted by -.Xr getdents 2 . -.Ef -.Pp .Fn Getdirentries reads directory entries from the directory referenced by the file descriptor @@ -77,7 +67,8 @@ structures each containing the following entries: .Bd -literal -offset indent unsigned long d_fileno; unsigned short d_reclen; -unsigned short d_namlen; +unsigned char d_type; +unsigned char d_namlen; char d_name[MAXNAMELEN + 1]; /* see below */ .Ed .Pp @@ -93,6 +84,11 @@ The .Fa d_reclen entry is the length, in bytes, of the directory record. The +.Fa d_type +entry is the type of the file pointed to by the directory record. +The file type values are defined in +.Fa . +The .Fa d_name entry contains a null terminated file name. The @@ -138,17 +134,17 @@ is set to indicate the error. .Sh ERRORS .Fn Getdirentries will fail if: -.Bl -tag -width Er -.It Bq Er EBADF +.Bl -tag -width [EFAULT] +.It EBADF .Fa fd is not a valid file descriptor open for reading. -.It Bq Er EFAULT +.It EFAULT Either .Fa buf or .Fa basep point outside the allocated address space. -.It Bq Er EIO +.It EIO An .Tn I/O error occurred while reading from or writing to the file system. @@ -158,5 +154,5 @@ error occurred while reading from or writing to the file system. .Xr lseek 2 .Sh HISTORY The -.Fn getdirentries +.Nm getdirentries function first appeared in 4.4BSD. diff --git a/lib/libc/sys/swapon.3 b/lib/libc/sys/swapon.3 index a9c5dd5637b7..5f152ccb9449 100644 --- a/lib/libc/sys/swapon.3 +++ b/lib/libc/sys/swapon.3 @@ -1,5 +1,3 @@ -.\" $NetBSD: swapon.3,v 1.1 1997/10/20 16:04:31 christos Exp $ -.\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -34,7 +32,7 @@ .\" @(#)swapon.2 8.1 (Berkeley) 6/4/93 .\" .Dd June 4, 1993 -.Dt SWAPON 3 +.Dt SWAPON 2 .Os BSD 4 .Sh NAME .Nm swapon @@ -44,13 +42,6 @@ .Ft int .Fn swapon "const char *special" .Sh DESCRIPTION -.Bf -symbolic -.\" This interface is available from the compatibility library, libcompat and -This interface is provided for compatibility only and -has been obsoleted by -.Xr swapctl 2 . -.Ef -.Pp .Fn Swapon makes the block device .Fa special @@ -68,15 +59,14 @@ is set to indicate the error. .Sh ERRORS .Fn Swapon succeeds unless: -.Bl -tag -width Er +.Bl -tag -width ENAMETOOLONG .It Bq Er ENOTDIR A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. .It Bq Er ENAMETOOLONG -A component of a pathname exceeded -.Dv {NAME_MAX} -characters, or an entire path name exceeded -.Dv {PATH_MAX} -characters. +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. .It Bq Er ENOENT The named device does not exist. .It Bq Er EACCES @@ -118,8 +108,6 @@ dismounted. This call will be upgraded in future versions of the system. .Sh HISTORY The -.Fn swapon +.Nm function call appeared in -.Bx 4.0 -and was removed -.Nx 1.3 +.Bx 4.0 . diff --git a/lib/libc/sys/undelete.2 b/lib/libc/sys/undelete.2 new file mode 100644 index 000000000000..317397c8d0d8 --- /dev/null +++ b/lib/libc/sys/undelete.2 @@ -0,0 +1,105 @@ +.\" Copyright (c) 1994 +.\" Jan-Simon Pendry +.\" 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. +.\" +.\" @(#)undelete.2 8.4 (Berkeley) 10/18/94 +.\" +.Dd October 18, 1994 +.Dt UNDELETE 2 +.Os BSD 4 +.Sh NAME +.Nm undelete +.Nd attempt to recover a deleted file +.Sh SYNOPSIS +.Fd #include +.Ft int +.Fn undelete "const char *path" +.Sh DESCRIPTION +The +.Fn undelete +function attempts to recover the deleted file named by +.Fa path . +Currently, this works only when the named object +is a whiteout in a union filesystem. +The system call removes the whiteout causing +any objects in a lower layer of the +union stack to become visible once more. +.Pp +Eventually, the +.Nm undelete +functionality may be expanded to other filesystems able to recover +deleted files such as the log-structured filesystem. +.Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +Otherwise, a value of -1 is returned and +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn undelete +succeeds unless: +.Bl -tag -width ENAMETOOLONGAA +.It Bq Er ENOTDIR +A component of the path prefix is not a directory. +.It Bq Er EINVAL +The pathname contains a character with the high-order bit set. +.It Bq Er ENAMETOOLONG +A component of a pathname exceeded 255 characters, +or an entire path name exceeded 1023 characters. +.It Bq Er EEXIST +The path does not reference a whiteout. +.It Bq Er ENOENT +The named whiteout does not exist. +.It Bq Er EACCES +Search permission is denied for a component of the path prefix. +.It Bq Er EACCES +Write permission is denied on the directory containing the name +to be undeleted. +.It Bq Er ELOOP +Too many symbolic links were encountered in translating the pathname. +.It Bq Er EPERM +The directory containing the name is marked sticky, +and the containing directory is not owned by the effective user ID. +.It Bq Er EIO +An I/O error occurred while updating the directory entry. +.It Bq Er EROFS +The name resides on a read-only file system. +.It Bq Er EFAULT +.Fa Path +points outside the process's allocated address space. +.El +.Sh SEE ALSO +.Xr unlink 2 , +.Xr mount_union 8 +.Sh HISTORY +An +.Nm undelete +function call first appeared in 4.4BSD-Lite.