Skip to content

Commit ac3f6cc

Browse files
committed
[FIX][fal]补充缺失的入参,适配DFSv2框架
1 parent c39e92f commit ac3f6cc

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

components/fal/src/fal_rtt.c

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -434,43 +434,55 @@ static int char_dev_fopen(struct dfs_file *fd)
434434

435435
return RT_EOK;
436436
}
437-
438-
static int char_dev_fread(struct dfs_file *fd, void *buf, rt_size_t count)
437+
#ifdef RT_USING_DFS_V2
438+
static ssize_t char_dev_fread(struct dfs_file *fd, const void *buf, size_t count, off_t *pos)
439+
#else
440+
static ssize_t char_dev_fread(struct dfs_file *fd, void *buf, size_t count)
441+
#endif
439442
{
440-
int ret = 0;
443+
ssize_t ret = 0;
441444
struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
445+
#ifndef RT_USING_DFS_V2
446+
off_t *pos = &(fd->pos);
447+
#endif
442448

443449
RT_ASSERT(part != RT_NULL);
444450

445-
if (DFS_FILE_POS(fd) + count > part->fal_part->len)
446-
count = part->fal_part->len - DFS_FILE_POS(fd);
451+
if (*pos + count > part->fal_part->len)
452+
count = part->fal_part->len - *pos;
447453

448-
ret = fal_partition_read(part->fal_part, DFS_FILE_POS(fd), buf, count);
454+
ret = fal_partition_read(part->fal_part, *pos, buf, count);
449455

450-
if (ret != (int)(count))
456+
if (ret != (ssize_t)(count))
451457
return 0;
452458

453-
DFS_FILE_POS(fd) += ret;
459+
*pos += ret;
454460

455461
return ret;
456462
}
457-
458-
static int char_dev_fwrite(struct dfs_file *fd, const void *buf, rt_size_t count)
463+
#ifdef RT_USING_DFS_V2
464+
static ssize_t char_dev_fwrite(struct dfs_file *fd, const void *buf, size_t count, off_t *pos)
465+
#else
466+
static ssize_t char_dev_fwrite(struct dfs_file *fd, const void *buf, size_t count)
467+
#endif
459468
{
460-
int ret = 0;
469+
ssize_t ret = 0;
461470
struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
471+
#ifndef RT_USING_DFS_V2
472+
off_t *pos = &(fd->pos);
473+
#endif
462474

463475
RT_ASSERT(part != RT_NULL);
464476

465-
if (DFS_FILE_POS(fd) + count > part->fal_part->len)
466-
count = part->fal_part->len - DFS_FILE_POS(fd);
477+
if (*pos + count > part->fal_part->len)
478+
count = part->fal_part->len - *pos;
467479

468-
ret = fal_partition_write(part->fal_part, DFS_FILE_POS(fd), buf, count);
480+
ret = fal_partition_write(part->fal_part, *pos, buf, count);
469481

470-
if (ret != (int) count)
482+
if (ret != (ssize_t) count)
471483
return 0;
472484

473-
DFS_FILE_POS(fd) += ret;
485+
*pos += ret;
474486

475487
return ret;
476488
}

0 commit comments

Comments
 (0)