Skip to content

Commit

Permalink
blk_io: Make blk_trim/blk_sync optional
Browse files Browse the repository at this point in the history
- Not all block devices might wish to implement these, so report the feature as unsupported
  • Loading branch information
LekKit authored Dec 16, 2023
1 parent 35b1f31 commit 16e4574
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/blk_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ static inline uint64_t blk_tell(blkdev_t* dev)

static inline bool blk_trim(blkdev_t* dev, uint64_t offset, uint64_t count)
{
if (!dev) return false;
if (!dev || !dev->type->trim) return false;
uint64_t real_pos = (offset == RVFILE_CURPOS) ? dev->pos : offset;
if (real_pos + count > dev->size) return false;
return dev->type->trim(dev->data, real_pos, count);
}

static inline bool blk_sync(blkdev_t* dev)
{
if (!dev) return false;
if (!dev || !dev->type->sync) return false;
return dev->type->sync(dev->data);
}

Expand Down

0 comments on commit 16e4574

Please sign in to comment.