Ejemplo n.º 1
0
int
_trc_open(
const char	*name,
int		flags,
int		mode,
struct fdinfo	*fio,
union spec_u	*spec,
struct ffsw	*stat,
long		cbits,
int		cblks,
struct gl_o_inf *oinf)
	{
	union spec_u *nspec;
	struct trace_f *trc_info;
	int *hp;
	char *ptr = NULL;
	int nextfio, namlen, trcfd;

	namlen = strlen(name);
	ptr = malloc(namlen + strlen(SUFFIX) + 1);
	if (ptr == NULL) goto badopen;

	trc_info = (struct trace_f *)calloc(sizeof(struct trace_f), 1);
	if (trc_info == NULL) goto badopen;

	fio->lyr_info = (char *)trc_info;
	strcpy(ptr, name);
	strcat(ptr, SUFFIX);
	trcfd = open(ptr, O_WRONLY | O_APPEND | O_CREAT, 0666);

	hp = (int *)malloc((HIST_INIT+1)*8);
	if (hp == NULL) goto badopen;
	trc_info->hist = hp;
	trc_info->histsiz = HIST_INIT;
	trc_info->histmax = HIST_MAX;
	trc_info->histincr = HIST_INCR;
	trc_info->histbkt = HIST_BKT;

	trc_info->lastseek = NO;
/*
 *	Yes, ignore errors on open.
 */
	trc_info->name = ptr;
	trc_info->trcfd = trcfd;
	ptr[namlen] = '\0';
	_trc_enter(fio, TRC_OPEN);
	_trc_info(fio, "(\"%s\", %o, %o, &statw[%d], %o);\n",
		name, flags, mode, stat, cbits);

/*
 *	Now, open the lower layers
 */
	nspec = spec;
	NEXT_SPEC(nspec);
	nextfio = _ffopen(name, flags, mode, nspec, stat, cbits, cblks, NULL,
			oinf);
	_trc_exit(fio, nextfio, stat);
	if (nextfio >= 0)
		{
		DUMP_IOB(fio); /* debugging only */
		return(nextfio);
		}
/*
 *	Error.  no memory.
 */
badopen:
	if (ptr != NULL) free(ptr);
	if (fio->lyr_info != NULL) free(fio->lyr_info);
	ERETURN(stat, FDC_ERR_NOMEM, 0);
	}
Ejemplo n.º 2
0
void
_trace_listio(
struct fdinfo		*fio,
int			which,
int			cmd,
struct fflistreq        *lr,
int			nreq)
{
	struct trace_f	*trc_info;

	trc_info = (struct trace_f *)fio->lyr_info;

	if (lr->li_flags & LF_LSEEK) {
		trc_info->lseeks++;
		trc_info->lastseek = YES;
		trc_info->curpos = lr->li_offset;
	}

	_trc_enter(fio, TRC_LISTIO);

	_trc_info(fio, " req %d of %d :",which+1, nreq);
	_trc_info(fio, " cmd=%s",
		cmd==LC_START? "LC_START": (cmd==LC_WAIT? "LC_WAIT" : "???"));
	_trc_info(fio, " li_opcode=%s" ,
		lr->li_opcode==LO_READ? "LO_READ":
		(lr->li_opcode==LO_WRITE? "LO_WRITE" : "???"));
	_trc_info(fio, " li_flags=%s" ,
		lr->li_flags==0? "0":
		((lr->li_flags == LF_LSEEK)? "LF_LSEEK": "???"));
	_trc_info(fio, " li_offset=%d",lr->li_offset);
	_trc_info(fio, " li_fildes=%d",lr->li_fildes);
	_trc_info(fio, " li_buf=%d",lr->li_buf);
	_trc_info(fio, " li_nbyte=%d",lr->li_nbyte);
	_trc_info(fio, " li_status=%d",lr->li_status);
	_trc_info(fio, " li_signo=%d",lr->li_signo);
	_trc_info(fio, " li_nstride=%d",lr->li_nstride);
	_trc_info(fio, " li_filstride=%d",lr->li_filstride);
	_trc_info(fio, " li_memstride=%d",lr->li_memstride);

	trc_info->lastseek = NO;
	trc_info->last_stpos = -1;		/* unknown */
	trc_info->last_endpos = -1;		/* unknown */
	trc_info->curpos = -1;			/* unknown */

	_trc_simple_exit(fio);
}