70
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
2 |
<html>
|
|
3 |
<head>
|
|
4 |
<title>Target Communication Framework Services - File System</title>
|
|
5 |
</head>
|
|
6 |
|
|
7 |
<body lang='EN-US'>
|
|
8 |
|
|
9 |
<h1>Target Communication Framework Services - File System</h1>
|
|
10 |
|
|
11 |
<ul>
|
|
12 |
<li><a href='#VersionHistory'>Version History</a>
|
|
13 |
<li><a href='#Overview'>Overview</a>
|
|
14 |
<li><a href='#ReqSync'>Request Synchronization and Reordering</a>
|
|
15 |
<li><a href='#FileNames'>File Names</a>
|
|
16 |
<li><a href='#FileModes'>File Open Modes</a>
|
|
17 |
<li><a href='#FileAttributes'>File Attributes</a>
|
|
18 |
<li><a href='#ErrorCodes'>Error Codes</a>
|
|
19 |
<li><a href='#Cmds'>Commands</a>
|
|
20 |
<ul>
|
|
21 |
<li><a href='#CmdOpen'>open</a>
|
|
22 |
<li><a href='#CmdClose'>close</a>
|
|
23 |
<li><a href='#CmdRead'>read</a>
|
|
24 |
<li><a href='#CmdWrite'>write</a>
|
|
25 |
<li><a href='#CmdStat'>stat</a>
|
|
26 |
<li><a href='#CmdLStat'>lstat</a>
|
|
27 |
<li><a href='#CmdFStat'>fstat</a>
|
|
28 |
<li><a href='#CmdSetStat'>setstat</a>
|
|
29 |
<li><a href='#CmdFSetStat'>fsetstat</a>
|
|
30 |
<li><a href='#CmdOpenDir'>opendir</a>
|
|
31 |
<li><a href='#CmdReadDir'>readdir</a>
|
|
32 |
<li><a href='#CmdMkDir'>mkdir</a>
|
|
33 |
<li><a href='#CmdRmDir'>rmdir</a>
|
|
34 |
<li><a href='#CmdRoots'>roots</a>
|
|
35 |
<li><a href='#CmdRemove'>remove</a>
|
|
36 |
<li><a href='#CmdRealPath'>realpath</a>
|
|
37 |
<li><a href='#CmdRename'>rename</a>
|
|
38 |
<li><a href='#CmdReadLink'>readlink</a>
|
|
39 |
<li><a href='#CmdSymLink'>symlink</a>
|
|
40 |
<li><a href='#CmdSymLink'>copy</a>
|
|
41 |
<li><a href='#CmdSymLink'>user</a>
|
|
42 |
</ul>
|
|
43 |
<li><a href='#API'>API</a>
|
|
44 |
</ul>
|
|
45 |
|
|
46 |
<h1>File System Service</h1>
|
|
47 |
|
|
48 |
<h2><a name='VersionHistory'>Version History</a></h2>
|
|
49 |
|
|
50 |
<table border=1 cellpadding=8>
|
|
51 |
<tr>
|
|
52 |
<th>Version
|
|
53 |
<th>Date
|
|
54 |
<th>Change
|
|
55 |
<tr>
|
|
56 |
<td>0.1
|
|
57 |
<td>2008-01-10
|
|
58 |
<td>Initial contribution
|
|
59 |
</table>
|
|
60 |
|
|
61 |
<h2><a name='Overview'>Overview</a></h2>
|
|
62 |
|
|
63 |
<p>File System service provides file transfer (and more generally file
|
|
64 |
system access) functionality in TCF. The service design is
|
|
65 |
derived from SSH File Transfer Protocol specifications.</p>
|
|
66 |
|
|
67 |
<h2><a name='ReqSync'>Request Synchronization and Reordering</a></h2>
|
|
68 |
|
|
69 |
<p>The protocol and implementations MUST process requests relating to
|
|
70 |
the same file in the order in which they are received. In other
|
|
71 |
words, if an application submits multiple requests to the server, the
|
|
72 |
results in the responses will be the same as if it had sent the
|
|
73 |
requests one at a time and waited for the response in each case. For
|
|
74 |
example, the server may process non-overlapping read/write requests
|
|
75 |
to the same file in parallel, but overlapping reads and writes cannot
|
|
76 |
be reordered or parallelized. However, there are no ordering
|
|
77 |
restrictions on the server for processing requests from two different
|
|
78 |
file transfer connections. The server may interleave and parallelize
|
|
79 |
them at will.</p>
|
|
80 |
|
|
81 |
<p>There are no restrictions on the order in which responses to
|
|
82 |
outstanding requests are delivered to the client, except that the
|
|
83 |
server must ensure fairness in the sense that processing of no
|
|
84 |
request will be indefinitely delayed even if the client is sending
|
|
85 |
other requests so that there are multiple outstanding requests all
|
|
86 |
the time.</p>
|
|
87 |
|
|
88 |
<p>There is no limit on the number of outstanding (non-acknowledged)
|
|
89 |
requests that the client may send to the server. In practice this is
|
|
90 |
limited by the buffering available on the data stream and the queuing
|
|
91 |
performed by the server. If the server's queues are full, it should
|
|
92 |
not read any more data from the stream, and flow control will prevent
|
|
93 |
the client from sending more requests.</p>
|
|
94 |
|
|
95 |
<h2><a name='FileNames'>File Names</a></h2>
|
|
96 |
|
|
97 |
<p>This protocol represents file names as strings. File names are
|
|
98 |
assumed to use the slash ('/') character as a directory separator.</p>
|
|
99 |
|
|
100 |
<p>File names starting with a slash are "absolute", and are relative to
|
|
101 |
the root of the file system. Names starting with any other character
|
|
102 |
are relative to the user's default directory (home directory). Client
|
|
103 |
can use 'user()' command to retrieve current user home directory.</p>
|
|
104 |
|
|
105 |
<p>Servers SHOULD interpret a path name component ".." as referring to
|
|
106 |
the parent directory, and "." as referring to the current directory.
|
|
107 |
If the server implementation limits access to certain parts of the
|
|
108 |
file system, it must be extra careful in parsing file names when
|
|
109 |
enforcing such restrictions. There have been numerous reported
|
|
110 |
security bugs where a ".." in a path name has allowed access outside
|
|
111 |
the intended area.</p>
|
|
112 |
|
|
113 |
<p>An empty path name is valid, and it refers to the user's default
|
|
114 |
directory (usually the user's home directory).</p>
|
|
115 |
|
|
116 |
<p>Otherwise, no syntax is defined for file names by this specification.
|
|
117 |
Clients should not make any other assumptions; however, they can
|
|
118 |
splice path name components returned by readdir() together
|
|
119 |
using a slash ('/') as the separator, and that will work as expected.</p>
|
|
120 |
|
|
121 |
<h2><a name='FileModes'>File Open Modes</a></h2>
|
|
122 |
|
|
123 |
<p>File open mode is bitwise OR of mode flags:</p>
|
|
124 |
|
|
125 |
<dl>
|
|
126 |
<dt><code>TCF_O_READ = 0x00000001</code>
|
|
127 |
<dd>Open the file for reading.
|
|
128 |
|
|
129 |
<dt><code>TCF_O_WRITE = 0x00000002</code>
|
|
130 |
<dd>Open the file for writing. If both this and TCF_O_READ are
|
|
131 |
specified, the file is opened for both reading and writing.
|
|
132 |
|
|
133 |
<dt><code>TCF_O_APPEND = 0x00000004</code>
|
|
134 |
<dd>Force all writes to append data at the end of the file.
|
|
135 |
|
|
136 |
<dt><code>TCF_O_CREAT = 0x00000008</code>
|
|
137 |
<dd>If this flag is specified, then a new file will be created if one
|
|
138 |
does not already exist (if TCF_O_TRUNC is specified, the new file will
|
|
139 |
be truncated to zero length if it previously exists).
|
|
140 |
|
|
141 |
<dt><code>TCF_O_TRUNC = 0x00000010</code>
|
|
142 |
<dd>Forces an existing file with the same name to be truncated to zero
|
|
143 |
length when creating a file by specifying TCF_O_CREAT.
|
|
144 |
TCF_O_CREAT MUST also be specified if this flag is used.
|
|
145 |
|
|
146 |
<dt><code>TCF_O_EXCL = 0x00000020</code>
|
|
147 |
<dd>Causes the request to fail if the named file already exists.
|
|
148 |
TCF_O_CREAT MUST also be specified if this flag is used.
|
|
149 |
</dl>
|
|
150 |
|
|
151 |
<h2><a name='FileAttributes'>File Attributes</a></h2>
|
|
152 |
|
|
153 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
154 |
<i><file attributes></i>
|
|
155 |
⇒ <i><object></i>
|
|
156 |
</font></b></pre>
|
|
157 |
|
|
158 |
<p>All attributes are optional.
|
|
159 |
Tools and targets can define additional attributes. Predefined attributes are:</p>
|
|
160 |
<ul>
|
|
161 |
<li><code><b><font face="Courier New" size=2 color=#333399>"Size" : <i><int></i></font></b></code>
|
|
162 |
- file size in bytes
|
|
163 |
<li><code><b><font face="Courier New" size=2 color=#333399>"UID" : <i><int></i></font></b></code>
|
|
164 |
- file owner user ID
|
|
165 |
<li><code><b><font face="Courier New" size=2 color=#333399>"GID" : <i><int></i></font></b></code>
|
|
166 |
- file owner group ID
|
|
167 |
<li><code><b><font face="Courier New" size=2 color=#333399>"Permissions" : <i><int></i></font></b></code>
|
|
168 |
- file access permissions
|
|
169 |
<li><code><b><font face="Courier New" size=2 color=#333399>"ATime" : <i><int></i></font></b></code>
|
|
170 |
- file last access time
|
|
171 |
<li><code><b><font face="Courier New" size=2 color=#333399>"MTime" : <i><int></i></font></b></code>
|
|
172 |
- file last modification time
|
|
173 |
</ul>
|
|
174 |
|
|
175 |
<h2><a name='ErrorCodes'>Error codes</a></h2>
|
|
176 |
|
|
177 |
<p>The service uses standard format for error reports,
|
|
178 |
see <a href='TCF Services.html#ErrorFormat'>Error Report Format</a>.</p>
|
|
179 |
|
|
180 |
<p>Currently, the following values are defined for service specific error codes (other values may be
|
|
181 |
defined by future versions of this protocol):</p>
|
|
182 |
|
|
183 |
<dl>
|
|
184 |
<dt><code>STATUS_EOF = 0x10001</code>
|
|
185 |
<dd>Indicates end-of-file condition; for 'read' it means that no
|
|
186 |
more data is available in the file, and for 'readdir' it
|
|
187 |
indicates that no more files are contained in the directory.
|
|
188 |
|
|
189 |
<dt><code>STATUS_NO_SUCH_FILE = 0x10002</code>
|
|
190 |
<dd>This code is returned when a reference is made to a file which
|
|
191 |
should exist but doesn't.
|
|
192 |
|
|
193 |
<dt><code>STATUS_PERMISSION_DENIED = 0x10003</code>
|
|
194 |
<dd>is returned when the authenticated user does not have sufficient
|
|
195 |
permissions to perform the operation.
|
|
196 |
</dl>
|
|
197 |
|
|
198 |
<h2><a name='Cmds'>Commands</a></h2>
|
|
199 |
|
|
200 |
<h3><a name='CmdOpen'>open</a></h3>
|
|
201 |
|
|
202 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
203 |
C • <i><token></i> • FileSystem • open • <i><string: file name></i> • <i><int: mode></i> • <i><file attributes></i> •
|
|
204 |
</font></b></pre>
|
|
205 |
|
|
206 |
<p>The command opens or creates a file on a remote system. If mode contains TCF_O_CREAT then new file is created, otherwise exsting
|
|
207 |
file is opened. If the file is created, file attributes is looked up for UID, GID and permissions. If no attribute value is found in
|
|
208 |
the command parameters, a default value is used.</p>
|
|
209 |
|
|
210 |
<p>Reply:</p>
|
|
211 |
|
|
212 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
213 |
R • <i><token></i> • <i><error report></i> • <i><file handle></i> •
|
|
214 |
|
|
215 |
<i><file handle></i>
|
|
216 |
⇒ null
|
|
217 |
⇒ <i><string></i>
|
|
218 |
</font></b></pre>
|
|
219 |
|
|
220 |
<p>On success, the replay contains open file handle. The handle is encoded as a string of characters. Client should never try
|
|
221 |
to decode the string, but should use it as is to issue further file access commands. Client should close the file when it is
|
|
222 |
not needed any more. Server should close all files that were left open after client connection was closed ot terminated.</p>
|
|
223 |
|
|
224 |
<h3><a name='CmdClose'>close</a></h3>
|
|
225 |
|
|
226 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
227 |
C • <i><token></i> • FileSystem • close • <i><string: file handle></i> •
|
|
228 |
</font></b></pre>
|
|
229 |
|
|
230 |
<p>The command closes a handle, which was open by 'open' or 'opendir' commands.</p>
|
|
231 |
|
|
232 |
<p>Reply:</p>
|
|
233 |
|
|
234 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
235 |
R • <i><token></i> • <i><error report></i> •
|
|
236 |
</font></b></pre>
|
|
237 |
|
|
238 |
<h3><a name='CmdRead'>read</a></h3>
|
|
239 |
|
|
240 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
241 |
C • <i><token></i> • FileSystem • read • <i><string: file handle></i> • <i><int: offset></i> • <i><int: size></i> •
|
|
242 |
</font></b></pre>
|
|
243 |
|
|
244 |
<p>The command reads bytes from an open file.
|
|
245 |
In response to this request, the server will read as many bytes as it
|
|
246 |
can from the file (up to `size'), and return them in a byte array.
|
|
247 |
If an error occurs or EOF is encountered, the server may return
|
|
248 |
fewer bytes then requested. Replay argument 'error report'
|
|
249 |
will be not null in case of error, and argument 'eof' will be
|
|
250 |
true in case of EOF. For normal disk files, it is guaranteed
|
|
251 |
that this will read the specified number of bytes, or up to end of file
|
|
252 |
or error. For e.g. device files this may return fewer bytes than requested.</p>
|
|
253 |
|
|
254 |
<p>If 'offset' < 0 then reading will start from current position in the file.</p>
|
|
255 |
|
|
256 |
<p>Reply:</p>
|
|
257 |
|
|
258 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
259 |
R • <i><token></i> • <i><string: data></i> • <i><error report></i> • <i><boolean: eof></i> •
|
|
260 |
</font></b></pre>
|
|
261 |
|
|
262 |
<p><i><string: data></i> is Base64 encoded byte array of file data. Number of bytes is determined by the string length.
|
|
263 |
'eof' is true when 'data' contains all available bytes up to the end of the file.</p>
|
|
264 |
|
|
265 |
<h3><a name='CmdWrite'>write</a></h3>
|
|
266 |
|
|
267 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
268 |
C • <i><token></i> • FileSystem • write • <i><string: file handle></i> • <i><int: offset></i> • <i><string: data></i> •
|
|
269 |
</font></b></pre>
|
|
270 |
|
|
271 |
<p>The command writes bytes into an open file.
|
|
272 |
The write will extend the file if writing beyond the end of the file.
|
|
273 |
It is legal to write way beyond the end of the file; the semantics
|
|
274 |
are to write zeroes from the end of the file to the specified offset
|
|
275 |
and then the data. <i><string: data></i> is Base64 encoded array of data bytes.</p>
|
|
276 |
|
|
277 |
<p>If 'offset' < 0 then writing will start from current position in the file.</p>
|
|
278 |
|
|
279 |
<p>Reply:</p>
|
|
280 |
|
|
281 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
282 |
R • <i><token></i> • <i><error report></i> •
|
|
283 |
</font></b></pre>
|
|
284 |
|
|
285 |
<h3><a name='CmdStat'>stat</a></h3>
|
|
286 |
|
|
287 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
288 |
C • <i><token></i> • FileSystem • stat • <i><string: file name></i> •
|
|
289 |
</font></b></pre>
|
|
290 |
|
|
291 |
<p>The command retrieves file attributes.</p>
|
|
292 |
|
|
293 |
<p>Reply:</p>
|
|
294 |
|
|
295 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
296 |
R • <i><token></i> • <i><error report></i> • <i><file attributes></i> •
|
|
297 |
</font></b></pre>
|
|
298 |
|
|
299 |
<h3><a name='CmdLStat'>lstat</a></h3>
|
|
300 |
|
|
301 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
302 |
C • <i><token></i> • FileSystem • lstat • <i><string: file name></i> •
|
|
303 |
</font></b></pre>
|
|
304 |
|
|
305 |
<p>The command retrieves file attributes.
|
|
306 |
Unlike 'stat', 'lstat' does not follow symbolic links.</p>
|
|
307 |
|
|
308 |
<p>Reply:</p>
|
|
309 |
|
|
310 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
311 |
R • <i><token></i> • <i><error report></i> • <i><file attributes></i> •
|
|
312 |
</font></b></pre>
|
|
313 |
|
|
314 |
<h3><a name='CmdFStat'>fstat</a></h3>
|
|
315 |
|
|
316 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
317 |
C • <i><token></i> • FileSystem • fstat • <i><string: file handle></i> •
|
|
318 |
</font></b></pre>
|
|
319 |
|
|
320 |
<p>The command retrieves file attributes for an open file (identified by the file handle).</p>
|
|
321 |
|
|
322 |
<p>Reply:</p>
|
|
323 |
|
|
324 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
325 |
R • <i><token></i> • <i><error report></i> • <i><file attributes></i> •
|
|
326 |
</font></b></pre>
|
|
327 |
|
|
328 |
<h3><a name='CmdSetStat'>setstat</a></h3>
|
|
329 |
|
|
330 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
331 |
C • <i><token></i> • FileSystem • setstat • <i><string: file name></i> • <i><file attributes></i> •
|
|
332 |
</font></b></pre>
|
|
333 |
|
|
334 |
<p>The command sets file attributes.
|
|
335 |
This request is used for operations such as changing the ownership,
|
|
336 |
permissions or access times, as well as for truncating a file.
|
|
337 |
An error will be returned if the specified file system object does
|
|
338 |
not exist or the user does not have sufficient rights to modify the
|
|
339 |
specified attributes.</p>
|
|
340 |
|
|
341 |
<p>Reply:</p>
|
|
342 |
|
|
343 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
344 |
R • <i><token></i> • <i><error report></i> •
|
|
345 |
</font></b></pre>
|
|
346 |
|
|
347 |
<h3><a name='CmdFSetStat'>fsetstat</a></h3>
|
|
348 |
|
|
349 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
350 |
C • <i><token></i> • FileSystem • fsetstat • <i><string: file handle></i> • <i><file attributes></i> •
|
|
351 |
</font></b></pre>
|
|
352 |
|
|
353 |
<p>The command sets file attributes for an open file (identified by the file handle).
|
|
354 |
This request is used for operations such as changing the ownership,
|
|
355 |
permissions or access times, as well as for truncating a file.</p>
|
|
356 |
|
|
357 |
<p>Reply:</p>
|
|
358 |
|
|
359 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
360 |
R • <i><token></i> • <i><error report></i> •
|
|
361 |
</font></b></pre>
|
|
362 |
|
|
363 |
<h3><a name='CmdOpenDir'>opendir</a></h3>
|
|
364 |
|
|
365 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
366 |
C • <i><token></i> • FileSystem • opendir • <i><string: path></i> •
|
|
367 |
</font></b></pre>
|
|
368 |
|
|
369 |
<p>The command opens a directory for reading.
|
|
370 |
Once the directory has been successfully opened, files (and
|
|
371 |
directories) contained in it can be listed using 'readdir' requests.
|
|
372 |
When the client no longer wishes to read more names from the
|
|
373 |
directory, it SHOULD call 'close' for the handle. The handle
|
|
374 |
should be closed regardless of whether a read errors have occurred or not.</p>
|
|
375 |
|
|
376 |
<p>Reply:</p>
|
|
377 |
|
|
378 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
379 |
R • <i><token></i> • <i><error report></i> • <i><file handle></i> •
|
|
380 |
</font></b></pre>
|
|
381 |
|
|
382 |
<h3><a name='CmdReadDir'>readdir</a></h3>
|
|
383 |
|
|
384 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
385 |
C • <i><token></i> • FileSystem • readdir • <i><string: file handle></i> •
|
|
386 |
</font></b></pre>
|
|
387 |
|
|
388 |
<p>The command returns one
|
|
389 |
or more file names with full file attributes for each file. The
|
|
390 |
client should call 'readdir' repeatedly until it has found the
|
|
391 |
file it is looking for or until the server responds with a
|
|
392 |
message indicating an error or end of file. The client should then
|
|
393 |
close the handle using the 'close' request.
|
|
394 |
Note: directory entries "." and ".." are NOT included into readdir()
|
|
395 |
response.</p>
|
|
396 |
|
|
397 |
<p>Reply:</p>
|
|
398 |
|
|
399 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
400 |
R • <i><token></i> • <i><array of directory entries></i> • <i><error report></i> • <i><boolean: eof></i> •
|
|
401 |
|
|
402 |
<i><array of directory entries></i>
|
|
403 |
⇒ null
|
|
404 |
⇒ [ ]
|
|
405 |
⇒ [ <i><directory entry list></i> ]
|
|
406 |
|
|
407 |
<i><directory entry list></i>
|
|
408 |
⇒ <i><directory entry></i>
|
|
409 |
⇒ <i><directory entry list></i> , <i><directory entry></i>
|
|
410 |
|
|
411 |
<i><directory entry></i>
|
|
412 |
⇒ <i><object></i>
|
|
413 |
</font></b></pre>
|
|
414 |
|
|
415 |
<p>Directory entry attributes are:</p>
|
|
416 |
<ul>
|
|
417 |
<li><code><b><font face="Courier New" size=2 color=#333399>"FileName" : <i><string></i></font></b></code>
|
|
418 |
- a file name being returned, it will be a relative name within the directory,
|
|
419 |
without any path components.
|
|
420 |
<li><code><b><font face="Courier New" size=2 color=#333399>"LongName" : <i><string></i></font></b></code>
|
|
421 |
- a human readable, expanded format for the file name, similar to what
|
|
422 |
is returned by "ls -l" on Unix systems
|
|
423 |
<li><code><b><font face="Courier New" size=2 color=#333399>"Attrs" : <i><file attributes></i></font></b></code>
|
|
424 |
- the attributes of the file as described in Section <a href='#FileAttributes'>File Attributes</a>.
|
|
425 |
</ul>
|
|
426 |
|
|
427 |
<h3><a name='CmdMkDir'>mkdir</a></h3>
|
|
428 |
|
|
429 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
430 |
C • <i><token></i> • FileSystem • mkdir • <i><string: directory path></i> • <i><file attributes></i> •
|
|
431 |
</font></b></pre>
|
|
432 |
|
|
433 |
<p>The command creates a directory on the server.
|
|
434 |
<i><string: directory path></i> specifies the directory to be created.
|
|
435 |
<i><file attributes></i> specifies new directory attributes.</p>
|
|
436 |
|
|
437 |
<p>Reply:</p>
|
|
438 |
|
|
439 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
440 |
R • <i><token></i> • <i><error report></i> •
|
|
441 |
</font></b></pre>
|
|
442 |
|
|
443 |
<h3><a name='CmdRmDir'>rmdir</a></h3>
|
|
444 |
|
|
445 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
446 |
C • <i><token></i> • FileSystem • rmdir • <i><string: directory path></i> •
|
|
447 |
</font></b></pre>
|
|
448 |
|
|
449 |
<p>The command removes a directory.
|
|
450 |
An error will be returned if no directory
|
|
451 |
with the specified path exists, or if the specified directory is not
|
|
452 |
empty, or if the path specified a file system object other than a
|
|
453 |
directory. <i><string: directory path></i> - specifies the directory to be removed.</p>
|
|
454 |
|
|
455 |
<p>Reply:</p>
|
|
456 |
|
|
457 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
458 |
R • <i><token></i> • <i><error report></i> •
|
|
459 |
</font></b></pre>
|
|
460 |
|
|
461 |
<h3><a name='CmdRoots'>roots</a></h3>
|
|
462 |
|
|
463 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
464 |
C • <i><token></i> • FileSystem • roots •
|
|
465 |
</font></b></pre>
|
|
466 |
|
|
467 |
<p>The command retrieves file system roots - top level file system objects.
|
|
468 |
UNIX file system can report just one root with path "/". Other types of systems
|
|
469 |
can have more the one root. For example, Windows server can return multiple roots:
|
|
470 |
one per disc (e.g. "/C:/", "/D:/", etc.). Note: even Windows implementation of
|
|
471 |
the service must use forward slash as directory separator, and must start
|
|
472 |
absolute path with "/". Server should implement proper translation of
|
|
473 |
protocol file names to OS native names and back.</p>
|
|
474 |
|
|
475 |
<p>Reply:</p>
|
|
476 |
|
|
477 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
478 |
R • <i><token></i> • <i><error report></i> • <i><array of directory entries></i> •
|
|
479 |
</font></b></pre>
|
|
480 |
|
|
481 |
<h3><a name='CmdRemove'>remove</a></h3>
|
|
482 |
|
|
483 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
484 |
C • <i><token></i> • FileSystem • remove • <i><string: path></i> •
|
|
485 |
</font></b></pre>
|
|
486 |
|
|
487 |
<p>The command removes a file or symbolic link.
|
|
488 |
This request cannot be used to remove directories.</p>
|
|
489 |
|
|
490 |
<p>Reply:</p>
|
|
491 |
|
|
492 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
493 |
R • <i><token></i> • <i><error report></i> •
|
|
494 |
</font></b></pre>
|
|
495 |
|
|
496 |
<h3><a name='CmdRealPath'>realpath</a></h3>
|
|
497 |
|
|
498 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
499 |
C • <i><token></i> • FileSystem • realpath • <i><string: path></i> •
|
|
500 |
</font></b></pre>
|
|
501 |
|
|
502 |
<p>The command canonicalizes any given path name to an absolute path.
|
|
503 |
This is useful for converting path names containing ".." components or
|
|
504 |
relative pathnames without a leading slash into absolute paths.</p>
|
|
505 |
|
|
506 |
<p>Reply:</p>
|
|
507 |
|
|
508 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
509 |
R • <i><token></i> • <i><error report></i> • <i><string: path></i> •
|
|
510 |
</font></b></pre>
|
|
511 |
|
|
512 |
<h3><a name='CmdRename'>rename</a></h3>
|
|
513 |
|
|
514 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
515 |
C • <i><token></i> • FileSystem • rename • <i><string: old path></i> • <i><string: new path></i> •
|
|
516 |
</font></b></pre>
|
|
517 |
|
|
518 |
<p>The command renames a file.
|
|
519 |
It is an error if there already exists a file
|
|
520 |
with the name specified by <i><string: new path></i>. The server may also fail rename
|
|
521 |
requests in other situations, for example if <i><string: old path></i> and <i><string: new path></i>
|
|
522 |
point to different file systems on the server.</p>
|
|
523 |
|
|
524 |
<p>Reply:</p>
|
|
525 |
|
|
526 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
527 |
R • <i><token></i> • <i><error report></i> •
|
|
528 |
</font></b></pre>
|
|
529 |
|
|
530 |
<h3><a name='CmdReadLink'>readlink</a></h3>
|
|
531 |
|
|
532 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
533 |
C • <i><token></i> • FileSystem • readlink • <i><string: link path></i> •
|
|
534 |
</font></b></pre>
|
|
535 |
|
|
536 |
<p>The command reads the target of a symbolic link.
|
|
537 |
<i><string: link path></i> specifies the path name of the symbolic link to be read.</p>
|
|
538 |
|
|
539 |
<p>Reply:</p>
|
|
540 |
|
|
541 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
542 |
R • <i><token></i> • <i><error report></i> • <i><string: path></i> •
|
|
543 |
</font></b></pre>
|
|
544 |
|
|
545 |
<h3><a name='CmdSymLink'>symlink</a></h3>
|
|
546 |
|
|
547 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
548 |
C • <i><token></i> • FileSystem • symlink • <i><string: link path></i> • <i><string: target path></i> •
|
|
549 |
</font></b></pre>
|
|
550 |
|
|
551 |
<p>The command creates a symbolic link on the server.
|
|
552 |
<i><string: link path></i> specifies the path name of the symbolic link to be created.
|
|
553 |
<i><string: target path></i> specifies the target of the symbolic link.</p>
|
|
554 |
|
|
555 |
<p>Reply:</p>
|
|
556 |
|
|
557 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
558 |
R • <i><token></i> • <i><error report></i> •
|
|
559 |
</font></b></pre>
|
|
560 |
|
|
561 |
<h3><a name='CmdCopy'>copy</a></h3>
|
|
562 |
|
|
563 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
564 |
C • <i><token></i> • FileSystem • copy • <i><string: source path></i> • <i><string: destination path></i> •
|
|
565 |
<i><boolean: copy permissions></i> • <i><boolean: copy ownership></i> •
|
|
566 |
</font></b></pre>
|
|
567 |
|
|
568 |
<p>The command copies a file on remote system.
|
|
569 |
<i><string: source path></i> specifies the path name of the file to be copied.
|
|
570 |
<i><string: destination path></i> specifies destination file name.
|
|
571 |
If <i><boolean: copy permissions></i> is true then copy source file permissions.
|
|
572 |
If <i><boolean: copy ownership></i> is true then copy source file UID and GID.</p>
|
|
573 |
|
|
574 |
<p>Reply:</p>
|
|
575 |
|
|
576 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
577 |
R • <i><token></i> • <i><error report></i> •
|
|
578 |
</font></b></pre>
|
|
579 |
|
|
580 |
<h3><a name='CmdUser'>user</a></h3>
|
|
581 |
|
|
582 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
583 |
C • <i><token></i> • FileSystem • user •
|
|
584 |
</font></b></pre>
|
|
585 |
|
|
586 |
<p>The command retrieves information about user account, which is used by server
|
|
587 |
to access file system on behalf of the client.</p>
|
|
588 |
|
|
589 |
<p>Reply:</p>
|
|
590 |
|
|
591 |
<pre><b><font face="Courier New" size=2 color=#333399>
|
|
592 |
R • <i><token></i> • <i><int: real UID></i> • <i><int: effective UID></i> •
|
|
593 |
<i><int: real GID></i> • <i><int: effective GID></i> • <i><string: home directory></i> •
|
|
594 |
</font></b></pre>
|
|
595 |
|
|
596 |
<h2><a name='API'>API</a></h2>
|
|
597 |
|
|
598 |
<pre>
|
|
599 |
<font color=#3F5FBF>/**
|
|
600 |
* File System service provides file transfer (and more generally file
|
|
601 |
* system access) functionality in TCF. The service design is
|
|
602 |
* derived from SSH File Transfer Protocol specifications.
|
|
603 |
*/</font>
|
|
604 |
<font color=#7F0055>public interface</font> IFileSystem <font color=#7F0055>extends</font> IService {
|
|
605 |
|
|
606 |
<font color=#3F5FBF>/**
|
|
607 |
* Service name.
|
|
608 |
*/</font>
|
|
609 |
<font color=#7F0055>static final</font> String NAME = "FileSystem";
|
|
610 |
|
|
611 |
<font color=#3F5FBF>/**
|
|
612 |
* Flags to be used with open() method.
|
|
613 |
*/</font>
|
|
614 |
<font color=#7F0055>static final int</font>
|
|
615 |
|
|
616 |
<font color=#3F5FBF>/**
|
|
617 |
* Open the file for reading.
|
|
618 |
*/</font>
|
|
619 |
TCF_O_READ = 0x00000001,
|
|
620 |
|
|
621 |
<font color=#3F5FBF>/**
|
|
622 |
* Open the file for writing. If both this and TCF_O_READ are
|
|
623 |
* specified, the file is opened for both reading and writing.
|
|
624 |
*/</font>
|
|
625 |
TCF_O_WRITE = 0x00000002,
|
|
626 |
|
|
627 |
<font color=#3F5FBF>/**
|
|
628 |
* Force all writes to append data at the end of the file.
|
|
629 |
*/</font>
|
|
630 |
TCF_O_APPEND = 0x00000004,
|
|
631 |
|
|
632 |
<font color=#3F5FBF>/**
|
|
633 |
* If this flag is specified, then a new file will be created if one
|
|
634 |
* does not already exist (if TCF_O_TRUNC is specified, the new file will
|
|
635 |
* be truncated to zero length if it previously exists).
|
|
636 |
*/</font>
|
|
637 |
TCF_O_CREAT = 0x00000008,
|
|
638 |
|
|
639 |
<font color=#3F5FBF>/**
|
|
640 |
* Forces an existing file with the same name to be truncated to zero
|
|
641 |
* length when creating a file by specifying TCF_O_CREAT.
|
|
642 |
* TCF_O_CREAT MUST also be specified if this flag is used.
|
|
643 |
*/</font>
|
|
644 |
TCF_O_TRUNC = 0x00000010,
|
|
645 |
|
|
646 |
<font color=#3F5FBF>/**
|
|
647 |
* Causes the request to fail if the named file already exists.
|
|
648 |
* TCF_O_CREAT MUST also be specified if this flag is used.
|
|
649 |
*/</font>
|
|
650 |
TCF_O_EXCL = 0x00000020;
|
|
651 |
|
|
652 |
<font color=#3F5FBF>/**
|
|
653 |
* Flags to be used together with FileAttrs.
|
|
654 |
* The flags specify which of the fields are present. Those fields
|
|
655 |
* for which the corresponding flag is not set are not present (not
|
|
656 |
* included in the message).
|
|
657 |
*/</font>
|
|
658 |
<font color=#7F0055>static final int</font>
|
|
659 |
ATTR_SIZE = 0x00000001,
|
|
660 |
ATTR_UIDGID = 0x00000002,
|
|
661 |
ATTR_PERMISSIONS = 0x00000004,
|
|
662 |
ATTR_ACMODTIME = 0x00000008;
|
|
663 |
|
|
664 |
<font color=#3F5FBF>/**
|
|
665 |
* FileAttrs is used both when returning file attributes from
|
|
666 |
* the server and when sending file attributes to the server. When
|
|
667 |
* sending it to the server, the flags field specifies which attributes
|
|
668 |
* are included, and the server will use default values for the
|
|
669 |
* remaining attributes (or will not modify the values of remaining
|
|
670 |
* attributes). When receiving attributes from the server, the flags
|
|
671 |
* specify which attributes are included in the returned data. The
|
|
672 |
* server normally returns all attributes it knows about.
|
|
673 |
*/</font>
|
|
674 |
<font color=#7F0055>final static class</font> FileAttrs {
|
|
675 |
|
|
676 |
<font color=#3F5FBF>/**
|
|
677 |
* The `flags' specify which of the fields are present.
|
|
678 |
*/</font>
|
|
679 |
<font color=#7F0055>public final int</font> flags;
|
|
680 |
|
|
681 |
<font color=#3F5FBF>/**
|
|
682 |
* The `size' field specifies the size of the file in bytes.
|
|
683 |
*/</font>
|
|
684 |
<font color=#7F0055>public final long</font> size;
|
|
685 |
|
|
686 |
<font color=#3F5FBF>/**
|
|
687 |
* The `uid' and `gid' fields contain numeric Unix-like user and group
|
|
688 |
* identifiers, respectively.
|
|
689 |
*/</font>
|
|
690 |
<font color=#7F0055>public final int</font> uid;
|
|
691 |
<font color=#7F0055>public final int</font> gid;
|
|
692 |
|
|
693 |
<font color=#3F5FBF>/**
|
|
694 |
* The `permissions' field contains a bit mask of file permissions as
|
|
695 |
* defined by posix [1].
|
|
696 |
*/</font>
|
|
697 |
<font color=#7F0055>public final int</font> permissions;
|
|
698 |
|
|
699 |
<font color=#3F5FBF>/**
|
|
700 |
* The `atime' and `mtime' contain the access and modification times of
|
|
701 |
* the files, respectively. They are represented as milliseconds from
|
|
702 |
* midnight Jan 1, 1970 in UTC.
|
|
703 |
*/</font>
|
|
704 |
<font color=#7F0055>public final long</font> atime;
|
|
705 |
<font color=#7F0055>public final long</font> mtime;
|
|
706 |
|
|
707 |
<font color=#3F5FBF>/**
|
|
708 |
* Additional (non-standard) attributes.
|
|
709 |
*/</font>
|
|
710 |
<font color=#7F0055>public final</font> Map<String,Object> attributes;
|
|
711 |
|
|
712 |
<font color=#7F0055>public</font> FileAttrs(<font color=#7F0055>int</font> flags, <font color=#7F0055>long</font> size, <font color=#7F0055>int</font> uid, <font color=#7F0055>int</font> gid,
|
|
713 |
<font color=#7F0055>int</font> permissions, <font color=#7F0055>long</font> atime, <font color=#7F0055>long</font> mtime, Map<String,Object> attributes);
|
|
714 |
|
|
715 |
<font color=#3F5FBF>/**
|
|
716 |
* Determines if the file system object is a file on the remote file system.
|
|
717 |
*
|
|
718 |
* @return true if and only if the object on the remote system can be considered to have "contents" that
|
|
719 |
* have the potential to be read and written as a byte stream.
|
|
720 |
*/</font>
|
|
721 |
<font color=#7F0055>public boolean</font> isFile();
|
|
722 |
|
|
723 |
<font color=#3F5FBF>/**
|
|
724 |
* Determines if the file system object is a directory on the remote file system.
|
|
725 |
*
|
|
726 |
* @return true if and only if the object on the remote system is a directory.
|
|
727 |
* That is, it contains entries that can be interpreted as other files.
|
|
728 |
*/</font>
|
|
729 |
<font color=#7F0055>public boolean</font> isDirectory();
|
|
730 |
}
|
|
731 |
|
|
732 |
<font color=#3F5FBF>/**
|
|
733 |
* The following flags are defined for the 'permissions' field:
|
|
734 |
*/</font>
|
|
735 |
<font color=#7F0055>static final int</font>
|
|
736 |
S_IFMT = 0170000, // bitmask for the file type bitfields
|
|
737 |
S_IFSOCK = 0140000, // socket
|
|
738 |
S_IFLNK = 0120000, // symbolic link
|
|
739 |
S_IFREG = 0100000, // regular file
|
|
740 |
S_IFBLK = 0060000, // block device
|
|
741 |
S_IFDIR = 0040000, // directory
|
|
742 |
S_IFCHR = 0020000, // character device
|
|
743 |
S_IFIFO = 0010000, // fifo
|
|
744 |
S_ISUID = 0004000, // set UID bit
|
|
745 |
S_ISGID = 0002000, // set GID bit (see below)
|
|
746 |
S_ISVTX = 0001000, // sticky bit (see below)
|
|
747 |
S_IRWXU = 00700, // mask for file owner permissions
|
|
748 |
S_IRUSR = 00400, // owner has read permission
|
|
749 |
S_IWUSR = 00200, // owner has write permission
|
|
750 |
S_IXUSR = 00100, // owner has execute permission
|
|
751 |
S_IRWXG = 00070, // mask for group permissions
|
|
752 |
S_IRGRP = 00040, // group has read permission
|
|
753 |
S_IWGRP = 00020, // group has write permission
|
|
754 |
S_IXGRP = 00010, // group has execute permission
|
|
755 |
S_IRWXO = 00007, // mask for permissions for others (not in group)
|
|
756 |
S_IROTH = 00004, // others have read permission
|
|
757 |
S_IWOTH = 00002, // others have write permisson
|
|
758 |
S_IXOTH = 00001; // others have execute permission
|
|
759 |
|
|
760 |
<font color=#7F0055>final static class</font> DirEntry {
|
|
761 |
<font color=#3F5FBF>/**
|
|
762 |
* `filename' is a file name being returned. It is a relative name within
|
|
763 |
* the directory, without any path components;
|
|
764 |
*/</font>
|
|
765 |
<font color=#7F0055>public final</font> String filename;
|
|
766 |
|
|
767 |
<font color=#3F5FBF>/**
|
|
768 |
* `longname' is an expanded format for the file name, similar to what
|
|
769 |
* is returned by "ls -l" on Unix systems.
|
|
770 |
* The format of the `longname' field is unspecified by this protocol.
|
|
771 |
* It MUST be suitable for use in the output of a directory listing
|
|
772 |
* command (in fact, the recommended operation for a directory listing
|
|
773 |
* command is to simply display this data). However, clients SHOULD NOT
|
|
774 |
* attempt to parse the longname field for file attributes; they SHOULD
|
|
775 |
* use the attrs field instead.
|
|
776 |
*/</font>
|
|
777 |
<font color=#7F0055>public final</font> String longname;
|
|
778 |
|
|
779 |
<font color=#3F5FBF>/**
|
|
780 |
* `attrs' is the attributes of the file.
|
|
781 |
*/</font>
|
|
782 |
<font color=#7F0055>public final</font> FileAttrs attrs;
|
|
783 |
|
|
784 |
<font color=#7F0055>public</font> DirEntry(String filename, String longname, FileAttrs attrs);
|
|
785 |
}
|
|
786 |
|
|
787 |
<font color=#3F5FBF>/**
|
|
788 |
* Opaque representation of open file handle.
|
|
789 |
* Note: open file handle can be used only with service instance that
|
|
790 |
* created the handle.
|
|
791 |
*/</font>
|
|
792 |
<font color=#7F0055>interface</font> IFileHandle {
|
|
793 |
IFileSystem getService();
|
|
794 |
}
|
|
795 |
|
|
796 |
<font color=#3F5FBF>/**
|
|
797 |
* Service specific error codes.
|
|
798 |
*/</font>
|
|
799 |
<font color=#7F0055>static final int</font>
|
|
800 |
|
|
801 |
<font color=#3F5FBF>/**
|
|
802 |
* Indicates end-of-file condition; for read() it means that no
|
|
803 |
* more data is available in the file, and for readdir() it
|
|
804 |
* indicates that no more files are contained in the directory.
|
|
805 |
*/</font>
|
|
806 |
STATUS_EOF = 0x10001,
|
|
807 |
|
|
808 |
<font color=#3F5FBF>/**
|
|
809 |
* This code is returned when a reference is made to a file which
|
|
810 |
* should exist but doesn't.
|
|
811 |
*/</font>
|
|
812 |
STATUS_NO_SUCH_FILE = 0x10002,
|
|
813 |
|
|
814 |
<font color=#3F5FBF>/**
|
|
815 |
* is returned when the authenticated user does not have sufficient
|
|
816 |
* permissions to perform the operation.
|
|
817 |
*/</font>
|
|
818 |
STATUS_PERMISSION_DENIED = 0x10003;
|
|
819 |
|
|
820 |
|
|
821 |
<font color=#3F5FBF>/**
|
|
822 |
* The class to represent File System error reports.
|
|
823 |
*/</font>
|
|
824 |
<font color=#7F0055>abstract static class</font> FileSystemException extends IOException {
|
|
825 |
|
|
826 |
<font color=#7F0055>protected</font> FileSystemException(String message);
|
|
827 |
|
|
828 |
<font color=#7F0055>protected</font> FileSystemException(Exception x)
|
|
829 |
|
|
830 |
<font color=#3F5FBF>/**
|
|
831 |
* Get error code. The code can be standard TCF error code or
|
|
832 |
* one of service specific codes, see STATUS_*.
|
|
833 |
* @return error code.
|
|
834 |
*/</font>
|
|
835 |
<font color=#7F0055>public abstract int</font> getStatus();
|
|
836 |
}
|
|
837 |
|
|
838 |
<font color=#3F5FBF>/**
|
|
839 |
* Open or create a file on a remote system.
|
|
840 |
*
|
|
841 |
* @param file_name specifies the file name. See 'File Names' for more information.
|
|
842 |
* @param flags is a bit mask of TCF_O_* flags.
|
|
843 |
* @param attrs specifies the initial attributes for the file.
|
|
844 |
* Default values will be used for those attributes that are not specified.
|
|
845 |
* @param done is call back object.
|
|
846 |
* @return pending command handle.
|
|
847 |
*/</font>
|
|
848 |
IToken open(String file_name, <font color=#7F0055>int</font> flags, FileAttrs attrs, DoneOpen done);
|
|
849 |
|
|
850 |
<font color=#7F0055>interface</font> DoneOpen {
|
|
851 |
<font color=#7F0055>void</font> doneOpen(IToken token, FileSystemException error, IFileHandle handle);
|
|
852 |
}
|
|
853 |
|
|
854 |
<font color=#3F5FBF>/**
|
|
855 |
* Close a file on a remote system.
|
|
856 |
*
|
|
857 |
* @param handle is a handle previously returned in the response to
|
|
858 |
* open() or opendir().
|
|
859 |
* @param done is call back object.
|
|
860 |
* @return pending command handle.
|
|
861 |
*/</font>
|
|
862 |
IToken close(IFileHandle handle, DoneClose done);
|
|
863 |
|
|
864 |
<font color=#7F0055>interface</font> DoneClose {
|
|
865 |
<font color=#7F0055>void</font> doneClose(IToken token, FileSystemException error);
|
|
866 |
}
|
|
867 |
|
|
868 |
<font color=#3F5FBF>/**
|
|
869 |
* Read bytes from an open file.
|
|
870 |
* In response to this request, the server will read as many bytes as it
|
|
871 |
* can from the file (up to `len'), and return them in a byte array.
|
|
872 |
* If an error occurs or EOF is encountered, the server may return
|
|
873 |
* fewer bytes then requested. Call back method doneRead() argument 'error'
|
|
874 |
* will be not null in case of error, and argument 'eof' will be
|
|
875 |
* true in case of EOF. For normal disk files, it is guaranteed
|
|
876 |
* that this will read the specified number of bytes, or up to end of file
|
|
877 |
* or error. For e.g. device files this may return fewer bytes than requested.
|
|
878 |
*
|
|
879 |
* @param handle is an open file handle returned by open().
|
|
880 |
* @param offset is the offset (in bytes) relative
|
|
881 |
* to the beginning of the file from where to start reading.
|
|
882 |
* @param len is the maximum number of bytes to read.
|
|
883 |
* @param done is call back object.
|
|
884 |
* @return pending command handle.
|
|
885 |
*/</font>
|
|
886 |
IToken read(IFileHandle handle, long offset, <font color=#7F0055>int</font> len, DoneRead done);
|
|
887 |
|
|
888 |
<font color=#7F0055>interface</font> DoneRead {
|
|
889 |
<font color=#7F0055>void</font> doneRead(IToken token, FileSystemException error, byte[] data, boolean eof);
|
|
890 |
}
|
|
891 |
|
|
892 |
<font color=#3F5FBF>/**
|
|
893 |
* Write bytes into an open file.
|
|
894 |
* The write will extend the file if writing beyond the end of the file.
|
|
895 |
* It is legal to write way beyond the end of the file; the semantics
|
|
896 |
* are to write zeroes from the end of the file to the specified offset
|
|
897 |
* and then the data.
|
|
898 |
*
|
|
899 |
* @param handle is an open file handle returned by open().
|
|
900 |
* @param offset is the offset (in bytes) relative
|
|
901 |
* to the beginning of the file from where to start writing.
|
|
902 |
* @param data is byte array that contains data for writing.
|
|
903 |
* @param data_pos if offset in 'data' of first byte to write.
|
|
904 |
* @param data_size is the number of bytes to write.
|
|
905 |
* @param done is call back object.
|
|
906 |
* @return pending command handle.
|
|
907 |
*/</font>
|
|
908 |
IToken write(IFileHandle handle, long offset,
|
|
909 |
byte[] data, <font color=#7F0055>int</font> data_pos, <font color=#7F0055>int</font> data_size, DoneWrite done);
|
|
910 |
|
|
911 |
<font color=#7F0055>interface</font> DoneWrite {
|
|
912 |
<font color=#7F0055>void</font> doneWrite(IToken token, FileSystemException error);
|
|
913 |
}
|
|
914 |
|
|
915 |
<font color=#3F5FBF>/**
|
|
916 |
* Retrieve file attributes.
|
|
917 |
*
|
|
918 |
* @param path - specifies the file system object for which
|
|
919 |
* status is to be returned.
|
|
920 |
* @param done is call back object.
|
|
921 |
* @return pending command handle.
|
|
922 |
*/</font>
|
|
923 |
IToken stat(String path, DoneStat done);
|
|
924 |
|
|
925 |
<font color=#3F5FBF>/**
|
|
926 |
* Retrieve file attributes.
|
|
927 |
* Unlike 'stat()', 'lstat()' does not follow symbolic links.
|
|
928 |
*
|
|
929 |
* @param path - specifies the file system object for which
|
|
930 |
* status is to be returned.
|
|
931 |
* @param done is call back object.
|
|
932 |
* @return pending command handle.
|
|
933 |
*/</font>
|
|
934 |
IToken lstat(String path, DoneStat done);
|
|
935 |
|
|
936 |
<font color=#3F5FBF>/**
|
|
937 |
* Retrieve file attributes for an open file (identified by the file handle).
|
|
938 |
*
|
|
939 |
* @param handle is a file handle returned by 'open()'.
|
|
940 |
* @param done is call back object.
|
|
941 |
* @return pending command handle.
|
|
942 |
*/</font>
|
|
943 |
IToken fstat(IFileHandle handle, DoneStat done);
|
|
944 |
|
|
945 |
<font color=#7F0055>interface</font> DoneStat {
|
|
946 |
<font color=#7F0055>void</font> doneStat(IToken token, FileSystemException error, FileAttrs attrs);
|
|
947 |
}
|
|
948 |
|
|
949 |
<font color=#3F5FBF>/**
|
|
950 |
* Set file attributes.
|
|
951 |
* This request is used for operations such as changing the ownership,
|
|
952 |
* permissions or access times, as well as for truncating a file.
|
|
953 |
* An error will be returned if the specified file system object does
|
|
954 |
* not exist or the user does not have sufficient rights to modify the
|
|
955 |
* specified attributes.
|
|
956 |
*
|
|
957 |
* @param path specifies the file system object (e.g. file or directory)
|
|
958 |
* whose attributes are to be modified.
|
|
959 |
* @param attrs specifies the modifications to be made to file attributes.
|
|
960 |
* @param done is call back object.
|
|
961 |
* @return pending command handle.
|
|
962 |
*/</font>
|
|
963 |
IToken setstat(String path, FileAttrs attrs, DoneSetStat done);
|
|
964 |
|
|
965 |
<font color=#3F5FBF>/**
|
|
966 |
* Set file attributes for an open file (identified by the file handle).
|
|
967 |
* This request is used for operations such as changing the ownership,
|
|
968 |
* permissions or access times, as well as for truncating a file.
|
|
969 |
*
|
|
970 |
* @param handle is a file handle returned by 'open()'.
|
|
971 |
* @param attrs specifies the modifications to be made to file attributes.
|
|
972 |
* @param done is call back object.
|
|
973 |
* @return pending command handle.
|
|
974 |
*/</font>
|
|
975 |
IToken fsetstat(IFileHandle handle, FileAttrs attrs, DoneSetStat done);
|
|
976 |
|
|
977 |
<font color=#7F0055>interface</font> DoneSetStat {
|
|
978 |
<font color=#7F0055>void</font> doneSetStat(IToken token, FileSystemException error);
|
|
979 |
}
|
|
980 |
|
|
981 |
<font color=#3F5FBF>/**
|
|
982 |
* The opendir() command opens a directory for reading.
|
|
983 |
* Once the directory has been successfully opened, files (and
|
|
984 |
* directories) contained in it can be listed using readdir() requests.
|
|
985 |
* When the client no longer wishes to read more names from the
|
|
986 |
* directory, it SHOULD call close() for the handle. The handle
|
|
987 |
* should be closed regardless of whether an error has occurred or not.
|
|
988 |
|
|
989 |
* @param path - name of the directory to be listed (without any trailing slash).
|
|
990 |
* @param done - result call back object.
|
|
991 |
* @return pending command handle.
|
|
992 |
*/</font>
|
|
993 |
IToken opendir(String path, DoneOpen done);
|
|
994 |
|
|
995 |
<font color=#3F5FBF>/**
|
|
996 |
* The files in a directory can be listed using the opendir() and
|
|
997 |
* readdir() requests. Each readdir() request returns one
|
|
998 |
* or more file names with full file attributes for each file. The
|
|
999 |
* client should call readdir() repeatedly until it has found the
|
|
1000 |
* file it is looking for or until the server responds with a
|
|
1001 |
* message indicating an error or end of file. The client should then
|
|
1002 |
* close the handle using the close() request.
|
|
1003 |
* Note: directory entries "." and ".." are NOT included into readdir()
|
|
1004 |
* response.
|
|
1005 |
* @param handle - file handle created by opendir()
|
|
1006 |
* @param done - result call back object.
|
|
1007 |
* @return pending command handle.
|
|
1008 |
*/</font>
|
|
1009 |
IToken readdir(IFileHandle handle, DoneReadDir done);
|
|
1010 |
|
|
1011 |
<font color=#7F0055>interface</font> DoneReadDir {
|
|
1012 |
<font color=#7F0055>void</font> doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof);
|
|
1013 |
}
|
|
1014 |
|
|
1015 |
<font color=#3F5FBF>/**
|
|
1016 |
* Create a directory on the server.
|
|
1017 |
*
|
|
1018 |
* @param path - specifies the directory to be created.
|
|
1019 |
* @param attrs - new directory attributes.
|
|
1020 |
* @param done - result call back object.
|
|
1021 |
* @return pending command handle.
|
|
1022 |
*/</font>
|
|
1023 |
IToken mkdir(String path, FileAttrs attrs, DoneMkDir done);
|
|
1024 |
|
|
1025 |
<font color=#7F0055>interface</font> DoneMkDir {
|
|
1026 |
<font color=#7F0055>void</font> doneMkDir(IToken token, FileSystemException error);
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
<font color=#3F5FBF>/**
|
|
1030 |
* Remove a directory.
|
|
1031 |
* An error will be returned if no directory
|
|
1032 |
* with the specified path exists, or if the specified directory is not
|
|
1033 |
* empty, or if the path specified a file system object other than a
|
|
1034 |
* directory.
|
|
1035 |
*
|
|
1036 |
* @param path - specifies the directory to be removed.
|
|
1037 |
* @param done - result call back object.
|
|
1038 |
* @return pending command handle.
|
|
1039 |
*/</font>
|
|
1040 |
IToken rmdir(String path, DoneRemove done);
|
|
1041 |
|
|
1042 |
<font color=#7F0055>interface</font> DoneRemove {
|
|
1043 |
<font color=#7F0055>void</font> doneRemove(IToken token, FileSystemException error);
|
|
1044 |
}
|
|
1045 |
|
|
1046 |
<font color=#3F5FBF>/**
|
|
1047 |
* Retrieve file system roots - top level file system objects.
|
|
1048 |
* UNIX file system can report just one root with path "/". Other types of systems
|
|
1049 |
* can have more the one root. For example, Windows server can return multiple roots:
|
|
1050 |
* one per disc (e.g. "/C:/", "/D:/", etc.). Note: even Windows implementation of
|
|
1051 |
* the service must use forward slash as directory separator, and must start
|
|
1052 |
* absolute path with "/". Server should implement proper translation of
|
|
1053 |
* protocol file names to OS native names and back.
|
|
1054 |
*
|
|
1055 |
* @param done - result call back object.
|
|
1056 |
* @return pending command handle.
|
|
1057 |
*/</font>
|
|
1058 |
IToken roots(DoneRoots done);
|
|
1059 |
|
|
1060 |
<font color=#7F0055>interface</font> DoneRoots {
|
|
1061 |
<font color=#7F0055>void</font> doneRoots(IToken token, FileSystemException error, DirEntry[] entries);
|
|
1062 |
}
|
|
1063 |
|
|
1064 |
<font color=#3F5FBF>/**
|
|
1065 |
* Remove a file or symbolic link.
|
|
1066 |
* This request cannot be used to remove directories.
|
|
1067 |
*
|
|
1068 |
* @param file_name is the name of the file to be removed.
|
|
1069 |
* @param done - result call back object.
|
|
1070 |
* @return pending command handle.
|
|
1071 |
*/</font>
|
|
1072 |
IToken remove(String file_name, DoneRemove done);
|
|
1073 |
|
|
1074 |
<font color=#3F5FBF>/**
|
|
1075 |
* Canonicalize any given path name to an absolute path.
|
|
1076 |
* This is useful for converting path names containing ".." components or
|
|
1077 |
* relative pathnames without a leading slash into absolute paths.
|
|
1078 |
*
|
|
1079 |
* @param path specifies the path name to be canonicalized.
|
|
1080 |
* @param done - result call back object.
|
|
1081 |
* @return pending command handle.
|
|
1082 |
*/</font>
|
|
1083 |
IToken realpath(String path, DoneRealPath done);
|
|
1084 |
|
|
1085 |
<font color=#7F0055>interface</font> DoneRealPath {
|
|
1086 |
<font color=#7F0055>void</font> doneRealPath(IToken token, FileSystemException error, String path);
|
|
1087 |
}
|
|
1088 |
|
|
1089 |
<font color=#3F5FBF>/**
|
|
1090 |
* Rename a file.
|
|
1091 |
* It is an error if there already exists a file
|
|
1092 |
* with the name specified by 'new_path'. The server may also fail rename
|
|
1093 |
* requests in other situations, for example if `old_path' and `new_path'
|
|
1094 |
* point to different file systems on the server.
|
|
1095 |
*
|
|
1096 |
* @param old_path is the name of an existing file or directory.
|
|
1097 |
* @param new_path is the new name for the file or directory.
|
|
1098 |
* @param done - result call back object.
|
|
1099 |
* @return pending command handle.
|
|
1100 |
*/</font>
|
|
1101 |
IToken rename(String old_path, String new_path, DoneRename done);
|
|
1102 |
|
|
1103 |
<font color=#7F0055>interface</font> DoneRename {
|
|
1104 |
<font color=#7F0055>void</font> doneRename(IToken token, FileSystemException error);
|
|
1105 |
}
|
|
1106 |
|
|
1107 |
<font color=#3F5FBF>/**
|
|
1108 |
* Read the target of a symbolic link.
|
|
1109 |
*
|
|
1110 |
* @param path specifies the path name of the symbolic link to be read.
|
|
1111 |
* @param done - result call back object.
|
|
1112 |
* @return pending command handle.
|
|
1113 |
*/</font>
|
|
1114 |
IToken readlink(String path, DoneReadLink done);
|
|
1115 |
|
|
1116 |
<font color=#7F0055>interface</font> DoneReadLink {
|
|
1117 |
<font color=#7F0055>void</font> doneReadLink(IToken token, FileSystemException error, String path);
|
|
1118 |
}
|
|
1119 |
|
|
1120 |
<font color=#3F5FBF>/**
|
|
1121 |
* Create a symbolic link on the server.
|
|
1122 |
*
|
|
1123 |
* @param link_path specifies the path name of the symbolic link to be created.
|
|
1124 |
* @param target_path specifies the target of the symbolic link.
|
|
1125 |
* @param done - result call back object.
|
|
1126 |
* @return pending command handle.
|
|
1127 |
*/</font>
|
|
1128 |
IToken symlink(String link_path, String target_path, DoneSymLink done);
|
|
1129 |
|
|
1130 |
<font color=#7F0055>interface</font> DoneSymLink {
|
|
1131 |
<font color=#7F0055>void</font> doneSymLink(IToken token, FileSystemException error);
|
|
1132 |
}
|
|
1133 |
|
|
1134 |
<font color=#3F5FBF>/**
|
|
1135 |
* Copy a file on remote system.
|
|
1136 |
*
|
|
1137 |
* @param src_path specifies the path name of the file to be copied.
|
|
1138 |
* @param dst_path specifies destination file name.
|
|
1139 |
* @param copy_permissions - if true then copy source file permissions.
|
|
1140 |
* @param copy_ownership - if true then copy source file UID and GID.
|
|
1141 |
* @param done - result call back object.
|
|
1142 |
* @return pending command handle.
|
|
1143 |
*/</font>
|
|
1144 |
IToken copy(String src_path, String dst_path,
|
|
1145 |
boolean copy_permissions, boolean copy_ownership, DoneCopy done);
|
|
1146 |
|
|
1147 |
<font color=#7F0055>interface</font> DoneCopy {
|
|
1148 |
<font color=#7F0055>void</font> doneCopy(IToken token, FileSystemException error);
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
<font color=#3F5FBF>/**
|
|
1152 |
* Retrieve information about user account, which is used by server
|
|
1153 |
* to access file system on behalf of the client.
|
|
1154 |
*
|
|
1155 |
* @param done - result call back object.
|
|
1156 |
* @return pending command handle.
|
|
1157 |
*/</font>
|
|
1158 |
IToken user(DoneUser done);
|
|
1159 |
|
|
1160 |
<font color=#7F0055>interface</font> DoneUser {
|
|
1161 |
<font color=#7F0055>void</font> doneUser(IToken token, FileSystemException error,
|
|
1162 |
<font color=#7F0055>int</font> real_uid, <font color=#7F0055>int</font> effective_uid, <font color=#7F0055>int</font> real_gid, <font color=#7F0055>int</font> effective_gid,
|
|
1163 |
String home);
|
|
1164 |
}
|
|
1165 |
}
|
|
1166 |
</pre>
|
|
1167 |
|
|
1168 |
</body>
|
|
1169 |
</html>
|
|
1170 |
|
|
1171 |
|