#include <stddef.h>
#include <sys/types.h>
-#ifndef NAME_MAX
-#define NAME_MAX 255
-#endif
-
-struct dirent {
- uint32_t d_ino;
- uint32_t d_off;
- uint16_t d_reclen;
- uint16_t d_type;
- char d_name[NAME_MAX + 1];
-};
-
-struct file;
-
-typedef struct {
- struct file *dd_dir;
-} DIR;
+#include <sys/dirent.h>
__extern DIR *opendir(const char *);
__extern struct dirent *readdir(DIR *);
--- /dev/null
+/*
+ * sys/dirent.h
+ */
+
+#ifndef DIRENT_H
+#define DIRENT_H
+
+#include <stdint.h>
+
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
+
+struct dirent {
+ uint32_t d_ino;
+ uint32_t d_off;
+ uint16_t d_reclen;
+ uint16_t d_type;
+ char d_name[NAME_MAX + 1];
+};
+
+struct file;
+
+typedef struct {
+ struct file *dd_dir;
+} DIR;
+
+#define DIR_REC_LEN(name) (12 + strlen(name) + 1 + 3) & ~3
+
+#endif /* sys/dirent.h */
/* Actual file structures (we don't have malloc yet...) */
struct file files[MAX_OPEN];
-/*
- * Convert between a 16-bit file handle and a file structure
- */
-inline uint16_t file_to_handle(struct file *file)
-{
- return file ? (file - files)+1 : 0;
-}
-inline struct file *handle_to_file(uint16_t handle)
-{
- return handle ? &files[handle-1] : NULL;
-}
/*
* Get an empty file structure
free_file(file);
}
+/*
+ * Convert between a 16-bit file handle and a file structure
+ */
+inline uint16_t file_to_handle(struct file *file)
+{
+ return file ? (file - files)+1 : 0;
+}
+inline struct file *handle_to_file(uint16_t handle)
+{
+ return handle ? &files[handle-1] : NULL;
+}
+
void load_config(com32sys_t *regs)
{
this_fs->fs_ops->load_config(regs);
#include <com32.h>
#include "core.h"
#include "disk.h"
-#include "dir.h"
/*
* Maximum number of open files. This is *currently* constrained by the
};
struct open_file_t; /* Filesystem private structure */
+struct dirent; /* Directory entry structure */
struct file {
struct open_file_t *open_file; /* Filesystem private data */