[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] chroot()



On Fri, Mar 10, 2000 at 01:00:57PM +0100, Tomas Berndtsson wrote:
> Martin-Éric Racine <q-funk@pp.fishpool.fi> writes:
> 
> > On 2000-3-10, Tomas Berndtsson <tomas@nocrew.org> wrote:
> > 
> > > > Why call it Dchroot when other OSes simply call it chroot?
> > > 
> > > You misunderstand. The GEMDOS trap call is called Dchroot(), but
> > > MiNTLib of course has a wrapper which is called chroot().
> > 
> > I see.  Needlessly confusing, but well... ;-)
> 
> It's not confusing, and necessary, because you don't want chroot() to
> go directly to the trap call, since the trap call is certainly not
> compatible with other OSes. Ok, maybe some of the trap calls are, but
> not all.

The Dchroot call is compatible with other OSes and still there is no
needless confusion.  The library function chroot() returns 0 on success
and -1 for failure and sets errno to the appropriate value in case of
failure. The _preprocessor macro_ Dchroot evaluates to 0 on success and to
a negative error code for failure.  See yourself:

int 
chroot (const char* dir)
{
	long retval = Dchroot (dir);
	if (retval != 0) {
		errno = -retval;
		return -1;
	}
	return 0;
}

int
naive_chroot (const char* dir)
{
	return Dchroot (dir);
}

That makes a big difference.

BTW, this is not MiNT-specific.  Other operating systems and system
libraries work exactly the same together.  Only that on other operating
systems system calls always look alike (like our chroot() function)
whereas the MiNTLib often does a lot of hubba-bubba in the libc wrappers
to emulate/fix missing (or incompatible) Unix calls.  See open.c or
do_stat.c for typical examples in the MiNTLib.

Ciao

Guido
-- 
http://stud.uni-sb.de/~gufl0000/
mailto:guido@freemint.de