Skip to content

Commit 8082d36

Browse files
konistorvalds
authored andcommitted
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>
1 parent dc498d0 commit 8082d36

5 files changed

Lines changed: 2 additions & 272 deletions

File tree

‎fs/nilfs2/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ struct file_operations nilfs_dir_operations = {
704704
.readdir = nilfs_readdir,
705705
.ioctl = nilfs_ioctl,
706706
#ifdef CONFIG_COMPAT
707-
.compat_ioctl = nilfs_compat_ioctl,
707+
.compat_ioctl = nilfs_ioctl,
708708
#endif /* CONFIG_COMPAT */
709709
.fsync = nilfs_sync_file,
710710

‎fs/nilfs2/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct file_operations nilfs_file_operations = {
142142
.aio_write = generic_file_aio_write,
143143
.ioctl = nilfs_ioctl,
144144
#ifdef CONFIG_COMPAT
145-
.compat_ioctl = nilfs_compat_ioctl,
145+
.compat_ioctl = nilfs_ioctl,
146146
#endif /* CONFIG_COMPAT */
147147
.mmap = nilfs_file_mmap,
148148
.open = generic_file_open,

‎fs/nilfs2/ioctl.c‎

Lines changed: 0 additions & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎fs/nilfs2/nilfs.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ extern int nilfs_sync_file(struct file *, struct dentry *, int);
243243

244244
/* ioctl.c */
245245
int nilfs_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
246-
long nilfs_compat_ioctl(struct file *, unsigned int, unsigned long);
247246
int nilfs_ioctl_prepare_clean_segments(struct the_nilfs *, void __user *);
248247

249248
/* inode.c */

‎include/linux/nilfs2_fs.h‎

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -793,45 +793,4 @@ struct nilfs_bdesc {
793793
#define NILFS_IOCTL_RESIZE \
794794
_IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
795795

796-
/* compat_ioctl */
797-
#ifdef CONFIG_COMPAT
798-
#include <linux/compat.h>
799-
800-
struct nilfs_cpmode32 {
801-
__u64 cm_cno;
802-
compat_int_t cm_mode;
803-
};
804-
805-
struct nilfs_argv32 {
806-
compat_caddr_t v_base;
807-
compat_size_t v_nmembs;
808-
compat_size_t v_size;
809-
compat_int_t v_index;
810-
compat_int_t v_flags;
811-
};
812-
813-
struct nilfs_sustat32 {
814-
__u64 ss_nsegs;
815-
__u64 ss_ncleansegs;
816-
__u64 ss_ndirtysegs;
817-
compat_time_t ss_ctime;
818-
compat_time_t ss_nongc_ctime;
819-
};
820-
821-
#define NILFS_IOCTL32_CHANGE_CPMODE \
822-
_IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode32)
823-
#define NILFS_IOCTL32_GET_CPINFO \
824-
_IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv32)
825-
#define NILFS_IOCTL32_GET_SUINFO \
826-
_IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv32)
827-
#define NILFS_IOCTL32_GET_SUSTAT \
828-
_IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat32)
829-
#define NILFS_IOCTL32_GET_VINFO \
830-
_IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv32)
831-
#define NILFS_IOCTL32_GET_BDESCS \
832-
_IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv32)
833-
#define NILFS_IOCTL32_CLEAN_SEGMENTS \
834-
_IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv32[5])
835-
#endif /* CONFIG_COMPAT */
836-
837796
#endif /* _LINUX_NILFS_FS_H */

0 commit comments

Comments
 (0)