提交 1884fa05 编写于 作者: M mucor

fix readdir, rename

Change-Id: Ic443742e125915f0e5332a338dedea5c40348928
上级 a50adf04
......@@ -1368,7 +1368,7 @@ int fatfs_readdir(struct Vnode *vp, struct fs_dirent_s *idir)
}
DEF_NAMBUF;
INIT_NAMBUF(fs);
for (i = 0; i < DIR_READ_COUNT && i < idir->read_cnt; i++) {
for (i = 0; i < idir->read_cnt; i++) {
result = dir_read(dp, 0);
if (result == FR_NO_FILE) {
break;
......
......@@ -113,7 +113,7 @@ extern void dec_mapping_nolock(struct page_mapping *mapping);
*
****************************************************************************/
extern int update_file_path(char *old_path, char *new_path);
extern int update_file_path(const char *old_path, const char *new_path);
/**
* @ingroup fs
......
......@@ -474,7 +474,7 @@ int VfsJffs2Readdir(struct Vnode *pVnode, struct fs_dirent_s *dir)
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
/* set jffs2_d */
while (i < MAX_DIRENT_NUM && i < dir->read_cnt) {
while (i < dir->read_cnt) {
ret = jffs2_readdir((struct jffs2_inode *)pVnode->data, &dir->fd_position,
&dir->fd_int_offset, &dir->fd_dir[i]);
if (ret) {
......
......@@ -182,7 +182,7 @@ int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
}
pde = VnodeToEntry(node);
while ((i < MAX_DIRENT_NUM) || (i < dir->read_cnt)) {
while (i < dir->read_cnt) {
buffer = (char *)zalloc(sizeof(char) * NAME_MAX);
if (buffer == NULL) {
PRINT_ERR("malloc failed\n");
......
......@@ -696,9 +696,13 @@ static INT32 DiskPartitionRecognition(struct Vnode *blkDrv, struct disk_divide_i
CHAR *mbrBuf = NULL;
CHAR *ebrBuf = NULL;
if (blkDrv == NULL) {
return -EINVAL;
}
struct block_operations *bops = (struct block_operations *)((struct drv_data *)blkDrv->data)->ops;
if ((blkDrv == NULL) || (bops == NULL) || (bops->read == NULL)) {
if ((bops == NULL) || (bops->read == NULL)) {
return -EINVAL;
}
......@@ -832,8 +836,11 @@ INT32 los_disk_read(INT32 drvID, VOID *buf, UINT64 sector, UINT32 count)
}
} else {
#endif
if (disk->dev == NULL) {
goto ERROR_HANDLE;
}
struct block_operations *bops = (struct block_operations *)((struct drv_data *)disk->dev->data)->ops;
if ((disk->dev != NULL) && (bops != NULL) && (bops->read != NULL)) {
if ((bops != NULL) && (bops->read != NULL)) {
result = bops->read(disk->dev, (UINT8 *)buf, sector, count);
if (result == (INT32)count) {
result = ENOERR;
......
......@@ -245,7 +245,7 @@ out:
(VOID)LOS_MuxUnlock(&g_file_mapping.lock);
}
int update_file_path(char *old_path, char *new_path)
int update_file_path(const char *old_path, const char *new_path)
{
unsigned int i = 3;
struct filelist *f_list = NULL;
......@@ -262,10 +262,10 @@ int update_file_path(char *old_path, char *new_path)
(VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER);
while (i < CONFIG_NFILE_DESCRIPTORS) {
i++;
if (!get_bit(i)) {
if (!get_bit(i - 1)) {
continue;
}
filp = &tg_filelist.fl_files[i];
filp = &tg_filelist.fl_files[i - 1];
if (filp->f_path == NULL || strcmp(filp->f_path, old_path)) {
continue;
}
......
......@@ -93,6 +93,7 @@ struct PathCache *PathCacheAlloc(struct Vnode *parent, struct Vnode *vnode, cons
{
struct PathCache *nc = NULL;
size_t pathCacheSize;
int ret;
if (name == NULL || len > NAME_MAX || parent == NULL || vnode == NULL) {
return NULL;
......@@ -105,7 +106,10 @@ struct PathCache *PathCacheAlloc(struct Vnode *parent, struct Vnode *vnode, cons
return NULL;
}
(void)strncpy_s(nc->name, pathCacheSize, name, len);
ret = strncpy_s(nc->name, pathCacheSize, name, len);
if (ret != LOS_OK) {
return NULL;
}
nc->parentVnode = parent;
nc->nameLen = len;
......
......@@ -573,6 +573,10 @@ int VnodeDevInit()
devNode->type = VNODE_TYPE_DIR;
devMount = MountAlloc(devNode, NULL);
if (devMount == NULL) {
PRINT_ERR("VnodeDevInit failed mount point alloc failed.\n");
return -ENOMEM;
}
devMount->vnodeCovered = devNode;
devMount->vnodeBeCovered->flag |= VNODE_FLAG_MOUNT_NEW;
return LOS_OK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册