ubi: Add truncate callback
The size of static ubi volumes changes depending on the content. Add truncate callback to handle resizes. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
a6785bae3b
commit
55513dcec5
|
@ -162,6 +162,21 @@ static loff_t ubi_volume_cdev_lseek(struct cdev *cdev, loff_t ofs)
|
||||||
return ofs;
|
return ofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ubi_volume_cdev_truncate(struct cdev *cdev, size_t size)
|
||||||
|
{
|
||||||
|
struct ubi_volume_cdev_priv *priv = cdev->priv;
|
||||||
|
struct ubi_device *ubi = priv->ubi;
|
||||||
|
struct ubi_volume *vol = priv->vol;
|
||||||
|
uint64_t rsvd_bytes;
|
||||||
|
|
||||||
|
rsvd_bytes = (long long)vol->reserved_pebs *
|
||||||
|
ubi->leb_size - vol->data_pad;
|
||||||
|
if (size > rsvd_bytes)
|
||||||
|
return -ENOSPC;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int ubi_volume_cdev_ioctl(struct cdev *cdev, int cmd, void *buf)
|
static int ubi_volume_cdev_ioctl(struct cdev *cdev, int cmd, void *buf)
|
||||||
{
|
{
|
||||||
struct ubi_volume_cdev_priv *priv = cdev->priv;
|
struct ubi_volume_cdev_priv *priv = cdev->priv;
|
||||||
|
@ -210,6 +225,7 @@ static struct file_operations ubi_volume_fops = {
|
||||||
.write = ubi_volume_cdev_write,
|
.write = ubi_volume_cdev_write,
|
||||||
.lseek = ubi_volume_cdev_lseek,
|
.lseek = ubi_volume_cdev_lseek,
|
||||||
.ioctl = ubi_volume_cdev_ioctl,
|
.ioctl = ubi_volume_cdev_ioctl,
|
||||||
|
.truncate = ubi_volume_cdev_truncate,
|
||||||
};
|
};
|
||||||
|
|
||||||
int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
|
int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
|
||||||
|
|
Loading…
Reference in New Issue