ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Воскресенье
19 мая
61283 Топик полностью
КонстантинТ (23.06.2006 13:30, просмотров: 1) ответил Сергей Борщ на 2 КонстантинТ вопросик по leanfs
Мне прищлось ее глубоко переработать Перед вызовом mount надо вызвать функцию int fs_init_device(struct Dev *dev,struct Volume **new_v) Инициализируется новое устройство и получаете указатель на новый раздел Volume. Затем работаем только с разделами. int fs_mount(struct Volume *v) Все манипуляции с открытием и закрытием файлов, mount форматирование делается только через указатель раздела. Для примера - декларация всех функций библиотеки. int fs_init_device(struct Dev *dev,struct Volume **new_v); int fs_mount(struct Volume *v); int fs_umount(struct Volume *v); int fs_make(struct Volume *v, uint32_t sectors, uint32_t log_bytes_per_sector, uint32_t log_sectors_per_cluster, const char *label); #define BYTES_512_PER_SECTOR 9 #define BYTES_1024_PER_SECTOR 10 #define BYTES_2048_PER_SECTOR 11 #define BYTES_4096_PER_SECTOR 12 #define BYTES_1024_PER_CLUSTER 1 #define BYTES_2048_PER_CLUSTER 2 #define BYTES_4096_PER_CLUSTER 3 #define BYTES_8192_PER_CLUSTER 4 int fs_open(struct Volume *v,struct File **file,const char *filename, int flag, mode_t mode); int fs_close(struct File *file); int fs_delete (struct Volume *v ,const char *filename,int flag); ssize_t fs_read (struct File *f, void *buffer, size_t size); ssize_t fs_write(struct File *f, const void *buffer, size_t size); off_t fs_lseek(struct File *f, off_t offset, int whence); int fs_ftruncate(struct File *f, off_t length); off_t fs_length(struct File *f); /* This callback function allows to store data "readdir" in any structure */ /* format, letting the caller chose the preferred "struct dirent" format. */ /* An idea borrowed from the Linux kernel. */ typedef int (*readdir_callback_t)(void *dirent, const char *d_name, int d_namlen, off_t f_pos, ino_t d_fileno, unsigned d_type); /* This functions does the actual work for readdir. * It reads the first non-deleted directory entry in the directory "dir", * using "de" as directory entry buffer. "de" must be big enough to store * a 256-byte name. A null terminator is appended to the name. */ int fs_readdir(struct File *dir, void *dirent, readdir_callback_t cb); /* The buffer pointed by 'de' must be big enough to store a 256-byte name */ int fs_find (struct File *dir, const char *name, struct DirEntry *de); /* Creates a new hard link to the file "pf", named "name", in the parent * directory "dir". On success, returns 0, and the parent shall update * the link counter of the file. On failure, returns a negative error. */ int fs_link (struct File *old_file, struct File *new_dir, const char *new_name); int fs_unlink (struct File *parent, const char *name); Собирал модифицировал и тестировал его под CW1.5 Если хотите поучавствовать и развивать этот очень интересный и нужный проект (файловая система у меня работает в нескольких проектах) - в личку в мыло. Есть написанные драйвера под IDE, SD карты, память AT45.