Ejemplo n.º 1
0
int XtAlloc(int  last,
               int  most,
               char *info,
	       xlist**rr)
{
  xlist *r;
  int ierr=0;

  r=(xlist*) calloc(1,sizeof(xlist));
  if (!r) ExitProc(OutOfSpc,info);

  
  r->loca=TRUE;
  r->last=last;
  r->most=most;
  r->ntot=0;
    
  ierr=iAlloc(most+1,info,&r->head); if(ierr) return 1;
  ierr=iAlloc(last,info,&r->port); if(ierr) return 1;
  ierr=iAlloc(last,info,&r->fwrd); if(ierr) return 1;
  ierr=iAlloc(last,info,&r->bwrd); if(ierr) return 1;
  
  XtClear(r);
  
  *rr=r;
  return (0);
} /* XtAlloc */
Ejemplo n.º 2
0
chfac *CfcAlloc(int  maxrow,
                char *info)
{
  chfac *r=NULL;
  
  if (maxrow) {
    r=(chfac*)calloc(1,sizeof(chfac));
    if (!r) ExitProc(OutOfSpc,info);
    
    r->mrow =maxrow;
    r->nrow =maxrow;
      
    r->snnz =0;
    r->shead=iAlloc(maxrow,info);
    r->ssize=iAlloc(maxrow,info);
    r->ssub =NULL;
    r->diag =dAlloc(maxrow,info);
    r->unnz =0;
    r->ujnz =0;
    r->ujbeg=iAlloc(maxrow,info);
    r->uhead=iAlloc(maxrow,info);
    r->ujsze=iAlloc(maxrow,info);
    r->usub =NULL;
    r->uval =NULL;
    r->perm =iAlloc(maxrow,info);
    r->invp =iAlloc(maxrow,info);
    r->nsnds=0;
    r->subg =iAlloc(maxrow+1,info);      
  }
  return r;
} /* SchlAlloc */
Ejemplo n.º 3
0
int GetOrder(order *od,
             int   *p)
{
  int   ierr=0,bbufs=2,*bbuf[2]={0},
        ibufs=9,*ibuf[9]={0},
        n,*iwmd;
  xlist *xt;

  n=od->nnod;

  ierr=XtAlloc(n,n+1,"xt, GetOrder",&xt); if(ierr) return FALSE;
  ierr=iAlloc(n,"ibuf21, GetOrder",&iwmd); if(ierr) return FALSE;
  
  IptAlloc(ibufs,n,ibuf,"ibuf, GetOrder");
  IptAlloc(bbufs,n,bbuf,"bbuf, GetOrder");
  
  OdProc(od,xt,ibuf[0],ibuf[1],ibuf[2],ibuf[3],ibuf[4],ibuf[5],
         ibuf[6],ibuf[7],ibuf[8],iwmd,bbuf[0],bbuf[1],p);
    

  /*
    XtFree(&xt);
  */

  free(xt->head);
  free(xt->port);
  free(xt->fwrd);
  free(xt->bwrd);
  free(xt);

  iFree(&iwmd);
  IptFree(ibufs,ibuf);
  IptFree(bbufs,bbuf); 
  return TRUE;
} /* GetOrder */
Ejemplo n.º 4
0
static void copyChl(chfac *af,
                    chfac *bf)
{
  iFree(&af->shead);
  iFree(&af->ssize);
  iFree(&af->ssub);
  
  iFree(&bf->shead);
  iFree(&bf->ssize);
  iFree(&bf->ssub);
  
  bf->unnz =af->unnz;
  bf->ujnz =af->ujnz;
  bf->nsnds=af->nsnds;
  bf->ndens=af->ndens;
  bf->nsndn=af->nsndn;
  bf->sdens=af->sdens;
  bf->upst =af->upst;
  
  bf->usub =iAlloc(bf->ujnz,"usub, copyChl");
  bf->uval =dAlloc(bf->unnz,"uval, copyChl");
  
  iCopy(af->ujnz,af->usub,bf->usub);
  iCopy(af->nrow,af->ujbeg,bf->ujbeg);
  iCopy(af->nrow,af->uhead,bf->uhead);
  iCopy(af->nrow,af->ujsze,bf->ujsze);
  iCopy(af->nrow,af->perm,bf->perm);
  iCopy(af->nrow,af->invp,bf->invp);
  iCopy(af->nrow+1,af->subg,bf->subg);
  
  bf->dhead=iAlloc(af->ndens+1,"dhead, copyChl");
  iCopy(af->ndens+1,af->dhead,bf->dhead);
  
  if (af->nsnds) {
    bf->dbeg=iAlloc(af->nsnds,"dbeg, copyChl");
    bf->dsub=iAlloc(af->nsnds,"dsub, copyChl");
    iCopy(af->nsnds,af->dbeg,bf->dbeg);
    iCopy(af->nsnds,af->dsub,bf->dsub);
  }
} /* copyChl */
Ejemplo n.º 5
0
int CfcAlloc(int  maxrow,
                char *info,chfac**rr)
{
  chfac *r=NULL;
  int ierr=0;

  if (maxrow) {
    r=(chfac*)calloc(1,sizeof(chfac));
    if (!r) ExitProc(OutOfSpc,info);
    
    r->mrow =maxrow;
    r->nrow =maxrow;
      
    r->snnz =0;
    ierr=iAlloc(maxrow,info,&r->shead); if(ierr) return 1;
    ierr=iAlloc(maxrow,info,&r->ssize); if(ierr) return 1;
    r->ssub =NULL;
    ierr=dAlloc(maxrow,info,&r->diag); if(ierr) return 1;
    ierr=dAlloc(maxrow,info,&r->sqrtdiag); if(ierr) return 1;
    r->unnz =0;
    r->ujnz =0;
    ierr=iAlloc(maxrow,info,&r->ujbeg); if(ierr) return 1;
    ierr=iAlloc(maxrow,info,&r->uhead); if(ierr) return 1;
    ierr=iAlloc(maxrow,info,&r->ujsze); if(ierr) return 1;
    r->usub =NULL;
    r->uval =NULL;
    ierr=iAlloc(maxrow,info,&r->perm); if(ierr) return 1;
    ierr=iAlloc(maxrow,info,&r->invp); if(ierr) return 1;
    r->nsnds=0;
    ierr=iAlloc(maxrow+1,info,&r->subg);  if(ierr) return 1;     
    r->n=maxrow;
    r->alldense=0;
    r->tolpiv=1.0e-13; /* Standard */
    r->tolpiv=1.0e-35;
    r->cachesize   =256;
#ifdef DSDPCACHESIZE
    if (DSDPCACHESIZE>0){
      r->cachesize   = (int)DSDPCACHESIZE;
    }
#endif
    r->cacheunit   =1000;

  }
  *rr=r;
  return 0;
} /* SchlAlloc */
Ejemplo n.º 6
0
smatx *SmtAlloc(int  nrow,
                int  nnzo,
                char *info)
{
  smatx *r;
  
  r=(smatx*)calloc(1,sizeof(smatx));
  if (!r) ExitProc(OutOfSpc,info);
  
  if (nrow) {
    r->rows=(array*)calloc(nrow,sizeof(array));
    if (!r) ExitProc(OutOfSpc,info);
    
    if (nnzo) {
      r->rows->ja=iAlloc(nnzo,info);
      r->rows->an=dAlloc(nnzo,info);
    }
  }
  r->maxnrow=nrow;
  r->nrow=nrow;
  r->non0=nnzo;
  return r;
} /* SmatAlloc */
Ejemplo n.º 7
0
syoff *SyoAlloc(int  nrow, 
                int  nnzo, 
                char *info) 
{ 
  syoff *r; 
   
  r=(syoff*)calloc(1,sizeof(syoff)); 
  if (!r) ExitProc(OutOfSpc,info); 
   
  if (nrow) { 
    r->roff=(array*)calloc(nrow,sizeof(array)); 
    if (!r) ExitProc(OutOfSpc,info); 
     
    if (nnzo) { 
      r->roff->ja=iAlloc(nnzo,info); 
      r->roff->an=dAlloc(nnzo,info); 
    } 
  } 
  r->nrow=nrow; 
  r->nnzo=nnzo; 
   
  return r; 
} /* SyoAlloc */ 
Ejemplo n.º 8
0
int OdAlloc(int  nnod,
               int  nn0,
               char *info,
	       order **rr)
{
  order *r;
  int ierr=0;

  r=(order*)calloc(1,sizeof(order));
  if (!r) ExitProc(OutOfSpc,info);
  
  r->nnod=nnod;
  r->nn0 =nn0;
  
  ierr=iAlloc(nn0,info,&r->adjn); if(ierr) return 1;
  ierr=iAlloc(nnod,info,&r->rbeg); if(ierr) return 1;
  ierr=iAlloc(nnod,info,&r->rexs); if(ierr) return 1;
  ierr=iAlloc(nnod,info,&r->rlen); if(ierr) return 1;
  ierr=iAlloc(nnod,info,&r->rend); if(ierr) return 1;
  ierr=iAlloc(nnod,info,&r->pres); if(ierr) return 1;
  ierr=iAlloc(nnod,info,&r->succ); if(ierr) return 1;
  *rr=r;
  return (0);
} /* OdAlloc */
Ejemplo n.º 9
0
/*
 * NAME:	jfs_mknod(dvp, name, mode, dev, crp)
 *
 * FUNCTION:	make a new object in directory <dvp> with mode = <mode>,
 *		name = <pname>, and rdev = <dev>.
 *
 * PARAMETER:	dvp 	- directory vnode
 *		name	- name of new object
 *		mode	- create mode (rwxrwxrwx).
 *		dev	- new device number if block/character-special file
 *		crp	- credential
 *
 * RETURN:	Errors from subroutines
 *
 * note: JFS allows mknod() to create a special file.
 * XPG4.2: the only portable use of mknod() is to create a FIFO-special file
 * with mode = S_IFIFO and dev = 0.
 */
jfs_mknod(
	struct vnode	*dvp,
	caddr_t		name,
	mode_t		mode,
	dev_t		dev,
	struct ucred	*crp)
{
	int32	rc;
	int32	tid;
	inode_t	*dip = VP2IP(dvp);
	inode_t *ip;
	ino_t	ino;
	component_t	dname;
	struct vfs	*vfsp = dvp->v_vfsp;
	btstack_t	btstack;
	inode_t		*iplist[2];

	/* JFS does NOT support mknod() of directory */
	if ((mode & IFMT) == IFDIR)
		return EISDIR;
		
	if ((mode & IFMT) != IFIFO && (mode & IFMT) != IFSOCK)
		if (rc = privcheck_cr(DEV_CONFIG, crp))
			return rc;

	IWRITE_LOCK(dip);

	txBegin(dip->i_ipmnt, &tid, 0);

	/* validate search+write permission on parent directory */
	if (rc = iAccess(dip, IEXEC|IWRITE, crp))
		goto out1;

	/*
	 * scan parent directory for entry/freespace
	 * (dtSearch() returns parent directory page pinned)
	 */
	dname.name = name;
	dname.namlen = strlen(name);
	if (rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))
		goto out1;

	/*
	 * allocate in-memory+on-disk inode:
	 * (iAlloc() returns new, locked inode)
	 */
	if (rc = iAlloc(vfsp, dip, mode, &ip, crp))
	{	
		/* release parent directory page */
		BT_PUTSEARCH(&btstack);

		goto out1;
	}

	/*
	 * create entry in parent directory
	 * (dtInsert() releases parent directory page)
	 */
	ino = ip->i_number;
	if (rc = dtInsert(tid, dip, &dname, &ino, &btstack))
	{
		/* discard the new inode */
		ip->i_nlink = 0;

		goto out2;
	}

	/*
	 * fo a block or character special file, the passed-in device number
	 * needs to be set into the inode's device field and the gnode's
	 * "real device" field.
	 */
	if ((ip->i_mode & IFMT) == IFBLK || (ip->i_mode & IFMT) == IFCHR)
	{
		ip->i_rdev = dev;
		IP2GP(ip)->gn_rdev = dev;
	}

	imark(ip, IACC|ICHG|IUPD|IFSYNC);	

	/* update parent directory inode */
	imark(dip, ICHG|IUPD|IFSYNC);

	/*
	 * insert entry for the new file to dnlc
	 */
	ncEnter(dip->i_ipimap, dip->i_number, &dname, ino, NULL);

	iplist[0] = dip;
	iplist[1] = ip;
	rc = txCommit(tid, 2, &iplist[0], 0);

out2:
	IWRITE_UNLOCK(ip);

	ICACHE_LOCK();
	iput(ip, vfsp);
	ICACHE_UNLOCK();

out1:
	IWRITE_UNLOCK(dip);

	txEnd(tid);

	return rc;
}
Ejemplo n.º 10
0
/*
 * NAME:	jfs_mkdir(dvp, name, mode, crp)
 *
 * FUNCTION:	create a child directory in the parent directory <dvp>
 *		with name = <name> and mode = <mode>
 *
 * PARAMETER:	dvp 	- parent directory vnode
 *		name	- name of child directory
 *		mode	- create mode (rwxrwxrwx).
 *		crp	- credential
 *
 * RETURN:	Errors from subroutines
 *
 * note:
 * EACCESS: user needs search+write permission on the parent directory
 */
jfs_mkdir(
	struct vnode	*dvp,
	UniChar		*name,
	mode_t		mode,
#ifdef _JFS_OS2
        EAOP		*pEABuf,
#endif	/* _JFS_OS2 */
	struct ucred	*crp)
{
	int32 	rc = 0, rc1 = 0;
	int32	tid;		/* transaction id */
	struct vfs	*vfsp = dvp->v_vfsp;
	inode_t	*dip = VP2IP(dvp); /* parent directory inode */
	struct dasd_usage	*du;				// F226941
	inode_t *ip = NULL;	/* child directory inode */
	ino_t	ino;
	component_t dname;	/* child directory name */
	btstack_t	btstack;
	inode_t	*iplist[2];
	int64	orig_nblocks;					// F226941
#ifdef _JFS_LAZYCOMMIT
	tblock_t *tblk;						// D230860
#endif
#ifdef _JFS_OS2
	FEALIST		*pfealist = NULL;
#endif	/* _JFS_OS2 */

NOISE(1,("jfs_mkdir: dip:0x%08x name:%s\n", dip, name));

	/*
	 * the named file exists for "." or ".."
	 */
	if (name[0] == '.')
	{
		if ((name[1] == '.' && name[2] == '\0') ||
		    name[1] == '\0')
			return EEXIST;
	}

#ifdef _JFS_OS2
	/* validate the EAOP buffer, FEALIST size storage location and the
	 * entire FEALIST storage area.  Once all the storage has been
	 * validated, the entire FEALIST is validated for format and the size is
	 * computed and compared against the limit.
	 */
	if (pEABuf)
	{
		if (rc = jfs_ValidateUserFEAList(pEABuf, &pfealist,
				&pEABuf->oError))
		{
			/* something failed -- bail out */
			return rc;
		}
	}
#endif	/* _JFS_OS2 */

	if (dip->i_nlink == 0)
	{
		rc = ENOENT;
		goto out1;
	}

	/* link count overflow on parent directory ? */
	if (dip->i_nlink >= LINK_MAX)
	{
		rc = EMLINK;
		goto out1;
	}

	/*
	 * search parent directory for entry/freespace
	 * (dtSearch() returns parent directory page pinned)
	 */
	dname.name = name;
	dname.namlen = UniStrlen(name);
	if (dname.namlen > JFS_NAME_MAX-1)
	{
		rc = ERROR_FILENAME_EXCED_RANGE;
		goto out1;
	}

// BEGIN D233382
#ifdef _JFS_LAZYCOMMIT
	if (isReadOnly(dip))
	{
		rc = EROFS;
		goto out1;
	}

	/*
	 * Either iAlloc() or txBegin() may block.  Deadlock can occur if we
	 * block there while holding dtree page, so we allocate the inode &
	 * begin the transaction before we search the directory.
	 */
	if (rc = iAlloc(vfsp, dip, IFDIR|mode|IDIRECTORY, &ip, crp))
		goto out1;

	txBegin(dip->i_ipmnt, &tid, 0);

	if (rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))
	{
		ip->i_nlink = 0;
		ICACHE_LOCK();
		iput(ip, vfsp);
		ICACHE_UNLOCK();
		txEnd(tid);
		goto out1;
	}

	tblk = &TxBlock[tid];					// D230860
	tblk->xflag |= COMMIT_CREATE;				// D230860
	tblk->ip = ip;						// D230860

#else /* ! _JFS_LAZYCOMMIT */
// END D233382

	if (rc = dtSearch(dip, &dname, &ino, &btstack, JFS_CREATE))
		goto out1;

	if (isReadOnly(dip))
	{
		rc = EROFS;

		/* release parent directory page */
		BT_PUTSEARCH(&btstack);
		goto out1;
	}

	/*
	 * allocate on-disk/in-memory inode for child directory:
	 * (iAlloc() returns new, locked inode)
	 */
	if (rc = iAlloc(vfsp, dip, IFDIR|mode|IDIRECTORY, &ip, crp))
	{
		/* release parent directory page */
		BT_PUTSEARCH(&btstack);

jEVENT(0,("jfs_mkdir: iAlloc error(%d)\n", rc));
		goto out1;
	}

	txBegin(dip->i_ipmnt, &tid, 0);
#endif /* _JFS_LAZYCOMMIT */

	du = ip->i_dasdlim = dip->i_dasdlim;			// F226941

	orig_nblocks = dip->i_nblocks;				// F226941

	iplist[0] = dip;
	iplist[1] = ip;
	
	/*
	 * initialize the child directory in-line in inode
	 */
	dtInitRoot(tid, ip, dip->i_number);

	/*
	 * create entry in parent directory for child directory
	 * (dtInsert() releases parent directory page)
	 */
	ino = ip->i_number;
	if (rc = dtInsert(tid, dip, &dname, &ino, &btstack))
	{	
		/* discard new directory inode */
		ip->i_nlink = 0;

		if (rc == EIO)
			txAbort(tid, 1);	/* Marks Filesystem dirty */
		else
			txAbort(tid, 0);	/* Filesystem full */
		txEnd(tid);
		goto out3;
	}

	/* update child directory inode */
// BEGIN F226941
	setDASDLIMIT(&ip->i_DASD, 0);
	setDASDUSED(&ip->i_DASD, 0);
// END F226941

	ip->i_nlink++;	/* for '.' */ 
	imark(ip, IACC|ICHG|IUPD|IFSYNC);	

	/* update parent directory inode */
	dip->i_nlink++; /* for '..' from child directory */
	imark(dip, ICHG|IUPD|IFSYNC);	

	/*
	 * insert entry for the new file to dnlc
	 */
	ncEnter(dip->i_ipimap, dip->i_number, &dname, ino, NULL);

#ifdef _JFS_OS2

	if ((rc1 == 0) && pfealist)				// F226941
		rc1 = jfs_InitializeFEAList(ip, tid, pfealist);

	if ((rc1 == 0) && (dip->i_acl.flag) && (dip->i_acl.size))
		rc1 = jfs_CopyACL(ip, dip, tid);

#endif	/* _JFS_OS2 */

// BEGIN FF226941
	DLIM_UPDATE(tid, dip, dip->i_nblocks + ip->i_nblocks - orig_nblocks);
	setDASDUSED(&ip->i_DASD, ip->i_nblocks);		// D233382
#ifndef _JFS_FASTDASD						// D233382
	/*
	 * If the transaction modified the ancestors of the inode, the
	 * parent will be in the dasd usage list.  Otherwise, transaction
	 * will only change new directory and parent.
	 */
	if (du && (du->flag & DLIM_LOGGED))
		rc = dasd_commit(tid, ip, 0);
	else
#endif /* _JFS_FASTDASD */					// D233382
// END FF226941

		rc = txCommit(tid, 2, &iplist[0], 0);
	txEnd(tid);

#ifdef _JFS_OS2

	/* If we successfully added the directory, but failed adding the EA or
	 * ACL, we must cleanup the created directory entry and return the
	 * error.
	 */
	if (rc1)
	{
// BEGIN D230860
		if ((du) && (du->first_locked))
		{
			/*
			 * txCommit unlocked one or more inodes.
			 * We need to unlock all the directories &
			 * relock them.
			 */
			dip->i_dasdlim = 0;
			DLIM_WRITE_UNLOCK_DETACH(ip, du);
			DLIM_WRITE_LOCK_ATTACH(ip, du);
			dip->i_dasdlim = du;
		}
// END D230860
		jfs_xrmdir(dip, ip, name);
		rc = rc1;
	}

#endif	/* _JFS_OS2 */

out3:
	ip->i_dasdlim = 0;					// F226941
	IWRITE_UNLOCK(ip);

	ICACHE_LOCK();
	iput(ip, vfsp);
	ICACHE_UNLOCK();

out1:

#ifdef _JFS_OS2
		/*
		 * this buffer was allocated by
		 * jfs_ValidateUserFEAList() at twice the
		 * size of the given list to provide buffer
		 * space for eliminating duplicate names
		 */
	if (pfealist)
		jfs_EABufFree((char *)pfealist, (pfealist->cbList << 1));
#endif	/* _JFS_OS2 */

NOISE(1,("jfs_mkdir: rc:%d\n", rc));
	return rc;
}