aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/file.c
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2012-06-02 13:09:29 +0200
committercodeworkx <daniel.hillenbrand@codeworkx.de>2012-06-02 13:09:29 +0200
commitc6da2cfeb05178a11c6d062a06f8078150ee492f (patch)
treef3b4021d252c52d6463a9b3c1bb7245e399b009c /fs/fat/file.c
parentc6d7c4dbff353eac7919342ae6b3299a378160a6 (diff)
downloadkernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.zip
kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.gz
kernel_samsung_smdk4412-c6da2cfeb05178a11c6d062a06f8078150ee492f.tar.bz2
samsung update 1
Diffstat (limited to 'fs/fat/file.c')
-rw-r--r--fs/fat/file.c59
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 */
}