![]() |
Data Structures | |
struct | PHATFILE |
PHAT file descriptor structure. More... | |
Modules | |
Volume Support | |
Dealing with volumes. | |
Directory Support | |
Routines for reading and writing directories. | |
PHAT12 Support | |
PHAT12 specific routines. | |
PHAT16 Support | |
PHAT16 specific routines. | |
PHAT32 Support | |
PHAT32 specific routines. | |
PHAT Block I/O | |
Reading and writing data blocks. | |
PHAT Utilities | |
General utility routines used by the PHAT file system. | |
PHAT Debugging Support | |
Listing various PHAT structures. | |
Defines | |
#define | PHATEOC 0x0FFFFFF8 |
Marks end of cluster chain. | |
Functions | |
uint32_t | AllocFirstCluster (NUTFILE *nfp) |
Allocate the first cluster of a file. | |
int | PhatFileClose (NUTFILE *nfp) |
Close a file. | |
NUTFILE * | PhatFileOpen (NUTDEVICE *dev, CONST char *path, int mode, int acc) |
Open a file. | |
int | PhatFileWrite (NUTFILE *nfp, CONST void *buffer, int len) |
Write data to a file. | |
int | PhatFileWrite_P (NUTFILE *nfp, PGM_P buffer, int len) |
Write data from program space to a file. | |
int | PhatFileRead (NUTFILE *nfp, void *buffer, int size) |
Read data from a file. | |
Variables | |
NUTDEVICE | devPhat0 |
PHAT file system driver information structure. | |
NUTDEVICE | devPhat1 |
File attributes. | |
#define | PHAT_FATTR_RDONLY 0x01 |
#define | PHAT_FATTR_HIDDEN 0x02 |
#define | PHAT_FATTR_SYSTEM 0x04 |
#define | PHAT_FATTR_VOLID 0x08 |
#define | PHAT_FATTR_DIR 0x10 |
#define | PHAT_FATTR_ARCHIV 0x20 |
#define | PHAT_FATTR_LFN (PHAT_FATTR_RDONLY | PHAT_FATTR_HIDDEN | PHAT_FATTR_SYSTEM | PHAT_FATTR_VOLID) |
#define | PHAT_FATTR_FILEMASK 0x37 |
#define PHATEOC 0x0FFFFFF8 |
Marks end of cluster chain.
Definition at line 123 of file phatfs.h.
Referenced by Phat12GetClusterLink(), Phat12ReleaseChain(), Phat16GetClusterLink(), Phat16ReleaseChain(), Phat32GetClusterLink(), Phat32ReleaseChain(), PhatFilePosSet(), PhatFileRead(), and PhatFileWrite().
#define PHAT_FATTR_RDONLY 0x01 |
Read only file.
Definition at line 131 of file phatfs.h.
Referenced by PhatDbgAttrList(), PhatDirReleaseChain(), and PhatFileWrite().
#define PHAT_FATTR_HIDDEN 0x02 |
#define PHAT_FATTR_SYSTEM 0x04 |
#define PHAT_FATTR_VOLID 0x08 |
No file, but a volume label.
Definition at line 137 of file phatfs.h.
Referenced by PhatDbgAttrList().
#define PHAT_FATTR_DIR 0x10 |
File contains a subdirectory.
Definition at line 139 of file phatfs.h.
Referenced by PhatDbgAttrList(), PhatDirCreate(), PhatDirEntryStatus(), PhatDirOpen(), PhatDirRead(), PhatDirRemove(), PhatFilePosSet(), PhatFileRead(), and PhatFileWrite().
#define PHAT_FATTR_ARCHIV 0x20 |
File is not archived. This flag will be set when the file is created or modified.
Definition at line 143 of file phatfs.h.
Referenced by PhatDbgAttrList(), and PhatFileWrite().
#define PHAT_FATTR_LFN (PHAT_FATTR_RDONLY | PHAT_FATTR_HIDDEN | PHAT_FATTR_SYSTEM | PHAT_FATTR_VOLID) |
#define PHAT_FATTR_FILEMASK 0x37 |
Only these flags are allowed for files and directories.
Definition at line 149 of file phatfs.h.
Referenced by PhatDirEntryStatus(), PhatDirOpen(), PhatDirRemove(), PhatDirRenameEntry(), and PhatFileOpen().
uint32_t AllocFirstCluster | ( | NUTFILE * | nfp | ) |
Allocate the first cluster of a file.
nfp | The file for which a cluster is allocated. |
Definition at line 224 of file phatfs.c.
References PHAT12CMASK, Phat12SetClusterLink(), PHAT16CMASK, Phat16SetClusterLink(), PHAT32CMASK, Phat32SetClusterLink(), PHATVOL::vol_numfree, and PHATVOL::vol_type.
Referenced by PhatDirCreate(), and PhatFileWrite().
int PhatFileClose | ( | NUTFILE * | nfp | ) |
Close a file.
nfp | File descriptor. |
Definition at line 336 of file phatfs.c.
References EBADF, errno, free, NUTFILE_EOF, PhatDbgFileInfo(), and stdout.
Referenced by PhatDirCreate(), PhatDirDelEntry(), PhatDirEntryStatus(), PhatDirRemove(), PhatDirRenameEntry(), and PhatFileOpen().
NUTFILE* PhatFileOpen | ( | NUTDEVICE * | dev, | |
CONST char * | path, | |||
int | mode, | |||
int | acc | |||
) |
Open a file.
This function is called by the low level open routine of the C runtime library, using the _NUTDEVICE::dev_open entry.
dev | Specifies the file system device. | |
path | Pathname of the file to open. If the last character is a slash, then a directory will be opened. | |
mode | Operation mode. | |
acc | File attribute. |
Definition at line 372 of file phatfs.c.
References _O_APPEND, _O_CREAT, _O_EXCL, _O_TRUNC, CONST, PHATDIRENT::dent_attr, PHATDIRENT::dent_cdate, PHATDIRENT::dent_clust, PHATDIRENT::dent_clusthi, PHATDIRENT::dent_ctime, PHATDIRENT::dent_ctsecs, PHATDIRENT::dent_fsize, PHATDIRENT::dent_name, PHATDIRENT::dent_rsvdnt, EEXIST, ENOENT, errno, PHATFILE::f_clust, PHATFILE::f_clust_pos, PHATFILE::f_de_dirty, PHATFILE::f_de_offs, PHATFILE::f_de_sect, PHATFILE::f_dirent, PHATFILE::f_mode, PHATFILE::f_pde_clust, PHATFILE::f_pde_clusthi, PHATFILE::f_sect_pos, free, malloc, memcpy(), memset(), NUTFILE_EOF, PHAT_FATTR_FILEMASK, PhatClusterSector(), PhatDbgFileInfo(), PhatDirEntryCreate(), PhatDirEntryFind(), PhatDirOpenParent(), PhatDirReleaseChain(), PhatFileClose(), PhatFilePosSet(), PHATFIND::phfind_ent, and stdout.
Referenced by PhatDirCreate(), and PhatDirRemove().
int PhatFileWrite | ( | NUTFILE * | nfp, | |
CONST void * | buffer, | |||
int | len | |||
) |
Write data to a file.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to PnutFileOpen(). | |
buffer | Pointer to the data to be written. If zero, then the output buffer will be flushed. | |
len | Number of bytes to write. |
Definition at line 538 of file phatfs.c.
References AllocFirstCluster(), PHATDIRENT::dent_adate, PHATDIRENT::dent_attr, PHATDIRENT::dent_fsize, PHATDIRENT::dent_mdate, PHATDIRENT::dent_mtime, EACCES, ENOSPC, errno, PHATFILE::f_clust, PHATFILE::f_clust_pos, PHATFILE::f_clust_prv, PHATFILE::f_de_dirty, PHATFILE::f_dirent, PHATFILE::f_pos, PHATFILE::f_sect_pos, GetDosTimeStamp(), IsFixedRootDir(), memcpy(), PHAT12CMASK, Phat12GetClusterLink(), PHAT16CMASK, Phat16GetClusterLink(), PHAT32CMASK, Phat32GetClusterLink(), PHAT_FATTR_ARCHIV, PHAT_FATTR_DIR, PHAT_FATTR_RDONLY, PhatClusterSector(), PHATEOC, PhatSectorLoad(), PHATSECTBUF::sect_data, PHATSECTBUF::sect_dirty, PHATVOL::vol_buf, PHATVOL::vol_clustsz, PHATVOL::vol_numfree, PHATVOL::vol_rootsz, PHATVOL::vol_sectsz, and PHATVOL::vol_type.
Referenced by PhatDirCreate().
int PhatFileWrite_P | ( | NUTFILE * | nfp, | |
PGM_P | buffer, | |||
int | len | |||
) |
Write data from program space to a file.
This function is not yet implemented and will always return -1.
Similar to PhatFileWrite() except that the data is located in program memory.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to PnutFileOpen(). | |
buffer | Pointer to the data in program space. If zero, then the output buffer will be flushed. | |
len | Number of bytes to write. |
int PhatFileRead | ( | NUTFILE * | nfp, | |
void * | buffer, | |||
int | size | |||
) |
Read data from a file.
nfp | Pointer to a NUTFILE structure, obtained by a previous call to PnutFileOpen(). | |
buffer | Pointer to the data buffer to fill. | |
size | Maximum number of bytes to read. |
Definition at line 723 of file phatfs.c.
References PHATDIRENT::dent_attr, PHATDIRENT::dent_fsize, PHATFILE::f_clust, PHATFILE::f_clust_pos, PHATFILE::f_clust_prv, PHATFILE::f_dirent, PHATFILE::f_pos, PHATFILE::f_sect_pos, IsFixedRootDir(), memcpy(), PHAT12CMASK, Phat12GetClusterLink(), PHAT16CMASK, Phat16GetClusterLink(), PHAT32CMASK, Phat32GetClusterLink(), PHAT_FATTR_DIR, PhatClusterSector(), PHATEOC, PhatSectorLoad(), PHATSECTBUF::sect_data, PHATVOL::vol_buf, PHATVOL::vol_clustsz, PHATVOL::vol_rootsz, PHATVOL::vol_sectsz, and PHATVOL::vol_type.
Referenced by PhatDirRemove().
NUTDEVICE devPhat0 |
Initial value:
{ 0, {'P', 'H', 'A', 'T', '0', 0, 0, 0, 0} , IFTYP_FS, 0, 0, 0, 0, PhatInit, PhatApiIOCtl, PhatApiFileRead, PhatApiFileWrite, PhatApiFileWrite_P, PhatApiFileOpen, PhatApiFileClose, PhatFileSize }
A pointer to this structure must be passed to NutRegisterDevice() to bind this file system driver to the Nut/OS kernel. An application may then call /verbatim _open("MMC0:1/PHAT0", _O_RDWR | _O_BINARY); /endverbatim to mount partition 1 on the previously registered block device (devMmc0 in this example).
NUTDEVICE devPhat1 |