Deleted Added
sdiff udiff text old ( 112342 ) new ( 112430 )
full compact
1/*
2 * Copyright (c) 1989, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Poul-Henning Kamp of the FreeBSD Project.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)vfs_cache.c 8.5 (Berkeley) 3/22/95
37 * $FreeBSD: head/sys/kern/vfs_cache.c 112430 2003-03-20 10:40:45Z phk $
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/kernel.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/sysctl.h>
46#include <sys/mount.h>
47#include <sys/vnode.h>
48#include <sys/namei.h>
49#include <sys/malloc.h>
50#include <sys/syscallsubr.h>
51#include <sys/sysproto.h>
52#include <sys/proc.h>
53#include <sys/filedesc.h>
54#include <sys/fnv_hash.h>
55
56/*
57 * This structure describes the elements in the cache of recent
58 * names looked up by namei.
59 */
60
61struct namecache {
62 LIST_ENTRY(namecache) nc_hash; /* hash chain */

--- 633 unchanged lines hidden (view full) ---

696#endif
697
698/*
699 * XXX All of these sysctls would probably be more productive dead.
700 */
701static int disablecwd;
702SYSCTL_INT(_debug, OID_AUTO, disablecwd, CTLFLAG_RW, &disablecwd, 0,
703 "Disable the getcwd syscall");
704
705/* Various statistics for the getcwd syscall */
706static u_long numcwdcalls; STATNODE(CTLFLAG_RD, numcwdcalls, &numcwdcalls);
707static u_long numcwdfail1; STATNODE(CTLFLAG_RD, numcwdfail1, &numcwdfail1);
708static u_long numcwdfail2; STATNODE(CTLFLAG_RD, numcwdfail2, &numcwdfail2);
709static u_long numcwdfail3; STATNODE(CTLFLAG_RD, numcwdfail3, &numcwdfail3);
710static u_long numcwdfail4; STATNODE(CTLFLAG_RD, numcwdfail4, &numcwdfail4);
711static u_long numcwdfound; STATNODE(CTLFLAG_RD, numcwdfound, &numcwdfound);
712
713/* Implementation of the getcwd syscall */
714int
715__getcwd(td, uap)
716 struct thread *td;
717 struct __getcwd_args *uap;
718{
719
720 return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen));
721}
722
723int
724kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen)
725{
726 char *bp, *tmpbuf;
727 int error, i, slash_prefixed;
728 struct filedesc *fdp;
729 struct namecache *ncp;
730 struct vnode *vp;
731
732 numcwdcalls++;
733 if (disablecwd)
734 return (ENODEV);
735 if (buflen < 2)
736 return (EINVAL);
737 if (buflen > MAXPATHLEN)
738 buflen = MAXPATHLEN;
739 error = 0;
740 tmpbuf = bp = malloc(buflen, M_TEMP, M_WAITOK);
741 bp += buflen - 1;

--- 64 unchanged lines hidden (view full) ---

806 bcopy(bp, buf, strlen(bp) + 1);
807 else
808 error = copyout(bp, buf, strlen(bp) + 1);
809 free(tmpbuf, M_TEMP);
810 return (error);
811}
812
813/*
814 * Thus begins the fullpath magic.
815 */
816
817#undef STATNODE
818#define STATNODE(name) \
819 static u_int name; \
820 SYSCTL_UINT(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, "")
821

--- 99 unchanged lines hidden ---