Annotation of researchv10no/netfs/libnetb/netb.h, revision 1.1.1.1

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