Skip to contentSkip to conversation

f2fs: add compat_ioctl to provide backward compatability

PATCH In review Namjae Jeon 2 participants 6 messages Feb 4, 2013 – Feb 5, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: add compat_ioctl to provide backward compatability

From: Namjae Jeon <[email protected]>

adding compat_ioctl to provide support for backward comptability - 32bit binary execution on 64bit kernel.

---
 fs/f2fs/f2fs.h |   15 +++++++++++++++
 fs/f2fs/file.c |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
fs/f2fs/f2fs.h +15 -0
index 58dd608..7bf86c8 100644
@@ -104,6 +104,20 @@ static inline int update_sits_in_cursum(struct f2fs_summary_block *rs, int i)
 }
 
 /*
+ * ioctl commands
+ */
+#define F2FS_IOC_GETFLAGS               FS_IOC_GETFLAGS
+#define F2FS_IOC_SETFLAGS               FS_IOC_SETFLAGS
+
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define F2FS_IOC32_GETFLAGS             FS_IOC32_GETFLAGS
+#define F2FS_IOC32_SETFLAGS             FS_IOC32_SETFLAGS
+#endif
+
+/*
  * For INODE and NODE manager
  */
 #define XATTR_NODE_OFFSET	(-1)	/*
@@ -850,6 +864,7 @@ void f2fs_truncate(struct inode *);
 int f2fs_setattr(struct dentry *, struct iattr *);
 int truncate_hole(struct inode *, pgoff_t, pgoff_t);
 long f2fs_ioctl(struct file *, unsigned int, unsigned long);
+long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /*
  * inode.c
fs/f2fs/file.c +20 -0
index 633667e..e79d26a 100644
@@ -644,6 +644,23 @@ out:
 	}
 }
 
+#ifdef CONFIG_COMPAT
+long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case F2FS_IOC32_GETFLAGS:
+		cmd = F2FS_IOC_GETFLAGS;
+		break;
+	case F2FS_IOC32_SETFLAGS:
+		cmd = F2FS_IOC_SETFLAGS;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif
+
 const struct file_operations f2fs_file_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= do_sync_read,
@@ -655,6 +672,9 @@ const struct file_operations f2fs_file_operations = {
 	.fsync		= f2fs_sync_file,
 	.fallocate	= f2fs_fallocate,
 	.unlocked_ioctl	= f2fs_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= f2fs_compat_ioctl,
+#endif
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= generic_file_splice_write,
 };
Signature · 1 line
1.7.9.5
#1 lore raw

Hi Jaegeuk.

Oops!, I was missing include header.
Sorry, I will send v2 patch again.

Thanks.

2013/2/4, Namjae Jeon <[email protected]>:

Quoted 90 lines

From: Namjae Jeon <[email protected]>

adding compat_ioctl to provide support for backward comptability - 32bit binary
execution on 64bit kernel.

---
 fs/f2fs/f2fs.h |   15 +++++++++++++++
 fs/f2fs/file.c |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
fs/f2fs/f2fs.h +14 -0
index 58dd608..7bf86c8 100644
@@ -104,6 +104,20 @@ static inline int update_sits_in_cursum(struct
 f2fs_summary_block *rs, int i)
 }
 
 /*
+ * ioctl commands
+ */
+#define F2FS_IOC_GETFLAGS               FS_IOC_GETFLAGS
+#define F2FS_IOC_SETFLAGS               FS_IOC_SETFLAGS
+
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define F2FS_IOC32_GETFLAGS             FS_IOC32_GETFLAGS
+#define F2FS_IOC32_SETFLAGS             FS_IOC32_SETFLAGS
+#endif
+
+/*
  * For INODE and NODE manager
  */

#define XATTR_NODE_OFFSET (-1) /*

fs/f2fs/f2fs.h +1 -0
@@ -850,6 +864,7 @@ void f2fs_truncate(struct inode *);
 int f2fs_setattr(struct dentry *, struct iattr *);
 int truncate_hole(struct inode *, pgoff_t, pgoff_t);
 long f2fs_ioctl(struct file *, unsigned int, unsigned long);
+long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /*
  * inode.c
fs/f2fs/file.c +17 -0
index 633667e..e79d26a 100644
@@ -644,6 +644,23 @@ out:
 	}
 }
 
+#ifdef CONFIG_COMPAT
+long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long
 arg)
+{
+	switch (cmd) {
+	case F2FS_IOC32_GETFLAGS:
+		cmd = F2FS_IOC_GETFLAGS;
+		break;
+	case F2FS_IOC32_SETFLAGS:
+		cmd = F2FS_IOC_SETFLAGS;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif
+
 const struct file_operations f2fs_file_operations = {
 	.llseek		= generic_file_llseek,
fs/f2fs/file.c +3 -1
 	.read		= do_sync_read,
@@ -655,6 +672,9 @@ const struct file_operations f2fs_file_operations = {
 	.fsync		= f2fs_sync_file,
 	.fallocate	= f2fs_fallocate,
 	.unlocked_ioctl	= f2fs_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= f2fs_compat_ioctl,
+#endif
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= generic_file_splice_write,
 };
--

1.7.9.5

#2 lore raw

Hi,

2013-02-05 (화), 14:28 +0900, Namjae Jeon:

Quoted 4 lines

Hi Jaegeuk.

Oops!, I was missing include header.
Sorry, I will send v2 patch again.

I got a build error, and simply added the following header file in your patch.

#include <linux/compat.h>

Is it correct?

Thanks,

Quoted 98 lines

Thanks.

2013/2/4, Namjae Jeon <[email protected]>:

Quoted 87 lines

From: Namjae Jeon <[email protected]>

adding compat_ioctl to provide support for backward comptability - 32bit binary
execution on 64bit kernel.

---
 fs/f2fs/f2fs.h |   15 +++++++++++++++
 fs/f2fs/file.c |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
fs/f2fs/f2fs.h +14 -0
index 58dd608..7bf86c8 100644
@@ -104,6 +104,20 @@ static inline int update_sits_in_cursum(struct
 f2fs_summary_block *rs, int i)
 }
 
 /*
+ * ioctl commands
+ */
+#define F2FS_IOC_GETFLAGS               FS_IOC_GETFLAGS
+#define F2FS_IOC_SETFLAGS               FS_IOC_SETFLAGS
+
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define F2FS_IOC32_GETFLAGS             FS_IOC32_GETFLAGS
+#define F2FS_IOC32_SETFLAGS             FS_IOC32_SETFLAGS
+#endif
+
+/*
  * For INODE and NODE manager
  */

#define XATTR_NODE_OFFSET (-1) /*

fs/f2fs/f2fs.h +1 -0
@@ -850,6 +864,7 @@ void f2fs_truncate(struct inode *);
 int f2fs_setattr(struct dentry *, struct iattr *);
 int truncate_hole(struct inode *, pgoff_t, pgoff_t);
 long f2fs_ioctl(struct file *, unsigned int, unsigned long);
+long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /*
  * inode.c
fs/f2fs/file.c +17 -0
index 633667e..e79d26a 100644
@@ -644,6 +644,23 @@ out:
 	}
 }
 
+#ifdef CONFIG_COMPAT
+long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long
 arg)
+{
+	switch (cmd) {
+	case F2FS_IOC32_GETFLAGS:
+		cmd = F2FS_IOC_GETFLAGS;
+		break;
+	case F2FS_IOC32_SETFLAGS:
+		cmd = F2FS_IOC_SETFLAGS;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif
+
 const struct file_operations f2fs_file_operations = {
 	.llseek		= generic_file_llseek,
fs/f2fs/file.c +3 -1
 	.read		= do_sync_read,
@@ -655,6 +672,9 @@ const struct file_operations f2fs_file_operations = {
 	.fsync		= f2fs_sync_file,
 	.fallocate	= f2fs_fallocate,
 	.unlocked_ioctl	= f2fs_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= f2fs_compat_ioctl,
+#endif
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= generic_file_splice_write,
 };
--
Quoted 3 lines

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Jaegeuk Kim
Samsung
#3 lore raw

2013/2/5, Jaegeuk Kim <[email protected]>:

Quoted 8 lines

Hi,

2013-02-05 (화), 14:28 +0900, Namjae Jeon:

Quoted 4 lines

Hi Jaegeuk.

Oops!, I was missing include header.
Sorry, I will send v2 patch again.

Quoted 6 lines

I got a build error, and simply added the following header file in your patch.

#include <linux/compat.h>

Is it correct?

Yes, Right :) It should be needed.
Sorry for my mistake again. Could you add this header instead of me ?(because I can resend the patch tonight....).

Thanks!

Quoted 110 lines

Thanks,

Quoted 94 lines

Thanks.

2013/2/4, Namjae Jeon <[email protected]>:

Quoted 90 lines

From: Namjae Jeon <[email protected]>

adding compat_ioctl to provide support for backward comptability - 32bit
binary
execution on 64bit kernel.

---
 fs/f2fs/f2fs.h |   15 +++++++++++++++
 fs/f2fs/file.c |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
fs/f2fs/f2fs.h +14 -0
index 58dd608..7bf86c8 100644
@@ -104,6 +104,20 @@ static inline int update_sits_in_cursum(struct
 f2fs_summary_block *rs, int i)
 }
 
 /*
+ * ioctl commands
+ */
+#define F2FS_IOC_GETFLAGS               FS_IOC_GETFLAGS
+#define F2FS_IOC_SETFLAGS               FS_IOC_SETFLAGS
+
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define F2FS_IOC32_GETFLAGS             FS_IOC32_GETFLAGS
+#define F2FS_IOC32_SETFLAGS             FS_IOC32_SETFLAGS
+#endif
+
+/*
  * For INODE and NODE manager
  */

#define XATTR_NODE_OFFSET (-1) /*

fs/f2fs/f2fs.h +1 -0
@@ -850,6 +864,7 @@ void f2fs_truncate(struct inode *);
 int f2fs_setattr(struct dentry *, struct iattr *);
 int truncate_hole(struct inode *, pgoff_t, pgoff_t);
 long f2fs_ioctl(struct file *, unsigned int, unsigned long);
+long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /*
  * inode.c
fs/f2fs/file.c +2 -0
index 633667e..e79d26a 100644
@@ -644,6 +644,23 @@ out:
 	}
 }
 
+#ifdef CONFIG_COMPAT
+long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned

long
arg)

fs/f2fs/file.c +18 -0
+{
+	switch (cmd) {
+	case F2FS_IOC32_GETFLAGS:
+		cmd = F2FS_IOC_GETFLAGS;
+		break;
+	case F2FS_IOC32_SETFLAGS:
+		cmd = F2FS_IOC_SETFLAGS;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif
+
 const struct file_operations f2fs_file_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= do_sync_read,
@@ -655,6 +672,9 @@ const struct file_operations f2fs_file_operations =
 {
 	.fsync		= f2fs_sync_file,
 	.fallocate	= f2fs_fallocate,
 	.unlocked_ioctl	= f2fs_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= f2fs_compat_ioctl,
+#endif
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= generic_file_splice_write,

};
--

Quoted 8 lines
Quoted 3 lines

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Jaegeuk Kim
Samsung

#4 lore raw

2013/2/5, Namjae Jeon <[email protected]>:

Quoted 12 lines

2013/2/5, Jaegeuk Kim <[email protected]>:

Quoted 11 lines

Hi,

2013-02-05 (화), 14:28 +0900, Namjae Jeon:

Quoted 4 lines

Hi Jaegeuk.

Oops!, I was missing include header.
Sorry, I will send v2 patch again.

I got a build error, and simply added the following header file in your patch.

Quoted 11 lines
Quoted 3 lines

#include <linux/compat.h>

Is it correct?

Yes, Right :) It should be needed.
Sorry for my mistake again. Could you add this header instead of me ?(because I can resend the patch tonight....).

Thanks!

Quoted 3 lines

Thanks,

Hi Jaegeuk.
I tried to paste the patch in mail.
Could you take below patch instead of previous patch ?

Thanks.

--------------------------------------------------------------------------------------------------------
Subject: [PATCH] f2fs: add compat_ioctl to provide backward compatibility
From: Namjae Jeon <[email protected]>

adding compat_ioctl to provide support for backward comptability - 32bit binary execution on 64bit kernel.

---
 fs/f2fs/f2fs.h |   15 +++++++++++++++
 fs/f2fs/file.c |   21 +++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
fs/f2fs/f2fs.h +0 -0
index 5022a7d..e980dd5 100644
@@ -104,6 +104,20 @@ static inline int update_sits_in_cursum(struct

f2fs_summary_block *rs, int i)
}

/*
+ * ioctl commands
+ */
+#define F2FS_IOC_GETFLAGS FS_IOC_GETFLAGS
+#define F2FS_IOC_SETFLAGS FS_IOC_SETFLAGS
+
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define F2FS_IOC32_GETFLAGS FS_IOC32_GETFLAGS
+#define F2FS_IOC32_SETFLAGS FS_IOC32_SETFLAGS
+#endif
+
+/*
* For INODE and NODE manager
*/
#define XATTR_NODE_OFFSET (-1) /*
@@ -842,6 +856,7 @@ void f2fs_truncate(struct inode *);
int f2fs_setattr(struct dentry *, struct iattr *);
int truncate_hole(struct inode *, pgoff_t, pgoff_t); long f2fs_ioctl(struct file *, unsigned int, unsigned long);
+long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);

/*
* inode.c

fs/f2fs/file.c +21 -0
index 33d1736..de3e533 100644
@@ -17,6 +17,7 @@
 #include <linux/types.h>
 #include <linux/uaccess.h>
 #include <linux/mount.h>
+#include <linux/compat.h>
 
 #include "f2fs.h"
 #include "node.h"
@@ -634,6 +635,23 @@ out:
 	}
 }
 
+#ifdef CONFIG_COMPAT
+long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+	case F2FS_IOC32_GETFLAGS:
+		cmd = F2FS_IOC_GETFLAGS;
+		break;
+	case F2FS_IOC32_SETFLAGS:
+		cmd = F2FS_IOC_SETFLAGS;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif
+
 const struct file_operations f2fs_file_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= do_sync_read,
@@ -645,6 +663,9 @@ const struct file_operations f2fs_file_operations = {
 	.fsync		= f2fs_sync_file,
 	.fallocate	= f2fs_fallocate,
 	.unlocked_ioctl	= f2fs_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl   = f2fs_compat_ioctl,
+#endif
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= generic_file_splice_write,
 };
Signature · 1 line
1.7.2.3
#5 lore raw
In reply to Namjae Jeon

2013-02-05 (화), 16:02 +0900, Namjae Jeon:

Quoted 12 lines

2013/2/5, Jaegeuk Kim <[email protected]>:

Quoted 11 lines

Hi,

2013-02-05 (화), 14:28 +0900, Namjae Jeon:

Quoted 4 lines

Hi Jaegeuk.

Oops!, I was missing include header.
Sorry, I will send v2 patch again.

I got a build error, and simply added the following header file in your patch.

Quoted 6 lines
Quoted 3 lines

#include <linux/compat.h>

Is it correct?

Yes, Right :) It should be needed.
Sorry for my mistake again. Could you add this header instead of me ?(because I can resend the patch tonight....).

No problem. I've already done it. :)
Thanks,

Quoted 116 lines

Thanks!

Quoted 106 lines

Thanks,

Quoted 94 lines

Thanks.

2013/2/4, Namjae Jeon <[email protected]>:

Quoted 90 lines

From: Namjae Jeon <[email protected]>

adding compat_ioctl to provide support for backward comptability - 32bit
binary
execution on 64bit kernel.

---
 fs/f2fs/f2fs.h |   15 +++++++++++++++
 fs/f2fs/file.c |   20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
fs/f2fs/f2fs.h +14 -0
index 58dd608..7bf86c8 100644
@@ -104,6 +104,20 @@ static inline int update_sits_in_cursum(struct
 f2fs_summary_block *rs, int i)
 }
 
 /*
+ * ioctl commands
+ */
+#define F2FS_IOC_GETFLAGS               FS_IOC_GETFLAGS
+#define F2FS_IOC_SETFLAGS               FS_IOC_SETFLAGS
+
+#if defined(__KERNEL__) && defined(CONFIG_COMPAT)
+/*
+ * ioctl commands in 32 bit emulation
+ */
+#define F2FS_IOC32_GETFLAGS             FS_IOC32_GETFLAGS
+#define F2FS_IOC32_SETFLAGS             FS_IOC32_SETFLAGS
+#endif
+
+/*
  * For INODE and NODE manager
  */

#define XATTR_NODE_OFFSET (-1) /*

fs/f2fs/f2fs.h +1 -0
@@ -850,6 +864,7 @@ void f2fs_truncate(struct inode *);
 int f2fs_setattr(struct dentry *, struct iattr *);
 int truncate_hole(struct inode *, pgoff_t, pgoff_t);
 long f2fs_ioctl(struct file *, unsigned int, unsigned long);
+long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long);
 
 /*
  * inode.c
fs/f2fs/file.c +2 -0
index 633667e..e79d26a 100644
@@ -644,6 +644,23 @@ out:
 	}
 }
 
+#ifdef CONFIG_COMPAT
+long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned

long
arg)

fs/f2fs/file.c +18 -0
+{
+	switch (cmd) {
+	case F2FS_IOC32_GETFLAGS:
+		cmd = F2FS_IOC_GETFLAGS;
+		break;
+	case F2FS_IOC32_SETFLAGS:
+		cmd = F2FS_IOC_SETFLAGS;
+		break;
+	default:
+		return -ENOIOCTLCMD;
+	}
+	return f2fs_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
+}
+#endif
+
 const struct file_operations f2fs_file_operations = {
 	.llseek		= generic_file_llseek,
 	.read		= do_sync_read,
@@ -655,6 +672,9 @@ const struct file_operations f2fs_file_operations =
 {
 	.fsync		= f2fs_sync_file,
 	.fallocate	= f2fs_fallocate,
 	.unlocked_ioctl	= f2fs_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= f2fs_compat_ioctl,
+#endif
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= generic_file_splice_write,

};
--

Quoted 8 lines
Quoted 3 lines

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Quoted 4 lines

--
Jaegeuk Kim
Samsung

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Jaegeuk Kim
Samsung