Beispiel #1
0
int au_dcsub_pages_rev(struct au_dcsub_pages *dpages, struct dentry *dentry,
		       int do_include, au_dpages_test test, void *arg)
{
	int err;

	TraceEnter();

	err = 0;
	spin_lock(&dcache_lock);
	if (do_include && (!test || test(dentry, arg))) {
		err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
		if (unlikely(err))
			goto out;
	}
	while (!IS_ROOT(dentry)) {
		dentry = dentry->d_parent;
		if (!test || test(dentry, arg)) {
			err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
			if (unlikely(err))
				break;
		}
	}

 out:
	spin_unlock(&dcache_lock);

	TraceErr(err);
	return err;
}
Beispiel #2
0
STDMETHODIMP CMemoryStream::Commit(DWORD grfCommitFlags)
{
    HRESULT hr = S_OK;
    TraceEnter();
    TraceLeaveHr(hr);
    return hr;
}
Beispiel #3
0
int au_dpages_init(struct au_dcsub_pages *dpages, gfp_t gfp)
{
	int err;
	void *p;

	TraceEnter();

	err = -ENOMEM;
	dpages->dpages = kmalloc(sizeof(*dpages->dpages), gfp);
	if (unlikely(!dpages->dpages))
		goto out;
	p = (void*)__get_free_page(gfp);
	if (unlikely(!p))
		goto out_dpages;
	dpages->dpages[0].ndentry = 0;
	dpages->dpages[0].dentries = p;
	dpages->ndpage = 1;
	return 0; /* success */

 out_dpages:
	kfree(dpages->dpages);
 out:
	TraceErr(err);
	return err;
}
Beispiel #4
0
static int make_xino(struct seq_file *seq, struct sysaufs_args *args,
		     int *do_size)
{
	int err;
	struct super_block *sb = args->sb;
	aufs_bindex_t bindex, bend;
	struct file *xf;
	struct inode *xi;

	TraceEnter();
	AuDebugOn(args->index != SysaufsSb_XINO);
	SiMustReadLock(sb);

	*do_size = 0;
	err = seq_printf(seq, "%lu %lu\n", (unsigned long)sizeof(struct xino),
			 (unsigned long)atomic_long_read(&stosi(sb)->si_xino));
	bend = sbend(sb);
	for (bindex = 0; !err && bindex <= bend; bindex++) {
		xf = stobr(sb, bindex)->br_xino;
		xi = xf->f_dentry->d_inode;
		err = seq_printf(seq, "%d: %d, %Lux%d %Ld\n",
				 bindex, file_count(xf),
				 (u64)xi->i_blocks, 1 << xi->i_blkbits,
				 i_size_read(xi));
	}
	return err;
}
Beispiel #5
0
STDMETHODIMP CMemoryStream::Revert()
{
    HRESULT hr = S_OK;
    TraceEnter();
    TraceLeaveHr(hr);
    return hr;
}
Beispiel #6
0
// IStream members
STDMETHODIMP CMemoryStream::Clone(IStream **ppstm)
{
    TraceEnter();
    if (NULL == ppstm)
    {
        return E_INVALIDARG;
    }

    CMemoryStream *pMemoryStream = new CMemoryStream(m_pbBuffer, m_nSize);

    if (NULL == pMemoryStream)
    {
        return E_INVALIDARG;
    }
    
    LARGE_INTEGER dlibMove;
    dlibMove.QuadPart = m_nPos;
    DWORD dwOrigin = STREAM_SEEK_SET;
    ULARGE_INTEGER dlibNewPosition;

    HRESULT hr = pMemoryStream->Seek(dlibMove, dwOrigin, &dlibNewPosition);

    if (FAILED(hr))
    {
        pMemoryStream->Release();
        return hr;
    }
    else
    {
        *ppstm = (IStream *)pMemoryStream;
        return S_OK;
    }
}
Beispiel #7
0
STDMETHODIMP CMemoryStream::LockRegion(ULARGE_INTEGER libOffset,
                                       ULARGE_INTEGER cb,
                                       DWORD dwLockType)
{
    HRESULT hr = E_NOTIMPL;
    TraceEnter();
    TraceLeaveHr(hr);
    return hr;
}
Beispiel #8
0
STDMETHODIMP CMemoryStream::CopyTo(IStream *pstm,
                                   ULARGE_INTEGER cb,
                                   ULARGE_INTEGER *pcbRead,
                                   ULARGE_INTEGER *pcbWritten)
{
    HRESULT hr = E_NOTIMPL;
    TraceEnter();
    TraceLeaveHr(hr);
    return hr;
}
Beispiel #9
0
void au_dpages_free(struct au_dcsub_pages *dpages)
{
	int i;

	TraceEnter();

	for (i = 0; i < dpages->ndpage; i++)
		au_dpage_free(dpages->dpages + i);
	kfree(dpages->dpages);
}
Beispiel #10
0
static void au_dpage_free(struct au_dpage *dpage)
{
	int i;

	TraceEnter();
	AuDebugOn(!dpage);

	for (i = 0; i < dpage->ndentry; i++)
		dput(dpage->dentries[i]);
	free_page((unsigned long)dpage->dentries);
}
Beispiel #11
0
STDMETHODIMP_(DWORD) CMemoryStream::Release()
{
    TraceEnter();
    DWORD dwNewRefCount = InterlockedDecrement(&m_lRefCount);

    if (0 == dwNewRefCount)
    {
        delete this;
    }

    return dwNewRefCount;
}
Beispiel #12
0
aufs_bindex_t new_br_id(struct super_block *sb)
{
	aufs_bindex_t br_id;

	TraceEnter();
	SiMustWriteLock(sb);

	while (1) {
		br_id = ++stosi(sb)->si_last_br_id;
		if (br_id && find_brindex(sb, br_id) < 0)
			return br_id;
	}
}
Beispiel #13
0
void nhash_fin(struct aufs_nhash *whlist)
{
	int i;
	struct hlist_head *head;
	struct aufs_wh *tpos;
	struct hlist_node *pos, *n;

	TraceEnter();

	for (i = 0; i < AUFS_NHASH_SIZE; i++) {
		head = whlist->heads + i;
		hlist_for_each_entry_safe(tpos, pos, n, head, wh_hash) {
			//hlist_del(pos);
			kfree(tpos);
		}
	}
Beispiel #14
0
CMemoryStream::CMemoryStream(BYTE *pbBuffer, int nSize)
    : m_pbBuffer(pbBuffer),
      m_nSize(nSize),
      m_nPos(0)
{
    TraceEnter();
    TraceOut("m_nSize=%d", m_nSize);
    m_lRefCount = 1;

    SYSTEMTIME st;
    GetSystemTime(&st);
    SystemTimeToFileTime(&st, &m_ftCreation);
    SystemTimeToFileTime(&st, &m_ftModified);
    SystemTimeToFileTime(&st, &m_ftAccessed);
    TraceLeave();
}
Beispiel #15
0
STDMETHODIMP CMemoryStream::Write(const void *pv,
                                  ULONG cb,
                                  ULONG *pcbWritten)
{
    TraceEnter();

    if (NULL == pv)
    {
        return STG_E_INVALIDPOINTER;
    }

    TraceOut("pv=%p, cb=%u, pcbWritten=%p", pv, cb, pcbWritten);

    BYTE *pbEnd = m_pbBuffer + m_nSize;
    BYTE *pbReqStart = m_pbBuffer + m_nPos;
    BYTE *pbReqEnd = pbReqStart + cb;
    ULONG nBytesToSet = (ULONG)(min(pbEnd, pbReqEnd) - pbReqStart);

    memcpy(pbReqStart, pv, nBytesToSet);
   
    if (NULL != pcbWritten)
    {
        *pcbWritten = nBytesToSet;
    }

    m_nPos += nBytesToSet;

    TraceOut("m_nPos=%d", m_nPos);

    SYSTEMTIME st;
    GetSystemTime(&st);
    SystemTimeToFileTime(&st, &m_ftModified);

    if (nBytesToSet < cb)
    {
        TraceLeaveHr(STG_E_MEDIUMFULL);
        return STG_E_MEDIUMFULL;
    }
    else
    {
        TraceLeaveHr(S_OK);
        return S_OK;
    }
}
Beispiel #16
0
void nhash_move(struct aufs_nhash *dst, struct aufs_nhash *src)
{
	int i;

	TraceEnter();

	//DbgWhlist(src);
	*dst = *src;
	for (i = 0; i < AUFS_NHASH_SIZE; i++) {
		struct hlist_head *h;
		h = dst->heads + i;
		if (h->first)
			h->first->pprev = &h->first;
		INIT_HLIST_HEAD(src->heads + i);
	}
	//DbgWhlist(src);
	//DbgWhlist(dst);
	//smp_mb();
}
Beispiel #17
0
// IUnknown methods
STDMETHODIMP CMemoryStream::QueryInterface(REFIID iid, void **ppvObject)
{
    TraceEnter();

    TraceOut("%S", GuidToString(iid));

    if (NULL == ppvObject)
    {
        return E_INVALIDARG;
    }

    if (IsEqualCLSID(iid, IID_IStream))
    {
        AddRef();
        *ppvObject = this;
        return S_OK;
    }
    else
    {
        return E_NOINTERFACE;
    }
}
Beispiel #18
0
STDMETHODIMP CMemoryStream::Read(void *pv,
                                 ULONG cb,
                                 ULONG *pcbRead)
{
    TraceEnter();

    if (NULL == pv)
    {
        TraceLeaveHr(STG_E_INVALIDPOINTER);
        return STG_E_INVALIDPOINTER;
    }

    TraceOut("pv=%p, cb=%u, pcbRead=%p, m_nPos=%d", pv, cb, pcbRead, m_nPos);

    BYTE *pbEnd = m_pbBuffer + m_nSize;
    BYTE *pbReqStart = m_pbBuffer + m_nPos;
    BYTE *pbReqEnd = pbReqStart + cb;
    ULONG nBytesToGet = (ULONG)(min(pbEnd - pbReqStart, pbReqEnd - pbReqStart));

    memcpy(pv, pbReqStart, nBytesToGet);
   
    if (NULL != pcbRead)
    {
        *pcbRead = nBytesToGet;
    }

    m_nPos += nBytesToGet;

    TraceOut("m_nPos=%d", m_nPos);

    SYSTEMTIME st;
    GetSystemTime(&st);
    SystemTimeToFileTime(&st, &m_ftAccessed);

    TraceLeaveHr(S_OK);
    return S_OK;
}
Beispiel #19
0
STDMETHODIMP CMemoryStream::Stat(STATSTG *pstatstg,
                                 DWORD grfStatFlag)
{
    TraceEnter();

    TraceOut("grfStatFlag=%u", grfStatFlag);

    if (NULL == pstatstg)
    {
        return STG_E_INVALIDPOINTER;
    }

    ZeroMemory(pstatstg, sizeof(*pstatstg));

    if (grfStatFlag != STATFLAG_NONAME)
    {
        WCHAR wszName[64];
        wsprintfW(wszName, L"%p", m_pbBuffer);
		size_t nSize = 1 + wcslen(wszName);
        pstatstg->pwcsName = (LPOLESTR)CoTaskMemAlloc(nSize);
        wcscpy_s(pstatstg->pwcsName, nSize, wszName);
    }

    pstatstg->cbSize.QuadPart = (ULONGLONG)m_nSize;
    pstatstg->type = STGTY_STREAM;
    pstatstg->ctime = m_ftCreation;
    pstatstg->mtime = m_ftModified;
    pstatstg->atime = m_ftAccessed;
    pstatstg->grfMode = STGM_READ;
    pstatstg->grfLocksSupported = 0;
    pstatstg->clsid = CLSID_NULL;
    pstatstg->grfStateBits = 0;
    pstatstg->reserved = 0;

    return S_OK;
}
Beispiel #20
0
int au_dcsub_pages(struct au_dcsub_pages *dpages, struct dentry *root,
		   au_dpages_test test, void *arg)
{
	int err;
	struct dentry *this_parent = root;
	struct list_head *next;
	struct super_block *sb = root->d_sb;

	TraceEnter();

	err = 0;
	spin_lock(&dcache_lock);
 repeat:
	next = this_parent->d_subdirs.next;
 resume:
	if (this_parent->d_sb == sb
	    && !IS_ROOT(this_parent)
	    && atomic_read(&this_parent->d_count)
	    && this_parent->d_inode
	    && (!test || test(this_parent, arg))) {
		err = au_dpages_append(dpages, this_parent, GFP_ATOMIC);
		if (unlikely(err))
			goto out;
	}

	while (next != &this_parent->d_subdirs) {
		struct list_head *tmp = next;
		struct dentry *dentry = list_entry(tmp, struct dentry, D_CHILD);
		next = tmp->next;
		if (unlikely(/*d_unhashed(dentry) || */!dentry->d_inode))
			continue;
		if (!list_empty(&dentry->d_subdirs)) {
			this_parent = dentry;
			goto repeat;
		}
		if (dentry->d_sb == sb
		    && atomic_read(&dentry->d_count)
		    && (!test || test(dentry, arg))) {
			err = au_dpages_append(dpages, dentry, GFP_ATOMIC);
			if (unlikely(err))
				goto out;
		}
	}

	if (this_parent != root) {
		next = this_parent->D_CHILD.next;
		this_parent = this_parent->d_parent;
		goto resume;
	}
 out:
	spin_unlock(&dcache_lock);
#if 0
	if (!err) {
		int i, j;
		j = 0;
		for (i = 0; i < dpages->ndpage; i++) {
			if ((dpages->dpages + i)->ndentry)
				Dbg("%d: %d\n",
				    i, (dpages->dpages + i)->ndentry);
			j += (dpages->dpages + i)->ndentry;
		}
		if (j)
			Dbg("ndpage %d, %d\n", dpages->ndpage, j);
	}
#endif
	TraceErr(err);
	return err;
}
Beispiel #21
0
STDMETHODIMP_(DWORD) CMemoryStream::AddRef()
{
    TraceEnter();
    return InterlockedIncrement(&m_lRefCount);
}
Beispiel #22
0
STDMETHODIMP CMemoryStream::Seek(LARGE_INTEGER dlibMove,
                                 DWORD dwOrigin,
                                 ULARGE_INTEGER *plibNewPosition)
{
    HRESULT hr = S_OK;
    TraceEnter();

    TraceOut("dlibMove=%Ld, dwOrigin=%d", dlibMove.QuadPart, dwOrigin);

    if (dlibMove.QuadPart > INT_MAX || dlibMove.QuadPart < INT_MIN)
    {
        hr = STG_E_INVALIDFUNCTION;
    }
    else
    {
        int nMove = (int)dlibMove.QuadPart;
        TraceOut("nMove = %d", nMove);
        int nNewPos = 0;

        switch (dwOrigin)
        {
            case STREAM_SEEK_SET:
                if (nMove >= 0 && nMove < m_nSize)
                {
                    m_nPos = nMove;

                    if (NULL != plibNewPosition)
                    {
                        plibNewPosition->QuadPart = (__int64)m_nPos;
                    }
                }
                else
                {
                    hr = STG_E_INVALIDFUNCTION;
                }

                break;

            case STREAM_SEEK_CUR:
                nNewPos = m_nPos + nMove;

                if (nNewPos >= 0 && nNewPos < m_nSize)
                {
                    m_nPos = nNewPos;

                    if (NULL != plibNewPosition)
                    {
                        plibNewPosition->QuadPart = (__int64)m_nPos;
                    }
                }
                else
                {
                    hr = STG_E_INVALIDFUNCTION;
                }

                break;

            case STREAM_SEEK_END:
                nNewPos = m_nSize - 1 + nMove;

                if (nNewPos >= 0 && nNewPos < m_nSize)
                {
                    m_nPos = nNewPos;

                    if (NULL != plibNewPosition)
                    {
                        plibNewPosition->QuadPart = (__int64)m_nPos;
                    }
                }
                else
                {
                    hr = STG_E_INVALIDFUNCTION;
                }

                break;                

            default:
                hr = STG_E_INVALIDFUNCTION;
                break;
        }
    }

    TraceLeaveHr(hr);
    return hr;
}