Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
dirent.h
Go to the documentation of this file.
1 
4 #ifndef __DIRENT_H__
5 #define __DIRENT_H__
6 
7 #include <stdint.h>
8 #include <sys/limits.h>
9 #include <sys/stat.h>
10 
11 #include "kconfig.h"
12 
13 /* File types of d_type, which is the file type of the mode shifted down by
14  * twelve bits
15  */
16 #define DT_UNKNOWN 0
17 #define DT_FIFO 1
18 #define DT_CHR 2
19 #define DT_DIR 4
20 #define DT_BLK 6
21 #define DT_REG 8
22 #define DT_LNK 10
23 #define DT_SOCK 12
24 
25 #define IFTODT(mode) (((mode) &S_IFMT) >> 12)
26 #define DTTOIF(dirtype) ((dirtype) << 12)
27 
28 /* Return type of the readdir() */
29 struct dirent {
30  char d_name[NAME_MAX]; /* File name */
31  uint32_t d_ino; /* The inode of the file */
32  uint8_t d_type; /* File type, one of the DT_ values above */
33 };
34 
35 /* Return type of the opendir(). The entry readdir() answers with lives here */
36 typedef struct dirstream {
37  struct inode *inode_dir; /* Directory inode */
38  struct list_head *dentry_list; /* List pointer of the dentry to return */
39  struct dirent entry; /* Storage of the entry readdir() returns */
40 } DIR;
41 
49 DIR *opendir(const char *name);
50 
58 struct dirent *readdir(DIR *dirp);
59 
65 int closedir(DIR *dirp);
66 
67 #endif
DIR * opendir(const char *name)
Open a directory stream corresponding to the directory name, and return a pointer to the directory st...
Definition: file.c:194
struct dirent * readdir(DIR *dirp)
Return the next entry of the directory stream. The entry belongs to the stream and is overwritten by ...
Definition: file.c:217
int closedir(DIR *dirp)
Close a directory stream and release what it holds.
Definition: file.c:225
Definition: dirent.h:29
Definition: dirent.h:36
Definition: fs.h:97
Definition: list.h:111