Пример #1
0
int op_open(mval *device, mval *devparms, int timeout, mval *mspace)
{
	LITREF unsigned char io_params_size[];
	char		buf1[MAX_TRANS_NAME_LEN];	/* buffer to hold translated name */
	io_log_name	*naml;				/* logical record for passed name */
	io_log_name	*tl;				/* logical record for translated name */
	io_log_name	*prev;				/* logical record for removal search */
	uint4		stat;				/* status */
	mstr		tn;				/* translated name */

	error_def(LP_NOTACQ);				/* bad license */

	MV_FORCE_STR(device);
	MV_FORCE_STR(devparms);
	if (mspace)
		MV_FORCE_STR(mspace);

	if (timeout < 0)
		timeout = 0;
	assert((unsigned char)*devparms->str.addr < n_iops);
	naml = get_log_name(&device->str, INSERT);
	if (naml->iod != 0)
		tl = naml;
	else
	{
#ifdef	NOLICENSE
	licensed= TRUE;
#else
		CRYPT_CHKSYSTEM;
		if (!licensed || LP_CONFIRM(lid, lkid)==LP_NOTACQ)
			licensed= FALSE;
#endif
		switch(stat = trans_log_name(&device->str, &tn, &buf1[0]))
		{
		case SS_NORMAL:
			tl = get_log_name(&tn, INSERT);
			break;
		case SS_NOLOGNAM:
			tl = naml;
			break;
		default:
			for (prev = io_root_log_name, tl = prev->next;  tl != 0;  prev = tl, tl = tl->next)
			{
				if (naml == tl)
				{
					prev->next = tl->next;
					free(tl);
					break;
				}
			}
			rts_error(VARLSTCNT(1) stat);
		}
	}
	stat = io_open_try(naml, tl, devparms, timeout, mspace);
	return (stat);
}
Пример #2
0
/*	The third parameter is dummy to keep the inteface same as op_open	*/
int mu_op_open(mval *v, mval *p, int t, mval *mspace)
{
	char		buf1[MAX_TRANS_NAME_LEN]; /* buffer to hold translated name */
	io_log_name	*naml;		/* logical record for passed name */
	io_log_name	*tl;		/* logical record for translated name */
	int4		stat;		/* status */
	mstr		tn;			/* translated name 	  */

	error_def(LP_NOTACQ);			/* bad license 		  */
	error_def(ERR_LOGTOOLONG);

	MV_FORCE_STR(v);
	MV_FORCE_STR(p);
	if (mspace)
		MV_FORCE_STR(mspace);

	if (t < 0)
		t = 0;
	assert((unsigned char)*p->str.addr < n_iops);
	naml = get_log_name(&v->str, INSERT);
	if (naml->iod != 0)
		tl = naml;
	else
	{
#		ifdef	NOLICENSE
		licensed= TRUE ;
#		else
		CRYPT_CHKSYSTEM;
		if (!licensed || LP_CONFIRM(lid,lkid)==LP_NOTACQ)
		{
			licensed= FALSE ;
		}
#		endif
		switch(stat = TRANS_LOG_NAME(&v->str, &tn, &buf1[0], sizeof(buf1), dont_sendmsg_on_log2long))
		{
		case SS_NORMAL:
			tl = get_log_name(&tn, INSERT);
			break;
		case SS_NOLOGNAM:
			tl = naml;
			break;
		case SS_LOG2LONG:
			rts_error(VARLSTCNT(5) ERR_LOGTOOLONG, 3, v->str.len, v->str.addr, sizeof(buf1) - 1);
			break;
		default:
			rts_error(VARLSTCNT(1) stat);
		}
	}
	stat = mu_open_try(naml, tl, p, mspace);
	return (stat);
}
void stdlog(char *fmt,...)
/*=======================*/
{  FILE *F;
   char buf[4086]="";
   va_list argptr;
   va_start(argptr, fmt);
   vsprintf(buf, fmt, argptr);
   va_end(argptr);
   F=fopen(get_log_name(),"at");
   if(F){ fprintf(F,buf);
          fclose(F);
        }
}
Пример #4
0
int op_open(mval *device, mval *devparms, int timeout, mval *mspace)
{
	char		buf1[MAX_TRANS_NAME_LEN];	/* buffer to hold translated name */
	io_log_name	*naml;				/* logical record for passed name */
	io_log_name	*tl;				/* logical record for translated name */
	io_log_name	*prev;				/* logical record for removal search */
	int4		stat;				/* status */
	mstr		tn;				/* translated name */
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	MV_FORCE_STR(device);
	MV_FORCE_STR(devparms);
	if (mspace)
		MV_FORCE_STR(mspace);
	if (timeout < 0)
		timeout = 0;
	else if (TREF(tpnotacidtime) < timeout)
		TPNOTACID_CHECK(OPENTIMESTR);
	assert((unsigned char)*devparms->str.addr < n_iops);
	naml = get_log_name(&device->str, INSERT);
	if (naml->iod != 0)
		tl = naml;
	else
	{
#		ifdef	NOLICENSE
		licensed= TRUE;
#		else
		CRYPT_CHKSYSTEM;
		if (!licensed || LP_CONFIRM(lid, lkid)==LP_NOTACQ)
			licensed= FALSE;
#		endif
		switch(stat = TRANS_LOG_NAME(&device->str, &tn, &buf1[0], SIZEOF(buf1), dont_sendmsg_on_log2long))
		{
		case SS_NORMAL:
			tl = get_log_name(&tn, INSERT);
			break;
		case SS_NOLOGNAM:
			tl = naml;
			break;
		default:
			for (prev = io_root_log_name, tl = prev->next;  tl != 0;  prev = tl, tl = tl->next)
			{
				if (naml == tl)
				{
					prev->next = tl->next;
					free(tl);
					break;
				}
			}
#			ifdef UNIX
			if (SS_LOG2LONG == stat)
				rts_error(VARLSTCNT(5) ERR_LOGTOOLONG, 3, device->str.len, device->str.addr, SIZEOF(buf1) - 1);
			else
#			endif
				rts_error(VARLSTCNT(1) stat);
		}
	}
	stat = io_open_try(naml, tl, devparms, timeout, mspace);
	return (stat);
}
Пример #5
0
bool io_open_try(io_log_name *naml, io_log_name *tl, mval *pp, int4 timeout, mval *mspace)
{
	char		buf1[MAX_TRANS_NAME_LEN];	/* buffer to hold translated name */
	char		dev_type[MAX_DEV_TYPE_LEN];
        int             n;
	mstr		tn;				/* translated name */
	uint4		stat;				/* status */
	int		p_offset;
	unsigned char	ch;
	ABS_TIME	cur_time, end_time;
	bool		out_of_time = FALSE;

	if (0 == naml->iod)
	{
		if (0 == tl->iod)
		{
			tl->iod = (io_desc *)malloc(SIZEOF(io_desc));
			memset((char*)tl->iod, 0, SIZEOF(io_desc));
			tl->iod->pair.in  = tl->iod;
			tl->iod->pair.out = tl->iod;
			tl->iod->trans_name = tl;
			p_offset = 0;
			while (iop_eol != *(pp->str.addr + p_offset))
			{
				if ((iop_tmpmbx == (ch = *(pp->str.addr + p_offset++))) || (iop_prmmbx == ch))
					tl->iod->type = mb;
				else  if (iop_nl == ch)
					tl->iod->type = nl;
				p_offset += ((IOP_VAR_SIZE == io_params_size[ch]) ?
					(unsigned char)*(pp->str.addr + p_offset) + 1 : io_params_size[ch]);
			}
			if (!tl->iod->type && mspace && mspace->str.len)
			{
				lower_to_upper(dev_type, mspace->str.addr, mspace->str.len);
				if (((SIZEOF("SOCKET") - 1) == mspace->str.len)
					&& (0 == memcmp(dev_type, LIT_AND_LEN("SOCKET"))))
					tl->iod->type = gtmsocket;
				else
					tl->iod->type = us;
			}
			if (!tl->iod->type)
			{
				tn.len = tl->len;
				tn.addr = &tl->dollar_io;
				tl->iod->type = io_type(&tn);
			}
		}
		naml->iod = tl->iod;
	}
	tl->iod->disp_ptr = &io_dev_dispatch[tl->iod->type];
	assert(0 != naml->iod);
	active_device = naml->iod;
	if (dev_never_opened == naml->iod->state)
	{
		naml->iod->wrap = DEFAULT_IOD_WRAP;
		naml->iod->width = DEFAULT_IOD_WIDTH;
		naml->iod->length = DEFAULT_IOD_LENGTH;
		naml->iod->write_filter = write_filter;
	}
	if (dev_open != naml->iod->state)
	{
		naml->iod->dollar.x = 0;
		naml->iod->dollar.y = 0;
		naml->iod->dollar.za = 0;
		naml->iod->dollar.zb[0] = 0;
		naml->iod->dollar.zeof = FALSE;
	}
	if (0 == timeout)
		stat = (naml->iod->disp_ptr->open)(naml, pp, -1, mspace, timeout);	/* ZY: add a parameter timeout */
	else  if (NO_M_TIMEOUT == timeout)
	{
		while (FALSE == (stat = (naml->iod->disp_ptr->open)(naml, pp, -1, mspace, timeout)))	/* ZY: add timeout */
		{
			hiber_start(1000);	/* 1 second */
			if (outofband)
				outofband_action(FALSE);
		}
	} else
	{
		sys_get_curr_time(&cur_time);
		add_int_to_abs_time(&cur_time, timeout * 1000, &end_time);
		while (FALSE == (stat = (naml->iod->disp_ptr->open)(naml, pp, -1, mspace, timeout))	/* ZY: add timeout */
			&& (!out_of_time))
		{
			hiber_start(1000);	/* 1 second */
			if (outofband)
				outofband_action(FALSE);
			sys_get_curr_time(&cur_time);
			if (abs_time_comp(&end_time, &cur_time) <= 0)
				out_of_time = TRUE;
		}
	}
	if (TRUE == stat)
	{
		naml->iod->state = dev_open;
		if (27 == naml->iod->trans_name->dollar_io[0])
		{
			tn.addr = &naml->iod->trans_name->dollar_io[4];
			n = naml->iod->trans_name->len - 4;
			if (n < 0)
				n = 0;
			tn.len = n;
			naml->iod->trans_name = get_log_name(&tn, INSERT);
			naml->iod->trans_name->iod = naml->iod;
		}
	}
	else
	{
		if (dev_open == naml->iod->state && (gtmsocket != naml->iod->type))
			naml->iod->state = dev_closed;
		else if ((gtmsocket == naml->iod->type) && naml->iod->newly_created)
		{
			assert(naml->iod->state != dev_open);
			iosocket_destroy(naml->iod);
		}
	}
	active_device = 0;
	if ((NO_M_TIMEOUT != timeout) && IS_MCODE_RUNNING)
		return (stat);
	return FALSE;
}
Пример #6
0
short iorm_open(io_log_name *iol, mval *pp, int fd, mval *mspace, int4 timeout)
{
	int4		status;
	io_desc		*iod;		/* local pointer to io_curr_device */
	d_rm_struct	*d_rm;
	struct	XABFHC	xabfhc;
	struct	XABPRO	xabpro;
	struct RAB	*r;
	struct FAB	*f;
	struct NAM	*nam;
	mstr		newtln;
	struct dsc$descriptor_s devname, outname;
	uint4		width;
	uint4		acebin[128];	/* needs to be big enough for any other ACLs on file */
	uint4		*acebinptr;
	struct acedef	*aceptr;
	char		*acetop;
	boolean_t	acefound = FALSE, created = FALSE, isdisk = FALSE, noacl = FALSE;
	unsigned int	devclass, devchar, devchar2, devtype, dvistat, iosb[2];
	short		devclassret, devcharret, devchar2ret, devtyperet;
	struct
	{
		item_list_3	item[4];
		int		terminator;
	} item_list;
	unsigned char resultant_name[255];
	unsigned char	tmpfdns;
	/** unsigned char resultant_name[MAX_TRANS_NAME_LEN]; THIS WOULD BE RIGHT BUT MAX_TRANS_NAME_LEN MUST BE <= 255 **/

	/* while sr_unix/iorm_open.c prefixes errors with ERR_DEVOPENFAIL and it might be nice to be consistent */
	/* changing VMS after all this time could break user programs */
	/* An exception is being made for the extremely unlikely problem creating a GTM ACE so it stands out */
	iod = iol->iod;
	assert(*(pp->str.addr) < n_iops);
	assert(iod);
	assert(iod->state >= 0 && iod->state < n_io_dev_states);
	assert(rm == iod->type);
	if (dev_never_opened == iod->state)
	{
		iod->dev_sp = (d_rm_struct *)(malloc(SIZEOF(d_rm_struct)));
		d_rm = (d_rm_struct *)iod->dev_sp;
		memset(d_rm, 0, SIZEOF(*d_rm));
		iod->width = DEF_RM_WIDTH;
		iod->length = DEF_RM_LENGTH;
		r  = &d_rm->r;
		f  = &d_rm->f;
		*r  = cc$rms_rab;
		*f  = cc$rms_fab;
		r->rab$l_fab = f;
		r->rab$w_usz = d_rm->l_usz = DEF_RM_WIDTH;
		f->fab$w_mrs = d_rm->l_mrs = DEF_RM_WIDTH;
		f->fab$b_rfm = d_rm->b_rfm = FAB$C_VAR;	/* default is variable record format */
		f->fab$l_fop = FAB$M_CIF | FAB$M_SQO | FAB$M_CBT | FAB$M_NAM;
		f->fab$b_fac = FAB$M_GET | FAB$M_PUT | FAB$M_TRN; /* TRN allows truncate option to be specified in RAB later */
		f->fab$b_rat = FAB$M_CR;

		f->fab$l_dna = DFLT_FILE_EXT;
		f->fab$b_dns = SIZEOF(DFLT_FILE_EXT) - 1;
		d_rm->f.fab$l_nam = nam = malloc(SIZEOF(*nam));
		*nam = cc$rms_nam;
		nam->nam$l_esa = resultant_name;
		nam->nam$b_ess = SIZEOF(resultant_name);
		nam->nam$b_nop = NAM$M_NOCONCEAL;

		r->rab$l_rop = RAB$M_TMO | RAB$M_WBH | RAB$M_RAH;
		d_rm->promask = 0xFFFF;
	} else
	{
		d_rm = (d_rm_struct *)iod->dev_sp;
		if (dev_closed == iod->state)
			d_rm->f.fab$w_bls = 0; /* Reset the block size to pass the block-record check below.
						* The FAB initialization sets the block size later so it's OK to zero it here.
						*/
		nam = d_rm->f.fab$l_nam;
		nam->nam$l_esa = 0;
		nam->nam$b_ess = 0;
		nam->nam$b_esl = 0;
	}
	iorm_use(iod, pp);
	if (dev_open != iod->state)
	{
		if (!d_rm->largerecord && (d_rm->f.fab$w_bls > 0) && (FAB$C_FIX != d_rm->f.fab$b_rfm)
			&& (d_rm->f.fab$w_bls < (d_rm->r.rab$w_usz + VREC_HDR_LEN)))
				rts_error(VARLSTCNT(1) ERR_VARRECBLKSZ);
		d_rm->r.rab$l_ctx = FAB$M_GET;
		d_rm->f.fab$l_fna = iol->dollar_io;
		d_rm->f.fab$b_fns = iol->len;
/* smw next overrides any xab set by iorm_use */
		xabpro = cc$rms_xabpro;
		d_rm->f.fab$l_xab = &xabpro;
		memset(acebin, 0, SIZEOF(acebin));
		status = sys$parse(&d_rm->f);	/* to get device for getdvi */
		if ((1 & status))
		{
			devname.dsc$w_length = nam->nam$b_dev;
			devname.dsc$a_pointer = nam->nam$l_dev;
			devname.dsc$b_dtype = DSC$K_DTYPE_T;
			devname.dsc$b_class = DSC$K_CLASS_S;
			item_list.item[0].item_code = DVI$_DEVCLASS;
			item_list.item[0].buffer_length = SIZEOF(devclass);
			item_list.item[0].buffer_address = &devclass;
			item_list.item[0].return_length_address = &devclassret;
			item_list.item[1].item_code = DVI$_DEVCHAR;
			item_list.item[1].buffer_length = SIZEOF(devchar);
			item_list.item[1].buffer_address = &devchar;
			item_list.item[1].return_length_address = &devcharret;
			item_list.item[2].item_code = DVI$_DEVCHAR2;
			item_list.item[2].buffer_length = SIZEOF(devchar2);
			item_list.item[2].buffer_address = &devchar2;
			item_list.item[2].return_length_address = &devchar2ret;
			item_list.item[3].item_code = DVI$_DEVTYPE;
			item_list.item[3].buffer_length = SIZEOF(devtype);
			item_list.item[3].buffer_address = &devtype;
			item_list.item[3].return_length_address = &devtyperet;
			item_list.terminator = 0;
			dvistat = sys$getdviw(EFN$C_ENF, NULL, &devname, &item_list, iosb, NULL, 0, 0);
			if (SS$_NORMAL == dvistat)
				dvistat = iosb[0];
			if (SS$_NONLOCAL == dvistat || (SS$_NORMAL == dvistat &&
				((DC$_DISK != devclass || (DEV$M_NET & devchar) ||
				(DEV$M_DAP | DEV$M_DFS) & devchar2) || /* UCX NFS sets DFS */
				(DT$_FD1 <= devtype && DT$_FD8 >= devtype) ))) /* but not tcpware so check foreign disk */
			{	/* if not disk, dfs/nfs, or non local, create gets BADATTRIB in stv if acl buf and siz set */
				noacl = TRUE;
			}
		} else /* let create/open report the problem */
			noacl = TRUE;
		if (DEV$M_NET & d_rm->f.fab$l_dev)
		{	/* need to release sys$parse channel if DECnet */
			tmpfdns = d_rm->f.fab$b_dns;
			d_rm->f.fab$b_dns = 0;
			assert(0 == nam->nam$l_rlf);
			nam->nam$l_rlf = 0;
			nam->nam$b_nop |= NAM$M_SYNCHK;
			status = sys$parse(&d_rm->f);	/* give up channel */
			d_rm->f.fab$b_dns = tmpfdns;	/* restore */
			nam->nam$b_nop &= ~NAM$M_SYNCHK;
		}
		if (noacl)
		{
			if (d_rm->largerecord && MAX_RMS_RECORDSIZE < d_rm->l_mrs)
				rts_error(VARLSTCNT(1) ERR_RMWIDTHTOOBIG);
			d_rm->largerecord = FALSE;
		}
		if (d_rm->largerecord && FAB$M_GET != d_rm->f.fab$b_fac)
		{	/* if readonly use format from existing file */
			aceptr = acebin;
			aceptr->ace$b_size = GTM_ACE_SIZE * SIZEOF(uint4);
			aceptr->ace$b_type = ACE$C_INFO;
			/* without NOPROPAGATE, new versions will get ACE,
			   PROTECTED prevents set acl /dele unless =all */
			aceptr->ace$w_flags = ACE$M_NOPROPAGATE | ACE$M_PROTECTED;
/*			if HIDDEN, dir/sec does not display which may make it harder to check if problems
			aceptr->ace$w_flags |= ACE$M_HIDDEN;
*/
			aceptr->ace$v_info_type = ACE$C_CUST;	/* must be after flags */
			aceptr->ace$w_application_facility = GTM_ACE_FAC;	/* GTM error fac */
			aceptr->ace$w_application_flags = GTM_ACE_BIGREC;
			assert(SIZEOF(uint4) * GTM_ACE_LAB_OFF == (&aceptr->ace$t_info_start - (char *)aceptr));
			acebin[GTM_ACE_LAB_OFF] = GTM_ACE_LABEL;
			acebin[GTM_ACE_RFM_OFF] = d_rm->b_rfm;
			acebin[GTM_ACE_MRS_OFF] = d_rm->l_mrs;
			acebin[GTM_ACE_SIZE] = 0;	/* terminate */
			d_rm->f.fab$b_rfm = FAB$C_UDF;
			d_rm->f.fab$w_mrs = 0;
		}
		if (!noacl)
		{	/* tape gets BADATTRIB in stv if acl buf and siz set */
			xabpro.xab$l_aclbuf = acebin;
			xabpro.xab$w_aclsiz = SIZEOF(acebin);
		}
		if (FAB$M_GET == d_rm->f.fab$b_fac)
		{
			xabfhc = cc$rms_xabfhc;
			xabpro.xab$l_nxt = &xabfhc;
			status = sys$open(&d_rm->f);
		} else
		{
			xabpro.xab$w_pro = d_rm->promask;
			status = sys$create(&d_rm->f);
		}
		nam->nam$l_esa = 0;
		nam->nam$b_ess = 0;
		nam->nam$b_esl = 0;
		d_rm->f.fab$l_xab = 0;
		switch (status)
		{
		case RMS$_NORMAL:
		if (d_rm->f.fab$l_fop & FAB$M_MXV)
			created = iod->dollar.zeof = TRUE;
		break;

		case RMS$_CRE_STM:
		case RMS$_CREATED:
		case RMS$_SUPERSEDE:
		case RMS$_FILEPURGED:
		if (d_rm->f.fab$l_dev & DEV$M_FOD)
			created = iod->dollar.zeof = TRUE;
		break;

		case RMS$_ACT:
		case RMS$_FLK:
			return(FALSE);

		default:
			rts_error(VARLSTCNT(2) status, d_rm->f.fab$l_stv);
		}
		if (!noacl && (DEV$M_RND & d_rm->f.fab$l_dev) && !(DEV$M_NET & d_rm->f.fab$l_dev))
			isdisk = TRUE;	/* local disk */
		else if (created && d_rm->largerecord && MAX_RMS_RECORDSIZE < d_rm->l_mrs)
			rts_error(VARLSTCNT(1) ERR_RMWIDTHTOOBIG);
		/* $create does not return the ACE:  if a new file is created aclsts is IVACL            */
		/*				     if CIF and existing file has no acl aclsts ACLEMPTY */
		/*				     if CIF and existing file has acl aclsts is NORMAL   */
		if (isdisk && ((created && SS$_IVACL == xabpro.xab$l_aclsts) || (0 != xabpro.xab$l_aclsts &&
			(FAB$M_GET != d_rm->f.fab$b_fac && ((1 & xabpro.xab$l_aclsts) || SS$_ACLEMPTY != xabpro.xab$l_aclsts)))))
		{
			xabpro.xab$l_aclctx = 0;        /* reset context */
			d_rm->f.fab$l_xab = &xabpro;
			status = sys$display(&d_rm->f);
			d_rm->f.fab$l_xab = 0;		/* prevent close error */
			if (!(1 & status))
				rts_error(VARLSTCNT(2) status, d_rm->f.fab$l_stv);
			if (0 != xabpro.xab$l_aclsts && !(1 & xabpro.xab$l_aclsts) && SS$_ACLEMPTY != xabpro.xab$l_aclsts)
				rts_error(VARLSTCNT(1) xabpro.xab$l_aclsts);
		}
		if (isdisk && (1 & status) && 0 != xabpro.xab$l_aclsts && !(1 & xabpro.xab$l_aclsts) &&
				SS$_ACLEMPTY != xabpro.xab$l_aclsts)
			rts_error(VARLSTCNT(1) xabpro.xab$l_aclsts);
		if (isdisk && 0 != xabpro.xab$w_acllen && (1 & status))	/* acl and success */
		{
			if (SIZEOF(acebin) < xabpro.xab$w_acllen)
			{	/* get a new buffer big enough */
				xabpro.xab$l_aclbuf = malloc(xabpro.xab$w_acllen);
				xabpro.xab$w_aclsiz = xabpro.xab$w_acllen;
				xabpro.xab$l_aclctx = 0;	/* reset context */
				d_rm->f.fab$l_xab = &xabpro;
				status = sys$display(&d_rm->f);
				d_rm->f.fab$l_xab = 0;
				if (!(1 & status))
					rts_error(VARLSTCNT(2) status, d_rm->f.fab$l_stv);
				if (!(1 & xabpro.xab$l_aclsts))
					rts_error(VARLSTCNT(1) xabpro.xab$l_aclsts);
			}
			acetop = (char *)xabpro.xab$l_aclbuf + xabpro.xab$w_acllen;
			for (aceptr = xabpro.xab$l_aclbuf; aceptr < acetop; aceptr = (char *)aceptr + aceptr->ace$b_size)
			{
				if (0 == aceptr->ace$b_size)
					break;
				if (ACE$C_INFO == aceptr->ace$b_type && ACE$C_CUST == aceptr->ace$v_info_type
					&& GTM_ACE_FAC == aceptr->ace$w_application_facility
					&& GTM_ACE_BIGREC == aceptr->ace$w_application_flags)
				{	/* info for large records */
					acebinptr = aceptr;
					assert(GTM_ACE_LABEL == acebinptr[GTM_ACE_LAB_OFF]);
					d_rm->largerecord = TRUE;
					d_rm->b_rfm = (unsigned char)acebinptr[GTM_ACE_RFM_OFF];
					d_rm->l_mrs = acebinptr[GTM_ACE_MRS_OFF];
					acefound = TRUE;
					break;
				}
			}
			if (acebin != xabpro.xab$l_aclbuf)
			{	/* free larger buffer now */
				free(xabpro.xab$l_aclbuf);
				xabpro.xab$l_aclbuf = acebin;
				xabpro.xab$w_aclsiz = SIZEOF(acebin);
			}
		}
		if (!acefound)
		{
			if (!created)
			{	/* copy from exisiting file */
				if (isdisk && d_rm->largerecord && FAB$C_UDF == d_rm->f.fab$b_rfm)
					rts_error(VARLSTCNT(1) ERR_BIGNOACL);	/* maybe lost in copy */
				d_rm->b_rfm = d_rm->f.fab$b_rfm;
				d_rm->l_mrs = d_rm->f.fab$w_mrs;
			} else if (isdisk && d_rm->largerecord)
				rts_error(VARLSTCNT(8) ERR_DEVOPENFAIL, 2, iol->len, iol->dollar_io,
					ERR_TEXT, 2, LEN_AND_LIT("GTM ACE on new file disappeared - possible VMS problem"));
			d_rm->largerecord = FALSE;
		}
/* smw does next overwriting of mrs make sense to RMS */
		/* if not largerecord, read only, sequential, not magtape ... */
		if (!d_rm->largerecord && (FAB$M_GET == d_rm->f.fab$b_fac) && (0 == d_rm->f.fab$w_mrs) && xabfhc.xab$w_lrl)
			d_rm->l_mrs = d_rm->l_usz = d_rm->r.rab$w_usz = d_rm->f.fab$w_mrs = xabfhc.xab$w_lrl;

		if (d_rm->largerecord)
		{ /* guess at a good blocks per IO */
			uint4 blocksperrec;
			blocksperrec = DIVIDE_ROUND_UP(d_rm->l_mrs, RMS_DISK_BLOCK);
			if (RMS_MAX_MBC <= blocksperrec * 2)
				d_rm->r.rab$b_mbc = RMS_MAX_MBC;
			else if (RMS_DEF_MBC < blocksperrec * 2)
				d_rm->r.rab$b_mbc = blocksperrec * 2;
		}
		status = sys$connect(&d_rm->r);
		if (RMS$_NORMAL != status)
			rts_error(VARLSTCNT(2) status, d_rm->r.rab$l_stv);
		if (d_rm->r.rab$l_rop & RAB$M_EOF)
			iod->dollar.zeof = TRUE;
		if (ESC == iod->trans_name->dollar_io[0])
		{
			/* process permanent file...get real name */
			status = sys$display(&d_rm->f);
			if (status & 1)
			{
				devname.dsc$w_length = nam->nam$t_dvi[0];
				devname.dsc$b_dtype = DSC$K_DTYPE_T;
				devname.dsc$b_class = DSC$K_CLASS_S;
				devname.dsc$a_pointer = &nam->nam$t_dvi[1];
				outname.dsc$w_length = SIZEOF(resultant_name);
				outname.dsc$b_dtype = DSC$K_DTYPE_T;
				outname.dsc$b_class = DSC$K_CLASS_S;
				outname.dsc$a_pointer = resultant_name;
				status = lib$fid_to_name(&devname, &nam->nam$w_fid, & outname, &newtln.len, 0, 0);
				if ((status & 1) && (0 != newtln.len))
				{
					newtln.addr = resultant_name;
					iod->trans_name = get_log_name(&newtln, INSERT);
					iod->trans_name->iod = iod;
				}
			}
		} else
		{	/* smw since esl zeroed above this is dead code since early days */
			if (nam->nam$b_esl && (iod->trans_name->len != nam->nam$b_esl ||
				memcmp(&iod->trans_name->dollar_io[0], resultant_name, nam->nam$b_esl)))
			{
				newtln.addr = resultant_name;
				newtln.len = nam->nam$b_esl;
				iod->trans_name = get_log_name(&newtln, INSERT);
				iod->trans_name->iod = iod;
			}
		}
		if (0 == d_rm->l_mrs)
			d_rm->l_mrs = iod->width;
		iod->width = d_rm->l_usz = d_rm->l_mrs;
		if (!d_rm->largerecord)
		{
			d_rm->r.rab$w_usz = d_rm->f.fab$w_mrs = d_rm->l_mrs;
			if (FAB$C_VFC == d_rm->f.fab$b_rfm) /* have to leave two bytes for the fixed control */
				iod->width = MIN(iod->width, VFC_MAX_RECLEN);
		}
		width = iod->width;
		if (d_rm->largerecord)
		{
			width = ROUND_UP(width, SIZEOF(uint4));
			if (FAB$C_VAR == d_rm->b_rfm)
				width += SIZEOF(uint4);	/* for count */
		}
		d_rm->bufsize = width + 1;
		d_rm->inbuf = (char*)malloc(width + 1);
		d_rm->outbuf_start = (char*)malloc(width + 1);
		d_rm->inbuf_pos = d_rm->inbuf;
		d_rm->inbuf_top = d_rm->inbuf + iod->width;
		d_rm->outbuf_pos = d_rm->outbuf = d_rm->outbuf_start + (d_rm->largerecord && FAB$C_VAR == d_rm->b_rfm
							? SIZEOF(uint4) : 0);
		d_rm->outbuf_top = d_rm->outbuf + iod->width;
		d_rm->promask = xabpro.xab$w_pro;
		iod->state = dev_open;
	}
	return TRUE;
}
Пример #7
0
static ssize_t bcmlog_ap_crash_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{
	return snprintf(buf, MAX_STR_NAME + 1, "%s\n",
			get_log_name(g_config.ap_crashlog.dev));
}
Пример #8
0
void op_use(mval *v, mval *p)
{
	char		buf1[MAX_TRANS_NAME_LEN];  /* buffer to hold translated name */
	io_log_name	*nl;		/* logical record for passed name */
	io_log_name	*tl;		/* logical record for translated name */
	int4		stat;		/* status */
	mstr		tn;		/* translated name */
	int		dollar_zpselect;	/* 0 - both, 1 - input only, 2 - output only */
	char		*c1;		/* used to compare $P name */
	int		nlen;		/* len of $P name */
	io_log_name	*tlp;		/* logical record for translated name for $principal */

	MV_FORCE_STR(v);
	MV_FORCE_STR(p);

	dollar_zpselect = 0;
	if (io_std_device->in != io_std_device->out)
	{
		/* if there is a split $P then determine from the name if it is the value of "$P< /" or "$P> /"
		   if the first then it is $ZPIN so set dollar_zpselect to 1
		   if the second then it is $ZPOUT so set dollar_zpselect to 2
		   else set dollar_zpselect to 0
		   if it is $ZPIN or $ZPOUT get the log_name for $P into nl else use the mval v passed in
		*/
		tlp = dollar_principal ? dollar_principal : io_root_log_name->iod->trans_name;
		nlen = tlp->len;
		assert(dollar_zpout.len == dollar_zpin.len);
		if ((nlen + dollar_zpin.len) == v->str.len)
		{
			/* passed the length test now compare the 2 pieces, the first one the length of $P and the
			   second $ZPIN or $ZPOUT */
			c1 = (char *)tlp->dollar_io;
			if (!memvcmp(c1, nlen, &(v->str.addr[0]), nlen))
			{
				if (!memvcmp(dollar_zpin.addr, dollar_zpin.len, &(v->str.addr[nlen]), dollar_zpin.len))
					dollar_zpselect = 1;
				else if (!memvcmp(dollar_zpout.addr, dollar_zpout.len, &(v->str.addr[nlen]), dollar_zpout.len))
					dollar_zpselect = 2;
			}
		}
	}
	if (0 == dollar_zpselect)
		nl = get_log_name(&v->str, NO_INSERT);
	else
		nl = get_log_name(&dollar_prin_log, NO_INSERT);
	if (!nl)
	{
		stat = TRANS_LOG_NAME(&v->str, &tn, buf1, SIZEOF(buf1), do_sendmsg_on_log2long);
		if (stat != SS_NORMAL)
			rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_IONOTOPEN);
		else
		{
			if ((tl = get_log_name(&tn, NO_INSERT)) == 0)
				rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_IONOTOPEN);
			if (!tl->iod)
				rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_IONOTOPEN);
			nl = get_log_name(&v->str, INSERT);
			nl->iod = tl->iod;
		}
	}
	if (nl->iod->state != dev_open)
		rts_error_csa(CSA_ARG(NULL) VARLSTCNT(1) ERR_IONOTOPEN);

	if (dollar_principal && nl->iod == dollar_principal->iod)
	{	/* if device is a GTM_PRINCIPAL synonym */
		nl = dollar_principal;
	}
	else
	{
		/* special case U "" , U 0, U $ZPIN, U $ZPOUT to be equivalent to U $P */
		/* $ZPIN or $ZPOUT force nl to "0" */
		/* note: "" is always the root */
		if (nl == io_root_log_name || ((1 == nl->len) && ('0' == nl->dollar_io[0])))
			nl = nl->iod->trans_name;
	}
	active_device = nl->iod;
	io_curr_device = nl->iod->pair;
	io_curr_device.in->name = nl;
	if (nl->iod->pair.in == nl->iod->pair.out)
		(nl->iod->disp_ptr->use)(nl->iod, p);
	else
	{
		if (2 != dollar_zpselect)
			(nl->iod->disp_ptr->use)(nl->iod, p);
		if (1 != dollar_zpselect)
			(nl->iod->pair.out->disp_ptr->use)(nl->iod->pair.out, p);
	}
	active_device = 0;
	return;
}
Пример #9
0
void io_init(bool term_ctrl)
{
	static readonly unsigned char open_params_list[2] =
	{
		(unsigned char)iop_newversion,
		(unsigned char)iop_eol
	};
	static readonly unsigned char null_params_list[2] =
	{
		(unsigned char)iop_nl,
		(unsigned char)iop_eol
	};
	static readonly unsigned char	no_params = (unsigned char)iop_eol;
	static readonly unsigned char	shr_params[3] =
	{
		(unsigned char)iop_shared,
		(unsigned char)iop_readonly,
		(unsigned char)iop_eol
	};

	int4		status;
        mval    	val;
	mstr		tn;
 	MSTR_CONST	(gtm_netout, "GTM_NETOUT");
 	MSTR_CONST	(sys_net, "SYS$NET");
	char		buf1[MAX_TRANS_NAME_LEN]; /* buffer to hold translated name */
	mval		pars;
	io_log_name	*inp, *outp;
	io_log_name	*ln;

	error_def(ERR_LOGTOOLONG);

	io_init_name();
	/* default logical names */
	io_root_log_name = (io_log_name *)malloc(SIZEOF(*io_root_log_name));
	memset(io_root_log_name, 0, SIZEOF(*io_root_log_name));
	val.mvtype = MV_STR;
	val.str.addr = "0";
	val.str.len = 1;
	ln = get_log_name(&val.str, INSERT);
	assert(ln != 0);
	val.str = gtm_principal;
	status = TRANS_LOG_NAME(&val.str, &tn, buf1, SIZEOF(buf1), dont_sendmsg_on_log2long);
	if (SS_NOLOGNAM == status)
		dollar_principal = 0;
	else if (SS_NORMAL == status)
		dollar_principal = get_log_name(&tn, INSERT);
#	ifdef UNIX
	else if (SS_LOG2LONG == status)
		rts_error(VARLSTCNT(5) ERR_LOGTOOLONG, 3, val.str.len, val.str.addr, SIZEOF(buf1) - 1);
#	endif
	else
		rts_error(VARLSTCNT(1) status);

	/* open devices */
	val.str = sys_input;
	inp = get_log_name(&val.str, INSERT);
	pars.mvtype = MV_STR;
	status = TRANS_LOG_NAME(&val.str, &tn, buf1, SIZEOF(buf1), dont_sendmsg_on_log2long);
	if (SS_NOLOGNAM == status)
	{
		pars.str.len = SIZEOF(null_params_list);
		pars.str.addr = (char *)null_params_list;
	} else if (SS_NORMAL == status)
	{
		if (!io_is_rm(&val.str))
		{
			pars.str.len = SIZEOF(no_params);
			pars.str.addr = (char *)&no_params;
		} else  if (io_is_sn(&val.str))
		{
			pars.str.len = SIZEOF(open_params_list);
			pars.str.addr = (char *)open_params_list;
		} else
		{
			pars.str.len = SIZEOF(shr_params);
			pars.str.addr = (char *)shr_params;
		}
	}
#	ifdef UNIX
	else if (SS_LOG2LONG == status)
		rts_error(VARLSTCNT(5) ERR_LOGTOOLONG, 3, val.str.len, val.str.addr, SIZEOF(buf1) - 1);
#	endif
	else
		rts_error(VARLSTCNT(1) status);
	ESTABLISH(io_init_ch);
	(*op_open_ptr)(&val, &pars, 0, 0);
	io_curr_device.in  = io_std_device.in  = inp->iod;
	val.str = sys_output;
	if ((SS_NORMAL == TRANS_LOG_NAME(&gtm_netout, &tn, buf1, SIZEOF(buf1), do_sendmsg_on_log2long))
			&& (SS_NORMAL == TRANS_LOG_NAME(&sys_net, &tn, buf1, SIZEOF(buf1), do_sendmsg_on_log2long))
			&& io_is_sn(&sys_net))
		val.str = sys_net;
	outp = get_log_name(&val.str, INSERT);
	status = TRANS_LOG_NAME(&val.str, &tn, buf1, SIZEOF(buf1), dont_sendmsg_on_log2long);
	if ((SS_NORMAL != status) && (SS_NOLOGNAM != status))
	{
#		ifdef UNIX
		if (SS_LOG2LONG == status)
			rts_error(VARLSTCNT(5) ERR_LOGTOOLONG, 3, val.str.len, val.str.addr, SIZEOF(buf1) - 1);
		else
#		endif
			rts_error(VARLSTCNT(1) status);
	}
	if ((val.str.addr == sys_net.addr) && (pars.str.addr == (char *)open_params_list))
		/* sys$net is the only input thing that uses open_params_list */
		outp->iod = io_curr_device.in;
	/* For terminals and mailboxes and sockets, SYS$INPUT and SYS$OUTPUT may point to
		the same device.  If input is one of those, then check translated
		name for output against translated name for input;
		in that case they should be joined by their logical names */
	if (((tt == io_curr_device.in->type) || (mb == io_curr_device.in->type) ||
		(gtmsocket == io_curr_device.in->type))
		&& same_device_check(tn, buf1))
		outp->iod = io_curr_device.in;
	if (!outp->iod)
	{
		if (status == SS_NOLOGNAM)
		{
			pars.str.len = SIZEOF(null_params_list);
			pars.str.addr = (char *)null_params_list;
		} else  if (status == SS_NORMAL)
		{
			pars.str.len = SIZEOF(open_params_list);
			pars.str.addr = (char *)open_params_list;
		}
		(*op_open_ptr)(&val, &pars, 0, 0);
	}
	io_curr_device.out = io_std_device.out = outp->iod;
	term_setup(term_ctrl);
	io_std_device.out->pair = io_std_device;
	io_std_device.in->pair = io_std_device;
	io_std_device.out->perm = io_std_device.in->perm = TRUE;
	for (ln = io_root_log_name;  ln;  ln = ln->next)
		ln->iod = io_std_device.in;

	if (dollar_principal)
		dollar_principal->iod = io_std_device.in;
	pars.str.len = SIZEOF(no_params);
	pars.str.addr = (char *)&no_params;
	val.str.len = io_curr_device.in->trans_name->len;
	val.str.addr = io_std_device.in->trans_name->dollar_io;
	op_use(&val, &pars);
	REVERT;
	return;
}