00001 /* 00002 ** dir.h for lseos in lseos-lib/libc/posix 00003 ** 00004 ** Copyright (c)2004 Vianney Rancurel 00005 ** Login <vianney@epita.fr> 00006 ** 00007 ** Started on Fri May 14 16:57:56 2004 Vianney Rancurel 00008 ** Last update Tue Nov 30 11:14:39 2004 Vianney Rancurel 00009 */ 00010 #ifndef __POSIX_DIR_H__ 00011 #define __POSIX_DIR_H__ 1 00012 #include <libc.h> 00013 00014 struct dirent 00015 { 00016 u_int32_t d_fileno; 00017 u_int16_t d_reclen; 00018 u_int8_t d_type; 00019 u_int8_t d_namlen; 00020 #define MAXNAMLEN 255 00021 char d_name[MAXNAMLEN + 1]; 00022 }; 00023 00024 typedef struct _DIR 00025 { 00026 u_int32_t magic; 00027 #define DIR_MAGIC 0xfafafafa 00028 int fd; 00029 int nbytes; 00030 int pos; 00031 #define NGETDENTBYTES 1024 00032 char bytes[NGETDENTBYTES]; 00033 } DIR; 00034 00035 /* 00036 * File types 00037 */ 00038 #define DT_UNKNOWN 0 00039 #define DT_FIFO 1 00040 #define DT_CHR 2 00041 #define DT_DIR 4 00042 #define DT_BLK 6 00043 #define DT_REG 8 00044 #define DT_LNK 10 00045 #define DT_SOCK 12 00046 #define DT_WHT 14 00047 00048 extern char *wd; 00049 extern int wd_static; 00050 00051 /* PROTO dir.c */ 00052 /* dir.c */ 00053 int getdents(int d, char *buf, size_t nbytes); 00054 DIR *opendir(const char *filename); 00055 struct dirent *readdir(DIR *dirp); 00056 long telldir(const DIR *dirp); 00057 void seekdir(DIR *dirp, long loc); 00058 void rewinddir(DIR *dirp); 00059 int closedir(DIR *dirp); 00060 int dirfd(DIR *dirp); 00061 int chdir(const char *path); 00062 int fchdir(int fd); 00063 int mkdir(const char *path, mode_t mode); 00064 int rmdir(const char *path); 00065 #endif