Miosix
2.0alpha1
|
#include <file.h>
Public Member Functions | |
DirectoryBase (intrusive_ref_ptr< FilesystemBase > parent) | |
virtual ssize_t | write (const void *data, size_t len) |
virtual ssize_t | read (void *data, size_t len) |
virtual off_t | lseek (off_t pos, int whence) |
virtual int | fstat (struct stat *pstat) const |
Public Member Functions inherited from miosix::FileBase | |
FileBase (intrusive_ref_ptr< FilesystemBase > parent) | |
virtual int | isatty () const |
virtual int | fcntl (int cmd, int opt) |
virtual int | ioctl (int cmd, void *arg) |
virtual int | getdents (void *dp, int len) |
const intrusive_ref_ptr < FilesystemBase > | getParent () const |
virtual | ~FileBase () |
Static Protected Member Functions | |
static int | addEntry (char **pos, char *end, int ino, char type, const StringPart &n) |
static int | addDefaultEntries (char **pos, int thisIno, int upIno) |
static int | addTerminatingEntry (char **pos, char *end) |
Static Protected Attributes | |
static const int | direntHeaderSizeNoPadding =offsetof(struct dirent,d_name) |
static const int | direntHeaderSize =(direntHeaderSizeNoPadding+3+3)/4*4 |
static const int | minimumBufferSize =3*direntHeaderSize |
Minimum buffer accepted by getdents, two for . and .., plus terminating. | |
Additional Inherited Members | |
Protected Member Functions inherited from miosix::IntrusiveRefCounted | |
IntrusiveRefCounted () | |
IntrusiveRefCounted (const IntrusiveRefCounted &) | |
IntrusiveRefCounted & | operator= (const IntrusiveRefCounted &) |
Directories are a special kind of files that implement the getdents() call Classes of this type are reference counted, must be allocated on the heap and managed through intrusive_ref_ptr<DirectoryBase>
|
inline |
Constructor
parent | the filesystem to which this file belongs |
|
staticprotected |
Helper function to add the default directory entries . and .. to a buffer
pos | position where to add the entry (four word aligned). Pointer is incremented. The caller is responsible to guarantee that there is at least space for 2*direntHeaderSize |
thisIno | inode number of . |
upInode | inode number of .. |
|
staticprotected |
Helper function to add a directory entry to a buffer
pos | position where to add the entry (four word aligned). Pointer is incremented. |
end | end of buffer (one char past the last), for bound checking |
ino | inode of file |
type | file type |
name | file name to append after the DirentHeader |
|
staticprotected |
Add an entry with d_reclen=0 which is used to terminate directory listing
pos | position where to add the entry (four word aligned). Pointer is incremented. The caller is responsible to guarantee that there is at least space for direntHeaderSize, including padding |
end | end of buffer (one char past the last), for bound checking |
|
virtual |
Return file information.
pstat | pointer to stat struct |
Implements miosix::FileBase.
|
virtual |
Move file pointer, if the file supports random-access.
pos | offset to sum to the beginning of the file, current position or end of file, depending on whence |
whence | SEEK_SET, SEEK_CUR or SEEK_END |
Implements miosix::FileBase.
|
virtual |
Read data from the file, if the file supports reading.
data | buffer to store read data |
len | the number of bytes to read |
Implements miosix::FileBase.
|
virtual |
Write data to the file, if the file supports writing.
data | the data to write |
len | the number of bytes to write |
Implements miosix::FileBase.
|
staticprotected |
Size of struct dirent including room for the "." and ".." string in d_name, including terminating \0 and padding for 4-word alignment. First +3: make room for '..\0', 3 bytes Second +3 and /4*4: four word alignment
|
staticprotected |
Size of struct dirent excluding d_name. That is, the size of d_ino, d_off, d_reclen and d_type. Notice that there are 4 bytes of padding between d_ino and d_off as d_off is a 64 bit number. Should be 19.