1/*
2 * Copyright (c) 2010, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10interface trivfs "Trivial file system interface" {
11    typedef uint32 fh; // file handle type
12    typedef uint32 fsize; // file size type (4G ought to be enough ...!)
13    typedef uint32 offset; // offset type
14    typedef uint32 bulkid; // bulk-transfer buffer ID
15
16    // initialise shared memory used for bulk data transfer
17    rpc bulk_init(in cap frame, out errval err);
18
19    // get the file handle of the root directory
20    rpc getroot(out fh rootfh);
21
22    // read the name/type/size of the i'th entry in the given directory
23    // (yes, there's no protection against concurrent addition/deletion)
24    rpc readdir(in fh dir, in uint32 idx,
25                out errval err, out String name[2048], out bool isdir, out fsize size);
26
27    // look for a named entry in the given directory, return the fh if found
28    rpc lookup(in fh dir, in String name[2048],
29               out errval err, out fh fh, out bool isdir);
30
31    // return the type/size of the given fh
32    rpc getattr(in fh fh,
33                out errval err, out bool isdir, out fsize size);
34
35    // read/write: fairly straightforward
36    rpc read(in fh file, in offset offset, in fsize maxlen,
37             out errval err, out uint8 data[retlen, 2048]);
38    rpc write(in fh file, in offset offset, in uint8 data[len, 2048],
39              out errval err);
40
41    // read/write using bulk data
42    rpc read_bulk(in fh file, in offset offset, in fsize maxlen, in bulkid bulkid,
43                  out errval err, out fsize retlen);
44    rpc write_bulk(in fh file, in offset offset, in fsize len, in bulkid bulkid,
45                   out errval err);
46
47    // truncate (or extend with zero bytes)
48    rpc truncate(in fh file, in fsize newsize,
49                 out errval err);
50
51    // create a new file in the given directory, fail if it already exists
52    rpc create(in fh dir, in String name[2048],
53               out errval err, out fh fh);
54
55    // create a new subdirectory in the given directory
56    rpc mkdir(in fh dir, in String name[2048],
57              out errval err, out fh fh);
58
59    // delete a file or directory
60    rpc delete(in fh fh, out errval err);
61};
62