![]() |
WL865E4-P
36.07.001
|
This section describes the M2MB APIs to perform various File system posix operations. More...
#define | M2MB_O_RDONLY 00 |
#define | M2MB_O_WRONLY 01 |
#define | M2MB_O_RDWR 02 |
#define | M2MB_O_CREAT 0100 |
#define | M2MB_O_EXCL 0200 |
#define | M2MB_O_TRUNC 01000 |
#define | M2MB_O_APPEND 02000 |
#define | M2MB_SEEK_SET 0 |
#define | M2MB_SEEK_CUR 1 |
#define | M2MB_SEEK_END 2 |
#define | M2MB_FS_ENOERR 0 |
#define | M2MB_FS_EPERM 1 |
#define | M2MB_FS_ENOENT 2 |
#define | M2MB_FS_EIO 5 |
#define | M2MB_FS_EBADF 9 |
#define | M2MB_FS_ENOMEM 12 |
#define | M2MB_FS_EACCES 13 |
#define | M2MB_FS_EBUSY 16 |
#define | M2MB_FS_EEXIST 17 |
#define | M2MB_FS_EXDEV 18 |
#define | M2MB_FS_ENODEV 19 |
#define | M2MB_FS_ENOTDIR 20 |
#define | M2MB_FS_EISDIR 21 |
#define | M2MB_FS_EINVAL 22 |
#define | M2MB_FS_EMFILE 24 |
#define | M2MB_FS_ETXTBSY 26 |
#define | M2MB_FS_ENOSPC 28 |
#define | M2MB_FS_ESPIPE 29 |
#define | M2MB_FS_ENAMETOOLONG 36 |
#define | M2MB_FS_ENOTEMPTY 39 |
#define | M2MB_FS_ELOOP 40 |
#define | M2MB_FS_EILSEQ 84 |
#define | M2MB_FS_ETIMEDOUT 110 |
#define | M2MB_FS_ESTALE 116 |
#define | M2MB_FS_EDQUOT 122 |
INT32 | m2mb_fs_open (const CHAR *path, INT32 oflag,...) |
Open file. More... | |
INT32 | m2mb_fs_secure_open (const CHAR *path, INT32 oflag, const char *pwd) |
Open secure file. More... | |
SSIZE_T | m2mb_fs_read (INT32 fd, void *buf, SIZE_T nbyte) |
Read file. More... | |
SSIZE_T | m2mb_fs_write (INT32 fd, const void *buf, SIZE_T nbyte) |
Write file. More... | |
INT32 | m2mb_fs_close (INT32 fd) |
Close file. More... | |
OFF_T | m2mb_fs_lseek (INT32 fd, OFF_T offset, INT32 whence) |
Move file offset. More... | |
INT32 | m2mb_fs_stat (const CHAR *path, struct M2MB_STAT *buf) |
File status. More... | |
INT32 | m2mb_fs_unlink (const CHAR *path) |
Delete file. More... | |
INT32 | m2mb_fs_statvfs (const CHAR *path, struct M2MB_STATVFS *buf) |
File system statistics. More... | |
INT32 | m2mb_fs_ls_open (const char *path, HANDLE *handle) |
List over all the files in the file system. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration. More... | |
INT32 | m2mb_fs_ls_next (HANDLE ls_hdl, struct M2MB_LS_ENTRY *ls_entry) |
Returns the next file system entry while listing. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration. More... | |
INT32 | m2mb_fs_ls_close (HANDLE ls_hdl) |
File system ls close. More... | |
This section describes the M2MB APIs to perform various File system posix operations.
#define M2MB_FS_EACCES 13 |
Permission denied
Definition at line 74 of file m2mb_fs_posix.h.
#define M2MB_FS_EBADF 9 |
Bad file descriptor
Definition at line 72 of file m2mb_fs_posix.h.
#define M2MB_FS_EBUSY 16 |
Device or resource busy
Definition at line 75 of file m2mb_fs_posix.h.
#define M2MB_FS_EDQUOT 122 |
Quota exceeded
Definition at line 92 of file m2mb_fs_posix.h.
#define M2MB_FS_EEXIST 17 |
File exists
Definition at line 76 of file m2mb_fs_posix.h.
#define M2MB_FS_EILSEQ 84 |
Illegal byte sequence
Definition at line 89 of file m2mb_fs_posix.h.
#define M2MB_FS_EINVAL 22 |
Invalid argument
Definition at line 81 of file m2mb_fs_posix.h.
#define M2MB_FS_EIO 5 |
I/O error
Definition at line 71 of file m2mb_fs_posix.h.
#define M2MB_FS_EISDIR 21 |
Is a directory
Definition at line 80 of file m2mb_fs_posix.h.
#define M2MB_FS_ELOOP 40 |
Too many symbolic links encountered
Definition at line 88 of file m2mb_fs_posix.h.
#define M2MB_FS_EMFILE 24 |
Too many open files
Definition at line 82 of file m2mb_fs_posix.h.
#define M2MB_FS_ENAMETOOLONG 36 |
File name too long
Definition at line 86 of file m2mb_fs_posix.h.
#define M2MB_FS_ENODEV 19 |
No such device
Definition at line 78 of file m2mb_fs_posix.h.
#define M2MB_FS_ENOENT 2 |
No such file or directory
Definition at line 70 of file m2mb_fs_posix.h.
#define M2MB_FS_ENOERR 0 |
Success
Definition at line 68 of file m2mb_fs_posix.h.
#define M2MB_FS_ENOMEM 12 |
Out of memory
Definition at line 73 of file m2mb_fs_posix.h.
#define M2MB_FS_ENOSPC 28 |
No space left on device
Definition at line 84 of file m2mb_fs_posix.h.
#define M2MB_FS_ENOTDIR 20 |
Not a directory
Definition at line 79 of file m2mb_fs_posix.h.
#define M2MB_FS_ENOTEMPTY 39 |
Directory not empty
Definition at line 87 of file m2mb_fs_posix.h.
#define M2MB_FS_EPERM 1 |
Operation not permitted
Definition at line 69 of file m2mb_fs_posix.h.
#define M2MB_FS_ESPIPE 29 |
Illegal seek
Definition at line 85 of file m2mb_fs_posix.h.
#define M2MB_FS_ESTALE 116 |
Stale remote file handle.
Definition at line 91 of file m2mb_fs_posix.h.
#define M2MB_FS_ETIMEDOUT 110 |
Operation/Connection timed out.
Definition at line 90 of file m2mb_fs_posix.h.
#define M2MB_FS_ETXTBSY 26 |
File or directory busy (already open)
Definition at line 83 of file m2mb_fs_posix.h.
#define M2MB_FS_EXDEV 18 |
Cross-device link
Definition at line 77 of file m2mb_fs_posix.h.
#define M2MB_O_APPEND 02000 |
File Append mode, the file offset shall be set to the end of the file prior to each write.
Definition at line 60 of file m2mb_fs_posix.h.
#define M2MB_O_CREAT 0100 |
File create mode
Definition at line 57 of file m2mb_fs_posix.h.
#define M2MB_O_EXCL 0200 |
Definition at line 58 of file m2mb_fs_posix.h.
#define M2MB_O_RDONLY 00 |
Read only mode
Definition at line 54 of file m2mb_fs_posix.h.
#define M2MB_O_RDWR 02 |
Read-write mode
Definition at line 56 of file m2mb_fs_posix.h.
#define M2MB_O_TRUNC 01000 |
File Truncate mode
Definition at line 59 of file m2mb_fs_posix.h.
#define M2MB_O_WRONLY 01 |
write only mode
Definition at line 55 of file m2mb_fs_posix.h.
#define M2MB_SEEK_CUR 1 |
Seek from current position
Definition at line 64 of file m2mb_fs_posix.h.
#define M2MB_SEEK_END 2 |
Seek from end of file
Definition at line 65 of file m2mb_fs_posix.h.
#define M2MB_SEEK_SET 0 |
Seek from beginning of file
Definition at line 63 of file m2mb_fs_posix.h.
Close file.
The function closes the file associated with the open file descriptor, fd.
[in] | fd | File descriptor. |
m2mb_fs_close(fd);
File system ls close.
The function is called to close the ls functionality.
[in] | ls_hdl | File ls handle. |
m2mb_fs_ls_close( handle );
INT32 m2mb_fs_ls_next | ( | HANDLE | ls_hdl, |
struct M2MB_LS_ENTRY * | ls_entry | ||
) |
Returns the next file system entry while listing. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration.
[in] | ls_hdl | Handle to the ls. |
[in] | ls_entry | Returns non NULL ls entry on success, or NULL for an error. |
struct M2MB_LS_ENTRY { char file_path[100]; struct M2MB_STAT sbuf; }; struct M2MB_STAT { DEV_T st_dev; UINT32 st_ino; UINT32 st_size; UINT32 st_blksize; UINT32 st_blocks; }; st_dev : Unique Device ID st_ino : INode number associated with the file. st_size : File size in bytes. st_blksize : Block size, smallest allocation unit of the file system. Unit in which block count is represented. st_blocks : Number of blocks allocated for this file in st_blksize units.
m2mb_fs_ls_next( handle, &ls_entry );
List over all the files in the file system. Depending on the read/write speeds of the underlying flash media, this API can take time in the order of seconds to complete, and clients calling this API should be prepared to have their task blocked for this time duration.
[in] | path | path of the file system to iterate. |
[in] | handle | Returns non NULL iterator handle on success, or NULL for an error. |
m2mb_fs_ls_open( file_path, &handle ));
Move file offset.
The function sets the file offset for the open file description associated with the file descriptor fd. The new offset, measured in bytes, is obtained by adding offset bytes to the position specified by whence.
[in] | fd | File descriptor. |
[in] | offset | Number of bytes to move the file offset from the position specified by whence. |
[in] | whence | File position. M2MB_SEEK_SET Beginning of the file. M2MB_SEEK_CUR Current file position. M2MB_SEEK_END End of file. |
m2mb_fs_lseek( fd, 0, M2MB_SEEK_END );
Open file.
The function opens the file whose name is the string pointed to by path.
[in] | path | Name of file to be open. |
[in] | oflag | Flags for opening file. One of the following three flags must be used: M2MB_O_RDONLY Open for reading only. M2MB_O_WRONLY Open for writing only. M2MB_O_RDWR Open for reading and writing. In addition any of the following flags may be bitwise ORed: M2MB_O_APPEND If set, the file offset shall be set to the end of the file prior to each write. M2MB_O_CREAT If the file exists, this flag has no effect except as noted under M2MB_O_EXCL below. Otherwise, the file shall be created. M2MB_O_EXCL If M2MB_O_CREAT and M2MB_O_EXCL are set, open fails if the file exists. M2MB_O_TRUNC If the file exists and is a regular file, and the file is successfully opened with M2MB_O_RDWR or M2MB_O_WRONLY, its length is truncated to 0, and the mode is unchanged. |
m2mb_fs_open( M2MB_PROV_FILE_CUST_JS_PATH, 0 );
Read file.
The function reads nbyte bytes from the file associated with the open file descriptor, fd, into the buffer pointed to by buf.
[in] | fd | File descriptor. |
[out] | buf | Buffer to fill with read data. |
[in] | nbyte | Number of bytes to read. |
m2mb_fs_read( fd, data, len );
Open secure file.
The function opens the file in secured mode, whose name is the string pointed to by path.
[in] | path | Name of file to be open. |
[in] | oflag | Flags for opening files. One of the following three flags must be used: M2MB_O_RDONLY Open for reading only. M2MB_O_WRONLY Open for writing only. M2MB_O_RDWR Open for reading and writing. In addition, any of the following flags may be bitwise ORed: M2MB_O_APPEND If set, the file offset shall be set to the end of the file prior to each write. M2MB_O_CREAT If the file exists, this flag has no effect except as noted under M2MB_O_EXCL below. Otherwise, the file shall be created. M2MB_O_EXCL If M2MB_O_CREAT and M2MB_O_EXCL are set, open fails if the file exists. M2MB_O_TRUNC If the file exists and is a regular file, and the file is successfully opened with M2MB_O_RDWR or M2MB_O_WRONLY, its length is truncated to 0, and the mode is unchanged. |
[in] | pwd | Password of the file to be opened. The password must of be 16 bytes length |
m2mb_fs_secure_open( file_name,M2MB_O_RDONLY, profile_pwd );
File status.
The function gets status of the file whose name is the string pointed to by path, and writes it to the area pointed to by buf.
[in] | path | Name of file. |
[in] | buf | Pointer to a stat structure (see definition) to be filled with the status of the file. |
m2mb_fs_stat( M2MB_PROV_FILE_CUST_JS_PATH, &stat );
INT32 m2mb_fs_statvfs | ( | const CHAR * | path, |
struct M2MB_STATVFS * | buf | ||
) |
File system statistics.
The function gets information about file system specified by the string pointed to by path, and writes it to the area pointed to by buf.
[in] | path | Pathname of any file within the mounted file system. |
[in] | buf | Pointer to a statvfs structure (see definition) to be filled with the information about file system. |
m2mb_fs_statvfs( M2MB_PROV_FILE_CUST_JS_PATH, &stat );
Delete file.
The function deletes the file whose name is the string pointed to by path.
[in] | path | Name of file to be deleted. |
m2mb_fs_unlink( file_name );
Write file.
The function writes nbyte bytes from the buffer pointed to by buf to the file associated with the open file descriptor, fd.
[in] | fd | File descriptor. |
[in] | buf | Buffer containing data to be written. |
[in] | nbyte | Number of bytes to write. |
m2mb_fs_write( fd, (UINT8*)buffer, (UINT32)length );