summaryrefslogtreecommitdiffstats
path: root/runtime/docs/html/group__copy.html
blob: 72321187101a82ba946bce29d16a133325bdd16c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SystemTap: Functions to copy from user space.</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>Functions to copy from user space.</h1>Functions to copy from user space.  
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__copy.html#ga0">_stp_strncpy_from_user</a> (char *dst, const char __user *src, long count)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy a NULL-terminated string from userspace.  <a href="#ga0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__copy.html#ga1">_stp_string_from_user</a> (String str, const char __user *src, long count)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy a String from userspace.  <a href="#ga1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned long&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__copy.html#ga2">_stp_copy_from_user</a> (char *dst, const char __user *src, unsigned long count)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy a block of data from user space.  <a href="#ga2"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__copy.html#ga3">_stp_copy_argv_from_user</a> (<a class="el" href="group__maps.html#ga1">MAP</a> list, char __user *__user *argv)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Copy an argv from user space to a List.  <a href="#ga3"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Functions to copy from user space. 
<p>
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. <hr><h2>Function Documentation</h2>
<a class="anchor" name="ga3" doxytag="copy.c::_stp_copy_argv_from_user"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">int _stp_copy_argv_from_user           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top"><a class="el" href="group__maps.html#ga1">MAP</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>list</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>char __user *__user *&nbsp;</td>
          <td class="mdname" nowrap> <em>argv</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy an argv from user space to a List. 
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>list</em>&nbsp;</td><td>A list. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>argv</em>&nbsp;</td><td>Source argv, in user space. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>number of elements in <em>list</em></dd></dl>
<b>Example:</b> <div class="fragment"><pre class="fragment"><a class="code" href="group__maps.html#ga1">MAP</a> arglist ;

<span class="keywordtype">int</span> inst_do_execve (<span class="keywordtype">char</span> * filename, <span class="keywordtype">char</span> __user *__user *argv, <span class="keywordtype">char</span> __user *__user *envp, <span class="keyword">struct</span> pt_regs * regs)
{
  <span class="keyword">struct </span>map_node_str *ptr;

  <a class="code" href="group__lists.html#ga1">_stp_list_clear</a> (arglist);
  <a class="code" href="group__copy.html#ga3">_stp_copy_argv_from_user</a> (arglist, argv);

  <a class="code" href="group__maps.html#ga32">foreach</a> (arglist, ptr)
    printk ("%s ", ptr-&gt;str);
  printk ("\n");
}
</pre></div> 
<p>
Definition at line <a class="el" href="copy_8c-source.html#l00154">154</a> of file <a class="el" href="copy_8c-source.html">copy.c</a>.
<p>
References <a class="el" href="map_8c-source.html#l00872">_stp_list_add_str()</a>, and <a class="el" href="copy_8c-source.html#l00096">_stp_strncpy_from_user()</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga2" doxytag="copy.c::_stp_copy_from_user"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">unsigned long _stp_copy_from_user           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">char *&nbsp;</td>
          <td class="mdname" nowrap> <em>dst</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char __user *&nbsp;</td>
          <td class="mdname" nowrap> <em>src</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>unsigned long&nbsp;</td>
          <td class="mdname" nowrap> <em>count</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy a block of data from user space. 
<p>
If some data could not be copied, this function will pad the copied data to the requested size using zero bytes.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dst</em>&nbsp;</td><td>Destination address, in kernel space. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>src</em>&nbsp;</td><td>Source address, in user space. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>count</em>&nbsp;</td><td>Number of bytes to copy. </td></tr>
  </table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>number of bytes that could not be copied. On success, this will be zero. </dd></dl>

<p>
Definition at line <a class="el" href="copy_8c-source.html#l00139">139</a> of file <a class="el" href="copy_8c-source.html">copy.c</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga1" doxytag="copy.c::_stp_string_from_user"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">void _stp_string_from_user           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">String&nbsp;</td>
          <td class="mdname" nowrap> <em>str</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char __user *&nbsp;</td>
          <td class="mdname" nowrap> <em>src</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>long&nbsp;</td>
          <td class="mdname" nowrap> <em>count</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy a String from userspace. 
<p>
Copies a string of up to <em>count</em> bytes from userspace into a String. If access to userspace fails, returns -EFAULT (some data may have been copied). <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>Destination String. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>src</em>&nbsp;</td><td>Source address, in user space. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>count</em>&nbsp;</td><td>Maximum number of bytes to copy, including the trailing NULL. </td></tr>
  </table>
</dl>

<p>
Definition at line <a class="el" href="copy_8c-source.html#l00113">113</a> of file <a class="el" href="copy_8c-source.html">copy.c</a>.
<p>
References <a class="el" href="string_8c-source.html#l00020">STP_STRING_SIZE</a>.    </td>
  </tr>
</table>
<a class="anchor" name="ga0" doxytag="copy.c::_stp_strncpy_from_user"></a><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top">long _stp_strncpy_from_user           </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">char *&nbsp;</td>
          <td class="mdname" nowrap> <em>dst</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>const char __user *&nbsp;</td>
          <td class="mdname" nowrap> <em>src</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td class="md"></td>
          <td class="md" nowrap>long&nbsp;</td>
          <td class="mdname" nowrap> <em>count</em></td>
        </tr>
        <tr>
          <td class="md"></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Copy a NULL-terminated string from userspace. 
<p>
On success, returns the length of the string (not including the trailing NULL).<p>
If access to userspace fails, returns -EFAULT (some data may have been copied). <dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>dst</em>&nbsp;</td><td>Destination address, in kernel space. This buffer must be at least <em>count</em> bytes long. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>src</em>&nbsp;</td><td>Source address, in user space. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>count</em>&nbsp;</td><td>Maximum number of bytes to copy, including the trailing NULL.</td></tr>
  </table>
</dl>
If <em>count</em> is smaller than the length of the string, copies <em>count</em> bytes and returns <em>count</em>. <p>
<dl compact><dt><b><a class="el" href="deprecated.html#_deprecated000001">Deprecated:</a></b></dt><dd>I can't think of why you wouldn't use <a class="el" href="group__copy.html#ga1">_stp_string_from_user()</a> instead. </dd></dl>

<p>
Definition at line <a class="el" href="copy_8c-source.html#l00096">96</a> of file <a class="el" href="copy_8c-source.html">copy.c</a>.
<p>
Referenced by <a class="el" href="copy_8c-source.html#l00154">_stp_copy_argv_from_user()</a>.    </td>
  </tr>
</table>
</body></html>