Annotation of 43BSDReno/usr.sbin/amd/rpcx/nfs_prot_xdr.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * $Id: nfs_prot_xdr.c,v 5.2 90/06/23 22:20:27 jsp Rel $
                      3:  *
                      4:  * Copyright (c) 1989 Jan-Simon Pendry
                      5:  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
                      6:  * Copyright (c) 1989 The Regents of the University of California.
                      7:  * All rights reserved.
                      8:  *
                      9:  * This code is derived from software contributed to Berkeley by
                     10:  * Jan-Simon Pendry at Imperial College, London.
                     11:  *
                     12:  * Redistribution and use in source and binary forms are permitted provided
                     13:  * that: (1) source distributions retain this entire copyright notice and
                     14:  * comment, and (2) distributions including binaries display the following
                     15:  * acknowledgement:  ``This product includes software developed by the
                     16:  * University of California, Berkeley and its contributors'' in the
                     17:  * documentation or other materials provided with the distribution and in
                     18:  * all advertising materials mentioning features or use of this software.
                     19:  * Neither the name of the University nor the names of its contributors may
                     20:  * be used to endorse or promote products derived from this software without
                     21:  * specific prior written permission.
                     22:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     23:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     24:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     25:  *
                     26:  *     @(#)nfs_prot_xdr.c      5.1 (Berkeley) 7/19/90
                     27:  */
                     28: 
                     29: #include "am.h"
                     30: 
                     31: 
                     32: #ifndef xdr_nfsstat
                     33: bool_t
                     34: xdr_nfsstat(xdrs, objp)
                     35:        XDR *xdrs;
                     36:        nfsstat *objp;
                     37: {
                     38:        if (!xdr_enum(xdrs, (enum_t *)objp)) {
                     39:                return (FALSE);
                     40:        }
                     41:        return (TRUE);
                     42: }
                     43: #endif /* xdr_nfsstat */
                     44: 
                     45: 
                     46: 
                     47: #ifndef xdr_ftype
                     48: static bool_t
                     49: xdr_ftype(xdrs, objp)
                     50:        XDR *xdrs;
                     51:        ftype *objp;
                     52: {
                     53:        if (!xdr_enum(xdrs, (enum_t *)objp)) {
                     54:                return (FALSE);
                     55:        }
                     56:        return (TRUE);
                     57: }
                     58: #endif /* xdr_ftype */
                     59: 
                     60: 
                     61: 
                     62: bool_t
                     63: xdr_nfs_fh(xdrs, objp)
                     64:        XDR *xdrs;
                     65:        nfs_fh *objp;
                     66: {
                     67:        if (!xdr_opaque(xdrs, objp->data, NFS_FHSIZE)) {
                     68:                return (FALSE);
                     69:        }
                     70:        return (TRUE);
                     71: }
                     72: 
                     73: 
                     74: 
                     75: 
                     76: static bool_t
                     77: xdr_nfstime(xdrs, objp)
                     78:        XDR *xdrs;
                     79:        nfstime *objp;
                     80: {
                     81:        if (!xdr_u_int(xdrs, &objp->seconds)) {
                     82:                return (FALSE);
                     83:        }
                     84:        if (!xdr_u_int(xdrs, &objp->useconds)) {
                     85:                return (FALSE);
                     86:        }
                     87:        return (TRUE);
                     88: }
                     89: 
                     90: 
                     91: 
                     92: 
                     93: static bool_t
                     94: xdr_fattr(xdrs, objp)
                     95:        XDR *xdrs;
                     96:        fattr *objp;
                     97: {
                     98:        if (!xdr_ftype(xdrs, &objp->type)) {
                     99:                return (FALSE);
                    100:        }
                    101:        if (!xdr_u_int(xdrs, &objp->mode)) {
                    102:                return (FALSE);
                    103:        }
                    104:        if (!xdr_u_int(xdrs, &objp->nlink)) {
                    105:                return (FALSE);
                    106:        }
                    107:        if (!xdr_u_int(xdrs, &objp->uid)) {
                    108:                return (FALSE);
                    109:        }
                    110:        if (!xdr_u_int(xdrs, &objp->gid)) {
                    111:                return (FALSE);
                    112:        }
                    113:        if (!xdr_u_int(xdrs, &objp->size)) {
                    114:                return (FALSE);
                    115:        }
                    116:        if (!xdr_u_int(xdrs, &objp->blocksize)) {
                    117:                return (FALSE);
                    118:        }
                    119:        if (!xdr_u_int(xdrs, &objp->rdev)) {
                    120:                return (FALSE);
                    121:        }
                    122:        if (!xdr_u_int(xdrs, &objp->blocks)) {
                    123:                return (FALSE);
                    124:        }
                    125:        if (!xdr_u_int(xdrs, &objp->fsid)) {
                    126:                return (FALSE);
                    127:        }
                    128:        if (!xdr_u_int(xdrs, &objp->fileid)) {
                    129:                return (FALSE);
                    130:        }
                    131:        if (!xdr_nfstime(xdrs, &objp->atime)) {
                    132:                return (FALSE);
                    133:        }
                    134:        if (!xdr_nfstime(xdrs, &objp->mtime)) {
                    135:                return (FALSE);
                    136:        }
                    137:        if (!xdr_nfstime(xdrs, &objp->ctime)) {
                    138:                return (FALSE);
                    139:        }
                    140:        return (TRUE);
                    141: }
                    142: 
                    143: 
                    144: 
                    145: 
                    146: static bool_t
                    147: xdr_sattr(xdrs, objp)
                    148:        XDR *xdrs;
                    149:        sattr *objp;
                    150: {
                    151:        if (!xdr_u_int(xdrs, &objp->mode)) {
                    152:                return (FALSE);
                    153:        }
                    154:        if (!xdr_u_int(xdrs, &objp->uid)) {
                    155:                return (FALSE);
                    156:        }
                    157:        if (!xdr_u_int(xdrs, &objp->gid)) {
                    158:                return (FALSE);
                    159:        }
                    160:        if (!xdr_u_int(xdrs, &objp->size)) {
                    161:                return (FALSE);
                    162:        }
                    163:        if (!xdr_nfstime(xdrs, &objp->atime)) {
                    164:                return (FALSE);
                    165:        }
                    166:        if (!xdr_nfstime(xdrs, &objp->mtime)) {
                    167:                return (FALSE);
                    168:        }
                    169:        return (TRUE);
                    170: }
                    171: 
                    172: 
                    173: 
                    174: 
                    175: static bool_t
                    176: xdr_filename(xdrs, objp)
                    177:        XDR *xdrs;
                    178:        filename *objp;
                    179: {
                    180:        if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
                    181:                return (FALSE);
                    182:        }
                    183:        return (TRUE);
                    184: }
                    185: 
                    186: 
                    187: 
                    188: 
                    189: bool_t
                    190: xdr_nfspath(xdrs, objp)
                    191:        XDR *xdrs;
                    192:        nfspath *objp;
                    193: {
                    194:        if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
                    195:                return (FALSE);
                    196:        }
                    197:        return (TRUE);
                    198: }
                    199: 
                    200: 
                    201: 
                    202: 
                    203: bool_t
                    204: xdr_attrstat(xdrs, objp)
                    205:        XDR *xdrs;
                    206:        attrstat *objp;
                    207: {
                    208:        if (!xdr_nfsstat(xdrs, &objp->status)) {
                    209:                return (FALSE);
                    210:        }
                    211:        switch (objp->status) {
                    212:        case NFS_OK:
                    213:                if (!xdr_fattr(xdrs, &objp->attrstat_u.attributes)) {
                    214:                        return (FALSE);
                    215:                }
                    216:                break;
                    217:        }
                    218:        return (TRUE);
                    219: }
                    220: 
                    221: 
                    222: 
                    223: 
                    224: bool_t
                    225: xdr_sattrargs(xdrs, objp)
                    226:        XDR *xdrs;
                    227:        sattrargs *objp;
                    228: {
                    229:        if (!xdr_nfs_fh(xdrs, &objp->file)) {
                    230:                return (FALSE);
                    231:        }
                    232:        if (!xdr_sattr(xdrs, &objp->attributes)) {
                    233:                return (FALSE);
                    234:        }
                    235:        return (TRUE);
                    236: }
                    237: 
                    238: 
                    239: 
                    240: 
                    241: bool_t
                    242: xdr_diropargs(xdrs, objp)
                    243:        XDR *xdrs;
                    244:        diropargs *objp;
                    245: {
                    246:        if (!xdr_nfs_fh(xdrs, &objp->dir)) {
                    247:                return (FALSE);
                    248:        }
                    249:        if (!xdr_filename(xdrs, &objp->name)) {
                    250:                return (FALSE);
                    251:        }
                    252:        return (TRUE);
                    253: }
                    254: 
                    255: 
                    256: 
                    257: 
                    258: bool_t
                    259: xdr_diropokres(xdrs, objp)
                    260:        XDR *xdrs;
                    261:        diropokres *objp;
                    262: {
                    263:        if (!xdr_nfs_fh(xdrs, &objp->file)) {
                    264:                return (FALSE);
                    265:        }
                    266:        if (!xdr_fattr(xdrs, &objp->attributes)) {
                    267:                return (FALSE);
                    268:        }
                    269:        return (TRUE);
                    270: }
                    271: 
                    272: 
                    273: 
                    274: 
                    275: bool_t
                    276: xdr_diropres(xdrs, objp)
                    277:        XDR *xdrs;
                    278:        diropres *objp;
                    279: {
                    280:        if (!xdr_nfsstat(xdrs, &objp->status)) {
                    281:                return (FALSE);
                    282:        }
                    283:        switch (objp->status) {
                    284:        case NFS_OK:
                    285:                if (!xdr_diropokres(xdrs, &objp->diropres_u.diropres)) {
                    286:                        return (FALSE);
                    287:                }
                    288:                break;
                    289:        }
                    290:        return (TRUE);
                    291: }
                    292: 
                    293: 
                    294: 
                    295: 
                    296: bool_t
                    297: xdr_readlinkres(xdrs, objp)
                    298:        XDR *xdrs;
                    299:        readlinkres *objp;
                    300: {
                    301:        if (!xdr_nfsstat(xdrs, &objp->status)) {
                    302:                return (FALSE);
                    303:        }
                    304:        switch (objp->status) {
                    305:        case NFS_OK:
                    306:                if (!xdr_nfspath(xdrs, &objp->readlinkres_u.data)) {
                    307:                        return (FALSE);
                    308:                }
                    309:                break;
                    310:        }
                    311:        return (TRUE);
                    312: }
                    313: 
                    314: 
                    315: 
                    316: 
                    317: bool_t
                    318: xdr_readargs(xdrs, objp)
                    319:        XDR *xdrs;
                    320:        readargs *objp;
                    321: {
                    322:        if (!xdr_nfs_fh(xdrs, &objp->file)) {
                    323:                return (FALSE);
                    324:        }
                    325:        if (!xdr_u_int(xdrs, &objp->offset)) {
                    326:                return (FALSE);
                    327:        }
                    328:        if (!xdr_u_int(xdrs, &objp->count)) {
                    329:                return (FALSE);
                    330:        }
                    331:        if (!xdr_u_int(xdrs, &objp->totalcount)) {
                    332:                return (FALSE);
                    333:        }
                    334:        return (TRUE);
                    335: }
                    336: 
                    337: 
                    338: 
                    339: 
                    340: bool_t
                    341: xdr_readokres(xdrs, objp)
                    342:        XDR *xdrs;
                    343:        readokres *objp;
                    344: {
                    345:        if (!xdr_fattr(xdrs, &objp->attributes)) {
                    346:                return (FALSE);
                    347:        }
                    348:        if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
                    349:                return (FALSE);
                    350:        }
                    351:        return (TRUE);
                    352: }
                    353: 
                    354: 
                    355: 
                    356: 
                    357: bool_t
                    358: xdr_readres(xdrs, objp)
                    359:        XDR *xdrs;
                    360:        readres *objp;
                    361: {
                    362:        if (!xdr_nfsstat(xdrs, &objp->status)) {
                    363:                return (FALSE);
                    364:        }
                    365:        switch (objp->status) {
                    366:        case NFS_OK:
                    367:                if (!xdr_readokres(xdrs, &objp->readres_u.reply)) {
                    368:                        return (FALSE);
                    369:                }
                    370:                break;
                    371:        }
                    372:        return (TRUE);
                    373: }
                    374: 
                    375: 
                    376: 
                    377: 
                    378: bool_t
                    379: xdr_writeargs(xdrs, objp)
                    380:        XDR *xdrs;
                    381:        writeargs *objp;
                    382: {
                    383:        if (!xdr_nfs_fh(xdrs, &objp->file)) {
                    384:                return (FALSE);
                    385:        }
                    386:        if (!xdr_u_int(xdrs, &objp->beginoffset)) {
                    387:                return (FALSE);
                    388:        }
                    389:        if (!xdr_u_int(xdrs, &objp->offset)) {
                    390:                return (FALSE);
                    391:        }
                    392:        if (!xdr_u_int(xdrs, &objp->totalcount)) {
                    393:                return (FALSE);
                    394:        }
                    395:        if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
                    396:                return (FALSE);
                    397:        }
                    398:        return (TRUE);
                    399: }
                    400: 
                    401: 
                    402: 
                    403: 
                    404: bool_t
                    405: xdr_createargs(xdrs, objp)
                    406:        XDR *xdrs;
                    407:        createargs *objp;
                    408: {
                    409:        if (!xdr_diropargs(xdrs, &objp->where)) {
                    410:                return (FALSE);
                    411:        }
                    412:        if (!xdr_sattr(xdrs, &objp->attributes)) {
                    413:                return (FALSE);
                    414:        }
                    415:        return (TRUE);
                    416: }
                    417: 
                    418: 
                    419: 
                    420: 
                    421: bool_t
                    422: xdr_renameargs(xdrs, objp)
                    423:        XDR *xdrs;
                    424:        renameargs *objp;
                    425: {
                    426:        if (!xdr_diropargs(xdrs, &objp->from)) {
                    427:                return (FALSE);
                    428:        }
                    429:        if (!xdr_diropargs(xdrs, &objp->to)) {
                    430:                return (FALSE);
                    431:        }
                    432:        return (TRUE);
                    433: }
                    434: 
                    435: 
                    436: 
                    437: 
                    438: bool_t
                    439: xdr_linkargs(xdrs, objp)
                    440:        XDR *xdrs;
                    441:        linkargs *objp;
                    442: {
                    443:        if (!xdr_nfs_fh(xdrs, &objp->from)) {
                    444:                return (FALSE);
                    445:        }
                    446:        if (!xdr_diropargs(xdrs, &objp->to)) {
                    447:                return (FALSE);
                    448:        }
                    449:        return (TRUE);
                    450: }
                    451: 
                    452: 
                    453: 
                    454: 
                    455: bool_t
                    456: xdr_symlinkargs(xdrs, objp)
                    457:        XDR *xdrs;
                    458:        symlinkargs *objp;
                    459: {
                    460:        if (!xdr_diropargs(xdrs, &objp->from)) {
                    461:                return (FALSE);
                    462:        }
                    463:        if (!xdr_nfspath(xdrs, &objp->to)) {
                    464:                return (FALSE);
                    465:        }
                    466:        if (!xdr_sattr(xdrs, &objp->attributes)) {
                    467:                return (FALSE);
                    468:        }
                    469:        return (TRUE);
                    470: }
                    471: 
                    472: 
                    473: 
                    474: 
                    475: static bool_t
                    476: xdr_nfscookie(xdrs, objp)
                    477:        XDR *xdrs;
                    478:        nfscookie objp;
                    479: {
                    480:        if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
                    481:                return (FALSE);
                    482:        }
                    483:        return (TRUE);
                    484: }
                    485: 
                    486: 
                    487: 
                    488: 
                    489: bool_t
                    490: xdr_readdirargs(xdrs, objp)
                    491:        XDR *xdrs;
                    492:        readdirargs *objp;
                    493: {
                    494:        if (!xdr_nfs_fh(xdrs, &objp->dir)) {
                    495:                return (FALSE);
                    496:        }
                    497:        if (!xdr_nfscookie(xdrs, objp->cookie)) {
                    498:                return (FALSE);
                    499:        }
                    500:        if (!xdr_u_int(xdrs, &objp->count)) {
                    501:                return (FALSE);
                    502:        }
                    503:        return (TRUE);
                    504: }
                    505: 
                    506: 
                    507: 
                    508: 
                    509: static bool_t
                    510: xdr_entry(xdrs, objp)
                    511:        XDR *xdrs;
                    512:        entry *objp;
                    513: {
                    514:        if (!xdr_u_int(xdrs, &objp->fileid)) {
                    515:                return (FALSE);
                    516:        }
                    517:        if (!xdr_filename(xdrs, &objp->name)) {
                    518:                return (FALSE);
                    519:        }
                    520:        if (!xdr_nfscookie(xdrs, objp->cookie)) {
                    521:                return (FALSE);
                    522:        }
                    523:        if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(entry), xdr_entry)) {
                    524:                return (FALSE);
                    525:        }
                    526:        return (TRUE);
                    527: }
                    528: 
                    529: 
                    530: 
                    531: 
                    532: static bool_t
                    533: xdr_dirlist(xdrs, objp)
                    534:        XDR *xdrs;
                    535:        dirlist *objp;
                    536: {
                    537:        if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(entry), xdr_entry)) {
                    538:                return (FALSE);
                    539:        }
                    540:        if (!xdr_bool(xdrs, &objp->eof)) {
                    541:                return (FALSE);
                    542:        }
                    543:        return (TRUE);
                    544: }
                    545: 
                    546: 
                    547: 
                    548: 
                    549: bool_t
                    550: xdr_readdirres(xdrs, objp)
                    551:        XDR *xdrs;
                    552:        readdirres *objp;
                    553: {
                    554:        if (!xdr_nfsstat(xdrs, &objp->status)) {
                    555:                return (FALSE);
                    556:        }
                    557:        switch (objp->status) {
                    558:        case NFS_OK:
                    559:                if (!xdr_dirlist(xdrs, &objp->readdirres_u.reply)) {
                    560:                        return (FALSE);
                    561:                }
                    562:                break;
                    563:        }
                    564:        return (TRUE);
                    565: }
                    566: 
                    567: 
                    568: 
                    569: 
                    570: bool_t
                    571: xdr_statfsokres(xdrs, objp)
                    572:        XDR *xdrs;
                    573:        statfsokres *objp;
                    574: {
                    575:        if (!xdr_u_int(xdrs, &objp->tsize)) {
                    576:                return (FALSE);
                    577:        }
                    578:        if (!xdr_u_int(xdrs, &objp->bsize)) {
                    579:                return (FALSE);
                    580:        }
                    581:        if (!xdr_u_int(xdrs, &objp->blocks)) {
                    582:                return (FALSE);
                    583:        }
                    584:        if (!xdr_u_int(xdrs, &objp->bfree)) {
                    585:                return (FALSE);
                    586:        }
                    587:        if (!xdr_u_int(xdrs, &objp->bavail)) {
                    588:                return (FALSE);
                    589:        }
                    590:        return (TRUE);
                    591: }
                    592: 
                    593: 
                    594: 
                    595: 
                    596: bool_t
                    597: xdr_statfsres(xdrs, objp)
                    598:        XDR *xdrs;
                    599:        statfsres *objp;
                    600: {
                    601:        if (!xdr_nfsstat(xdrs, &objp->status)) {
                    602:                return (FALSE);
                    603:        }
                    604:        switch (objp->status) {
                    605:        case NFS_OK:
                    606:                if (!xdr_statfsokres(xdrs, &objp->statfsres_u.reply)) {
                    607:                        return (FALSE);
                    608:                }
                    609:                break;
                    610:        }
                    611:        return (TRUE);
                    612: }

unix.superglobalmegacorp.com

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