diff options
author | Mikulas Patocka <mikulas@twibright.com> | 2015-06-28 15:16:57 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-09 22:35:30 +0200 |
commit | a27b5b97d6fe91f55058ad8ac28a8768700201ab (patch) | |
tree | 84272380472c484455a662d17b0b544421a26fe2 /fs/hpfs/super.c | |
parent | ioctl_compat: handle FITRIM (diff) | |
download | linux-a27b5b97d6fe91f55058ad8ac28a8768700201ab.tar.xz linux-a27b5b97d6fe91f55058ad8ac28a8768700201ab.zip |
hpfs: add fstrim support
This patch adds support for fstrim to the HPFS filesystem.
Signed-off-by: Mikulas Patocka <mikulas@twibright.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/hpfs/super.c')
-rw-r--r-- | fs/hpfs/super.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 7cd00d3a7c9b..037e3e597ff4 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c @@ -196,6 +196,33 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf) return 0; } + +long hpfs_ioctl(struct file *file, unsigned cmd, unsigned long arg) +{ + switch (cmd) { + case FITRIM: { + struct fstrim_range range; + secno n_trimmed; + int r; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (copy_from_user(&range, (struct fstrim_range __user *)arg, sizeof(range))) + return -EFAULT; + r = hpfs_trim_fs(file_inode(file)->i_sb, range.start >> 9, (range.start + range.len) >> 9, (range.minlen + 511) >> 9, &n_trimmed); + if (r) + return r; + range.len = (u64)n_trimmed << 9; + if (copy_to_user((struct fstrim_range __user *)arg, &range, sizeof(range))) + return -EFAULT; + return 0; + } + default: { + return -ENOIOCTLCMD; + } + } +} + + static struct kmem_cache * hpfs_inode_cachep; static struct inode *hpfs_alloc_inode(struct super_block *sb) |