diff options
Diffstat (limited to 'fs/fat/file.c')
-rw-r--r-- | fs/fat/file.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/fs/fat/file.c b/fs/fat/file.c index 7018e1d..7279b96 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -17,6 +17,7 @@ #include <linux/blkdev.h> #include <linux/fsnotify.h> #include <linux/security.h> +#include <linux/namei.h> #include "fat.h" static int fat_ioctl_get_attributes(struct inode *inode, u32 __user *user_attr) @@ -115,6 +116,62 @@ out: return err; } +extern int _fat_fallocate(struct inode *inode, loff_t len); + +static long fat_vmw_extend(struct file *filp, unsigned long len) +{ + struct inode *inode = filp->f_path.dentry->d_inode; + loff_t off = len; + const char mvpEnabledPath[] = "/data/data/com.vmware.mvp.enabled"; + struct path path; + struct kstat stat; + int err; + + /* + * Perform some sanity checks (from do_fallocate) + */ + + if (len <= 0) { + return -EINVAL; + } + + if (!(filp->f_mode & FMODE_WRITE)) { + return -EBADF; + } + + /* + * Revalidate the write permissions, in case security policy has + * changed since the files were opened. + */ + err = security_file_permission(filp, MAY_WRITE); + if (err) { + return err; + } + + /* + * Verify caller process belongs to mvp. + */ + + err = kern_path(mvpEnabledPath, 0, &path); + if (err) { + return err; + } + + err = vfs_getattr(path.mnt, path.dentry, &stat); + if (err) { + return err; + } + + if (current_euid() != stat.uid && current_euid() != 0) { + return -EPERM; + } + + /* + * Every thing is clear, let's allocate space. + */ + return _fat_fallocate(inode, off); +} + long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct inode *inode = filp->f_path.dentry->d_inode; @@ -125,6 +182,8 @@ long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) return fat_ioctl_get_attributes(inode, user_attr); case FAT_IOCTL_SET_ATTRIBUTES: return fat_ioctl_set_attributes(filp, user_attr); + case FAT_IOCTL_VMW_EXTEND: + return fat_vmw_extend(filp, arg); default: return -ENOTTY; /* Inappropriate ioctl for device */ } |