diff --git a/fs/devfs.c b/fs/devfs.c index 6fabcf8ff..2a7b1b346 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -168,6 +168,11 @@ static int devfs_ioctl(struct device_d *_dev, FILE *f, int request, void *buf) static int devfs_truncate(struct device_d *dev, FILE *f, ulong size) { + struct cdev *cdev = f->priv; + + if (cdev->ops->truncate) + return cdev->ops->truncate(cdev, size); + if (f->fsdev->dev.num_resources < 1) return -ENOSPC; if (size > resource_size(&f->fsdev->dev.resource[0])) diff --git a/include/driver.h b/include/driver.h index 80aa8d821..6abaaad8b 100644 --- a/include/driver.h +++ b/include/driver.h @@ -434,6 +434,7 @@ struct file_operations { int (*erase)(struct cdev*, loff_t count, loff_t offset); int (*protect)(struct cdev*, size_t count, loff_t offset, int prot); int (*memmap)(struct cdev*, void **map, int flags); + int (*truncate)(struct cdev*, size_t size); }; #define MAX_PARTUUID_STR sizeof("00112233-4455-6677-8899-AABBCCDDEEFF")