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

	/* loop through the argv, grabbing each arg string */
	buf->nargs = 0;
	while (1) {
		/*
		 * First, grab the pointer at argv.
		 * (argv is incremented at the end of the loop)
		 */
		result = copyin(uargv, &thisarg, sizeof(userptr_t));
		if (result) {
			return result;
		}

		/* If we got NULL, we're at the end of the argv. */
		if (thisarg == NULL) {
			break;
		}

		/* Use the pointer to fetch the argument string. */
		result = copyinstr(thisarg, buf->data + buf->len,
				   buf->max - buf->len, &thisarglen);
		if (result == ENAMETOOLONG) {
			return E2BIG;
		}
		else if (result) {
			return result;
		}

		/* Move ahead. Note: thisarglen includes the \0. */
		buf->len += thisarglen;
		uargv += sizeof(userptr_t);
		buf->nargs++;
	}

	return 0;
}
/*
 * Copy an argv array into kernel space, using an argvdata buffer.
 */
Copy an argv array into kernel space, using an argvdata buffer.
Copy an argv array into kernel space using an argvdata buffer .
static
int
argbuf_copyin(struct argbuf *buf, userptr_t uargv)
{
	userptr_t thisarg;
	size_t thisarglen;
	int result;
	buf->nargs = 0;
	while (1) {
		result = copyin(uargv, &thisarg, sizeof(userptr_t));
		if (result) {
			return result;
		}
		if (thisarg == NULL) {
			break;
		}
		result = copyinstr(thisarg, buf->data + buf->len,
				   buf->max - buf->len, &thisarglen);
		if (result == ENAMETOOLONG) {
			return E2BIG;
		}
		else if (result) {
			return result;
		}
		buf->len += thisarglen;
		uargv += sizeof(userptr_t);
		buf->nargs++;
	}
	return 0;
}
static int argbuf_copyin ( struct argbuf * buf , userptr_t uargv ) { userptr_t thisarg ; size_t thisarglen ; int result ; buf -> nargs = 0 ; while ( 1 ) { result = copyin ( uargv , & thisarg , sizeof ( userptr_t ) ) ; if ( result ) { return result ; } if ( thisarg == NULL ) { break ; } result = copyinstr ( thisarg , buf -> data + buf -> len , buf -> max - buf -> len , & thisarglen ) ; if ( result == ENAMETOOLONG ) { return E2BIG ; } else if ( result ) { return result ; } buf -> len += thisarglen ; uargv += sizeof ( userptr_t ) ; buf -> nargs ++ ; } return 0 ; }
Copy an argv array into kernel space, using an argvdata buffer.
Copy an argv array into kernel space using an argvdata buffer .
/* loop through the argv, grabbing each arg string */ /*
		 * First, grab the pointer at argv.
		 * (argv is incremented at the end of the loop)
		 */ /* If we got NULL, we're at the end of the argv. */ /* Use the pointer to fetch the argument string. */ /* Move ahead. Note: thisarglen includes the \0. */