From owner-freebsd-hackers@FreeBSD.ORG Sun Jun 4 09:30:01 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 343DE16A492 for ; Sun, 4 Jun 2006 09:30:01 +0000 (UTC) (envelope-from unledev@gmail.com) Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.200]) by mx1.FreeBSD.org (Postfix) with ESMTP id 467F943D49 for ; Sun, 4 Jun 2006 09:30:00 +0000 (GMT) (envelope-from unledev@gmail.com) Received: by nz-out-0102.google.com with SMTP id 13so796733nzn for ; Sun, 04 Jun 2006 02:29:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=CA8taQFkW1r+AkapP/YMerivMMl1Oe2dkbgC1QLKNNZ2BqucWGguxqTz+eTrN6r/wuaHm0kqyiyeH5S9hjL+x8699Ru8GshVoAVQtIxX4NJ+g9tFLH+eP43x0tRHhVPMANReX3kvE6XYE0wpLsJqaUmY2m35IH0uMwzxkPjWef0= Received: by 10.64.83.17 with SMTP id g17mr2836287qbb; Sun, 04 Jun 2006 02:29:59 -0700 (PDT) Received: by 10.65.181.5 with HTTP; Sun, 4 Jun 2006 02:29:59 -0700 (PDT) Message-ID: <5e4707340606040229s1689fa5cl758d8d7df1ce2b60@mail.gmail.com> Date: Sun, 4 Jun 2006 11:29:59 +0200 From: "=?ISO-8859-1?Q?Alex_Mart=EDnez?=" To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: __getcwd() question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jun 2006 09:30:01 -0000 Hi guys, I've come across some problems while porting to FreeBSD a wrapper library which protects the filesystem from unauthorized accesses by overriding potentially dangerous functions and making some checks before calling the real thing. Turns out that overriding getcwd() resulted in segfaults because the library wrapped both getcwd() and __getcwd(), so that libc's getcwd() would call my wrapped __getcwd() instead of its own version, and my version would call libc's getcwd() again (which is wrong anyways), effectively building an infinite recursion loop. This stems from the fact that __getcwd() is exported by FreeBSD's libc (as a weak alias to __sys___getcwd(), along with ___getcwd()), while the libc this library ran originally on (GNU) does not export it. So here come my questions: is there any legal use of __getcwd() (and the other two functions for that matter) outside the libc? Any reason explaining why it should be exported? I guess backwards compatibility can be one such reason, but I'd like to know what you people think about it, specially if they were initially exported on purpose. TIA, Alex