Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Functions to copy from user space.

Functions to copy from user space. More...

Functions

long _stp_strncpy_from_user (char *dst, const char __user *src, long count)
 Copy a NULL-terminated string from userspace.
unsigned long _stp_copy_from_user (char *dst, const char __user *src, unsigned long count)
 Copy a block of data from user space.
int _stp_copy_argv_from_user (MAP list, char __user *__user *argv)
 Copy an argv from user space to a List.

Detailed Description

Functions to copy from user space.

None of these functions will sleep (for example to allow pages to be swapped in). It is possible (although rare) that the data in user space will not present and these functions will return an error.


Function Documentation

int _stp_copy_argv_from_user MAP  list,
char __user *__user *  argv
 

Copy an argv from user space to a List.

Parameters:
list A list.
argv Source argv, in user space.
Returns:
number of elements in list
Example:
MAP arglist ;

int inst_do_execve (char * filename, char __user *__user *argv, char __user *__user *envp, struct pt_regs * regs)
{
  struct map_node_str *ptr;

  _stp_list_clear (arglist);
  _stp_copy_argv_from_user (arglist, argv);

  foreach (arglist, ptr)
    printk ("%s ", ptr->str);
  printk ("\n");
}

Definition at line 130 of file copy.c.

References _stp_list_add_str(), _stp_strncpy_from_user(), and map_root::num.

unsigned long _stp_copy_from_user char *  dst,
const char __user *  src,
unsigned long  count
[inline]
 

Copy a block of data from user space.

If some data could not be copied, this function will pad the copied data to the requested size using zero bytes.

Parameters:
dst Destination address, in kernel space.
src Source address, in user space.
count Number of bytes to copy.
Returns:
number of bytes that could not be copied. On success, this will be zero.

Definition at line 115 of file copy.c.

long _stp_strncpy_from_user char *  dst,
const char __user *  src,
long  count
 

Copy a NULL-terminated string from userspace.

On success, returns the length of the string (not including the trailing NULL).

If access to userspace fails, returns -EFAULT (some data may have been copied).

Parameters:
dst Destination address, in kernel space. This buffer must be at least count bytes long.
src Source address, in user space.
count Maximum number of bytes to copy, including the trailing NULL.
If count is smaller than the length of the string, copies count bytes and returns count.

Definition at line 94 of file copy.c.

Referenced by _stp_copy_argv_from_user().