From owner-freebsd-questions@FreeBSD.ORG Sat Jan 14 03:23:25 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E331E1065675 for ; Sat, 14 Jan 2012 03:23:25 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id A89B88FC12 for ; Sat, 14 Jan 2012 03:23:25 +0000 (UTC) Received: from r56.edvax.de (port-92-195-26-82.dynamic.qsc.de [92.195.26.82]) by mx02.qsc.de (Postfix) with ESMTP id 188F51E105; Sat, 14 Jan 2012 04:23:24 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id q0E3NMn8002515; Sat, 14 Jan 2012 04:23:23 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Sat, 14 Jan 2012 04:23:22 +0100 From: Polytropon To: Gary Kline Message-Id: <20120114042322.b234d352.freebsd@edvax.de> In-Reply-To: <20120114000513.GA17888@thought.org> References: <20120114000513.GA17888@thought.org> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List Subject: Re: access(FULLPATH, xxx); X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jan 2012 03:23:26 -0000 On Fri, 13 Jan 2012 16:05:18 -0800, Gary Kline wrote: > > excuse this slip of memory, but do you need the full path PLUS the > filename to use access? or just the filename? > > say that i'm i n ~/tmp/foob and want to deetermine wheether i can > access file foob. do i need to use "access("home/kline/tmp/foob", F_OK)" > or will "access("foob", F_OK)" do the trick? i have already rub > "chdir("~/tmp")" in main(). please note. According to what I read from "man 2 access" I would assume it has to be an absolute path. When you read to the faccessat() function, you'll see: The faccessat() system call is equivalent to access() except in the case where path specifies a relative path. In this case the file whose accessibility is to be determined is located relative to the directory associated with the file descriptor fd instead of the current working directory. If faccessat() is passed the special value AT_FDCWD in the fd parameter, the current working directory is used and the behavior is identical to a call to access(). Also see "SECURITY CONSIDERATIONS" later on. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...