Subject: Re: fchroot(2) emulation ?
To: Todd Vierling <tv@pobox.com>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: port-sparc
Date: 12/13/1997 13:13:02
On Fri, 12 Dec 1997 08:40:37 -0500 (EST) 
 Todd Vierling <tv@pobox.com> wrote:

 > [-current users note:  I've seen fchroot on other OS'es; does the below
 > function look sane enough to go in libcompat?  It certainly doesn't *need*
 > to be a syscall as far as I can tell.]

It needs to be a syscall in order to emulate that syscall on other systems.

 > 
 > =====
 > 
 > int fchroot(int fd) {
 > 	int cfd;
 > 	int rc = -1;
 > 
 > 	if ((cfd = open(".", O_RDONLY)) >= 0) {
 > 		if (fchdir(fd) == 0) {
 > 			if (chroot(".") == 0)
 > 				rc = 0;
 > 			fchdir(cfd);
 > 		}
 > 		close(cfd);
 > 	}
 > 	return rc;
 > }
 > 
 > =====
 > == Todd Vierling (Personal tv@pobox.com; Business tv@lucent.com)
 > == Vierling's Axiom: The revolution won't be televised; it will be posted.
 > 

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                            Home: +1 408 866 1912
NAS: M/S 258-6                                       Work: +1 650 604 0935
Moffett Field, CA 94035                             Pager: +1 415 428 6939