blob: 6e15a669cee4f4c69a7dbc6bbf5104ac0abce66f [file] [log] [blame]
/******************************************************************************
*(C) Copyright 2011 Marvell International Ltd.
* All Rights Reserved
******************************************************************************/
#ifndef NVMFILEOPS_INCLUDE
#define NVMFILEOPS_INCLUDE
#ifdef __cplusplus
extern "C"{
#endif
#include <pthread.h>
#include <semaphore.h>
#include <dirent.h>
#include "nvm_shared.h"
#include <stdbool.h>
#include <limits.h>
#include "list.h"
typedef struct FileItem
{
char* handle;
char fName[NAME_MAX];
int fd;
unsigned flag; //IS_COMM, IS_DIR, IS_READONLY...
}FileItem;
void NVMFileOps(const char* dir, bool async);
NVM_STATUS_T FileFindClose(int handle, List list);
NVM_STATUS_T FileFindFirst(int ClientID, const char* szFileName,
NVM_FILE_INFO* pFindResults, unsigned *fStatus, int *searchHandle, List list);
NVM_STATUS_T FileFindNext(NVM_FILE_INFO* pFindResults, unsigned *fStatus, int handle, List list);
NVM_STATUS_T GetFileSize(const char* szFileName, unsigned *pdwSizeHigh, unsigned* pdwSizeLow);
NVM_STATUS_T FileOpen(int ClientID, const char* szFileName, const char* szAttrib, unsigned* hFile, List list);
NVM_STATUS_T FileWrite(unsigned hFile, const void* pBuffer, unsigned dwBufferLen,
short wItemSize, unsigned dwCount, unsigned *pdwActual, List list);
NVM_STATUS_T FileFlush(unsigned hFile, List list);
NVM_STATUS_T FileSeek(unsigned hFile, long dwOffset, int dwOrigin, List list);
NVM_STATUS_T FileRead(unsigned hFile, short wItemSize, unsigned dwCount,
unsigned *pdwActual, void* pBuffer, List list);
NVM_STATUS_T FileClose(int ClientID, unsigned hFile, List list);
NVM_STATUS_T FileCloseAll(int ClientID, List list);
NVM_STATUS_T FileDelete(const char* szFileName);
/* NVM extension for flash explorer */
NVM_STATUS_T FileRename(const char* szOldFileName, const char* szNewFileName);
NVM_STATUS_T GetFileStat(const char* szFileName, int *dwStat);
NVM_STATUS_T FileChangeMode(const char* szFileName, mode_t dwNewMode);
NVM_STATUS_T GetAvailSpace(const char* szVol, unsigned* pdwSize);
NVM_STATUS_T GetTotalSpace(unsigned long long* pdwSize);
NVM_STATUS_T MkDir(const char* szDirName, mode_t dwMode);
NVM_STATUS_T RmDir(const char* szDirName);
void* syncThread(void);
extern pthread_mutex_t lock;
#ifdef NVMS_SYNC_THREAD_ENA
extern pthread_mutex_t syncLock;
extern pthread_t syncTaskRef;
extern sem_t syncSem;
#endif
extern char rootDir[80];
/**************************************************************************
* COMM Silent Reset
* When COMM assert occurs there could still be opened files/dirs
* To avoid this situation the opened files/dirs are saved in list
* and closed when assert
***************************************************************************
*/
//std::list<FileItem*> openList;
//std::list<FileItem*> syncList;
FILE* FileOpenSafe(const char* fName, const char* szAttrib);
int FileCloseSafe(FileItem* item);
int FileFindEntry(DIR** dirstream, const char* szFileName, NVM_FILE_INFO* pFindResults, unsigned* fStatus);
FileItem* removeItemByFd(int fd, List list);
#ifdef __cplusplus
}
#endif
#endif