From owner-freebsd-current Sat Apr 5 12:29:42 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id MAA26072 for current-outgoing; Sat, 5 Apr 1997 12:29:42 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id MAA26067 for ; Sat, 5 Apr 1997 12:29:40 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id NAA23502; Sat, 5 Apr 1997 13:11:41 -0700 From: Terry Lambert Message-Id: <199704052011.NAA23502@phaeton.artisoft.com> Subject: Re: using opendir, but passing a fd instead of path... To: gurney_j@resnet.uoregon.edu Date: Sat, 5 Apr 1997 13:11:41 -0700 (MST) Cc: freebsd-current@freebsd.org In-Reply-To: <19970405042421.06894@hydrogen.nike.efn.org> from "John-Mark Gurney" at Apr 5, 97 04:24:21 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > I was looking at the man page for opendir, and currently there isn't > a way to open a dir from a file descriptor... would this be a useful > addition to the opendir set of routines? or would this be a "wart" on > something that really shouldn't be touched? > > the reason I ask is because of a program that I'm writing, and I don't > feel like having to pass the path to a subfunction, but I am passing > an open fd of the dir... How did you get the open fd of the dir? Probably you should be passing around a DIR *, not an fd. I admit that there is a discrepancy in the interface between the reflexive stdio "fdopen". If you are passing around the fd for fchdir, you should be able to reference the fd out of the dir struct. This would be an interface violation, too, but a minor one: there is a defined macro "dirfd(DIR *)" which returns the fd out of the DIR * in dirent.h, even though it isn't part of the POSIX definition. The reason, if you are interested, is that POSIX does not require a directory to be a normal file accessable through "open". Probably a cleaner overall fix would be to get a "dichdir(DIR *)" defined, but that's not going to happen any time soon, if at all. Regards, Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.