From owner-freebsd-bugs Sun May 17 10:04:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA11239 for freebsd-bugs-outgoing; Sun, 17 May 1998 10:04:11 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA11233 for ; Sun, 17 May 1998 10:04:09 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id KAA16811; Sun, 17 May 1998 10:00:01 -0700 (PDT) Date: Sun, 17 May 1998 10:00:01 -0700 (PDT) Message-Id: <199805171700.KAA16811@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: Ian Dowse Subject: Re: bin/6658: -stable getcwd(3) performs unnecessary lstats Reply-To: Ian Dowse Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/6658; it has been noted by GNATS. From: Ian Dowse To: freebsd-gnats-submit@freebsd.org Cc: Subject: Re: bin/6658: -stable getcwd(3) performs unnecessary lstats Date: Sun, 17 May 1998 18:03:16 +0100 In message <9805170338.aa14317@walton.maths.tcd.ie>, iedowse writes: > >! >! if (!statfs(".", &sfs) && Whoops... That of course will only work for the first mount point. The corrected patch is below. Ian *** /usr/src/lib/libc/gen/getcwd.c Thu Mar 26 09:22:48 1998 --- getcwd.c Sun May 17 17:40:25 1998 *************** *** 36,41 **** --- 36,42 ---- #endif /* LIBC_SCCS and not lint */ #include + #include #include #include *************** *** 169,175 **** if (dp->d_fileno == ino) break; } ! } else for (;;) { if (!(dp = readdir(dir))) goto notfound; --- 170,197 ---- if (dp->d_fileno == ino) break; } ! } else { ! struct statfs sfs; ! char *dirname; ! ! /* ! * Try to get the directory name by using statfs on ! * the mount point. ! */ ! if (!statfs(up[3] ? up + 3 : ".", &sfs) && ! (dirname = rindex(sfs.f_mntonname, '/'))) ! while((dp = readdir(dir))) { ! if (ISDOT(dp)) ! continue; ! bcopy(dp->d_name, bup, dp->d_namlen+1); ! if (!strcmp(dirname + 1, dp->d_name) && ! !lstat(up, &s) && ! s.st_dev == dev && ! s.st_ino == ino) ! goto found; ! } ! rewinddir(dir); ! for (;;) { if (!(dp = readdir(dir))) goto notfound; *************** *** 187,193 **** --- 209,217 ---- if (s.st_dev == dev && s.st_ino == ino) break; } + } + found: /* * Check for length of the current name, preceding slash, * leading slash. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message