diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 934d1dd8599158e8b2364aad35151e0ce447b2cb..123299ee511b06d54f894a254e736589d30f1c80 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -165,11 +165,11 @@ int dfs_romfs_stat(struct dfs_filesystem* fs, const char *path, struct stat *st) if (dirent == RT_NULL) return -DFS_STATUS_ENOENT; st->st_dev = 0; - st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH | - DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH; + st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH | + DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH; if (dirent->type == ROMFS_DIRENT_DIR) - { + { st->st_mode &= ~DFS_S_IFREG; st->st_mode |= DFS_S_IFDIR | DFS_S_IXUSR | DFS_S_IXGRP | DFS_S_IXOTH; } @@ -202,7 +202,7 @@ int dfs_romfs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t cou for (index = 0; index < count && file->pos < file->size; index ++) { d = dirp + index; - + sub_dirent = &dirent[file->pos]; name = sub_dirent->name; @@ -212,7 +212,7 @@ int dfs_romfs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t cou else d->d_type = DFS_DT_REG; - d->d_namlen = rt_strlen(name); + d->d_namlen = rt_strlen(name); d->d_reclen = (rt_uint16_t)sizeof(struct dirent); rt_strncpy(d->d_name, name, rt_strlen(name) + 1); diff --git a/components/dfs/filesystems/romfs/mkromfs.py b/components/dfs/filesystems/romfs/mkromfs.py index ebda107b763731a59fe1e8cec4487b7ba33f27d3..e0ed938dc16fd5fb659a2c6092afe5896fd6ad07 100644 --- a/components/dfs/filesystems/romfs/mkromfs.py +++ b/components/dfs/filesystems/romfs/mkromfs.py @@ -85,7 +85,7 @@ def mkromfs_dir(dirname, is_root = False): if not os.path.isfile(fullpath): l = os.listdir(fullpath) if len(l): - mkromfs_output(('\t{ROMFS_DIRENT_DIR, "%s", %s, sizeof(%s)/sizeof(%s[0])},\n' % (fn, item_name, item_name, item_name))) + mkromfs_output(('\t{ROMFS_DIRENT_DIR, "%s", (rt_uint8_t*) %s, sizeof(%s)/sizeof(%s[0])},\n' % (fn, item_name, item_name, item_name))) else: mkromfs_output(('\t{ROMFS_DIRENT_DIR, "%s", RT_NULL, 0},\n' % fn)) @@ -122,4 +122,4 @@ if __name__ == "__main__": mkromfs_output("#include \n\n") mkromfs_dir(basename, is_root = True) - mkromfs_output("const struct romfs_dirent romfs_root = {ROMFS_DIRENT_DIR, \"/\", _root_dirent, sizeof(_root_dirent)/sizeof(_root_dirent[0])};\n\n") + mkromfs_output("const struct romfs_dirent romfs_root = {ROMFS_DIRENT_DIR, \"/\", (rt_uint8_t*) _root_dirent, sizeof(_root_dirent)/sizeof(_root_dirent[0])};\n\n")