FreeBSD/sys/compat/linux/linux_getcwd.c
/*
 * Find pathname of process's current directory.
 */
Find pathname of process's current directory.
Find pathname of process ' s current directory .
int
linux_getcwd(struct thread *td, struct linux_getcwd_args *args)
{
	char *path;
	int error, lenused;
#ifdef DEBUG
	if (ldebug(getcwd))
		printf(ARGS(getcwd, "%p, %ld"), args->buf, (long)args->bufsize);
#endif
	if (args->bufsize < 2)
		return (ERANGE);
	path = malloc(LINUX_PATH_MAX, M_LINUX, M_WAITOK);
	error = kern___getcwd(td, path, UIO_SYSSPACE, args->bufsize,
	    LINUX_PATH_MAX);
	if (error == 0) {
		lenused = strlen(path) + 1;
		error = copyout(path, args->buf, lenused);
		if (error == 0)
			td->td_retval[0] = lenused;
	}
	free(path, M_LINUX);
	return (error);
}
int linux_getcwd ( struct thread * td , struct linux_getcwd_args * args ) { char * path ; int error , lenused ; #ifdef DEBUG if ( ldebug ( getcwd ) ) printf ( ARGS ( getcwd , " " ) , args -> buf , ( long ) args -> bufsize ) ; #endif if ( args -> bufsize < 2 ) return ( ERANGE ) ; path = malloc ( LINUX_PATH_MAX , M_LINUX , M_WAITOK ) ; error = kern___getcwd ( td , path , UIO_SYSSPACE , args -> bufsize , LINUX_PATH_MAX ) ; if ( error == 0 ) { lenused = strlen ( path ) + 1 ; error = copyout ( path , args -> buf , lenused ) ; if ( error == 0 ) td -> td_retval [ 0 ] = lenused ; } free ( path , M_LINUX ) ; return ( error ) ; }
Find pathname of process's current directory.
Find pathname of process ' s current directory .
/*
	 * Linux returns ERANGE instead of EINVAL.
	 */