Annotation of 43BSDReno/contrib/isode-beta/ftam/ftamaccess1.c, revision 1.1.1.1

1.1       root        1: /* ftamaccess1.c - FPM: initiate file access */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/ftam/RCS/ftamaccess1.c,v 7.0 89/11/23 21:53:20 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/ftam/RCS/ftamaccess1.c,v 7.0 89/11/23 21:53:20 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       ftamaccess1.c,v $
                     12:  * Revision 7.0  89/11/23  21:53:20  mrose
                     13:  * Release 6.0
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                               NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: 
                     28: /* LINTLIBRARY */
                     29: 
                     30: #include <stdio.h>
                     31: #include <signal.h>
                     32: #include "fpkt.h"
                     33: 
                     34: /*    F-{LOCATE,ERASE}.REQUEST */
                     35: 
                     36: int    FAccessRequest (sd, operation, identity, lock, fti)
                     37: int    sd;
                     38: int    operation;
                     39: struct FADUidentity *identity;
                     40: int    lock;   /* F-LOCATE.REQUEST only */
                     41: struct FTAMindication *fti;
                     42: {
                     43:     SBV      smask;
                     44:     int     result,
                     45:            state;
                     46:     register struct ftamblk *fsb;
                     47: 
                     48:     switch (operation) {
                     49:        case FA_OPS_LOCATE: 
                     50:            state = FSB_LOCATE;
                     51:            break;
                     52: 
                     53:        case FA_OPS_ERASE: 
                     54:            state = FSB_ERASE;
                     55:            break;
                     56: 
                     57:        default: 
                     58:            return ftamlose (fti, FS_GEN_NOREASON, 0, NULLCP,
                     59:                    "bad value for operation parameter");
                     60:     }
                     61:     missingP (identity);
                     62:     missingP (fti);
                     63: 
                     64:     smask = sigioblock ();
                     65: 
                     66:     ftamPsig (fsb, sd);
                     67: 
                     68:     result = FAccessRequestAux (fsb, state, identity, lock, fti);
                     69: 
                     70:     (void) sigiomask (smask);
                     71: 
                     72:     return result;
                     73: }
                     74: 
                     75: /*  */
                     76: 
                     77: static int  FAccessRequestAux (fsb, state, identity, lock, fti)
                     78: register struct ftamblk *fsb;
                     79: int    state;
                     80: struct FADUidentity *identity;
                     81: int    lock;
                     82: struct FTAMindication *fti;
                     83: {
                     84:     int     result;
                     85:     PE     pe;
                     86:     struct PSAPindication   pis;
                     87:     struct PSAPindication  *pi = &pis;
                     88:     struct PSAPabort   *pa = &pi -> pi_abort;
                     89:     register struct type_FTAM_PDU *pdu;
                     90:     register struct type_FTAM_F__LOCATE__request *req;
                     91: 
                     92:     if (!(fsb -> fsb_flags & FSB_INIT))
                     93:        return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "not initiator");
                     94:     if (fsb -> fsb_state != FSB_DATAIDLE)
                     95:        return ftamlose (fti, FS_GEN (fsb), 0, NULLCP, "wrong state");
                     96:     if (!(fsb -> fsb_units & FUNIT_ACCESS))
                     97:        return ftamlose (fti, FS_GEN (fsb), 0, NULLCP,
                     98:                    "file access not allowed");
                     99: 
                    100:     pe = NULLPE;
                    101:     if ((pdu = (struct type_FTAM_PDU *) calloc (1, sizeof *pdu)) == NULL) {
                    102: no_mem: ;
                    103:        (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP, "out of memory");
                    104: out: ;
                    105:        if (pe)
                    106:            pe_free (pe);
                    107:        if (pdu)
                    108:            free_FTAM_PDU (pdu);
                    109:        if (fti -> fti_abort.fta_action == FACTION_PERM)
                    110:            freefsblk (fsb);
                    111:        return NOTOK;
                    112:     }
                    113:                        /* F-ERASE-request is identical... */
                    114:     pdu -> offset = state != FSB_LOCATE ? type_FTAM_PDU_f__erase__request
                    115:                                        : type_FTAM_PDU_f__locate__request;
                    116:     if ((req = (struct type_FTAM_F__LOCATE__request *)
                    117:                        calloc (1, sizeof *req)) == NULL)
                    118:        goto no_mem;
                    119:     pdu -> un.f__locate__request = req;
                    120:     if ((req -> file__access__data__unit__identity =
                    121:                        faduid2fpm (fsb, identity, fti)) == NULL)
                    122:        goto out;
                    123:     if ((fsb -> fsb_units & FUNIT_FADULOCK) && state == FSB_LOCATE) {
                    124:        if ((req -> fadu__lock = (struct type_FTAM_FADU__Lock *)
                    125:                                        calloc (1, sizeof *req -> fadu__lock))
                    126:                == NULL)
                    127:            goto no_mem;
                    128:        req -> fadu__lock -> parm = lock ? int_FTAM_FADU__Lock_on
                    129:                                         : int_FTAM_FADU__Lock_off;
                    130:     }
                    131: 
                    132:     if (encode_FTAM_PDU (&pe, 1, 0, NULLCP, pdu) == NOTOK) {
                    133:        (void) ftamlose (fti, FS_GEN (fsb), 1, NULLCP,
                    134:                         "error encoding PDU: %s", PY_pepy);
                    135:        goto out;
                    136:     }
                    137: 
                    138:     pe -> pe_context = fsb -> fsb_id;
                    139: 
                    140:     fsbtrace (fsb, (fsb -> fsb_fd, "P-DATA.REQUEST",
                    141:                    state == FSB_LOCATE ? "F-LOCATE-request"
                    142:                                        : "F-ERASE-request", pe, 0));
                    143: 
                    144:     result = PDataRequest (fsb -> fsb_fd, &pe, 1, pi);
                    145: 
                    146:     pe_free (pe);
                    147:     pe = NULLPE;
                    148:     free_FTAM_PDU (pdu);
                    149:     pdu = NULL;
                    150: 
                    151:     if (result == NOTOK) {
                    152:        (void) ps2ftamlose (fsb, fti, "PDataRequest", pa);
                    153:        goto out;
                    154:     }
                    155: 
                    156:     fsb -> fsb_state = state;
                    157: 
                    158:     return FWaitRequestAux (fsb, NOTOK, fti);
                    159: }

unix.superglobalmegacorp.com

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