root/xfs/xfs_message.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. xfs_cred
  2. xfs_handle
  3. xfs_cache_handle

    1 /*
    2  * Copyright (c) 1995 - 2002 Kungliga Tekniska Högskolan
    3  * (Royal Institute of Technology, Stockholm, Sweden).
    4  * All rights reserved.
    5  * 
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 
   17  * 3. Neither the name of the Institute nor the names of its contributors
   18  *    may be used to endorse or promote products derived from this software
   19  *    without specific prior written permission.
   20  * 
   21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
   22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
   25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   31  * SUCH DAMAGE.
   32  */
   33 
   34 /* $arla: xfs_message.h,v 1.55 2002/09/27 09:43:21 lha Exp $ */
   35 
   36 #ifndef _xmsg_h
   37 #define _xmsg_h
   38 
   39 /* bump this for any incompatible changes */
   40 
   41 #define NNPFS_VERSION 18
   42 
   43 #include <xfs/xfs_attr.h>
   44 
   45 /* Temporary hack? */
   46 #define MAX_XMSG_SIZE (1024*64)
   47 
   48 typedef uint32_t xfs_pag_t;
   49 
   50 /*
   51  * The xfs_cred, if pag == 0, use uid 
   52  */
   53 typedef struct xfs_cred {
   54     uint32_t uid;
   55     xfs_pag_t pag;
   56 } xfs_cred;
   57 
   58 typedef uint32_t xfs_locktype_t;
   59 typedef uint32_t xfs_lockid_t;
   60 
   61 
   62 #define MAXHANDLE (4*4)
   63 #define MAXRIGHTS 8
   64 
   65 #define NNPFS_ANONYMOUSID 32766
   66 
   67 typedef struct xfs_handle {
   68     uint32_t a, b, c, d;
   69 } xfs_handle;
   70 
   71 #define xfs_handle_eq(p, q) \
   72 ((p)->a == (q)->a && (p)->b == (q)->b && (p)->c == (q)->c && (p)->d == (q)->d)
   73 
   74 /*
   75  * This should be the maximum size of any `file handle'
   76  */
   77 
   78 #define CACHEHANDLESIZE 80
   79 
   80 typedef struct xfs_cache_handle {
   81     u_char data[CACHEHANDLESIZE];
   82 } xfs_cache_handle;
   83 
   84 /*
   85  * Tokens that apply to nodes, open modes and attributes. Shared
   86  * reading might be used for exec and exclusive write for remove.
   87  */
   88 #define NNPFS_OPEN_MASK 0x000f
   89 #define NNPFS_OPEN_NR   0x0001         /* Normal reading, data might change */
   90 #define NNPFS_OPEN_SR   0x0002         /* Shared reading, data won't change */
   91 #define NNPFS_OPEN_NW   0x0004         /* Normal writing, multiple writers */
   92 #define NNPFS_OPEN_EW   0x0008         /* Exclusive writing (open really) */
   93 
   94 #define NNPFS_ATTR_MASK 0x0030
   95 #define NNPFS_ATTR_R    0x0010         /* Attributes valid */
   96 #define NNPFS_ATTR_W    0x0020         /* Attributes valid and modifiable */
   97 
   98 /*
   99  * Tokens that apply to node data.
  100  */
  101 #define NNPFS_DATA_MASK 0x00c0
  102 #define NNPFS_DATA_R    0x0040         /* Data valid */
  103 #define NNPFS_DATA_W    0x0080         /* Data valid and modifiable */
  104 #define NNPFS_LOCK_MASK 0x0300
  105 #define NNPFS_LOCK_R    0x0100         /* Data Shared locks */
  106 #define NNPFS_LOCK_W    0x0200         /* Data Exclusive locks */
  107 
  108 #define NNPFS_ATTR_VALID                NNPFS_ATTR_R
  109 #define NNPFS_DATA_VALID                NNPFS_DATA_W
  110 
  111 /* xfs_node.flags
  112  * The lower 16 bit flags are reserved for common xfs flags
  113  * The upper 16 bit flags are reserved for operating system dependent
  114  * flags.
  115  */
  116 
  117 #define NNPFS_DATA_DIRTY        0x0001
  118 #define NNPFS_ATTR_DIRTY        0x0002
  119 #define NNPFS_AFSDIR            0x0004
  120 #define NNPFS_STALE             0x0008
  121 #define NNPFS_XDELETED          0x0010
  122 #define NNPFS_VMOPEN            0x0020
  123 
  124 /*
  125  * Token match macros, NNPFS_TOKEN_GOT is depricated and
  126  * NNPFS_TOKEN_GOT_* should be used instead.
  127  */
  128 
  129 /* Are necessary tokens available? */
  130 #define NNPFS_TOKEN_GOT(xn, tok)      ((xn)->tokens & (tok))          /* deprecated */
  131 #define NNPFS_TOKEN_GOT_ANY(xn, tok)  ((xn)->tokens & (tok))          /* at least one must match */
  132 #define NNPFS_TOKEN_GOT_ALL(xn, tok)  (((xn)->tokens & (tok)) == (tok)) /* all tokens must match */
  133 #define NNPFS_TOKEN_SET(xn, tok, mask)  ((xn)->tokens |= ((tok) & (mask)))
  134 #define NNPFS_TOKEN_CLEAR(xn, tok, mask)        ((xn)->tokens &= ~((tok) & (mask)))
  135 
  136 /* definitions for the rights fields */
  137 #define NNPFS_RIGHT_R   0x01            /* may read? */
  138 #define NNPFS_RIGHT_W   0x02            /* may write? */
  139 #define NNPFS_RIGHT_X   0x04            /* may execute? */
  140 
  141 /* Max name length passed in xfs messages */
  142 
  143 #define NNPFS_MAX_NAME 256
  144 #define NNPFS_MAX_SYMLINK_CONTENT 2048
  145 
  146 struct xfs_msg_node {
  147     xfs_handle handle;
  148     uint32_t tokens;
  149     uint32_t pad1;
  150     struct xfs_attr attr;
  151     xfs_pag_t id[MAXRIGHTS];
  152     u_char rights[MAXRIGHTS];
  153     u_char anonrights;
  154     uint16_t pad2;
  155     uint32_t pad3;
  156 };
  157 
  158 /*
  159  * Messages passed through the  xfs_dev.
  160  */
  161 struct xfs_message_header {
  162   uint32_t size;
  163   uint32_t opcode;
  164   uint32_t sequence_num;                /* Private */
  165   uint32_t pad1;
  166 };
  167 
  168 /*
  169  * Used by putdata flag
  170  */
  171 enum { NNPFS_READ     = 0x01,
  172        NNPFS_WRITE    = 0x02,
  173        NNPFS_NONBLOCK = 0x04,
  174        NNPFS_APPEND   = 0x08,
  175        NNPFS_FSYNC    = 0x10};
  176 
  177 /*
  178  * Flags for inactivenode
  179  */
  180 enum { NNPFS_NOREFS = 1, NNPFS_DELETE = 2 };
  181 
  182 /*
  183  * Flags for installdata
  184  */
  185 
  186 enum { NNPFS_ID_INVALID_DNLC = 0x01, NNPFS_ID_AFSDIR = 0x02,
  187        NNPFS_ID_HANDLE_VALID = 0x04 };
  188 
  189 /*
  190  * Defined message types and their opcodes.
  191  */
  192 #define NNPFS_MSG_VERSION               0
  193 #define NNPFS_MSG_WAKEUP                1
  194 
  195 #define NNPFS_MSG_GETROOT               2
  196 #define NNPFS_MSG_INSTALLROOT   3
  197 
  198 #define NNPFS_MSG_GETNODE               4
  199 #define NNPFS_MSG_INSTALLNODE   5
  200 
  201 #define NNPFS_MSG_GETATTR               6
  202 #define NNPFS_MSG_INSTALLATTR   7
  203 
  204 #define NNPFS_MSG_GETDATA               8
  205 #define NNPFS_MSG_INSTALLDATA   9
  206 
  207 #define NNPFS_MSG_INACTIVENODE  10
  208 #define NNPFS_MSG_INVALIDNODE   11
  209                 /* XXX Must handle dropped/revoked tokens better */
  210 
  211 #define NNPFS_MSG_OPEN          12
  212 
  213 #define NNPFS_MSG_PUTDATA               13
  214 #define NNPFS_MSG_PUTATTR               14
  215 
  216 /* Directory manipulating messages. */
  217 #define NNPFS_MSG_CREATE                15
  218 #define NNPFS_MSG_MKDIR         16
  219 #define NNPFS_MSG_LINK          17
  220 #define NNPFS_MSG_SYMLINK               18
  221 
  222 #define NNPFS_MSG_REMOVE                19
  223 #define NNPFS_MSG_RMDIR         20
  224 
  225 #define NNPFS_MSG_RENAME                21
  226 
  227 #define NNPFS_MSG_PIOCTL                22
  228 #define NNPFS_MSG_WAKEUP_DATA   23
  229 
  230 #define NNPFS_MSG_UPDATEFID     24
  231 
  232 #define NNPFS_MSG_ADVLOCK               25
  233 
  234 #define NNPFS_MSG_GC_NODES      26
  235 
  236 #define NNPFS_MSG_COUNT         27
  237 
  238 /* NNPFS_MESSAGE_VERSION */
  239 struct xfs_message_version {
  240   struct xfs_message_header header;
  241   uint32_t ret;
  242 };
  243 
  244 /* NNPFS_MESSAGE_WAKEUP */
  245 struct xfs_message_wakeup {
  246   struct xfs_message_header header;
  247   uint32_t sleepers_sequence_num;       /* Where to send wakeup */
  248   uint32_t error;                       /* Return value */
  249 };
  250 
  251 /* NNPFS_MESSAGE_GETROOT */
  252 struct xfs_message_getroot {
  253   struct xfs_message_header header;
  254   struct xfs_cred cred;
  255 };
  256 
  257 /* NNPFS_MESSAGE_INSTALLROOT */
  258 struct xfs_message_installroot {
  259   struct xfs_message_header header;
  260   struct xfs_msg_node node;
  261 };
  262 
  263 /* NNPFS_MESSAGE_GETNODE */
  264 struct xfs_message_getnode {
  265   struct xfs_message_header header;
  266   struct xfs_cred cred;
  267   xfs_handle parent_handle;
  268   char name[NNPFS_MAX_NAME];
  269 };
  270 
  271 /* NNPFS_MESSAGE_INSTALLNODE */
  272 struct xfs_message_installnode {
  273   struct xfs_message_header header;
  274   xfs_handle parent_handle;
  275   char name[NNPFS_MAX_NAME];
  276   struct xfs_msg_node node;
  277 };
  278 
  279 /* NNPFS_MESSAGE_GETATTR */
  280 struct xfs_message_getattr {
  281   struct xfs_message_header header;
  282   struct xfs_cred cred;
  283   xfs_handle handle;
  284 };
  285 
  286 /* NNPFS_MESSAGE_INSTALLATTR */
  287 struct xfs_message_installattr {
  288   struct xfs_message_header header;
  289   struct xfs_msg_node node;
  290 };
  291 
  292 /* NNPFS_MESSAGE_GETDATA */
  293 struct xfs_message_getdata {
  294   struct xfs_message_header header;
  295   struct xfs_cred cred;
  296   xfs_handle handle;
  297   uint32_t tokens;
  298   uint32_t pad1;
  299   uint32_t offset;
  300   uint32_t pad2;
  301 };
  302 
  303 /* NNPFS_MESSAGE_INSTALLDATA */
  304 struct xfs_message_installdata {
  305   struct xfs_message_header header;
  306   struct xfs_msg_node node;
  307   char cache_name[NNPFS_MAX_NAME];
  308   struct xfs_cache_handle cache_handle;
  309   uint32_t flag;
  310   uint32_t pad1;
  311   uint32_t offset;
  312   uint32_t pad2;
  313 };
  314 
  315 /* NNPFS_MSG_INACTIVENODE */
  316 struct xfs_message_inactivenode {
  317   struct xfs_message_header header;
  318   xfs_handle handle;
  319   uint32_t flag;
  320   uint32_t pad1;
  321 };
  322 
  323 /* NNPFS_MSG_INVALIDNODE */
  324 struct xfs_message_invalidnode {
  325   struct xfs_message_header header;
  326   xfs_handle handle;
  327 };
  328 
  329 /* NNPFS_MSG_OPEN */
  330 struct xfs_message_open {
  331   struct xfs_message_header header;
  332   struct xfs_cred cred;
  333   xfs_handle handle;
  334   uint32_t tokens;
  335   uint32_t pad1;
  336 };
  337 
  338 /* NNPFS_MSG_PUTDATA */
  339 struct xfs_message_putdata {
  340   struct xfs_message_header header;
  341   xfs_handle handle;
  342   struct xfs_attr attr;         /* XXX ??? */
  343   struct xfs_cred cred;
  344   uint32_t flag;
  345   uint32_t pad1;
  346 };
  347 
  348 /* NNPFS_MSG_PUTATTR */
  349 struct xfs_message_putattr {
  350   struct xfs_message_header header;
  351   xfs_handle handle;
  352   struct xfs_attr attr;
  353   struct xfs_cred cred;
  354 };
  355 
  356 /* NNPFS_MSG_CREATE */
  357 struct xfs_message_create {
  358   struct xfs_message_header header;
  359   xfs_handle parent_handle;
  360   char name[NNPFS_MAX_NAME];
  361   struct xfs_attr attr;
  362   uint32_t mode;
  363   uint32_t pad1;
  364   struct xfs_cred cred;
  365 };
  366 
  367 /* NNPFS_MSG_MKDIR */
  368 struct xfs_message_mkdir {
  369   struct xfs_message_header header;
  370   xfs_handle parent_handle;
  371   char name[NNPFS_MAX_NAME];
  372   struct xfs_attr attr;
  373   struct xfs_cred cred;
  374 };
  375 
  376 /* NNPFS_MSG_LINK */
  377 struct xfs_message_link {
  378   struct xfs_message_header header;
  379   xfs_handle parent_handle;
  380   char name[NNPFS_MAX_NAME];
  381   xfs_handle from_handle;
  382   struct xfs_cred cred;
  383 };
  384 
  385 /* NNPFS_MSG_SYMLINK */
  386 struct xfs_message_symlink {
  387   struct xfs_message_header header;
  388   xfs_handle parent_handle;
  389   char name[NNPFS_MAX_NAME];
  390   char contents[NNPFS_MAX_SYMLINK_CONTENT];
  391   struct xfs_attr attr;
  392   struct xfs_cred cred;
  393 };
  394 
  395 /* NNPFS_MSG_REMOVE */
  396 struct xfs_message_remove {
  397   struct xfs_message_header header;
  398   xfs_handle parent_handle;
  399   char name[NNPFS_MAX_NAME];
  400   struct xfs_cred cred;
  401 };
  402 
  403 /* NNPFS_MSG_RMDIR */
  404 struct xfs_message_rmdir {
  405   struct xfs_message_header header;
  406   xfs_handle parent_handle;
  407   char name[NNPFS_MAX_NAME];
  408   struct xfs_cred cred;
  409 };
  410 
  411 /* NNPFS_MSG_RENAME */
  412 struct xfs_message_rename {
  413   struct xfs_message_header header;
  414   xfs_handle old_parent_handle;
  415   char old_name[NNPFS_MAX_NAME];
  416   xfs_handle new_parent_handle;
  417   char new_name[NNPFS_MAX_NAME];
  418   struct xfs_cred cred;
  419 };
  420 
  421 #define NNPFS_MSG_MAX_DATASIZE  2048
  422 
  423 /* NNPFS_MSG_PIOCTL */
  424 struct xfs_message_pioctl {
  425   struct xfs_message_header header;
  426   uint32_t opcode ;
  427   uint32_t pad1;
  428   xfs_cred cred;
  429   uint32_t insize;
  430   uint32_t outsize;
  431   char msg[NNPFS_MSG_MAX_DATASIZE];
  432   xfs_handle handle;
  433 };
  434 
  435 
  436 /* NNPFS_MESSAGE_WAKEUP_DATA */
  437 struct xfs_message_wakeup_data {
  438   struct xfs_message_header header;
  439   uint32_t sleepers_sequence_num;       /* Where to send wakeup */
  440   uint32_t error;                       /* Return value */
  441   uint32_t len;
  442   uint32_t pad1;
  443   char msg[NNPFS_MSG_MAX_DATASIZE];
  444 };
  445 
  446 /* NNPFS_MESSAGE_UPDATEFID */
  447 struct xfs_message_updatefid {
  448   struct xfs_message_header header;
  449   xfs_handle old_handle;
  450   xfs_handle new_handle;
  451 };
  452 
  453 /* NNPFS_MESSAGE_ADVLOCK */
  454 struct xfs_message_advlock {
  455   struct xfs_message_header header;
  456   xfs_handle handle;
  457   struct xfs_cred cred;
  458   xfs_locktype_t locktype;
  459 #define NNPFS_WR_LOCK 1 /* Write lock */
  460 #define NNPFS_RD_LOCK 2 /* Read lock */
  461 #define NNPFS_UN_LOCK 3 /* Unlock */
  462 #define NNPFS_BR_LOCK 4 /* Break lock (inform that we don't want the lock) */
  463   xfs_lockid_t lockid;
  464 };
  465 
  466 /* NNPFS_MESSAGE_GC_NODES */
  467 struct xfs_message_gc_nodes {
  468   struct xfs_message_header header;
  469 #define NNPFS_GC_NODES_MAX_HANDLE 50
  470   uint32_t len;
  471   uint32_t pad1;
  472   xfs_handle handle[NNPFS_GC_NODES_MAX_HANDLE];
  473 };
  474 
  475 #if 0 
  476 struct xfs_name {
  477     u_int16_t name;
  478     char name[1];
  479 };
  480 #endif
  481 
  482 struct xfs_message_bulkgetnode {
  483   struct xfs_message_header header;
  484   xfs_handle parent_handle;
  485   uint32_t flags;
  486 #define NNPFS_BGN_LAZY          0x1
  487   uint32_t numnodes;
  488   struct xfs_handle handles[1];
  489 };
  490 
  491 #endif /* _xmsg_h */

/* [<][>][^][v][top][bottom][index][help] */