示例#1
0
/*
 * lock listio requests
 * The lock layer will be called only if the lower layer can handle listio 
 * requests.
 */
_lock_listio(
int			cmd,		/* LC_WAIT or LC_START */
struct fflistreq	*list,		/* list of requests (see fflistio) */
int			nreq,		/* number of requests */
struct ffsw		*stat)		/* status structure */
{

	int	i;
	struct fdinfo	*llfio;
	struct fdinfo	*first_fio;
	struct fdinfo	*fio;
	struct fflistreq *copy;		/* copy of the list of requests */
	int	numdone;
	int	curent;
	int	pos;
	bitptr	buf;
	int	nb;
	int	zero;
	int	ret;
	int	nstr;
	struct ffsw	locstat;
	struct ffsw	 *istat;

	if (nreq == 0)
		return(0);
	first_fio = GETIOB(list[0].li_fildes);
	for (i = 0; i < nreq; i++) {
		fio = GETIOB(list[i].li_fildes);
		if (fio != first_fio) {
			_SETERROR(stat, FDC_ERR_LSTIO, 0);
			return (-1);
		}
	}

	llfio = first_fio->fioptr;
	if (llfio->can_listio) {
		copy = malloc(nreq * sizeof(*list));
		if (copy == NULL)
			ERETURN(stat, FDC_ERR_NOMEM, 0);

		for (i = 0; i < nreq; i++) {
			copy[i] = list[i];		/* copy the entry */
			copy[i].li_fildes = (int)llfio;	
		}
		LYR_LOCK(fio);
		numdone = XRCALL(llfio, listiortn) cmd, copy, nreq, stat);
		LYR_UNLOCK(fio);
		free(copy);
		return(numdone);
	}
示例#2
0
ffreada(int fd, char *buf, int nbytes, struct ffsw *stat, ...)
	{
	struct fdinfo *fio;
	int ret, locfulp;
	bitptr bufptr;
	int locubc, *pubc, na;	/* need a place to put result */
	va_list ap;

	fio = GETIOB(fd);
	SET_BPTR(bufptr, CPTR2BP(buf));
	/* adjust number of bits requested if ubc passed in */
	NUMARG(na);
	locubc = 0;
	pubc = &locubc;
	locfulp = FULL;
	if (na < 4 || na > 6)
		{
		errno = FDC_ERR_NOPARM;
		return(ERR);
		}
	va_start(ap, stat);
	if (na > 4)
		locfulp = va_arg(ap, int);
	if (na > 5)
		pubc = va_arg(ap, int *);
	CHECK_FIOPTR(fio, stat);
	ret = XRCALL(fio, readartn) fio, bufptr, nbytes,
						stat, locfulp, pubc);
	return (ret);
	}
示例#3
0
ffbksp(int fd, ...)
#endif
	{
	struct fdinfo *fio;
	int ret, na;
	struct ffsw locstat, *pstat;
#ifdef _CRAY
	va_list ap;
#endif

	fio = GETIOB(fd);
#ifdef _CRAY
	NUMARG(na);
	if (na < 2)
		pstat = &locstat;
	else
		{
		va_start(ap, fd);
		pstat = va_arg(ap, struct ffsw *);
		}
#else
	pstat = &locstat;
	na = 1;
#endif
	CHECK_FIOPTR(fio, pstat);
	ret = XRCALL(fio, backrtn) fio, pstat);
	/* set errno only if stat was not passed */
	if (na < 2)
		errno = locstat.sw_error;
	return (ret);
	}
示例#4
0
ffweof(int fd, ...)
#endif
	{
	struct fdinfo *fio;
	int ret, na;
	struct ffsw locstat, *pstat;
#if	!defined(__mips) && !defined(_LITTLE_ENDIAN)
	va_list ap;
#endif

	fio = GETIOB(fd);
#if	defined(__mips) || defined(_LITTLE_ENDIAN)
	na = 1;
	pstat = &locstat;
#else
	NUMARG(na);
	if (na < 2)
		pstat = &locstat;
	else
		{
		va_start(ap, fd);
		pstat = va_arg(ap, struct ffsw *);
		}
#endif
	CHECK_FIOPTR(fio, pstat);
	ret = XRCALL(fio, weofrtn) fio, pstat);
#if	!defined(__mips) && !defined(_LITTLE_ENDIAN)
	if (na < 2)
		errno = locstat.sw_error;
#endif
	return (ret);
	}
示例#5
0
off_t
#else
int
#endif
ffpos(
int fd,
int cmd,
#if	defined(__mips) || defined(_LITTLE_ENDIAN)
void *arg,
#else
long *arg,
#endif
int len,
struct ffsw *stat
)
	{
	struct fdinfo *fio;
	_ffseek_t ret;

	fio = GETIOB(fd);
	CHECK_FIOPTR(fio, stat);
#if	defined(__mips) || defined(_LITTLE_ENDIAN)
	if (cmd == FP_BSEEK)
		ERETURN(stat, FDC_ERR_NOSUP, 0);
#endif
	ret = XRCALL(fio, posrtn) fio, cmd, arg, len, stat);
	return (ret);
	}
示例#6
0
int
ffbkspf(int fd, struct ffsw *pstat)
{
	struct fdinfo *fio;
	fio = GETIOB(fd);
	CHECK_FIOPTR(fio, pstat);
	return(XRCALL(fio, backrtn) fio, pstat));
}
示例#7
0
/*
 * This routine is like ffweof, except it expects 2 parameters
 */
ffweoff(int fd, struct ffsw *pstat)
{
	struct fdinfo *fio;
	int ret;

	fio = GETIOB(fd);
	CHECK_FIOPTR(fio, pstat);
	ret = XRCALL(fio, weofrtn) fio, pstat);
	return (ret);
}
示例#8
0
int
ffread(int fd, char *buf, int nbytes, ...)
#endif
	{
	struct fdinfo *fio;
	ssize_t ret;
	int  locfulp;
	bitptr bufptr;
	int locubc, *pubc, na;	/* need a place to put result */
	struct ffsw locstat, *pstat;	/* need a place to put result */
#if	!defined(__mips) && !defined(_LITTLE_ENDIAN)
	va_list ap;
#endif

	fio = GETIOB(fd);
	SET_BPTR(bufptr, CPTR2BP(buf));
	/* adjust number of bits requested if ubc passed in */
#ifdef _CRAY
	NUMARG(na);
#elif	defined(__mips) || defined(_LITTLE_ENDIAN)
	na = 3;
#endif
	locubc = 0;
	pubc = &locubc;
	locfulp = FULL;
	pstat = &locstat;
#if	!defined(__mips) && !defined(_LITTLE_ENDIAN)
	va_start(ap, nbytes);
	if (na < 3 || na > 6)
		{
		errno = FDC_ERR_NOPARM;
		return(ERR);
		}
	if (na > 3)
		pstat = va_arg(ap, struct ffsw *);
	if (na > 4)
		locfulp = va_arg(ap, int);
	if (na > 5)
		pubc = va_arg(ap, int *);
#endif
	CHECK_FIOPTR(fio, pstat);
	ret = XRCALL(fio, readrtn) fio, bufptr, nbytes,
						pstat, locfulp, pubc);
	if (na < 4)
		errno = locstat.sw_error;
	return (ret);
	}
示例#9
0
/*
 * trace listio requests
 * The trace layer indicates that it can handle listio requests iff
 * the lower layer can.
 */
_trc_listio(
int			cmd,		/* LC_WAIT or LC_START */
struct fflistreq	*list,		/* list of requests (see fflistio) */
int			nreq,		/* number of requests */
struct ffsw		*stat)		/* status structure */
{

	int	ret;
	int	i;
	struct fdinfo	*llfio;
	struct fdinfo	*first_llfio;
	struct fdinfo	*fio;
	struct fflistreq *copy;		/* copy of the list of requests */

	if (nreq == 0)
		return(0);

	copy = malloc(nreq * sizeof(*list));
	if (copy == NULL)
		ERETURN(stat, FDC_ERR_NOMEM, 0);

	for (i = 0; i < nreq; i++) {
		fio = GETIOB(list[i].li_fildes);
		llfio = fio->fioptr;

		if (i == 0)
			first_llfio = llfio;
		else if (llfio != first_llfio) {
			_SETERROR(list[i].li_status, FDC_ERR_LSTIO, 0);
			continue;
		}

		copy[i] = list[i];		/* copy the entry */
		copy[i].li_fildes = (int)llfio;	/* pass it on to lower layer */

		_trace_listio(fio, i, cmd, &copy[i], nreq);
	}

	ret = XRCALL(llfio, listiortn) cmd, copy, nreq, stat);

	free(copy);

	return(ret);
}
示例#10
0
/*
 * This routine is like ffread, except it expects all parameters .
 * If ubc == NULL, then do not return ubc information to user.
 */
ssize_t
ffreadf(int fd, void *buf, size_t nbytes, struct ffsw *pstat, int locfulp,
 int *ubc)
	{
	struct fdinfo *fio;
	ssize_t ret;
	bitptr bufptr;
	int locubc, *pubc;

	
	if (ubc == NULL) {
		pubc = &locubc;
		locubc = 0;
	}
	else {
		pubc = ubc;
	}
	fio = GETIOB(fd);
	SET_BPTR(bufptr, CPTR2BP(buf));
	CHECK_FIOPTR(fio, pstat);
	ret = XRCALL(fio, readrtn) fio, bufptr, nbytes,
						pstat, locfulp, pubc);
	return (ret);
	}
示例#11
0
ffsetsp(int fd, ...)
	{
	struct fdinfo *fio;
	struct ffsw locstat, *pstat;
	int ret, na;
	va_list ap;

	fio = GETIOB(fd);
	NUMARG(na);
	if (na < 2)
		pstat = &locstat;
	else
		{
		va_start(ap, fd);
		pstat = va_arg(ap, struct ffsw *);
		}
	CHECK_FIOPTR(fio, pstat);
	_eov_load(1);	/* Call a routine that provides hard references */
			/* to eov routines. */
	ret = XRCALL(fio, fcntlrtn) fio, FC_SETSP, 1, pstat);
	if (na < 2)
		errno = locstat.sw_error;
	return (ret);
	}
示例#12
0
/*
 * _cca_listio
 *
 *	Issue a listio request for the cachea layer.
 *
 * Return Value:
 *
 *	On success, nreq is returned, and the contents of the stat structure are
 *	unspecified.
 *
 *	If an error in setup is encountered, stat is set as follows:
 *
 *		stat->sw_error	= error code
 *		stat->sw_stat	= FFERR
 *		stat->sw_flag	= 1
 *		stat->sw_count	= 0
 *
 *	If an error in I/O request I is detected, the list[I].li_stat
 *	structure will be set as follows:
 *
 *		list[I].li_stat->sw_error	= error code
 *		list[I].li_stat->sw_flag	= 1
 */
_cca_listio( 
int			cmd,		/* LC_START or LC_START */
struct fflistreq	*list,		/* list of requests (see fflistio) */
int			nreq,		/* number of requests */
struct ffsw		*stat)		/* status structure */
{
	int	ret;
	int	i;
	int	n_handled;
	int	status;
	int	zero;
	int	pos;
	bitptr buf;
	struct ffsw	loc_stat;
	struct fdinfo	*fio;
	struct fdinfo	*oldfio;
	struct cca_f *cca_info;

	n_handled = 0;

	oldfio = GETIOB(list[0].li_fildes);
	cca_info = (struct cca_f *)oldfio->lyr_info;
	for (i = 0; i < nreq; i++) {

		fio = GETIOB(list[i].li_fildes);
		if (fio != oldfio) {
			_SETERROR(list[i].li_status, FDC_ERR_LSTIO, 0);
			continue;
		}
		if ( list[i].li_signo != 0 ) {
			_SETERROR(list[i].li_status, FDC_ERR_REQ, 0);
			continue;
		}

		cca_info = (struct cca_f *)fio->lyr_info;
		CLRFFSTAT(*(list[i].li_status));

		SET_BPTR(buf, CPTR2BP(list[i].li_buf));
		if ( list[i].li_nstride > 1 ) {

			status = _ffcompound(&list[i]);
			if (status == 0)
				n_handled++;
			continue;
		}
		if ( list[i].li_flags == LF_LSEEK ) {
			pos = _cca_seek(fio, list[i].li_offset, SEEK_SET,
					   &loc_stat);
			if (pos == -1) {
				*list[i].li_status = loc_stat;
				continue;
			}
		}
		else if (list[i].li_flags != 0) {
			_SETERROR(list[i].li_status, FDC_ERR_REQ, 0);
		}

		zero = 0;
		status = 0;
		if ( cmd == LC_START ) {
			if ( list[i].li_opcode == LO_READ ) {
				status = _cca_reada(fio, buf, list[i].li_nbyte,
				    		    list[i].li_status, FULL,
						    &zero );
			}
			else if (list[i].li_opcode == LO_WRITE ) {
				status = _cca_writea(fio, buf, list[i].li_nbyte,
				    		     list[i].li_status, FULL,
						     &zero );
			}
			else {
				_SETERROR(list[i].li_status, FDC_ERR_REQ, 0);
			}
		}
		else if ( cmd == LC_WAIT ) {
			if ( list[i].li_opcode == LO_READ ) {
				status = _cca_read(fio, buf, list[i].li_nbyte,
				    		   list[i].li_status, FULL,
						   &zero );
			}
			else if (list[i].li_opcode == LO_WRITE ) {
				status = _cca_write(fio, buf, list[i].li_nbyte,
				    		    list[i].li_status, FULL,
						    &zero );
			}
			else {
				_SETERROR(list[i].li_status, FDC_ERR_REQ, 0);
			}
		}
		else {
			_SETERROR(list[i].li_status, FDC_ERR_REQ, 0);
		}
		if (status == ERR) {
			continue;
		}

		n_handled++;
	}

	return( n_handled );
}
示例#13
0
void
OPENWA(
    long	*dn,	/* pointer to null-terminated file name */
    long	*index,
    long	*eoi,
    long	**addr,
    long	*blocks,
    long	*sector,
    long	*ier	/* optional error return. If this parameter is */
    /* not present, we abort on error */
)
{
    WAFIL		*f;
    assign_info	ai;
    int		aifound;
    char		*nmstr;
    unum_t		unitnum;
    unum_t		unitid;
    int		rfd;
    char		c;
    char		*ptr;
    struct ffc_info_s ffi;
    struct fdinfo	*fio;
    struct ffsw	iostat;
    int		errflg = 0;
    long		*erptr;

    unitnum	= -1;			/* assume no unit number */
    unitid	= *(unum_t *) dn;	/* unit ID is 'name' */

    if (_numargs() > 6)
        errflg	= 1;
    /*
     *	Check the assign environment for user requested changes to the
     *	default file characteristics.
     */
    if (strncmp((char *)dn, "fort.", 5) == 0) {
        register unum_t	unum;

        ptr	= (char *)dn + 5;
        unum	= 0;

        while (isdigit(c = *ptr++)) {
            unum	= unum * 10;
            unum	= unum + ((int) c - (int) '0');
        }
        if (c == '\0') {
            unitnum	= unum;
            unitid	= unum;
        }
    }


    aifound	= _assign_asgcmd_info((char *)dn, unitnum, ASN_G_ALL,
                                  &ai, NULL, 1);
    if (aifound == -1) {
        if (errflg) {
            *ier	= -errno;
            _errwa_msg(errno);
            return;
        }
        else
            _errwa_abort(errno);
    }

    if (aifound == 1 && ai.a_actfil_flg)	/* if actual file assigned */
        nmstr	= ai.a_actfil;
    else
        nmstr	= (char *)dn;

    if (errflg)
        erptr	= ier;
    else
        erptr	= NULL;

    G@OPENWA(nmstr, index, eoi, addr, blocks, &aifound, &ai,
             NULL, erptr, sector);

    if (erptr && *erptr != 0) {
        _errwa_msg(-(*erptr));
        return;
    }

    f	= wafils + (*index-1);
    /*
     *	The file name is stored only if we're not being called from libf
     *	via the '-s bin' mechanism.
     */
    (void) strncpy(f->wa_idn, (char*)dn, WA_NAMLEN);

    fio	= GETIOB(f->wa_fd);

    if (f->wa_fdc == YES) {
        if (XRCALL(fio, fcntlrtn)fio, FC_GETINFO, &ffi, &iostat) < 0) {
            if (errflg) {
                *ier	= -iostat.sw_error;
                _errwa_msg(iostat.sw_error);
                return;
            }
            else
                _errwa("OPENWA", "Fcntlrtn error on", f,
                       iostat.sw_error);
        }
        rfd	= ffi.ffc_fd;
    }
    else