Skip to content

Commit aab8848

Browse files
author
Miklos Szeredi
committed
ovl: add ovl_fallocate()
Implement stacked fallocate. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 2f50283 commit aab8848

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎fs/overlayfs/file.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,29 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma)
286286
return ret;
287287
}
288288

289+
static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
290+
{
291+
struct inode *inode = file_inode(file);
292+
struct fd real;
293+
const struct cred *old_cred;
294+
int ret;
295+
296+
ret = ovl_real_fdget(file, &real);
297+
if (ret)
298+
return ret;
299+
300+
old_cred = ovl_override_creds(file_inode(file)->i_sb);
301+
ret = vfs_fallocate(real.file, mode, offset, len);
302+
revert_creds(old_cred);
303+
304+
/* Update size */
305+
ovl_copyattr(ovl_inode_real(inode), inode);
306+
307+
fdput(real);
308+
309+
return ret;
310+
}
311+
289312
const struct file_operations ovl_file_operations = {
290313
.open = ovl_open,
291314
.release = ovl_release,
@@ -294,4 +317,5 @@ const struct file_operations ovl_file_operations = {
294317
.write_iter = ovl_write_iter,
295318
.fsync = ovl_fsync,
296319
.mmap = ovl_mmap,
320+
.fallocate = ovl_fallocate,
297321
};

0 commit comments

Comments
 (0)