Question: Using system calls in C language: Memcpy (memory copy) function Using Debian app on VM interface to compile. Adding a Memory Copy System Call The

Using system calls in C language:

Memcpy (memory copy) function

Using system calls in C language: Memcpy (memory copy) function Using Debian

app on VM interface to compile. Adding a Memory Copy System Call

The memcpy() function In C, a commonly used function from the system's

C library is the memcpy () function. This function takes in two

Using Debian app on VM interface to compile.

Adding a Memory Copy System Call The memcpy() function In C, a commonly used function from the system's C library is the memcpy () function. This function takes in two pointers and a size and copies the given number of bytes from one to the other of the pointers. A very simple (albeit slow, performance-wise) version of this function might be implemented in the following manner: void *memopy (void *dest, const void *src, size t n) \{ unsigned char *d - (unsigned char *) dest; const unsigned char s= (unsigned char *)src; size t; unsigned char tmp; for (i=0;i header files at the top of copy.c to use any of these functions. If any checks fail (from access_ok, get_user, or put_user), you should stop trying to copy data and immediately return-EFAULT. If all data is copied correctly, return 0 at the end of the function (rather than the destination pointer as the userspace memopy does). Recall that in C, that a pointer to the i th element at a pointer ptr (or the ith element of an array, equivalently) can be obtained in the following two ways (use whichever you would like in your get_user and put_user calls: &ptr[i]/OR/ptr+i Testing Your System Call As with the hello world system call earlier, you should test your new memory copy system call to ensure that it works properly. You should test your function with a variety of pointers, both good and bad (for instance, try copying to or from a NULL pointer to see what happens. You should notice that when you copy to or from a bad pointer that the system call always returns 1. If you look at the errno variable in your program (\#include .h> in your test program to get access to it), you will find that it should be set to the constant EFAULT (also in errno.h) when an error occurs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!