@@ -631,231 +631,3 @@ int nilfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
631631 return - ENOTTY ;
632632 }
633633}
634-
635- /* compat_ioctl */
636- #ifdef CONFIG_COMPAT
637- #include <linux/compat.h>
638-
639- static 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-
650- static int
651- nilfs_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-
672- static int
673- nilfs_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-
684- static int
685- nilfs_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-
705- static int
706- nilfs_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-
726- static inline int
727- nilfs_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-
733- static inline int
734- nilfs_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-
740- static inline int
741- nilfs_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-
747- static inline int
748- nilfs_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-
754- static int
755- nilfs_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-
784- static inline int
785- nilfs_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-
791- static inline int
792- nilfs_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-
798- static int
799- nilfs_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-
818- static 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-
824- long 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
0 commit comments