Commit bcb4fdef authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

sdb-lib: adding file erase function

parent 3aebf265
......@@ -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 (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;
}
......@@ -70,6 +70,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