old/512restor/512restor.c
/*
 * allocate a block off the free list.
 */
allocate a block off the free list.
allocate a block off the free list .
daddr_t
balloc()
{
	daddr_t	bno;
	register i;
	static char zeroes[BSIZE];
	union {
		char	data[BSIZE];
		struct	fblk frees;
	} fbuf;
	if(sblock.s_nfree == 0 || (bno=sblock.s_free[--sblock.s_nfree]) == 0) {
#ifdef STANDALONE
		printf("Out of space\n");
#else
		fprintf(stderr, "Out of space.\n");
#endif
		exit(1);
	}
	if(sblock.s_nfree == 0) {
		dread(bno, fbuf.data, BSIZE);
		sblock.s_nfree = fbuf.df_nfree;
		for(i=0;i<NICFREE;i++)
			sblock.s_free[i] = fbuf.df_free[i];
	}
	dwrite(bno, zeroes);
	return(bno);
}
daddr_t balloc ( ) { daddr_t bno ; register i ; static char zeroes [ BSIZE ] ; union { char data [ BSIZE ] ; struct fblk frees ; } fbuf ; if ( sblock . s_nfree == 0 || ( bno = sblock . s_free [ -- sblock . s_nfree ] ) == 0 ) { #ifdef STANDALONE printf ( " \n " ) ; #else fprintf ( stderr , " \n " ) ; #endif exit ( 1 ) ; } if ( sblock . s_nfree == 0 ) { dread ( bno , fbuf . data , BSIZE ) ; sblock . s_nfree = fbuf . df_nfree ; for ( i = 0 ; i < NICFREE ; i ++ ) sblock . s_free [ i ] = fbuf . df_free [ i ] ; } dwrite ( bno , zeroes ) ; return ( bno ) ; }
allocate a block off the free list.
allocate a block off the free list .