Commit 8b69a115 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk Committed by Érico Nogueira Rolim

sdbfs: adding file erase function.

Commit taken from [1].

[1] wrpc-sw@bcb4fdef
parent 3d3fd837
......@@ -58,3 +58,23 @@ int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count)
fs->read_offset = offset + ret;
return ret;
}
int sdbfs_ferase(struct sdbfs *fs, int offset, int count)
{
int ret;
if (!fs->currentp)
return -ENOENT;
if (offset < 0)
offset = fs->read_offset;
if ((unsigned int)(offset + count) > fs->f_len)
count = fs->f_len - offset;
ret = count;
if (fs->data)
memset(fs->data + fs->f_offset + offset, 0xFF, count);
else
ret = fs->erase(fs, fs->f_offset + offset, count);
if (ret > 0)
fs->read_offset = offset + ret;
return ret;
}
......@@ -79,6 +79,7 @@ struct sdb_device *sdbfs_scan(struct sdbfs *fs, int newscan);
int sdbfs_fstat(struct sdbfs *fs, struct sdb_device *record_return);
int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count);
int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count);
int sdbfs_ferase(struct sdbfs *fs, int offset, int count);
/* This is needed to convert endianness. Hoping it is not defined elsewhere */
static inline uint64_t htonll(uint64_t ll)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment