diff --git a/fs/hmdfs/file_merge.c b/fs/hmdfs/file_merge.c index 8048a203a8e67f17401959aca54182a359f6c70a..ed805645f5741a37ebd6e9a7058695ff29371f3c 100644 --- a/fs/hmdfs/file_merge.c +++ b/fs/hmdfs/file_merge.c @@ -8,6 +8,7 @@ #include "hmdfs_merge_view.h" #include +#include #include "hmdfs.h" #include "hmdfs_trace.h" @@ -582,12 +583,74 @@ static long hmdfs_ioc_get_writeopen_cnt(struct file *filp, unsigned long arg) return put_user(wo_cnt, (int __user *)arg); } +static long hmdfs_ioc_get_drag_path(struct file *filp, unsigned long arg) +{ + int error = 0; + char localPath[NAME_MAX]; + char cloudPath[NAME_MAX]; + struct dentry *dentry; + struct path path; + struct hmdfs_drag_info hdi; + + if (!access_ok((struct hmdfs_drag_info __user *)arg, + sizeof(struct hmdfs_drag_info))) { + hmdfs_info("hmdfs_ioc_get_drag_path: struct is not OK, error: -EFAULT"); + return -EFAULT; + } + + if (copy_from_user(&hdi, (struct hmdfs_drag_info __user *)arg, + sizeof(hdi))) { + hmdfs_info("hmdfs_ioc_get_drag_path: copy_from_user failed, error: -EFAULT"); + return -EFAULT; + } + + hmdfs_info("localLen: %llu", hdi.localLen); + hmdfs_info("localLen: %llx", hdi.localPath); + hmdfs_info("localLen: %llu", hdi.cloudLen); + hmdfs_info("localLen: %llx", hdi.cloudPath); + + if (!access_ok((char *)hdi.localPath, hdi.localLen)) { + hmdfs_info("hmdfs_ioc_get_drag_path: localPath is not OK, error: -EFAULT"); + return -EFAULT; + } + if (!access_ok((char *)hdi.cloudPath, hdi.cloudLen)) { + hmdfs_info("hmdfs_ioc_get_drag_path: cloudPath is not OK, error: -EFAULT"); + return -EFAULT; + } + if (copy_from_user(localPath, (char __user *)hdi.localPath, + hdi.localLen)) { + hmdfs_info("hmdfs_ioc_get_drag_path: localPath failed, error: -EFAULT"); + return -EFAULT; + } + if (copy_from_user(cloudPath, (char __user *)hdi.cloudPath, + hdi.cloudLen)) { + hmdfs_info("hmdfs_ioc_get_drag_path: cloudPath failed, error: -EFAULT"); + return -EFAULT; + } + hmdfs_info("localPath: %s", localPath); + hmdfs_info("localPath: %s", cloudPath); + + dentry = kern_path_create(AT_FDCWD, cloudPath, &path, 0); + if (IS_ERR(dentry)) + return PTR_ERR(dentry); + hmdfs_info("dentry finish"); + error = vfs_symlink(path.dentry->d_inode, dentry, localPath); + done_path_create(&path, dentry); + hmdfs_info("error: %d", error); + return error; +} + static long hmdfs_file_ioctl_merge(struct file *filp, unsigned int cmd, unsigned long arg) { + hmdfs_info("hmdfs_file_ioctl_merge"); switch (cmd) { case HMDFS_IOC_GET_WRITEOPEN_CNT: return hmdfs_ioc_get_writeopen_cnt(filp, arg); + case HMDFS_IOC_GET_DRAG_PATH: + hmdfs_info("HMDFS_IOC_GET_WRITEOPEN_CNT"); + return hmdfs_ioc_get_drag_path(filp, arg); default: + hmdfs_info("Case does not hit! error:-%d", ENOTTY); return -ENOTTY; } } @@ -606,6 +669,7 @@ const struct file_operations hmdfs_file_fops_merge = { .release = hmdfs_file_release_local, .fsync = hmdfs_fsync_local, .unlocked_ioctl = hmdfs_file_ioctl_merge, + .compat_ioctl = hmdfs_file_ioctl_merge, .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, }; diff --git a/fs/hmdfs/hmdfs.h b/fs/hmdfs/hmdfs.h index 14adb4fac1b715c7a76d479dfb74285ca4e2af90..181ba0a39ab2258bcab7721a04a8cb9815465da7 100644 --- a/fs/hmdfs/hmdfs.h +++ b/fs/hmdfs/hmdfs.h @@ -30,6 +30,7 @@ #define HMDFS_IOC 0xf2 #define HMDFS_IOC_SET_SHARE_PATH _IOW(HMDFS_IOC, 1, struct hmdfs_share_control) #define HMDFS_IOC_GET_WRITEOPEN_CNT _IOR(HMDFS_IOC, 2, __u32) +#define HMDFS_IOC_GET_DRAG_PATH _IOR(HMDFS_IOC, 3, __u32) #define HMDFS_PAGE_SIZE 4096 #define HMDFS_PAGE_OFFSET 12 @@ -222,6 +223,13 @@ static inline bool hmdfs_is_stash_enabled(const struct hmdfs_sb_info *sbi) return sbi->s_offline_stash; } +struct hmdfs_drag_info{ + uint64_t localLen; + uint64_t localPath; + uint64_t cloudLen; + uint64_t cloudPath; +}; + struct setattr_info { loff_t size; unsigned int valid; diff --git a/fs/hmdfs/inode_local.c b/fs/hmdfs/inode_local.c index 5d26f6dbbd02076af13627662f01d5d73d17eabc..76f7a4bfe83392b45aa66c2d5f49ec2da842a98b 100644 --- a/fs/hmdfs/inode_local.c +++ b/fs/hmdfs/inode_local.c @@ -779,6 +779,7 @@ static int hmdfs_getattr_local(const struct path *path, struct kstat *stat, stat->gid = d_inode(path->dentry)->i_gid; hmdfs_put_lower_path(&lower_path); + hmdfs_info("hmdfs_getattr_local, ret: %d", ret); return ret; }