Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions components/drivers/block/blk_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <dfs_fs.h>
#endif

#ifdef RT_USING_LWP
#include <lwp_user_mm.h>
#endif

static rt_err_t blk_dev_open(rt_device_t dev, rt_uint16_t oflag)
{
struct rt_blk_device *blk = to_blk(dev);
Expand Down Expand Up @@ -106,15 +110,25 @@ static rt_err_t blk_dev_control(rt_device_t dev, int cmd, void *args)
break;

case RT_DEVICE_CTRL_BLK_PARTITION:
if (args)
if (!args)
{
rt_memcpy(args, &blk->partition, sizeof(blk->partition));
err = -RT_EINVAL;
break;
}
else
#ifdef RT_USING_LWP
if (lwp_self() != RT_NULL)
{
err = -RT_EINVAL;
struct dfs_partition kpart;
rt_memcpy(&kpart, &blk->partition, sizeof(kpart));
if (lwp_put_to_user(args, &kpart, sizeof(kpart)) != sizeof(kpart))
err = -RT_EFAULT;
else
err = RT_EOK;
break;
}

#endif
rt_memcpy(args, &blk->partition, sizeof(blk->partition));
err = RT_EOK;
break;

case RT_DEVICE_CTRL_BLK_SSIZEGET:
Expand Down
Loading