예제 #1
0
//Implementation of DeviceCtrl routine,this routine will be called
//by applications through IOControl interface routine of IOManager.
static DWORD NtfsDeviceCtrl(__COMMON_OBJECT* lpDrv,
						   __COMMON_OBJECT* lpDev,
						   __DRCB* lpDrcb)
{
	__COMMON_OBJECT*       pFindHandle = NULL;

	if((NULL == lpDev) || (NULL == lpDrcb))  //Invalid parameters.
	{
		goto __TERMINAL;
	}
	//Dispatch the request to appropriate routines according to control command.
	switch(lpDrcb->dwCtrlCommand)
	{
	case IOCONTROL_FS_CHECKPARTITION:
		return CheckPartition(lpDev,(__COMMON_OBJECT*)lpDrcb->lpInputBuffer) ? 1 : 0;
	case IOCONTROL_FS_FINDFIRSTFILE:
		return FindFirstFile(lpDrv,lpDev,lpDrcb);
	case IOCONTROL_FS_FINDNEXTFILE:
		return FindNextFile(lpDrv,lpDev,lpDrcb);
	case IOCONTROL_FS_FINDCLOSE:
		return FindClose(lpDrv,lpDev,lpDrcb);
	case IOCONTROL_FS_CREATEDIR:
		break;
	case IOCONTROL_FS_GETFILEATTR:
		return GetFileAttributes(lpDrv,lpDev,lpDrcb);
	case IOCONTROL_FS_DELETEFILE:
	case IOCONTROL_FS_REMOVEDIR:
	default:
		break;
	}

__TERMINAL:
	return 0;
}
예제 #2
0
파일: FAT32.C 프로젝트: bladely/HelloX_OS
//Implementation of DeviceCtrl routine.
static DWORD FatDeviceCtrl(__COMMON_OBJECT* lpDrv,__COMMON_OBJECT* lpDev, __DRCB* lpDrcb)
{
    __COMMON_OBJECT*       pFindHandle = NULL;

    if((NULL == lpDev) || (NULL == lpDrcb))  //Invalid parameters.
    {
        goto __TERMINAL;
    }
    //Dispatch the request to appropriate routines according to control command.
    switch(lpDrcb->dwCtrlCommand)
    {
    case IOCONTROL_FS_CHECKPARTITION:
        return CheckPartition(lpDev,(__COMMON_OBJECT*)lpDrcb->lpInputBuffer) ? 1 : 0;
    case IOCONTROL_FS_FINDFIRSTFILE:
        pFindHandle = _fat32FindFirstFile((__COMMON_OBJECT*)lpDev,
                                          (CHAR*)lpDrcb->dwExtraParam1,
                                          (FS_FIND_DATA*)lpDrcb->dwExtraParam2);
        if(NULL == pFindHandle)  //Can not start the iterate.
        {
            return 0;
        }
        lpDrcb->lpOutputBuffer = (LPVOID)pFindHandle;
        return 1;
    case IOCONTROL_FS_FINDNEXTFILE:
        return _FindNextFile((__COMMON_OBJECT*)lpDev,
                             (__COMMON_OBJECT*)lpDrcb->lpInputBuffer,
                             (FS_FIND_DATA*)lpDrcb->dwExtraParam2) ? 1 : 0;
    case IOCONTROL_FS_FINDCLOSE:
        _fat32FindClose((__COMMON_OBJECT*)lpDev,
                        (__COMMON_OBJECT*)lpDrcb->lpInputBuffer);
        break;
    case IOCONTROL_FS_CREATEDIR:
        if(_CreateDirectory(lpDev,
                            (LPSTR)lpDrcb->lpInputBuffer,
                            0))
        {
            lpDrcb->dwStatus = DRCB_STATUS_SUCCESS;
            return 1;
        }
        else
        {
            lpDrcb->dwStatus = DRCB_STATUS_FAIL;
            return 0;
        }
        break;
    case IOCONTROL_FS_GETFILEATTR:
        lpDrcb->dwExtraParam2 = _fat32GetFileAttributes(
                                    lpDev,
                                    (LPCTSTR)lpDrcb->dwExtraParam1);
        lpDrcb->dwStatus = DRCB_STATUS_SUCCESS;
        return 1;
        break;
    case IOCONTROL_FS_DELETEFILE:
        if(_fat32DeleteFile(lpDev,
                            (LPSTR)lpDrcb->lpInputBuffer))
        {
            lpDrcb->dwStatus = DRCB_STATUS_SUCCESS;
            return 1;
        }
        else
        {
            lpDrcb->dwStatus = DRCB_STATUS_FAIL;
            return 0;
        }
        break;
    case IOCONTROL_FS_REMOVEDIR:
        if(_RemoveDirectory(lpDev,
                            (LPSTR)lpDrcb->lpInputBuffer))
        {
            lpDrcb->dwStatus = DRCB_STATUS_SUCCESS;
            return 1;
        }
        else
        {
            lpDrcb->dwStatus = DRCB_STATUS_FAIL;
            return 0;
        }
        break;
    case IOCONTROL_FS_SETENDFILE:
    {
        if(_SetEndOfFile(lpDev))
        {
            lpDrcb->dwStatus = DRCB_STATUS_SUCCESS;
            return 1;
        }
        else
        {
            lpDrcb->dwStatus = DRCB_STATUS_FAIL;
            return 0;
        }
    }
    break;
    default:
        break;
    }

__TERMINAL:
    return 0;
}