*** etc/afpd/Makefile- Tue Apr 18 17:59:48 1995 --- etc/afpd/Makefile Sat Apr 20 10:34:29 1996 *************** *** 1,10 **** ########################################################################## ! SRC = unix.c afs.c kuam.c send_to_kdc.c lifetime.c \ main.c switch.c auth.c volume.c directory.c file.c \ enumerate.c desktop.c filedir.c fork.c appl.c gettok.c bprint.c ! OBJ = unix.o afs.o kuam.o send_to_kdc.o lifetime.o \ main.o switch.o auth.o volume.o directory.o file.o \ enumerate.o desktop.o filedir.o fork.o appl.o gettok.o bprint.o --- 1,10 ---- ########################################################################## ! SRC = unix.c afs.c kuam.c send_to_kdc.c lifetime.c ofork.c \ main.c switch.c auth.c volume.c directory.c file.c \ enumerate.c desktop.c filedir.c fork.c appl.c gettok.c bprint.c ! OBJ = unix.o afs.o kuam.o send_to_kdc.o lifetime.o ofork.o \ main.o switch.o auth.o volume.o directory.o file.o \ enumerate.o desktop.o filedir.o fork.o appl.o gettok.o bprint.o *** etc/afpd/fork.c- Thu Aug 31 16:42:38 1995 --- etc/afpd/fork.c Sat Apr 20 10:33:38 1996 *************** *** 27,48 **** extern int errno; - static struct ofork *oforks[ ( NOFILE - 10 ) / 2 ]; struct ofork *writtenfork; - pforkdesc( f ) - FILE *f; - { - u_short ofrefnum; - - for ( ofrefnum = 0; ofrefnum < sizeof( oforks ) / sizeof( oforks[ 0 ] ); - ofrefnum++ ) { - if ( oforks[ ofrefnum ] != NULL ) { - fprintf( f, "%hu <%s>\n", ofrefnum, oforks[ ofrefnum ]->of_name ); - } - } - } - afp_openfork( ibuf, ibuflen, rbuf, rbuflen ) char *ibuf, *rbuf; int ibuflen, *rbuflen; --- 32,39 ---- *************** *** 49,54 **** --- 40,46 ---- { struct vol *vol; struct dir *dir; + struct ofork *ofork; int did, pathtype, buflen, oflags, ret, adflags, plen; int lockop = 0, lockfd; u_short vid, bitmap, access, ofrefnum; *************** *** 89,121 **** return( AFPERR_NOOBJ ); } ! /* ! * Find a free slot. ! */ ! for ( ofrefnum = 0; ofrefnum < sizeof( oforks ) / sizeof( oforks[ 0 ] ); ! ofrefnum++ ) { ! if ( oforks[ ofrefnum ] == NULL ) { ! break; ! } ! } ! if ( ofrefnum == sizeof( oforks ) / sizeof( oforks[ 0 ] )) { *rbuflen = 0; return( AFPERR_NFILE ); } - if (( oforks[ ofrefnum ] = (struct ofork *)malloc( sizeof( struct ofork ))) - == NULL ) { - syslog( LOG_ERR, "afp_openfork: malloc: %m" ); - exit( 1 ); - } - oforks[ ofrefnum ]->of_dir = curdir; - if (( oforks[ ofrefnum ]->of_name = (char *)malloc( strlen( path ) + 1 )) - == NULL ) { - syslog( LOG_ERR, "afp_openfork: malloc: %m" ); - exit( 1 ); - } - strcpy( oforks[ ofrefnum ]->of_name, path ); - if ( access & OPENACC_WR ) { oflags = O_RDWR; } else { --- 81,91 ---- return( AFPERR_NOOBJ ); } ! if (( ofork = of_alloc( curdir, path, &ofrefnum )) == NULL ) { *rbuflen = 0; return( AFPERR_NFILE ); } if ( access & OPENACC_WR ) { oflags = O_RDWR; } else { *************** *** 128,149 **** } if ( ad_open( mtoupath( path ), adflags, oflags, 0, ! &oforks[ ofrefnum ]->of_ad ) < 0 ) { if ( errno == ENOENT && adflags != ADFLAGS_HF ) { ! ad_close( &oforks[ ofrefnum ]->of_ad, adflags ); if ( ad_open( mtoupath( path ), ADFLAGS_DF, oflags, 0, ! &oforks[ ofrefnum ]->of_ad ) < 0 ) { ! ad_close( &oforks[ ofrefnum ]->of_ad, ADFLAGS_DF ); ! free( oforks[ ofrefnum ]->of_name ); ! free( oforks[ ofrefnum ] ); ! oforks[ ofrefnum ] = NULL; *rbuflen = 0; return( AFPERR_NOOBJ ); } } else { ! free( oforks[ ofrefnum ]->of_name ); ! free( oforks[ ofrefnum ] ); ! oforks[ ofrefnum ] = NULL; *rbuflen = 0; switch ( errno ) { case EMFILE : --- 98,115 ---- } if ( ad_open( mtoupath( path ), adflags, oflags, 0, ! &ofork->of_ad ) < 0 ) { if ( errno == ENOENT && adflags != ADFLAGS_HF ) { ! ad_close( &ofork->of_ad, adflags ); if ( ad_open( mtoupath( path ), ADFLAGS_DF, oflags, 0, ! &ofork->of_ad ) < 0 ) { ! ad_close( &ofork->of_ad, ADFLAGS_DF ); ! of_dealloc( ofork ); *rbuflen = 0; return( AFPERR_NOOBJ ); } } else { ! of_dealloc( ofork ); *rbuflen = 0; switch ( errno ) { case EMFILE : *************** *** 161,178 **** } } ! if ( ad_getoflags( &oforks[ ofrefnum ]->of_ad, ADFLAGS_HF ) & O_CREAT ) { ! ad_flush( &oforks[ ofrefnum ]->of_ad, adflags ); } buflen = *rbuflen - 2 * sizeof( u_short ); ! if (( ret = getforkparams( oforks[ ofrefnum ], bitmap, ! rbuf + 2 * sizeof( u_short ), &buflen )) != AFP_OK ) { *rbuflen = 0; ! ad_close( &oforks[ ofrefnum ]->of_ad, adflags ); ! free( oforks[ ofrefnum ]->of_name ); ! free( oforks[ ofrefnum ] ); ! oforks[ ofrefnum ] = NULL; return( ret ); } --- 127,142 ---- } } ! if ( ad_getoflags( &ofork->of_ad, ADFLAGS_HF ) & O_CREAT ) { ! ad_flush( &ofork->of_ad, adflags ); } buflen = *rbuflen - 2 * sizeof( u_short ); ! if (( ret = getforkparams( ofork, bitmap, rbuf + 2 * sizeof( u_short ), ! &buflen )) != AFP_OK ) { *rbuflen = 0; ! ad_close( &ofork->of_ad, adflags ); ! of_dealloc( ofork ); return( ret ); } *************** *** 207,227 **** #endif AFS } if ( fork == OPENFORK_DATA ) { ! lockfd = ad_dfileno( &oforks[ ofrefnum ]->of_ad ); } else { ! lockfd = ad_hfileno( &oforks[ ofrefnum ]->of_ad ); } if ( lockop && flock( lockfd, lockop|LOCK_NB ) < 0 ) { ! ad_close( &oforks[ ofrefnum ]->of_ad, adflags ); ! free( oforks[ ofrefnum ]->of_name ); ! free( oforks[ ofrefnum ] ); ! oforks[ ofrefnum ] = NULL; ! if ( errno == EWOULDBLOCK ) { /* return data anyway */ ofrefnum = 0; bcopy( &ofrefnum, rbuf, sizeof( u_short )); return( AFPERR_DENYCONF ); } else { *rbuflen = 0; return( AFPERR_PARAM ); } } --- 171,191 ---- #endif AFS } if ( fork == OPENFORK_DATA ) { ! lockfd = ad_dfileno( &ofork->of_ad ); } else { ! lockfd = ad_hfileno( &ofork->of_ad ); } if ( lockop && flock( lockfd, lockop|LOCK_NB ) < 0 ) { ! ret = errno; ! ad_close( &ofork->of_ad, adflags ); ! of_dealloc( ofork ); ! if ( ret == EWOULDBLOCK ) { /* return data anyway */ ofrefnum = 0; bcopy( &ofrefnum, rbuf, sizeof( u_short )); return( AFPERR_DENYCONF ); } else { *rbuflen = 0; + syslog( LOG_ERR, "afp_openfork: flock: %m" ); return( AFPERR_PARAM ); } } *************** *** 234,242 **** char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! long intime; ! int size; ! u_short ofrefnum; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); --- 198,207 ---- char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! struct ofork *ofork; ! long intime; ! int size; ! u_short ofrefnum; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); *************** *** 246,271 **** size = ntohl( size ); *rbuflen = 0; ! if ( oforks[ ofrefnum ] == NULL ) { return( AFPERR_PARAM ); } ! if ( ad_dfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { ! if ( ad_dtruncate( &oforks[ ofrefnum ]->of_ad, size ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: ad_dtruncate: %m" ); return( AFPERR_PARAM ); } ! } else if ( ad_hfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { ! bcopy( ad_entry( &oforks[ ofrefnum ]->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &intime, sizeof( intime )); ! ad_refresh( &oforks[ ofrefnum ]->of_ad, ADFLAGS_HF ); ! bcopy( &intime, ad_entry( &oforks[ ofrefnum ]->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, sizeof( intime )); ! if ( ad_rtruncate( &oforks[ ofrefnum ]->of_ad, size ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: ad_rtruncate: %m" ); return( AFPERR_PARAM ); } ! if ( ad_flush( &oforks[ ofrefnum ]->of_ad, ADFLAGS_HF ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: ad_flush: %m" ); return( AFPERR_PARAM ); } --- 211,237 ---- size = ntohl( size ); *rbuflen = 0; ! if (( ofork = of_find( ofrefnum )) == NULL ) { ! syslog( LOG_ERR, "afp_setforkparams: of_find: %m" ); return( AFPERR_PARAM ); } ! if ( ad_dfileno( &ofork->of_ad ) != -1 ) { ! if ( ad_dtruncate( &ofork->of_ad, size ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: ad_dtruncate: %m" ); return( AFPERR_PARAM ); } ! } else if ( ad_hfileno( &ofork->of_ad ) != -1 ) { ! bcopy( ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &intime, sizeof( intime )); ! ad_refresh( &ofork->of_ad, ADFLAGS_HF ); ! bcopy( &intime, ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, sizeof( intime )); ! if ( ad_rtruncate( &ofork->of_ad, size ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: ad_rtruncate: %m" ); return( AFPERR_PARAM ); } ! if ( ad_flush( &ofork->of_ad, ADFLAGS_HF ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: ad_flush: %m" ); return( AFPERR_PARAM ); } *************** *** 272,278 **** } #ifdef AFS ! if ( flushfork( oforks[ ofrefnum ] ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: flushfork: %m" ); } #endif AFS --- 238,244 ---- } #ifdef AFS ! if ( flushfork( ofork ) < 0 ) { syslog( LOG_ERR, "afp_setforkparams: flushfork: %m" ); } #endif AFS *************** *** 325,330 **** --- 291,297 ---- char *ibuf, *rbuf; int ibuflen, *rbuflen; { + struct ofork *ofork; long offset; int reqcount, cc, rc, eid, eof = 0; u_short ofrefnum; *************** *** 335,342 **** bcopy( ibuf, &ofrefnum, sizeof( u_short )); ibuf += sizeof( u_short ); ! if ( oforks[ ofrefnum ] == NULL ) { *rbuflen = 0; return( AFPERR_PARAM ); } --- 302,310 ---- bcopy( ibuf, &ofrefnum, sizeof( u_short )); ibuf += sizeof( u_short ); ! if (( ofork = of_find( ofrefnum )) == NULL ) { *rbuflen = 0; + syslog( LOG_ERR, "afp_read: of_find: %m" ); return( AFPERR_PARAM ); } *************** *** 350,356 **** nlmask = *ibuf++; nlchar = *ibuf++; ! if ( ad_dfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { eid = ADEID_DFORK; } else { eid = ADEID_RFORK; --- 318,324 ---- nlmask = *ibuf++; nlchar = *ibuf++; ! if ( ad_dfileno( &ofork->of_ad ) != -1 ) { eid = ADEID_DFORK; } else { eid = ADEID_RFORK; *************** *** 362,370 **** } #define min(a,b) ((a)<(b)?(a):(b)) rc = min( reqcount, *rbuflen ); ! cc = ad_read( &oforks[ ofrefnum ]->of_ad, eid, offset, rbuf, rc ); if ( cc < 0 ) { *rbuflen = 0; return( AFPERR_PARAM ); } if ( cc < rc ) { --- 330,339 ---- } #define min(a,b) ((a)<(b)?(a):(b)) rc = min( reqcount, *rbuflen ); ! cc = ad_read( &ofork->of_ad, eid, offset, rbuf, rc ); if ( cc < 0 ) { *rbuflen = 0; + syslog( LOG_ERR, "afp_read: ad_read: %m" ); return( AFPERR_PARAM ); } if ( cc < rc ) { *************** *** 390,396 **** /* * If this file is of type TEXT, then swap \012 to \015. */ ! if ( eid == ADEID_DFORK && crlf( oforks[ ofrefnum ] )) { for ( p = rbuf, q = p + cc; p < q; p++ ) { if ( *p == '\012' ) { *p = '\015'; --- 359,365 ---- /* * If this file is of type TEXT, then swap \012 to \015. */ ! if ( eid == ADEID_DFORK && crlf( ofork )) { for ( p = rbuf, q = p + cc; p < q; p++ ) { if ( *p == '\012' ) { *p = '\015'; *************** *** 413,426 **** u_short ofrefnum; *rbuflen = 0; ! for ( ofrefnum = 0; ofrefnum < sizeof( oforks ) / sizeof( oforks[ 0 ] ); ! ofrefnum++ ) { ! if ( oforks[ ofrefnum ] != NULL && ! flushfork( oforks[ ofrefnum ] ) < 0 ) { ! syslog( LOG_ERR, "afp_flush: %m" ); ! } ! } ! return( AFP_OK ); } --- 382,388 ---- u_short ofrefnum; *rbuflen = 0; ! of_flush(); return( AFP_OK ); } *************** *** 428,444 **** char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! u_short ofrefnum; *rbuflen = 0; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); ! if ( oforks[ ofrefnum ] == NULL ) { return( AFPERR_PARAM ); } ! if ( flushfork( oforks[ ofrefnum ] ) < 0 ) { syslog( LOG_ERR, "afp_flushfork: %m" ); } --- 390,408 ---- char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! struct ofork *ofork; ! u_short ofrefnum; *rbuflen = 0; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); ! if (( ofork = of_find( ofrefnum )) == NULL ) { ! syslog( LOG_ERR, "afp_flushfork: of_find: %m" ); return( AFPERR_PARAM ); } ! if ( flushfork( ofork ) < 0 ) { syslog( LOG_ERR, "afp_flushfork: %m" ); } *************** *** 467,499 **** char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! long intime, filetime; ! int adflags, aint, doflush = 0; ! u_short ofrefnum; *rbuflen = 0; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); ! if ( oforks[ ofrefnum ] == NULL ) { return( AFPERR_PARAM ); } adflags = 0; ! if ( ad_dfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { adflags |= ADFLAGS_DF; } ! if ( ad_hfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { adflags |= ADFLAGS_HF; ! aint = ad_getentrylen( &oforks[ ofrefnum ]->of_ad, ADEID_RFORK ); ! bcopy( ad_entry( &oforks[ ofrefnum ]->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &intime, sizeof( intime )); ! ad_refresh( &oforks[ ofrefnum ]->of_ad, adflags ); ! bcopy( ad_entry( &oforks[ ofrefnum ]->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &filetime, sizeof( filetime )); if ( intime != filetime ) { ! bcopy( &intime, ad_entry( &oforks[ ofrefnum ]->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, sizeof( filetime )); doflush++; } --- 431,465 ---- char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! struct ofork *ofork; ! long intime, filetime; ! int adflags, aint, doflush = 0; ! u_short ofrefnum; *rbuflen = 0; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); ! if (( ofork = of_find( ofrefnum )) == NULL ) { ! syslog( LOG_ERR, "afp_closefork: of_find: %m" ); return( AFPERR_PARAM ); } adflags = 0; ! if ( ad_dfileno( &ofork->of_ad ) != -1 ) { adflags |= ADFLAGS_DF; } ! if ( ad_hfileno( &ofork->of_ad ) != -1 ) { adflags |= ADFLAGS_HF; ! aint = ad_getentrylen( &ofork->of_ad, ADEID_RFORK ); ! bcopy( ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &intime, sizeof( intime )); ! ad_refresh( &ofork->of_ad, adflags ); ! bcopy( ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &filetime, sizeof( filetime )); if ( intime != filetime ) { ! bcopy( &intime, ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, sizeof( filetime )); doflush++; } *************** *** 502,524 **** * Only set the rfork's length if we're closing the rfork. */ if (( adflags & ADFLAGS_DF ) == 0 && aint != ! ad_getentrylen( &oforks[ ofrefnum ]->of_ad, ADEID_RFORK )) { ! ad_setentrylen( &oforks[ ofrefnum ]->of_ad, ADEID_RFORK, aint ); doflush++; } if ( doflush ) { ! ad_flush( &oforks[ ofrefnum ]->of_ad, adflags ); } } ! if ( ad_close( &oforks[ ofrefnum ]->of_ad, adflags ) < 0 ) { return( AFPERR_PARAM ); } ! ! free( oforks[ ofrefnum ]->of_name ); ! free( oforks[ ofrefnum ] ); ! oforks[ ofrefnum ] = NULL; ! return( AFP_OK ); } --- 468,487 ---- * Only set the rfork's length if we're closing the rfork. */ if (( adflags & ADFLAGS_DF ) == 0 && aint != ! ad_getentrylen( &ofork->of_ad, ADEID_RFORK )) { ! ad_setentrylen( &ofork->of_ad, ADEID_RFORK, aint ); doflush++; } if ( doflush ) { ! ad_flush( &ofork->of_ad, adflags ); } } ! if ( ad_close( &ofork->of_ad, adflags ) < 0 ) { ! syslog( LOG_ERR, "afp_closefork: ad_close: %m" ); return( AFPERR_PARAM ); } ! of_dealloc( ofork ); return( AFP_OK ); } *************** *** 527,532 **** --- 490,496 ---- int ibuflen, *rbuflen; ASP asp; { + struct ofork *ofork; struct timeval tv; register char *p, *q; int endflag, offset, reqcount, cc, eid; *************** *** 543,562 **** reqcount = ntohl( reqcount ); ibuf += sizeof( int ); ! if ( oforks[ ofrefnum ] == NULL ) { *rbuflen = 0; return( AFPERR_PARAM ); } #ifdef AFS ! writtenfork = oforks[ ofrefnum ]; #endif AFS if ( asp_wrtcont( asp, rbuf, rbuflen ) < 0 ) { *rbuflen = 0; return( AFPERR_PARAM ); } ! if ( ad_dfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { eid = ADEID_DFORK; } else { eid = ADEID_RFORK; --- 507,528 ---- reqcount = ntohl( reqcount ); ibuf += sizeof( int ); ! if (( ofork = of_find( ofrefnum )) == NULL ) { *rbuflen = 0; + syslog( LOG_ERR, "afp_write: of_find: %m" ); return( AFPERR_PARAM ); } #ifdef AFS ! writtenfork = ofork; #endif AFS if ( asp_wrtcont( asp, rbuf, rbuflen ) < 0 ) { *rbuflen = 0; + syslog( LOG_ERR, "afp_write: asp_wrtcont: %m" ); return( AFPERR_PARAM ); } ! if ( ad_dfileno( &ofork->of_ad ) != -1 ) { eid = ADEID_DFORK; } else { eid = ADEID_RFORK; *************** *** 566,572 **** /* * If this file is of type TEXT, swap \015 to \012. */ ! if ( eid == ADEID_DFORK && crlf( oforks[ ofrefnum ] )) { for ( p = rbuf, q = p + *rbuflen; p < q; p++ ) { if ( *p == '\015' ) { *p = '\012'; --- 532,538 ---- /* * If this file is of type TEXT, swap \015 to \012. */ ! if ( eid == ADEID_DFORK && crlf( ofork )) { for ( p = rbuf, q = p + *rbuflen; p < q; p++ ) { if ( *p == '\015' ) { *p = '\012'; *************** *** 575,581 **** } #endif CRLF ! if (( cc = ad_write( &oforks[ ofrefnum ]->of_ad, eid, offset, endflag, rbuf, *rbuflen )) < 0 ) { switch ( errno ) { case EDQUOT : --- 541,547 ---- } #endif CRLF ! if (( cc = ad_write( &ofork->of_ad, eid, offset, endflag, rbuf, *rbuflen )) < 0 ) { switch ( errno ) { case EDQUOT : *************** *** 590,602 **** } } ! if ( ad_hfileno( &oforks[ ofrefnum ]->of_ad ) != -1 ) { if ( gettimeofday( &tv, 0 ) < 0 ) { syslog( LOG_ERR, "afp_write: gettimeofday: %m" ); exit( 1 ); } tv.tv_sec = htonl( tv.tv_sec ); ! bcopy( &tv.tv_sec, ad_entry( &oforks[ ofrefnum ]->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, sizeof( tv.tv_sec )); } --- 556,568 ---- } } ! if ( ad_hfileno( &ofork->of_ad ) != -1 ) { if ( gettimeofday( &tv, 0 ) < 0 ) { syslog( LOG_ERR, "afp_write: gettimeofday: %m" ); exit( 1 ); } tv.tv_sec = htonl( tv.tv_sec ); ! bcopy( &tv.tv_sec, ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, sizeof( tv.tv_sec )); } *************** *** 611,618 **** char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! int buflen, ret; ! u_short ofrefnum, bitmap; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); --- 577,585 ---- char *ibuf, *rbuf; int ibuflen, *rbuflen; { ! struct ofork *ofork; ! int buflen, ret; ! u_short ofrefnum, bitmap; ibuf += 2; bcopy( ibuf, &ofrefnum, sizeof( u_short )); *************** *** 621,633 **** bitmap = ntohs( bitmap ); ibuf += sizeof( u_short ); ! if ( oforks[ ofrefnum ] == NULL ) { *rbuflen = 0; return( AFPERR_PARAM ); } buflen = *rbuflen - sizeof( u_short ); ! if (( ret = getforkparams( oforks[ ofrefnum ], bitmap, rbuf + sizeof( u_short ), &buflen )) != AFP_OK ) { *rbuflen = 0; return( ret ); --- 588,601 ---- bitmap = ntohs( bitmap ); ibuf += sizeof( u_short ); ! if (( ofork = of_find( ofrefnum )) == NULL ) { *rbuflen = 0; + syslog( LOG_ERR, "afp_getforkparams: of_find: %m" ); return( AFPERR_PARAM ); } buflen = *rbuflen - sizeof( u_short ); ! if (( ret = getforkparams( ofork, bitmap, rbuf + sizeof( u_short ), &buflen )) != AFP_OK ) { *rbuflen = 0; return( ret ); *************** *** 661,666 **** --- 629,635 ---- bcopy( ad_entry( &ofork->of_ad, ADEID_FILEI ) + FILEIOFF_MODIFY, &intime, sizeof( intime )); if ( ad_refresh( &ofork->of_ad ) < 0 ) { + syslog( LOG_ERR, "getforkparams: ad_refresh: %m" ); return( AFPERR_PARAM ); } /* See afp_closefork() for why this is bad */ *** etc/afpd/fork.h- Fri Sep 3 01:49:45 1993 --- etc/afpd/fork.h Sat Apr 20 10:33:38 1996 *************** *** 20,22 **** --- 20,25 ---- #define AFPFORK_OPEN (1<<0) #define AFPFORK_RSRC (1<<1) #define AFPFORK_DATA (1<<2) + + struct ofork *of_alloc(); + struct ofork *of_find(); *** /dev/null Sat Apr 20 08:48:01 1996 --- etc/afpd/ofork.c Sat Apr 20 10:33:38 1996 *************** *** 0 **** --- 1,105 ---- + /* + * Copyright (c) 1996 Regents of The University of Michigan. + * All Rights Reserved. See COPYRIGHT. + */ + + #include + #include + #include + + #include + + #include "directory.h" + #include "fork.h" + + static struct ofork *oforks[ ( NOFILE - 10 ) / 2 ]; + int nforks = sizeof( oforks ) / sizeof( oforks[ 0 ] ); + static u_short lastrefnum = 0; + + pforkdesc( f ) + FILE *f; + { + u_short ofrefnum; + + for ( ofrefnum = 0; ofrefnum < sizeof( oforks ) / sizeof( oforks[ 0 ] ); + ofrefnum++ ) { + if ( oforks[ ofrefnum ] != NULL ) { + fprintf( f, "%hu <%s>\n", ofrefnum, oforks[ ofrefnum ]->of_name ); + } + } + } + + of_flush() + { + u_short refnum; + + for ( refnum = 0; refnum < nforks; refnum++ ) { + if ( oforks[ refnum ] != NULL && + flushfork( oforks[ refnum ] ) < 0 ) { + syslog( LOG_ERR, "of_flush: %m" ); + } + } + return( 0 ); + } + + struct ofork * + of_alloc( dir, path, ofrefnum ) + struct dir *dir; + char *path; + u_short *ofrefnum; + { + u_short refnum; + int i; + + for ( refnum = lastrefnum++, i = 0; i < nforks; i++, refnum++ ) { + if ( oforks[ refnum % nforks ] == NULL ) { + break; + } + } + if ( i == nforks ) { + return( NULL ); + } + + if (( oforks[ refnum % nforks ] = + (struct ofork *)malloc( sizeof( struct ofork ))) == NULL ) { + syslog( LOG_ERR, "of_alloc: malloc: %m" ); + exit( 1 ); + } + oforks[ refnum % nforks ]->of_dir = dir; + if (( oforks[ refnum % nforks ]->of_name = + (char *)malloc( strlen( path ) + 1 )) == NULL ) { + syslog( LOG_ERR, "of_alloc: malloc: %m" ); + exit( 1 ); + } + strcpy( oforks[ refnum % nforks ]->of_name, path ); + *ofrefnum = refnum; + return( oforks[ refnum % nforks ] ); + } + + struct ofork * + of_find( ofrefnum ) + u_short ofrefnum; + { + return( oforks[ ofrefnum % nforks ] ); + } + + of_dealloc( of ) + struct ofork *of; + { + u_short refnum; + + for ( refnum = 0; refnum < nforks; refnum++ ) { + if ( oforks[ refnum ] == of ) { + break; + } + } + if ( refnum == nforks ) { + syslog( LOG_ERR, "of_dealloc: OOPS!" ); + return; + } + + free( of ); + free( of->of_name ); + oforks[ refnum ] = NULL; + return; + }