Accessing User-Space Memory When copying string data from user space (e.g. string parameters), we do not know the size of the string we need to copy. This is because C strings (char*) have no size information, other then at the end of the string. Thus, to copy user data, we allocate a page of memory (limiting parameter size to the size of a memory page - 4096 characters on an Intel architecture), and use the 'strncpy_from_user' routine. /* we assume 'page' is a memory page previously */ /* allocated using get_free_page. */ long retval = strncpy_from_user((char *)page, filename, PAGE_SIZE); if (retval > 0) { if (retval < PAGE_SIZE) { const char* buf = (char *)page; /* do something with the copied string... */ } retval = -ENAMETOOLONG; } else if (!retval) retval = -EINVAL;