diff options
author | peter <peter@FreeBSD.org> | 1997-03-11 11:29:42 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-03-11 11:29:42 +0000 |
commit | e8e23405def4966834a6703435257f5f00ed1ac1 (patch) | |
tree | dbcfbcbf175d67996919b391d49ba44933521f9e /lib/libc | |
parent | f635e3d3fe547173e7c723038996fbe151718b1d (diff) | |
parent | e0e06d68d52707cbac25844a417ab6919613e9eb (diff) | |
download | FreeBSD-src-e8e23405def4966834a6703435257f5f00ed1ac1.zip FreeBSD-src-e8e23405def4966834a6703435257f5f00ed1ac1.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r23658,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/devname.c | 6 | ||||
-rw-r--r-- | lib/libc/gen/getvfsbyname.3 | 98 | ||||
-rw-r--r-- | lib/libc/gen/readdir.c | 21 | ||||
-rw-r--r-- | lib/libc/gen/realpath.3 | 125 | ||||
-rw-r--r-- | lib/libc/stdio/local.h | 34 | ||||
-rw-r--r-- | lib/libc/stdlib/atexit.h | 4 | ||||
-rw-r--r-- | lib/libc/stdlib/getopt.c | 10 | ||||
-rw-r--r-- | lib/libc/string/strmode.c | 7 | ||||
-rw-r--r-- | lib/libc/sys/undelete.2 | 105 |
9 files changed, 373 insertions, 37 deletions
diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c index 3929f92..39178fe 100644 --- a/lib/libc/gen/devname.c +++ b/lib/libc/gen/devname.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)devname.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -64,7 +64,7 @@ devname(dev, type) failure = 1; } if (failure) - return ("??"); + return (NULL); /* * Keys are a mode_t followed by a dev_t. The former is the type of @@ -76,5 +76,5 @@ devname(dev, type) bkey.type = type; key.data = &bkey; key.size = sizeof(bkey); - return ((db->get)(db, &key, &data, 0) ? "??" : (char *)data.data); + return ((db->get)(db, &key, &data, 0) ? NULL : (char *)data.data); } diff --git a/lib/libc/gen/getvfsbyname.3 b/lib/libc/gen/getvfsbyname.3 new file mode 100644 index 0000000..746d4df --- /dev/null +++ b/lib/libc/gen/getvfsbyname.3 @@ -0,0 +1,98 @@ +.\" Copyright (c) 1995 +.\" 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. +.\" +.\" @(#)kvm_getvfsbyname.3 8.3 (Berkeley) 5/4/95 +.\" +.Dd May 4, 1995 +.Dt GETVFSBYNAME 3 +.Os +.Sh NAME +.Nm getvfsbyname +.Nd get information about a filesystem +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/mount.h> +.Fd #include <kvm.h> +.br +.Ft int +.Fn getvfsbyname "const char *name" "struct vfsconf *vfc" +.Sh DESCRIPTION +The +.Fn getvfsbyname +function provides access to information about a +filesystem module that is configured in the kernel. +If successful, +the requested filesystem +.Fa vfsconf +is returned in the location pointed to by +.Nm vfc . +The fields in a +.Dq Li struct vfsconf +are defined as follows: +.Pp +.Bl -tag -compact -width vfc_refcount +.It vfc_name +the name of the filesystem +.It vfc_typenum +the filesystem type number assigned by the kernel +.It vfc_refcount +the number of active mount points using the filesystem +.It vfc_flags +flag bits that are used to initialize a new mount point +using the filesystem +.El +.Sh RETURN VALUES +If the call to +.Nm getvfsbyname +is successful, 0 is returned. +Otherwise \-1 is returned and +.Va errno +is set appropriately. +.Sh ERRORS +The following errors may be reported: +.Bl -tag -width Er +.It Bq Er EFAULT +The +.Fa vfc +pointer contains an invalid address. +.It Bq Er ENOENT +The +.Fa name +specifies a filesystem that is unknown or not configured in the kernel. +.Sh SEE ALSO +.Xr sysctl 1 , +.Xr mount 2 , +.Xr sysctl 3 , +.Xr mount 8 +.Sh HISTORY +A variant of the +.Fn getvfsbyname +function first appeared in FreeBSD 2.0. diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c index d0651da..2e97661 100644 --- a/lib/libc/gen/readdir.c +++ b/lib/libc/gen/readdir.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)readdir.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -48,25 +48,28 @@ readdir(dirp) register struct dirent *dp; for (;;) { - if (dirp->dd_loc == 0) { + if (dirp->dd_loc >= dirp->dd_size) { + if (dirp->dd_flags & __DTF_READALL) + return (NULL); + dirp->dd_loc = 0; + } + if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) { dirp->dd_size = getdirentries(dirp->dd_fd, dirp->dd_buf, dirp->dd_len, &dirp->dd_seek); if (dirp->dd_size <= 0) - return NULL; - } - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - continue; + return (NULL); } dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); if ((int)dp & 03) /* bogus pointer check */ - return NULL; + return (NULL); if (dp->d_reclen <= 0 || dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) - return NULL; + return (NULL); dirp->dd_loc += dp->d_reclen; if (dp->d_ino == 0) continue; + if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW)) + continue; return (dp); } } diff --git a/lib/libc/gen/realpath.3 b/lib/libc/gen/realpath.3 new file mode 100644 index 0000000..83f4a43 --- /dev/null +++ b/lib/libc/gen/realpath.3 @@ -0,0 +1,125 @@ +.\" Copyright (c) 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Jan-Simon Pendry. +.\" +.\" 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. +.\" +.\" @(#)realpath.3 8.2 (Berkeley) 2/16/94 +.\" +.Dd "February 16, 1994" +.Dt REALPATH 3 +.Os +.Sh NAME +.Nm realpath +.Nd returns the canonicalized absolute pathname +.Sh SYNOPSIS +.Fd #include <sys/param.h> +.Fd #include <stdlib.h> +.Ft "char *" +.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]" +.Sh DESCRIPTION +The +.Fn realpath +function resolves all symbolic links, extra +.Dq / +characters and references to +.Pa /./ +and +.Pa /../ +in +.Fa pathname , +and copies the resulting absolute pathname into +the memory referenced by +.Fa resolvedname . +The +.Fa resolvedname +argument +.Em must +refer to a buffer capable of storing at least +.Dv MAXPATHLEN +characters. +.Pp +The +.Fn realpath +function will resolve both absolute and relative paths +and return the absolute pathname corresponding to +.Fa pathname . +All but the last component of +.Fa pathname +must exist when +.Fn realpath +is called. +.Sh "RETURN VALUES" +The +.Fn realpath +function returns +.Fa resolved_name +on success. +If an error occurs, +.Fn realpath +returns +.Dv NULL , +and +.Fa resolved_name +contains the pathname which caused the problem. +.Sh ERRORS +The function +.Fn realpath +may fail and set the external variable +.Va errno +for any of the errors specified for the library functions +.Xr chdir 2 , +.Xr close 2 , +.Xr fchdir 2 , +.Xr lstat 2 , +.Xr open 2 , +.Xr readlink 2 +and +.Xr getcwd 3 . +.Sh CAVEATS +This implementation of +.Fn realpath +differs slightly from the Solaris implementation. +The +.Bx 4.4 +version always returns absolute pathnames, +whereas the Solaris implementation will, +under certain circumstances, return a relative +.Fa resolved_path +when given a relative +.Fa pathname . +.Sh "SEE ALSO" +.Xr getcwd 3 +.Sh HISTORY +The +.Fn realpath +function call first appeared in +.Bx 4.4 . diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index 9021d74..cbc07a9 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)local.h 8.2 (Berkeley) 1/2/94 + * @(#)local.h 8.3 (Berkeley) 7/3/94 */ /* @@ -41,23 +41,23 @@ * in particular, macros and private variables. */ -int __sflush __P((FILE *)); -FILE *__sfp __P((void)); -int __srefill __P((FILE *)); -int __sread __P((void *, char *, int)); -int __swrite __P((void *, char const *, int)); -fpos_t __sseek __P((void *, fpos_t, int)); -int __sclose __P((void *)); -void __sinit __P((void)); -void _cleanup __P((void)); -void (*__cleanup) __P((void)); -void __smakebuf __P((FILE *)); -int __swhatbuf __P((FILE *, size_t *, int *)); -int _fwalk __P((int (*)(FILE *))); -int __swsetup __P((FILE *)); -int __sflags __P((const char *, int *)); +extern int __sflush __P((FILE *)); +extern FILE *__sfp __P((void)); +extern int __srefill __P((FILE *)); +extern int __sread __P((void *, char *, int)); +extern int __swrite __P((void *, char const *, int)); +extern fpos_t __sseek __P((void *, fpos_t, int)); +extern int __sclose __P((void *)); +extern void __sinit __P((void)); +extern void _cleanup __P((void)); +extern void (*__cleanup) __P((void)); +extern void __smakebuf __P((FILE *)); +extern int __swhatbuf __P((FILE *, size_t *, int *)); +extern int _fwalk __P((int (*)(FILE *))); +extern int __swsetup __P((FILE *)); +extern int __sflags __P((const char *, int *)); -extern int __sdidinit; +extern int __sdidinit; /* * Return true iff the given FILE cannot be written now. diff --git a/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h index 3067e8d..819151e 100644 --- a/lib/libc/stdlib/atexit.h +++ b/lib/libc/stdlib/atexit.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)atexit.h 8.1 (Berkeley) 6/4/93 + * @(#)atexit.h 8.2 (Berkeley) 7/3/94 */ /* must be at least 32 to guarantee ANSI conformance */ @@ -42,4 +42,4 @@ struct atexit { void (*fns[ATEXIT_SIZE])(); /* the table itself */ }; -struct atexit *__atexit; /* points to head of LIFO stack */ +extern struct atexit *__atexit; /* points to head of LIFO stack */ diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c index 994d757..5dddf86 100644 --- a/lib/libc/stdlib/getopt.c +++ b/lib/libc/stdlib/getopt.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94"; +static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> @@ -67,22 +67,22 @@ getopt(nargc, nargv, ostr) optreset = 0; if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; - return (EOF); + return (-1); } if (place[1] && *++place == '-') { /* found "--" */ ++optind; place = EMSG; - return (EOF); + return (-1); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) { /* * if the user didn't specify '-' as an option, - * assume it means EOF. + * assume it means -1. */ if (optopt == (int)'-') - return (EOF); + return (-1); if (!*place) ++optind; if (opterr && *ostr != ':') diff --git a/lib/libc/string/strmode.c b/lib/libc/string/strmode.c index 651b263..2c3f44a 100644 --- a/lib/libc/string/strmode.c +++ b/lib/libc/string/strmode.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strmode.c 8.1 (Berkeley) 6/4/93"; +static char sccsid[] = "@(#)strmode.c 8.3 (Berkeley) 8/15/94"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -69,6 +69,11 @@ strmode(mode, p) *p++ = 'p'; break; #endif +#ifdef S_IFWHT + case S_IFWHT: /* whiteout */ + *p++ = 'w'; + break; +#endif default: /* unknown */ *p++ = '?'; break; diff --git a/lib/libc/sys/undelete.2 b/lib/libc/sys/undelete.2 new file mode 100644 index 0000000..317397c --- /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 <unistd.h> +.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. |