Exemplo n.º 1
0
/*++

Routine Name:

    CRemoteDictionary::WriteData

Routine Description:

    This method handles the parsing of a new dictionary and
    the writing out the new dictionary

Arguments:

    pWriter - Pointer to a stream to write the resource out to

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CRemoteDictionary::WriteData(
    _In_ IPartBase*         pResource,
    _In_ IPrintWriteStream* pWriter
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pResource, E_POINTER)) &&
        SUCCEEDED(hr = CHECK_POINTER(pWriter, E_POINTER)))
    {
        try
        {
            CComPtr<IUnknown>                pRead(NULL);
            CComPtr<IPartResourceDictionary> pResDictPart(NULL);
            CComPtr<IPrintReadStream>        pReader(NULL);

            if (SUCCEEDED(hr = m_pFixedPage->GetPagePart(m_bstrDictionaryURI, &pRead)) &&
                SUCCEEDED(hr = pRead->QueryInterface(&pResDictPart)) &&
                SUCCEEDED(hr = pResDictPart->GetStream(&pReader)))
            {
                //
                // Create a SAX handler to parse the markup in the fixed page
                //
                CCMSaxHandler cmSaxHndlr(pWriter, m_pBmpConverter, m_pRefConverter, NULL);

                //
                // Set-up the SAX reader and begin parsing the mark-up
                //
                CComPtr<ISAXXMLReader> pSaxRdr(NULL);

                if (SUCCEEDED(hr = pSaxRdr.CoCreateInstance(CLSID_SAXXMLReader60)) &&
                    SUCCEEDED(hr = pSaxRdr->putContentHandler(&cmSaxHndlr)))
                {
                    CComPtr<ISequentialStream> pReadStreamToSeq(NULL);

                    pReadStreamToSeq.Attach(new pfp::PrintReadStreamToSeqStream(pReader));

                    if (SUCCEEDED(hr = CHECK_POINTER(pReadStreamToSeq, E_OUTOFMEMORY)))
                    {
                        hr = pSaxRdr->parse(CComVariant(static_cast<ISequentialStream*>(pReadStreamToSeq)));
                    }
                }
            }
        }
        catch (CXDException& e)
        {
            hr = e;
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 2
0
// PCANLight Read function
// This function get the next message or the next error from the Receive Queue of
// the CAN Hardware.
// REMARK:
//		- Check always the type of the received Message (MSGTYPE_STANDARD,MSGTYPE_RTR,
//		  MSGTYPE_EXTENDED,MSGTYPE_STATUS)
//		- The function will return ERR_OK always that you receive a CAN message successfully
//		  although if the messages is a MSGTYPE_STATUS message.
//		- When a MSGTYPE_STATUS mesasge is got, the ID and Length information of the message
//		  will be treated as indefined values. Actually information of the received message
//		  should be interpreted using the first 4 data bytes as follow:
//			*	Data0	Data1	Data2	Data3	Kind of Error
//				0x00	0x00	0x00	0x02	CAN_ERR_OVERRUN		0x0002	CAN Controller was read to late
//				0x00	0x00	0x00	0x04	CAN_ERR_BUSLIGHT	0x0004  Bus Error: An error counter limit reached (96)
//				0x00	0x00	0x00	0x08	CAN_ERR_BUSHEAVY	0x0008	Bus Error: An error counter limit reached (128)
//				0x00	0x00	0x00	0x10	CAN_ERR_BUSOFF		0x0010	Bus Error: Can Controller went "Bus-Off"
//		- If a CAN_ERR_BUSOFF status message is received, the CAN Controller must to be
//		  initialized again using the Init() function.  Otherwise, will be not possible
//		  to send/receive more messages.
//
// "MsgBufer" = The TPCANMsg structure to store the CAN message
// RETURN = A CANResult value - Error/status of the hardware after execute the function
//
CANResult PCANLight::Read(TPCANMsg *MsgBuffer)
{
	// DLL for the current HardwareType is not loaded
	//
	if(!bWasLoaded)
		return ERR_NO_DLL;

	// Function CAN_Read/CAN2_Read is called
	//
	return (CANResult)pRead(MsgBuffer);   
}
Exemplo n.º 3
0
/*++

Routine Name:

    CPTManager::MergeTicket

Routine Description:

    This routine merges a PrintTicket (supplied as a IPartPrintTicket pointer) into
    the DOM representation of the PrintTicket at the requested scope

Arguments:

    ptScope - The scope at which the PrintTicket is to be merged
    pPTRef  - Pointer to an IPartPrintTicket interface containing the PrintTicket to be merged

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CPTManager::MergeTicket(
    _In_ CONST EPrintTicketScope ptScope,
    _In_ CONST IPartPrintTicket* pPTRef
    )
{
    HRESULT hr = S_OK;

    if (SUCCEEDED(hr = CHECK_POINTER(pPTRef, E_POINTER)))
    {
        //
        // Create a DOM document from the PT ref stream
        //
        CComPtr<IXMLDOMDocument2> pNewPT(NULL);
        CComPtr<IPrintReadStream> pRead(NULL);

        if (SUCCEEDED(hr = pNewPT.CoCreateInstance(CLSID_DOMDocument60)) &&
            SUCCEEDED(hr = const_cast<IPartPrintTicket*>(pPTRef)->GetStream(&pRead)))
        {
            CComPtr<ISequentialStream> pReadStreamToSeq(NULL);
            VARIANT_BOOL fLoaded = VARIANT_FALSE;

            pReadStreamToSeq.Attach(new(std::nothrow) pfp::PrintReadStreamToSeqStream(pRead));

            if (SUCCEEDED(hr = CHECK_POINTER(pReadStreamToSeq, E_OUTOFMEMORY)) &&
                SUCCEEDED(hr = pNewPT->load(CComVariant(pReadStreamToSeq), &fLoaded)))
            {
                if (fLoaded == VARIANT_TRUE)
                {
                    hr = MergeTicket(ptScope, pNewPT);
                }
                else
                {
                    hr = E_FAIL;
                }
            }
        }
    }

    ERR_ON_HR(hr);
    return hr;
}
Exemplo n.º 4
0
/****************************************************************************
 * NAME: 	 process_Inode_Xtree
 *		
 * FUNCTION:	Traverse the xtree of the given inode looking for
 *		allocated extents containing bad blocks.
 *
 * PARAMETERS:	
 *	dip		ptr to the owning disk inode in a buffer
 *
 *	doRelocate	 0 => this is not the JFS Bad Block inode
 *			!0 => this is the JFS Bad Block inode
 *
 * NOTES:	
 *
 * RETURNS:
 *      success: 0
 *      failure: something else
 */
int32 process_Inode_Xtree( dinode_t *dip, int8 doRelocate )
{
    int32		pix_rc = 0;
    int32		relocate_rc;
    xtpage_t	*p; 
    int32		xlen, i;
    int64		xaddr, xoff, xlastblk;
    int8		didRelocate = 0;
    int32		xtype;
    cbbl_bdblk_recptr bdblk_recptr = NULL;
    int32		pList;
    ULONG 	pListLen = 0;
    clrbblks_t	pData;
    ULONG 	pDataLen = 0;

    int64	lmxaddr;	/* address of left-most child		*/
    xtpage_t next_xtpg;  	/* next xtpage to work on for the inode */
    xtpage_t *pnext_xtpg;
    int32 nxtpg_inx; 		/* the next index in next_xtpg to work on */

	/* 
	 * we start with the root 
	 */
    pnext_xtpg = p = (xtpage_t *)&dip->di_btroot;
    if (p->header.flag & BT_LEAF)  {
	xtype = DATAEXT;
	}
    else  {
	xtype = XTPAGE;
	p->header.next = 0;
		/* 
		 * save leftmost child xtpage xaddr 
		 */
	lmxaddr = addressXAD(&p->xad[XTENTRYSTART]);
	}

    nxtpg_inx = XTENTRYSTART;

	/*
	 * scan each level of xtree
	 */
    while(1)  {
		/*
		 * scan each xtpage of current level of xtree
		 */
	while(1)  {
		/*
		 * scan each xad in current xtpage
		 */
	    for (i = nxtpg_inx; i < p->header.nextindex; i++)  {
			/* 
			 * does the extent contain at least 1 
			 * bad block? 
			 */ 
		xoff = offsetXAD(&p->xad[i]);
		xaddr = addressXAD(&p->xad[i]) ;
		xlen = lengthXAD(&p->xad[i]) ;

		pix_rc = baltree_search( xaddr, &bdblk_recptr );
		if( pix_rc != 0 ) {  /* something fatal on search */
		    return( pix_rc );
		    }
		else if( bdblk_recptr == NULL ) {  /* hit end of tree w/o match */
		    continue;
		    }  /* end hit end of tree w/o match */

		xlastblk = xaddr + xlen - 1;
		if( bdblk_recptr->fs_blkno <= xlastblk ) { /*
				* the extent contains at least 1 bad block
				*/
#ifdef _JFS_DEBUG
	printf("bad block 0x0%llx found in xtree for inode %d\n", 
		bdblk_recptr->fs_blkno, dip->di_number );
#endif
		    if( !doRelocate ) { /* relocation not requested */
			pix_rc = we_DidntTryTo_Relocate( xaddr,
							     xlastblk,
							     bdblk_recptr
							    );
			}  /* end relocation not requested */
		    else {  /* relocation is requested */
			pDataLen = sizeof(clrbblks_t);
			pData.flag = CLRBBLKS_RELOCATE | IFREG | xtype;
//PS24072004			pData.dev = lvMount->LVNumber;
			pData.dev = LVNumber;
			pData.fileset = dip->di_fileset;
			pData.inostamp = dip->di_inostamp;
			pData.ino = dip->di_number;
			pData.gen = dip->di_gen;
			pData.xoff = xoff;	/* offset within the file */
			pData.old_xaddr = xaddr;
			pData.new_xaddr = 0;
			pData.xlen = xlen;
			pData.agg_blksize = agg_recptr->fs_blksize;
				/*
				 * attempt to relocate the extent
				 */
			didRelocate = 0;
			relocate_rc = fscntl(	JFSCTL_CLRBBLKS,
						(void *)&pList, &pListLen,
						(void *)&pData, &pDataLen
						);
			if( (relocate_rc == 0) && 
			    (pData.new_xaddr != 0) ) {  /*
				* extent has been relocated 
				*/
			    didRelocate = -1;
			    }  /* end extent has been relocated */	
				/*
				 * Now handle the individual bad block(s) 
				 * in the extent
				 */
			if( didRelocate ) {  /* 
				* actually did relocate 
				*/
			    pix_rc = we_Did_Relocate( xaddr, 
							  xlastblk,
							  bdblk_recptr 
							  );
			    }  /* end actually did relocate */
			else {  /* tried but failed to relocate */
			    pix_rc = we_Couldnt_Relocate( xaddr, 
							      xlastblk,
							      bdblk_recptr, 
							      relocate_rc 
							     );
			    }  /* end else tried but failed to relocate */
			}  /* end else relocation is requested */
		    }  /* end the extent contains at least 1 bad block */
		}  /* end for current xtpage scan */

		/*
		 * read in next/right sibling xtpage 
		 */
	    if (p->header.next != 0) {
		xaddr = p->header.next;
		pix_rc = pRead(fsMount, xaddr, fsMount->nbperpage, &next_xtpg);
		if ( pix_rc != 0 )  {
		    return CBBL_CANTREADNEXTXTPG; /* i/o error */
		    }

		pnext_xtpg = p = &next_xtpg;
		nxtpg_inx = XTENTRYSTART;
		}
	    else
		break;
	    } /* end while current level scan */

		/*
		 * descend: 	read leftmost xtpage of next 
		 * 		lower level of xtree
		 */
	if (xtype == XTPAGE)  {
		/* 
		 * get the leftmost child page  
		 */
	    pix_rc = pRead(fsMount, lmxaddr, fsMount->nbperpage, &next_xtpg);
	    if ( pix_rc != 0 )  {
		return CBBL_CANTREADLMXTCHILD; /* i/o error */
		}

	    pnext_xtpg = p = &next_xtpg;
	    nxtpg_inx = XTENTRYSTART;
	    if (p->header.flag & BT_LEAF)  {
		xtype = DATAEXT;
		}
	    else  {
		xtype = XTPAGE;
			/* 
			 * save leftmost child xtpage xaddr 
			 */
		lmxaddr = addressXAD(&p->xad[XTENTRYSTART]);
		}
	    }   /* end xtype == XTPAGE */
		else
			break;
	} /* end while level scan */

	/* 
	 * this inode is done: reset variables 
	 */
    pnext_xtpg = NULL;

    return 0;
}					/* end process_Inode_Xtree() */
Exemplo n.º 5
0
/****************************************************************************
 * NAME: 	process_Inode_Dtree 
 *		
 * FUNCTION:	Traverse the dtree of the given directory inode
 *		looking for allocated extents containing bad blocks.
 *
 * PARAMETERS:	
 *	dip		ptr to the owning disk inode in a buffer
 *
 *	doRelocate	 0 => this is not the JFS Bad Block inode
 *			!0 => this is the JFS Bad Block inode
 *
 * NOTES:	
 *
 * RETURNS:
 *      success: 0
 *      failure: something else
 */
int32 process_Inode_Dtree( dinode_t *dip, int8 doRelocate )
{
    int32	pid_rc = 0;
    int32 relocate_rc = 0;
    dtpage_t	*p; 
    int8	*stbl;
    int32	i;	
    pxd_t	*pxd;
    int64	xaddr, lmxaddr, xlastblk;
    int32	xlen;
    int8	didRelocate = 0;
    cbbl_bdblk_recptr bdblk_recptr = NULL;
    int32	pList;

    ULONG 	pListLen = 0;
    clrbblks_t	pData;
    ULONG 	pDataLen = 0;
    int64		lmpg_addr;
    int32		lmxlen;
    dtpage_t 	next_dtpg;  	/* next dtpage to work on  */
    dtpage_t 	*pnext_dtpg;
    int32 	ndtpg_inx; 	/* the next index in next_dtpg to work on */

	/* 
	 * we start with the root 
	 */
    pnext_dtpg = p = (dtpage_t *)&dip->di_btroot;

	/* 
	 * is it leaf, i.e., inode inline data ? 
	 */
    if (p->header.flag & BT_LEAF)  {
	goto out;
	}
	
    p->header.next = 0;
	/* 
	 * save leftmost dtpage xaddr 
	 */
    lmpg_addr = 0;

    stbl = DT_GETSTBL(p);
    pxd = (pxd_t *)&p->slot[stbl[0]];
	/* 
	 * save leftmost child dtpage extent 
	 */
    lmxaddr = addressPXD(pxd); /* leftmost child xaddr */
    lmxlen = lengthPXD(pxd);
    ndtpg_inx = 0;

	/*
	 * scan each level of dtree
	 */
    while(1)  {
	/*
	 * scan each dtpage of current level of dtree
	 */
	while(1)  {
	    stbl = DT_GETSTBL(p);

		/*
		 * scan each idtentry in current dtpage
		 */
	    for (i = ndtpg_inx; i < p->header.nextindex; i++) {
		pxd = (pxd_t *)&p->slot[stbl[i]];

			/* 
			 * does the extent contain at least 1 
			 * bad block? 
			 */ 
		xaddr = addressPXD(pxd);
		xlen = lengthPXD(pxd);

		pid_rc = baltree_search( xaddr, &bdblk_recptr );
		if( pid_rc != 0 ) {  /* something fatal on search */
		    return( pid_rc );
		    }
		else if( bdblk_recptr == NULL ) {  /* hit end of tree w/o match */
		    continue;
		    }  /* end hit end of tree w/o match */

		xlastblk = xaddr + xlen - 1;
		if( bdblk_recptr->fs_blkno <= xlastblk ) { /*
				* the extent contains at least 1 bad block
				*/
#ifdef _JFS_DEBUG
	printf("bad block 0x0%llx found in dtree for inode %d\n", 
		bdblk_recptr->fs_blkno, dip->di_number );
#endif
		    if( !doRelocate ) { /* relocation not requested */
			pid_rc = we_DidntTryTo_Relocate( xaddr,
							     xlastblk,
							     bdblk_recptr
							    );
			}  /* end relocation not requested */
		    else {  /* relocation is requested */
			pDataLen = sizeof(clrbblks_t);
			pData.flag = CLRBBLKS_RELOCATE | IFDIR | DTPAGE;
//PS24072004			pData.dev = lvMount->LVNumber;
			pData.dev = LVNumber;
			pData.fileset = dip->di_fileset;
			pData.inostamp = dip->di_inostamp;
			pData.ino = dip->di_number;
			pData.gen = dip->di_gen;
			pData.xoff = lmpg_addr; /* leftmost page 
						 * describing this level 
						 */
			pData.old_xaddr = xaddr;
			pData.new_xaddr = 0;
			pData.xlen = xlen;
			pData.agg_blksize = agg_recptr->fs_blksize;
				/*
				 * attempt to relocate the extent
				 */
			didRelocate = 0;
			relocate_rc = fscntl(	JFSCTL_CLRBBLKS,
						(void *)&pList, &pListLen,
						(void *)&pData, &pDataLen
						);
			if( (relocate_rc == 0) && 
			    (pData.new_xaddr != 0) ) {  /*
				* extent has been relocated 
				*/
			    didRelocate = -1;
			    }  /* end extent has been relocated */	
				/*
				 * Now handle the individual bad block(s) 
				 * in the extent
				 */
			if( didRelocate ) {  /* 
				* actually did relocate 
				*/
			    pid_rc = we_Did_Relocate( xaddr, 
							  xlastblk,
							  bdblk_recptr 
							  );
			    }  /* end actually did relocate */
			else {  /* tried but failed to relocate */
			    pid_rc = we_Couldnt_Relocate( xaddr, 
							      xlastblk,
							      bdblk_recptr, 
							      relocate_rc 
							     );
			    }  /* end else tried but failed to relocate */
			}  /* end else relocation is requested */
		    }  /* end the extent contains at least 1 bad block */
		}  /* end for loop */

		/* 
		 * read in next/right sibling dtpage 
		 */
	    if (p->header.next != 0) {
		xaddr = p->header.next;
		pid_rc = pRead(fsMount, xaddr, fsMount->nbperpage, &next_dtpg);
		if (pid_rc != 0) {
		    return CBBL_CANTREADNEXTDTPG; /* i/o error */
		    }

		pnext_dtpg = p = &next_dtpg;
		ndtpg_inx = 0;
		}
	    else
		break;
	    } /* end while current level scan */

		/*
		 * descend: read leftmost dtpage of next lower level of dtree
		 */
		/* 
		 * the first child of the dtroot split may not have PSIZE 
		 */ 
	pid_rc = pRead(fsMount, lmxaddr, lmxlen, &next_dtpg);
	if ( pid_rc != 0 )  {
	    return CBBL_CANTREADLMDTCHILD; /* i/o error */
	    }

	pnext_dtpg = p = &next_dtpg;

		/* 
		 * for dir, the leaf contains data, its pxd info 
		 * has been reported by the parent page. so we stop here 
		 */
	if (p->header.flag & BT_LEAF) {
	    break;
	    }

		/* 
		 * save leftmost dtpage xaddr 
		 */
	lmpg_addr = lmxaddr;

	stbl = DT_GETSTBL(p);
	pxd = (pxd_t *)&p->slot[stbl[0]];
		/* 
		 * save leftmost child dtpage extent 
		 */
	lmxaddr = addressPXD(pxd); /* leftmost child xaddr */
	lmxlen = lengthPXD(pxd);
	ndtpg_inx = 0;
	}  /* end while scan each level of tree */

	/* reset global state variable for the inode */
out:
	pnext_dtpg = NULL;

	return pid_rc;
}					/* end process_Inode_Dtree() */
Exemplo n.º 6
0
/****************************************************************************
 * NAME: 	process_FilesetInodes 
 *
 * FUNCTION:	Reads in the fileset inode extents, one by one, and for
 *		each in-use inode, calls process_Inode() to scan for 
 *		blocks on the bad block list and handle any that are 
 *		detected.
 *
 * PARAMETERS:	none
 *
 * NOTES:
 *
 * RETURNS:
 *      success: 0
 *      failure: something else
 */
int32 process_FilesetInodes ( ) 
{
    int32	pfsi_rc = 0;
    dinode_t	*inoptr = NULL;
    dinomap_t	*icp;
    int64	xaddr;
    int32	xlen;
    int8	isBadBlockInode = 0;

	/*
	 * scan each IAG in the file set 
	 */
    icp = (dinomap_t *)&IMap.ctl; 
    for ( agg_recptr->iag_idx = 0; 
	  (	(agg_recptr->iag_idx < icp->in_nextiag) && 
		(pfsi_rc == 0) &&
		(agg_recptr->bdblk_baltree.seq_list != NULL)	); 
	  agg_recptr->iag_idx++) {  /* for each IAG */

	 	/* 
		 * read in the next IAG 
		 */
	pfsi_rc = readIMapSequential(&iagbuf);
		/*
		 * process the extents described by the IAG
		 */
	for ( agg_recptr->extent_idx = 0; 
	     (  	(agg_recptr->extent_idx < EXTSPERIAG) && 
		(pfsi_rc == 0) &&
		(agg_recptr->bdblk_baltree.seq_list != NULL)	); 
	    agg_recptr->extent_idx++) {  /* for each extent in the IAG */
		/*
		 * Get the address and length of the extent
		 */
	    xaddr = addressPXD(&iagbuf.inoext[agg_recptr->extent_idx]);
	    xlen = lengthPXD(&iagbuf.inoext[agg_recptr->extent_idx]);
		/* 
		 * If the extent isn't allocated, bump current inode number
		 */
	    if( xaddr == 0 ) {  /* not allocated */
		agg_recptr->this_inonum += INOSPEREXT;
		}
	    else {  /* extent is allocated */
		/*
		 * Otherwise, read in the inode extent
		 */
		pfsi_rc = pRead(fsMount, xaddr, xlen, (void *)ixbuf);
			/*
			 * process the inodes in the extent 
			 */
		for ( agg_recptr->inode_idx = 0; 
	 	      (	(agg_recptr->inode_idx < INOSPEREXT) && 
			(pfsi_rc == 0) &&
			(agg_recptr->bdblk_baltree.seq_list != NULL)	); 
		      agg_recptr->inode_idx++) {  /* 
				* for each inode in the extent
				*/
		    inoptr = &ixbuf[agg_recptr->inode_idx];
			/*
			 * if the inode isn't in use, just
			 * increment the inode number
			 */
		    if( (inoptr->di_nlink == 0) || 
			(inoptr->di_inostamp != DIIMap.di_inostamp) ) {
			agg_recptr->this_inonum += 1;
			}
			/*
			 * otherwise, scan the inode for bad blocks 
			 * allocated to it and, if possible, relocate
			 * their contents and get them transferred to 
			 * the JFS Bad Block Inode 
			 */
		    else {  /* the inode is in use */
			pfsi_rc = process_Inode( isBadBlockInode, inoptr );
				/*
				 * increment to the next inode
				 */
			agg_recptr->this_inonum += 1; 
			}  /* end else the inode is in use */
		    }  /* end for each inode in the extent */
		}  /* end else extent is allocated */
	    }  /* end for each extent in the IAG */ 
	}  /* end for each IAG */

    return( pfsi_rc );
}				/* end process_FilesetInodes() */