asst3-Virtual Memory Translation/kern/syscall/runprogram.c
static
int
argbuf_fromuser(struct argbuf *buf, userptr_t uargv)
{
	int result;

	/* try with a small buffer */
	result = argbuf_allocate(buf, PAGE_SIZE);
	if (result) {
		return result;
	}

	/* do the copyin */
	result = argbuf_copyin(buf, uargv);
	if (result == E2BIG) {
		/*
		 * Try again with the full-size buffer. Just start
		 * over instead of trying to keep the page we already
		 * did; this is a bit inefficient but it's not that
		 * important.
		 */
		argbuf_cleanup(buf);
		argbuf_init(buf);

		/* Wait on the semaphore, to throttle this allocation */
		P(execthrottle);
		buf->tooksem = true;

		result = argbuf_allocate(buf, ARG_MAX);
		if (result) {
			return result;
		}

		result = argbuf_copyin(buf, uargv);
	}
	return result;
}
/*
 * Get an argv from user space.
 */
Get an argv from user space.
Get an argv from user space .
static
int
argbuf_fromuser(struct argbuf *buf, userptr_t uargv)
{
	int result;
	result = argbuf_allocate(buf, PAGE_SIZE);
	if (result) {
		return result;
	}
	result = argbuf_copyin(buf, uargv);
	if (result == E2BIG) {
		argbuf_cleanup(buf);
		argbuf_init(buf);
		P(execthrottle);
		buf->tooksem = true;
		result = argbuf_allocate(buf, ARG_MAX);
		if (result) {
			return result;
		}
		result = argbuf_copyin(buf, uargv);
	}
	return result;
}
static int argbuf_fromuser ( struct argbuf * buf , userptr_t uargv ) { int result ; result = argbuf_allocate ( buf , PAGE_SIZE ) ; if ( result ) { return result ; } result = argbuf_copyin ( buf , uargv ) ; if ( result == E2BIG ) { argbuf_cleanup ( buf ) ; argbuf_init ( buf ) ; P ( execthrottle ) ; buf -> tooksem = true ; result = argbuf_allocate ( buf , ARG_MAX ) ; if ( result ) { return result ; } result = argbuf_copyin ( buf , uargv ) ; } return result ; }
Get an argv from user space.
Get an argv from user space .
/* try with a small buffer */ /* do the copyin */ /*
		 * Try again with the full-size buffer. Just start
		 * over instead of trying to keep the page we already
		 * did; this is a bit inefficient but it's not that
		 * important.
		 */ /* Wait on the semaphore, to throttle this allocation */