aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-04-06 22:01:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:31:18 -0400
commit8082d36aed26c4fb6ed43e4008303682eabf839e (patch)
treed51eff46a3ebe29e0a445597570599b5b7c4a037 /fs
parentdc498d09be28172846cacded35ca2378222a8c7b (diff)
nilfs2: remove compat ioctl code
This removes compat code from the nilfs ioctls and applies the same function for both .ioctl and .compat_ioctl file operations. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nilfs2/dir.c2
-rw-r--r--fs/nilfs2/file.c2
-rw-r--r--fs/nilfs2/ioctl.c228
-rw-r--r--fs/nilfs2/nilfs.h1
4 files changed, 2 insertions, 231 deletions
diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
index 1b7e6ddabbeb..393316cd3cad 100644
--- a/fs/nilfs2/dir.c
+++ b/fs/nilfs2/dir.c
@@ -704,7 +704,7 @@ struct file_operations nilfs_dir_operations = {
704 .readdir = nilfs_readdir, 704 .readdir = nilfs_readdir,
705 .ioctl = nilfs_ioctl, 705 .ioctl = nilfs_ioctl,
706#ifdef CONFIG_COMPAT 706#ifdef CONFIG_COMPAT
707 .compat_ioctl = nilfs_compat_ioctl, 707 .compat_ioctl = nilfs_ioctl,
708#endif /* CONFIG_COMPAT */ 708#endif /* CONFIG_COMPAT */
709 .fsync = nilfs_sync_file, 709 .fsync = nilfs_sync_file,
710 710
diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index cd38124372f3..a2bd962ebd85 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -142,7 +142,7 @@ struct file_operations nilfs_file_operations = {
142 .aio_write = generic_file_aio_write, 142 .aio_write = generic_file_aio_write,
143 .ioctl = nilfs_ioctl, 143 .ioctl = nilfs_ioctl,
144#ifdef CONFIG_COMPAT 144#ifdef CONFIG_COMPAT
145 .compat_ioctl = nilfs_compat_ioctl, 145 .compat_ioctl = nilfs_ioctl,
146#endif /* CONFIG_COMPAT */ 146#endif /* CONFIG_COMPAT */
147 .mmap = nilfs_file_mmap, 147 .mmap = nilfs_file_mmap,
148 .open = generic_file_open, 148 .open = generic_file_open,
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 7fbd9fe1d035..33aff8842ce9 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -631,231 +631,3 @@ int nilfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
631 return -ENOTTY; 631 return -ENOTTY;
632 } 632 }
633} 633}
634
635/* compat_ioctl */
636#ifdef CONFIG_COMPAT
637#include <linux/compat.h>
638
639static int nilfs_compat_locked_ioctl(struct inode *inode, struct file *filp,
640 unsigned int cmd, unsigned long arg)
641{
642 int ret;
643
644 lock_kernel();
645 ret = nilfs_ioctl(inode, filp, cmd, arg);
646 unlock_kernel();
647 return ret;
648}
649
650static int
651nilfs_compat_ioctl_uargv32_to_uargv(struct nilfs_argv32 __user *uargv32,
652 struct nilfs_argv __user *uargv)
653{
654 compat_uptr_t base;
655 compat_size_t nmembs, size;
656 compat_int_t index, flags;
657
658 if (get_user(base, &uargv32->v_base) ||
659 put_user(compat_ptr(base), &uargv->v_base) ||
660 get_user(nmembs, &uargv32->v_nmembs) ||
661 put_user(nmembs, &uargv->v_nmembs) ||
662 get_user(size, &uargv32->v_size) ||
663 put_user(size, &uargv->v_size) ||
664 get_user(index, &uargv32->v_index) ||
665 put_user(index, &uargv->v_index) ||
666 get_user(flags, &uargv32->v_flags) ||
667 put_user(flags, &uargv->v_flags))
668 return -EFAULT;
669 return 0;
670}
671
672static int
673nilfs_compat_ioctl_uargv_to_uargv32(struct nilfs_argv __user *uargv,
674 struct nilfs_argv32 __user *uargv32)
675{
676 size_t nmembs;
677
678 if (get_user(nmembs, &uargv->v_nmembs) ||
679 put_user(nmembs, &uargv32->v_nmembs))
680 return -EFAULT;
681 return 0;
682}
683
684static int
685nilfs_compat_ioctl_get_by_argv(struct inode *inode, struct file *filp,
686 unsigned int cmd, unsigned long arg)
687{
688 struct nilfs_argv __user *uargv;
689 struct nilfs_argv32 __user *uargv32;
690 int ret;
691
692 uargv = compat_alloc_user_space(sizeof(struct nilfs_argv));
693 uargv32 = compat_ptr(arg);
694 ret = nilfs_compat_ioctl_uargv32_to_uargv(uargv32, uargv);
695 if (ret < 0)
696 return ret;
697
698 ret = nilfs_compat_locked_ioctl(inode, filp, cmd, (unsigned long)uargv);
699 if (ret < 0)
700 return ret;
701
702 return nilfs_compat_ioctl_uargv_to_uargv32(uargv, uargv32);
703}
704
705static int
706nilfs_compat_ioctl_change_cpmode(struct inode *inode, struct file *filp,
707 unsigned int cmd, unsigned long arg)
708{
709 struct nilfs_cpmode __user *ucpmode;
710 struct nilfs_cpmode32 __user *ucpmode32;
711 int mode;
712
713 ucpmode = compat_alloc_user_space(sizeof(struct nilfs_cpmode));
714 ucpmode32 = compat_ptr(arg);
715 if (copy_in_user(&ucpmode->cm_cno, &ucpmode32->cm_cno,
716 sizeof(__u64)) ||
717 get_user(mode, &ucpmode32->cm_mode) ||
718 put_user(mode, &ucpmode->cm_mode))
719 return -EFAULT;
720
721 return nilfs_compat_locked_ioctl(
722 inode, filp, cmd, (unsigned long)ucpmode);
723}
724
725
726static inline int
727nilfs_compat_ioctl_delete_checkpoint(struct inode *inode, struct file *filp,
728 unsigned int cmd, unsigned long arg)
729{
730 return nilfs_compat_locked_ioctl(inode, filp, cmd, arg);
731}
732
733static inline int
734nilfs_compat_ioctl_get_cpinfo(struct inode *inode, struct file *filp,
735 unsigned int cmd, unsigned long arg)
736{
737 return nilfs_compat_ioctl_get_by_argv(inode, filp, cmd, arg);
738}
739
740static inline int
741nilfs_compat_ioctl_get_cpstat(struct inode *inode, struct file *filp,
742 unsigned int cmd, unsigned long arg)
743{
744 return nilfs_compat_locked_ioctl(inode, filp, cmd, arg);
745}
746
747static inline int
748nilfs_compat_ioctl_get_suinfo(struct inode *inode, struct file *filp,
749 unsigned int cmd, unsigned long arg)
750{
751 return nilfs_compat_ioctl_get_by_argv(inode, filp, cmd, arg);
752}
753
754static int
755nilfs_compat_ioctl_get_sustat(struct inode *inode, struct file *filp,
756 unsigned int cmd, unsigned long arg)
757{
758 struct nilfs_sustat __user *usustat;
759 struct nilfs_sustat32 __user *usustat32;
760 time_t ctime, nongc_ctime;
761 int ret;
762
763 usustat = compat_alloc_user_space(sizeof(struct nilfs_sustat));
764 ret = nilfs_compat_locked_ioctl(inode, filp, cmd,
765 (unsigned long)usustat);
766 if (ret < 0)
767 return ret;
768
769 usustat32 = compat_ptr(arg);
770 if (copy_in_user(&usustat32->ss_nsegs, &usustat->ss_nsegs,
771 sizeof(__u64)) ||
772 copy_in_user(&usustat32->ss_ncleansegs, &usustat->ss_ncleansegs,
773 sizeof(__u64)) ||
774 copy_in_user(&usustat32->ss_ndirtysegs, &usustat->ss_ndirtysegs,
775 sizeof(__u64)) ||
776 get_user(ctime, &usustat->ss_ctime) ||
777 put_user(ctime, &usustat32->ss_ctime) ||
778 get_user(nongc_ctime, &usustat->ss_nongc_ctime) ||
779 put_user(nongc_ctime, &usustat32->ss_nongc_ctime))
780 return -EFAULT;
781 return 0;
782}
783
784static inline int
785nilfs_compat_ioctl_get_vinfo(struct inode *inode, struct file *filp,
786 unsigned int cmd, unsigned long arg)
787{
788 return nilfs_compat_ioctl_get_by_argv(inode, filp, cmd, arg);
789}
790
791static inline int
792nilfs_compat_ioctl_get_bdescs(struct inode *inode, struct file *filp,
793 unsigned int cmd, unsigned long arg)
794{
795 return nilfs_compat_ioctl_get_by_argv(inode, filp, cmd, arg);
796}
797
798static int
799nilfs_compat_ioctl_clean_segments(struct inode *inode, struct file *filp,
800 unsigned int cmd, unsigned long arg)
801{
802 struct nilfs_argv __user *uargv;
803 struct nilfs_argv32 __user *uargv32;
804 int i, ret;
805
806 uargv = compat_alloc_user_space(sizeof(struct nilfs_argv) * 5);
807 uargv32 = compat_ptr(arg);
808 for (i = 0; i < 5; i++) {
809 ret = nilfs_compat_ioctl_uargv32_to_uargv(&uargv32[i],
810 &uargv[i]);
811 if (ret < 0)
812 return ret;
813 }
814 return nilfs_compat_locked_ioctl(
815 inode, filp, cmd, (unsigned long)uargv);
816}
817
818static int nilfs_compat_ioctl_sync(struct inode *inode, struct file *filp,
819 unsigned int cmd, unsigned long arg)
820{
821 return nilfs_compat_locked_ioctl(inode, filp, cmd, arg);
822}
823
824long nilfs_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
825{
826 struct inode *inode = filp->f_dentry->d_inode;
827
828 switch (cmd) {
829 case NILFS_IOCTL32_CHANGE_CPMODE:
830 return nilfs_compat_ioctl_change_cpmode(
831 inode, filp, NILFS_IOCTL_CHANGE_CPMODE, arg);
832 case NILFS_IOCTL_DELETE_CHECKPOINT:
833 return nilfs_compat_ioctl_delete_checkpoint(
834 inode, filp, cmd, arg);
835 case NILFS_IOCTL32_GET_CPINFO:
836 return nilfs_compat_ioctl_get_cpinfo(
837 inode, filp, NILFS_IOCTL_GET_CPINFO, arg);
838 case NILFS_IOCTL_GET_CPSTAT:
839 return nilfs_compat_ioctl_get_cpstat(inode, filp, cmd, arg);
840 case NILFS_IOCTL32_GET_SUINFO:
841 return nilfs_compat_ioctl_get_suinfo(
842 inode, filp, NILFS_IOCTL_GET_SUINFO, arg);
843 case NILFS_IOCTL32_GET_SUSTAT:
844 return nilfs_compat_ioctl_get_sustat(
845 inode, filp, NILFS_IOCTL_GET_SUSTAT, arg);
846 case NILFS_IOCTL32_GET_VINFO:
847 return nilfs_compat_ioctl_get_vinfo(
848 inode, filp, NILFS_IOCTL_GET_VINFO, arg);
849 case NILFS_IOCTL32_GET_BDESCS:
850 return nilfs_compat_ioctl_get_bdescs(
851 inode, filp, NILFS_IOCTL_GET_BDESCS, arg);
852 case NILFS_IOCTL32_CLEAN_SEGMENTS:
853 return nilfs_compat_ioctl_clean_segments(
854 inode, filp, NILFS_IOCTL_CLEAN_SEGMENTS, arg);
855 case NILFS_IOCTL_SYNC:
856 return nilfs_compat_ioctl_sync(inode, filp, cmd, arg);
857 default:
858 return -ENOIOCTLCMD;
859 }
860}
861#endif
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 48c070676cc5..f767644a7242 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -243,7 +243,6 @@ extern int nilfs_sync_file(struct file *, struct dentry *, int);
243 243
244/* ioctl.c */ 244/* ioctl.c */
245int nilfs_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 245int nilfs_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
246long nilfs_compat_ioctl(struct file *, unsigned int, unsigned long);
247int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, void __user *); 246int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, void __user *);
248 247
249/* inode.c */ 248/* inode.c */