1/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
3 *
4 *  Copyright (C) 2001, 2002 Cluster File Systems, Inc.
5 *  Copyright (C) 2001 Tacit Networks, Inc.
6 *
7 *   This file is part of InterMezzo, http://www.inter-mezzo.org.
8 *
9 *   InterMezzo is free software; you can redistribute it and/or
10 *   modify it under the terms of version 2 of the GNU General Public
11 *   License as published by the Free Software Foundation.
12 *
13 *   InterMezzo is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with InterMezzo; if not, write to the Free Software
20 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#ifndef __INTERMEZZO_IDL_H__
24#define __INTERMEZZO_IDL_H__
25
26#include <linux/ioctl.h>
27#include <linux/types.h>
28
29/* this file contains all data structures used in InterMezzo's interfaces:
30 * - upcalls
31 * - ioctl's
32 * - KML records
33 * - RCVD records
34 * - rpc's
35 */
36
37/* UPCALL */
38#define INTERMEZZO_MINOR 248
39
40
41#define IZO_UPC_VERSION 0x00010002
42#define IZO_UPC_PERMIT        1
43#define IZO_UPC_CONNECT       2
44#define IZO_UPC_GO_FETCH_KML  3
45#define IZO_UPC_OPEN          4
46#define IZO_UPC_REVOKE_PERMIT 5
47#define IZO_UPC_KML           6
48#define IZO_UPC_BACKFETCH     7
49#define IZO_UPC_KML_TRUNC     8
50#define IZO_UPC_SET_KMLSIZE   9
51#define IZO_UPC_BRANCH_UNDO   10
52#define IZO_UPC_BRANCH_REDO   11
53#define IZO_UPC_GET_FILEID    12
54#define IZO_UPC_CLIENT_MAKE_BRANCH    13
55#define IZO_UPC_SERVER_MAKE_BRANCH    14
56#define IZO_UPC_REPSTATUS    15
57
58#define IZO_UPC_LARGEST_OPCODE 15
59
60struct izo_upcall_hdr {
61        __u32 u_len;
62        __u32 u_version;
63        __u32 u_opc;
64        __u32 u_uniq;
65        __u32 u_pid;
66        __u32 u_uid;
67        __u32 u_pathlen;
68        __u32 u_fsetlen;
69        __u64 u_offset;
70        __u64 u_length;
71        __u32 u_first_recno;
72        __u32 u_last_recno;
73        __u32 u_async;
74        __u32 u_reclen;
75        __u8  u_uuid[16];
76};
77
78/* This structure _must_ sit at the beginning of the buffer */
79struct izo_upcall_resp {
80        __u32 opcode;
81        __u32 unique;
82        __u32 result;
83};
84
85
86/* IOCTL */
87
88#define IZO_IOCTL_VERSION 0x00010003
89
90/* maximum size supported for ioc_pbuf1 */
91#define KML_MAX_BUF (64*1024)
92
93struct izo_ioctl_hdr {
94        __u32  ioc_len;
95        __u32  ioc_version;
96};
97
98struct izo_ioctl_data {
99        __u32 ioc_len;
100        __u32 ioc_version;
101        __u32 ioc_izodev;
102        __u32 ioc_kmlrecno;
103        __u64 ioc_kmlsize;
104        __u32 ioc_flags;
105        __s32 ioc_inofd;
106        __u64 ioc_ino;
107        __u64 ioc_generation;
108        __u32 ioc_mark_what;
109        __u32 ioc_and_flag;
110        __u32 ioc_or_flag;
111        __u32 ioc_dev;
112        __u32 ioc_offset;
113        __u32 ioc_slot;
114        __u64 ioc_uid;
115        __u8  ioc_uuid[16];
116
117        __u32 ioc_inllen1;   /* path */
118        char *ioc_inlbuf1;
119        __u32 ioc_inllen2;   /* fileset */
120        char *ioc_inlbuf2;
121
122        __u32 ioc_plen1;     /* buffers in user space (KML) */
123        char *ioc_pbuf1;
124        __u32 ioc_plen2;     /* buffers in user space (KML) */
125        char *ioc_pbuf2;
126
127        char  ioc_bulk[0];
128};
129
130#define IZO_IOC_DEVICE          _IOW ('p',0x50, void *)
131#define IZO_IOC_REINTKML        _IOW ('p',0x51, void *)
132#define IZO_IOC_GET_RCVD        _IOW ('p',0x52, void *)
133#define IZO_IOC_SET_IOCTL_UID   _IOW ('p',0x53, void *)
134#define IZO_IOC_GET_KML_SIZE    _IOW ('p',0x54, void *)
135#define IZO_IOC_PURGE_FILE_DATA _IOW ('p',0x55, void *)
136#define IZO_IOC_CONNECT         _IOW ('p',0x56, void *)
137#define IZO_IOC_GO_FETCH_KML    _IOW ('p',0x57, void *)
138#define IZO_IOC_MARK            _IOW ('p',0x58, void *)
139#define IZO_IOC_CLEAR_FSET      _IOW ('p',0x59, void *)
140#define IZO_IOC_CLEAR_ALL_FSETS _IOW ('p',0x60, void *)
141#define IZO_IOC_SET_FSET        _IOW ('p',0x61, void *)
142#define IZO_IOC_REVOKE_PERMIT   _IOW ('p',0x62, void *)
143#define IZO_IOC_SET_KMLSIZE     _IOW ('p',0x63, void *)
144#define IZO_IOC_CLIENT_MAKE_BRANCH _IOW ('p',0x64, void *)
145#define IZO_IOC_SERVER_MAKE_BRANCH _IOW ('p',0x65, void *)
146#define IZO_IOC_BRANCH_UNDO    _IOW ('p',0x66, void *)
147#define IZO_IOC_BRANCH_REDO    _IOW ('p',0x67, void *)
148#define IZO_IOC_SET_PID        _IOW ('p',0x68, void *)
149#define IZO_IOC_SET_CHANNEL    _IOW ('p',0x69, void *)
150#define IZO_IOC_GET_CHANNEL    _IOW ('p',0x70, void *)
151#define IZO_IOC_GET_FILEID    _IOW ('p',0x71, void *)
152#define IZO_IOC_ADJUST_LML    _IOW ('p',0x72, void *)
153#define IZO_IOC_SET_FILEID    _IOW ('p',0x73, void *)
154#define IZO_IOC_REPSTATUS    _IOW ('p',0x74, void *)
155
156/* marking flags for fsets */
157#define FSET_CLIENT_RO        0x00000001
158#define FSET_LENTO_RO         0x00000002
159#define FSET_HASPERMIT        0x00000004 /* we have a permit to WB */
160#define FSET_INSYNC           0x00000008 /* this fileset is in sync */
161#define FSET_PERMIT_WAITING   0x00000010 /* Lento is waiting for permit */
162#define FSET_STEAL_PERMIT     0x00000020 /* take permit if Lento is dead */
163#define FSET_JCLOSE_ON_WRITE  0x00000040 /* Journal closes on writes */
164#define FSET_DATA_ON_DEMAND   0x00000080 /* update data on file_open() */
165#define FSET_PERMIT_EXCLUSIVE 0x00000100 /* only one permitholder allowed */
166#define FSET_HAS_BRANCHES     0x00000200 /* this fileset contains branches */
167#define FSET_IS_BRANCH        0x00000400 /* this fileset is a branch */
168#define FSET_FLAT_BRANCH      0x00000800 /* this fileset is ROOT with branches */
169
170/* what to mark indicator (ioctl parameter) */
171#define MARK_DENTRY   101
172#define MARK_FSET     102
173#define MARK_CACHE    103
174#define MARK_GETFL    104
175
176/* KML */
177
178#define KML_MAJOR_VERSION 0x00010000
179#define KML_MINOR_VERSION 0x00000002
180#define KML_OPCODE_NOOP          0
181#define KML_OPCODE_CREATE        1
182#define KML_OPCODE_MKDIR         2
183#define KML_OPCODE_UNLINK        3
184#define KML_OPCODE_RMDIR         4
185#define KML_OPCODE_CLOSE         5
186#define KML_OPCODE_SYMLINK       6
187#define KML_OPCODE_RENAME        7
188#define KML_OPCODE_SETATTR       8
189#define KML_OPCODE_LINK          9
190#define KML_OPCODE_OPEN          10
191#define KML_OPCODE_MKNOD         11
192#define KML_OPCODE_WRITE         12
193#define KML_OPCODE_RELEASE       13
194#define KML_OPCODE_TRUNC         14
195#define KML_OPCODE_SETEXTATTR    15
196#define KML_OPCODE_DELEXTATTR    16
197#define KML_OPCODE_KML_TRUNC     17
198#define KML_OPCODE_GET_FILEID    18
199#define KML_OPCODE_NUM           19
200/* new stuff */
201struct presto_version {
202        __u64 pv_mtime;
203        __u64 pv_ctime;
204        __u64 pv_size;
205};
206
207struct kml_prefix_hdr {
208        __u32                    len;
209        __u32                    version;
210        __u32                    pid;
211        __u32                    auid;
212        __u32                    fsuid;
213        __u32                    fsgid;
214        __u32                    opcode;
215        __u32                    ngroups;
216};
217
218struct kml_prefix {
219        struct kml_prefix_hdr    *hdr;
220        __u32                    *groups;
221};
222
223struct kml_suffix {
224        __u32                    prevrec;
225        __u32                    recno;
226        __u32                    time;
227        __u32                    len;
228};
229
230struct kml_rec {
231        char                   *buf;
232        struct kml_prefix       prefix;
233        __u64                   offset;
234        char                   *path;
235        int                     pathlen;
236        char                   *name;
237        int                     namelen;
238        char                   *target;
239        int                     targetlen;
240        struct presto_version  *old_objectv;
241        struct presto_version  *new_objectv;
242        struct presto_version  *old_parentv;
243        struct presto_version  *new_parentv;
244        struct presto_version  *old_targetv;
245        struct presto_version  *new_targetv;
246        __u32                   valid;
247        __u32                   mode;
248        __u32                   uid;
249        __u32                   gid;
250        __u64                   size;
251        __u32                   mtime;
252        __u32                   ctime;
253        __u32                   flags;
254        __u32                   ino;
255        __u32                   rdev;
256        __u32                   major;
257        __u32                   minor;
258        __u32                   generation;
259        __u32                   old_mode;
260        __u32                   old_rdev;
261        __u64                   old_uid;
262        __u64                   old_gid;
263        char                   *old_target;
264        int                     old_targetlen;
265        struct kml_suffix      *suffix;
266};
267
268
269/* RCVD */
270
271/* izo_rcvd_rec fills the .intermezzo/fset/last_rcvd file and provides data about
272 * our view of reintegration offsets for a given peer.
273 *
274 * The only exception is the last_rcvd record which has a UUID consisting of all
275 * zeroes; this record's lr_local_offset field is the logical byte offset of our
276 * KML, which is updated when KML truncation takes place.  All other fields are
277 * reserved. */
278
279
280struct izo_rcvd_rec {
281        __u8    lr_uuid[16];       /* which peer? */
282        __u64   lr_remote_recno;   /* last confirmed remote recno  */
283        __u64   lr_remote_offset;  /* last confirmed remote offset */
284        __u64   lr_local_recno;    /* last locally reinted recno   */
285        __u64   lr_local_offset;   /* last locally reinted offset  */
286        __u64   lr_last_ctime;     /* the largest ctime that has reintegrated */
287};
288
289/* Cache purge database
290 *
291 * Each DB entry is this structure followed by the path name, no trailing NUL. */
292struct izo_purge_entry {
293        __u64 p_atime;
294        __u32 p_pathlen;
295};
296
297/* RPC */
298
299#endif
300