Annotation of researchv10dc/lsys/sys/netb.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * network filesystem protocol
                      3:  *
                      4:  * messages are character arrays,
                      5:  * encoding structures of characters,
                      6:  * two-byte shorts, and four-byte longs.
                      7:  * shorts and longs have a specific byte order,
                      8:  * and should be accessed through the macros below.
                      9:  */
                     10: 
                     11: /*
                     12:  * general numbers
                     13:  */
                     14: #define        NETB    2       /* protocol version */
                     15: #define        NBMAXMSG        (5*1024)        /* max message size */
                     16: #define        NBROOTTAG       0       /* i_tag assumed for the root */
                     17: 
                     18: 
                     19: /*
                     20:  * turn network numbers into host numbers
                     21:  * unsigned char *p
                     22:  */
                     23: #define        frnetlong(p, off)       (p[off+0]+(p[off+1]<<8)+((long)p[off+2]<<16)+((long)p[off+3]<<24))
                     24: #define        frnetshort(p, off)      (p[off+0]+(p[off+1]<<8))
                     25: #define        frnetchar(p, off)       p[off]
                     26: 
                     27: /*
                     28:  * turn host numbers to network numbers
                     29:  */
                     30: 
                     31: #define        tonetlong(p, off, l)    (p[off+0]=(l), p[off+1]=(l)>>8, p[off+2]=(l)>>16, p[off+3]=(l)>>24)
                     32: #define        tonetshort(p, off, s)   (p[off+0]=(s), p[off+1]=(s)>>8)
                     33: #define        tonetchar(p, off, c)    (p[off]=c)
                     34: 
                     35: /*
                     36:  * messages from client to server
                     37:  */
                     38: 
                     39: /*
                     40:  * general header
                     41:  */
                     42: 
                     43: #define        SNB_VERSION     0       /* (char) version */
                     44: #define        SNB_CMD         1       /* (char) command; see below */
                     45: #define        SNB_FLAGS       2       /* (char) mostly for nami */
                     46: /* one byte of padding */
                     47: #define        SNB_TRANNUM     4       /* (long) unique transaction ID */
                     48: #define        SNB_LEN         8       /* (long) including header and any data */
                     49: #define        SNB_TAG         12      /* (long) which file this is about */
                     50: #define        SNB_UID         16      /* (short) who wants to do IO */
                     51: #define        SNB_GID         18      /* (short) ditto */
                     52: /* four more bytes of junk */
                     53: #define        SNBSIZE         24
                     54: 
                     55: /*
                     56:  * commands
                     57:  */
                     58: #define        NBPUT   1       /* put file */
                     59: /* 2 was NAGET */
                     60: #define        NBUPD   3       /* update attributes */
                     61: #define        NBREAD  4       /* read data */
                     62: #define        NBWRT   5       /* write data */
                     63: #define        NBNAMI  6       /* translate name (with many side effects) */
                     64: #define        NBSTAT  7       /* read file status */
                     65: #define        NBIOCTL 8       /* ioctl */
                     66: #define        NBTRNC  9       /* truncate */
                     67: #define        NBDIR   10      /* directory read */
                     68: 
                     69: /*
                     70:  * flags, for namei sub-function code,
                     71:  * are defined in inode.h
                     72:  * should they be here too?
                     73:  */
                     74: 
                     75: /*
                     76:  * additional data for each command
                     77:  */
                     78: 
                     79: /*
                     80:  * update
                     81:  */
                     82: #define        SUP_MODE        (SNBSIZE+0)     /* (short) new mode */
                     83: /* two bytes for raw device (mknod) */
                     84: /* four bytes of junk */
                     85: #define        SUP_ATIME       (SNBSIZE+8)     /* (long) access time */
                     86: #define        SUP_MTIME       (SNBSIZE+12)    /* (long) mod time */
                     87: #define        SUPSIZE         (SNBSIZE+16)
                     88: 
                     89: /*
                     90:  * read, dirread
                     91:  */
                     92: #define        SRD_LEN         (SNBSIZE+0)     /* (long) how much to read */
                     93: #define        SRD_OFFSET      (SNBSIZE+4)     /* (long) file offset */
                     94: #define        SRDSIZE         (SNBSIZE+8)
                     95: 
                     96: /*
                     97:  * write
                     98:  */
                     99: #define        SWR_LEN         (SNBSIZE+0)     /* (long) how much to write */
                    100: #define        SWR_OFFSET      (SNBSIZE+4)     /* (long) where to write it */
                    101: #define        SWRSIZE         (SNBSIZE+8)
                    102: /* data to be written follows immediately */
                    103: 
                    104: /*
                    105:  * namei
                    106:  */
                    107: #define        SNM_MODE        (SNBSIZE+0)     /* (short) mode for creat */
                    108: #define        SNM_DEV         (SNBSIZE+2)     /* (short) device (mknod); used? */
                    109: #define        SNM_INO         (SNBSIZE+4)     /* (long) i-number, for link */
                    110: #define        SNMSIZE         (SNBSIZE+8)
                    111: /* name to be translated follows immediately */
                    112: 
                    113: /*
                    114:  * SNB_FLAGS: namei function codes
                    115:  * these must match the numbers in inode.h;
                    116:  * they are repeated here so the protocol
                    117:  * is all defined in one place
                    118:  */
                    119: #define NI_SEARCH 0    /* search only (0 value known to nilargnamei, beware) */
                    120: #define NI_DEL 1       /* unlink this file */
                    121: #define NI_CREAT 2     /* create it if it doesn't exits */
                    122: #define NI_NXCREAT 3   /* create it, error if it already exists */
                    123: #define NI_LINK        4       /* make a link */
                    124: #define NI_MKDIR 5     /* make a directory */
                    125: #define NI_RMDIR 6     /* remove a directory */
                    126: 
                    127: /*
                    128:  * stat
                    129:  */
                    130: #define        SST_TIME        (SNBSIZE+0)     /* (long) time, for synchronization */
                    131: /* four bytes of padding */
                    132: #define        SSTSIZE         (SNBSIZE+8)
                    133: 
                    134: /*
                    135:  * ioctl
                    136:  */
                    137: #define        SIO_CMD         (SNBSIZE+0)     /* (long) function code */
                    138: #define        SIO_FLAG        (SNBSIZE+4)     /* (short) file flags; silly? */
                    139: /* two bytes padding */
                    140: #define        SIOSIZE         (SNBSIZE+8)
                    141: #define        SIODATA         64              /* bytes of data follow */
                    142: /* does some ioctl data follow? */
                    143: 
                    144: /*
                    145:  * responses from server to client
                    146:  */
                    147: 
                    148: /*
                    149:  * general header
                    150:  */
                    151: #define        RNB_TRANNUM     0       /* (long) transaction ID */
                    152: #define        RNB_ERRNO       4       /* (short) error number; zero if OK */
                    153: #define        RNB_FLAGS       6       /* (char) see below */
                    154: /* one byte of pad */
                    155: #define        RNB_LEN         8       /* (long) including header and any data */
                    156: #define        RNB_FSIZE       12      /* (long) file size after write (why here?) */
                    157: #define        RNBSIZE         16
                    158: 
                    159: /*
                    160:  * flags
                    161:  */
                    162: #define        NBROOT  1       /* namei popped out of root */
                    163: #define        NBEND   2       /* last read was short, probably end of file */
                    164: 
                    165: /*
                    166:  * extra data for each type of response
                    167:  */
                    168: 
                    169: /*
                    170:  * read: no extra header info;
                    171:  * data follows at offset RNBSIZE
                    172:  */
                    173: 
                    174: /*
                    175:  * namei
                    176:  * contains an entire stat response
                    177:  * so sys stat sends one namei message and no stat message
                    178:  * not exactly a stat message, though: RNM_USED is in the middle
                    179:  */
                    180: 
                    181: #define        RNM_TAG         (RNBSIZE+0)     /* (long) new file */
                    182: #define        RNM_INO         (RNBSIZE+4)     /* (long) its i-number */
                    183: #define        RNM_DEV         (RNBSIZE+8)     /* (short) st_dev */
                    184: #define        RNM_MODE        (RNBSIZE+10)    /* (short) mode */
                    185: #define        RNM_USED        (RNBSIZE+12)    /* (long) filename chars consumed (NBROOT only) */
                    186: #define        RNM_NLINK       (RNBSIZE+16)    /* (short) */
                    187: #define        RNM_UID         (RNBSIZE+18)    /* (short) */
                    188: #define        RNM_GID         (RNBSIZE+20)    /* (short) */
                    189: #define        RNM_RDEV        (RNBSIZE+22)    /* (short) st_rdev; useful? */
                    190: #define        RNM_SIZE        (RNBSIZE+24)    /* (long) */
                    191: #define        RNM_ATIME       (RNBSIZE+28)    /* (long) */
                    192: #define        RNM_MTIME       (RNBSIZE+32)    /* (long) */
                    193: #define        RNM_CTIME       (RNBSIZE+36)    /* (long) */
                    194: #define        RNMSIZE         (RNBSIZE+40)
                    195: 
                    196: /*
                    197:  * stat
                    198:  */
                    199: #define        RST_INO         (RNBSIZE+0)     /* (long) i-number */
                    200: #define        RST_DEV         (RNBSIZE+4)     /* (short) st_dev */
                    201: #define        RST_MODE        (RNBSIZE+6)     /* (short) */
                    202: #define        RST_NLINK       (RNBSIZE+8)     /* (short) */
                    203: #define        RST_UID         (RNBSIZE+10)    /* (short) */
                    204: #define        RST_GID         (RNBSIZE+12)    /* (short) */
                    205: #define        RST_RDEV        (RNBSIZE+14)    /* (short) st_rdev; used? */
                    206: #define        RST_SIZE        (RNBSIZE+16)    /* (long) */
                    207: #define        RST_ATIME       (RNBSIZE+20)    /* (long) */
                    208: #define        RST_MTIME       (RNBSIZE+24)    /* (long) */
                    209: #define        RST_CTIME       (RNBSIZE+28)    /* (long) */
                    210: #define        RSTSIZE         (RNBSIZE+32)
                    211: 
                    212: /*
                    213:  * ioctl:
                    214:  * no header, just SIOSIZE bytes of ioctl data
                    215:  */
                    216: 
                    217: /*
                    218:  * dirread
                    219:  */
                    220: #define        RDI_USED        (RNBSIZE+0)     /* (long) advance file pointer this much */
                    221: /* four bytes of junk */
                    222: #define        RDISIZE         (RNBSIZE+8)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.