[PATCH 2/2] Properly support lseek for n32 and x32

H.J. Lu hongjiu.lu at intel.com
Sun Apr 15 18:21:15 UTC 2012


Hi,

Linux kernel v3.4 adds x32 support.  Both x32 and n32 use 64bit offset
for lseek parameter and return value.  We need u_lrval to handle it
properly.  Also we shouldn't check HAVE_LONG_LONG_OFF_T for n32 lseek.
This patch fixes it properly and prepares lseek for x32.

Thanks.

H.J.
----
2012-04-15  H.J. Lu  <hongjiu.lu at intel.com>

	* defs.h (tcb): Restore u_lrval.
	(RVAL_LDECIMAL): Restored.
	(RVAL_LHEX): Likewise.
	(RVAL_LOCTAL): Likewise.
	(RVAL_LUDECIMAL): Likewise.
	(RVAL_MASK): Set to 7.

	* file.c (sys_lseek): Print 64bit offset and return RVAL_LUDECIMAL
	for n32.

	* syscall.c (get_error): Set u_lrval for n32.

diff --git a/defs.h b/defs.h
index 1ebbd29..0993855 100644
--- a/defs.h
+++ b/defs.h
@@ -328,6 +328,9 @@ struct tcb {
 	long long ext_arg[MAX_ARGS];	/* System call arguments */
 #endif
 	long u_rval;		/* (first) return value */
+#ifdef HAVE_LONG_LONG
+	long long u_lrval;	/* long long return value */
+#endif
 #if SUPPORTED_PERSONALITIES > 1
 	int currpers;		/* Personality at the time of scno update */
 #endif
@@ -418,7 +421,11 @@ extern const struct xlat open_access_modes[];
 #define RVAL_HEX	001	/* hex format */
 #define RVAL_OCTAL	002	/* octal format */
 #define RVAL_UDECIMAL	003	/* unsigned decimal format */
-#define RVAL_MASK	003	/* mask for these values */
+#define RVAL_LDECIMAL	004	/* long decimal format */
+#define RVAL_LHEX	005	/* long hex format */
+#define RVAL_LOCTAL	006	/* long octal format */
+#define RVAL_LUDECIMAL	007	/* long unsigned decimal format */
+#define RVAL_MASK	007	/* mask for these values */
 
 #define RVAL_STR	010	/* Print `auxstr' field after return val */
 #define RVAL_NONE	020	/* Print nothing */
diff --git a/file.c b/file.c
index 1a448cd..fa4b314 100644
--- a/file.c
+++ b/file.c
@@ -478,8 +478,7 @@ static const struct xlat whence[] = {
 	{ 0,		NULL		},
 };
 
-#if !defined(HAVE_LONG_LONG_OFF_T)
-# if defined(LINUX_MIPSN32)
+#if defined(LINUX_MIPSN32)
 int
 sys_lseek(struct tcb *tcp)
 {
@@ -497,9 +496,9 @@ sys_lseek(struct tcb *tcp)
 			tprintf("%lld, ", offset);
 		printxval(whence, _whence, "SEEK_???");
 	}
-	return RVAL_UDECIMAL;
+	return RVAL_LUDECIMAL;
 }
-# else /* !LINUX_MIPSN32 */
+#else
 int
 sys_lseek(struct tcb *tcp)
 {
@@ -519,7 +518,6 @@ sys_lseek(struct tcb *tcp)
 	}
 	return RVAL_UDECIMAL;
 }
-# endif
 #endif
 
 int
diff --git a/syscall.c b/syscall.c
index ddc461c..db0b576 100644
--- a/syscall.c
+++ b/syscall.c
@@ -1735,6 +1735,9 @@ get_error(struct tcb *tcp)
 		u_error = r2;
 	} else {
 		tcp->u_rval = r2;
+# if defined(LINUX_MIPSN32)
+		tcp->u_lrval = r2;
+# endif
 	}
 #elif defined(POWERPC)
 	if (check_errno && is_negated_errno(ppc_result)) {
@@ -2065,6 +2068,20 @@ trace_syscall_exiting(struct tcb *tcp)
 			case RVAL_DECIMAL:
 				tprintf("= %ld", tcp->u_rval);
 				break;
+#ifdef HAVE_LONG_LONG
+			case RVAL_LHEX:
+				tprintf("= %#llx", tcp->u_lrval);
+				break;
+			case RVAL_LOCTAL:
+				tprintf("= %#llo", tcp->u_lrval);
+				break;
+			case RVAL_LUDECIMAL:
+				tprintf("= %llu", tcp->u_lrval);
+				break;
+			case RVAL_LDECIMAL:
+				tprintf("= %lld", tcp->u_lrval);
+				break;
+#endif
 			default:
 				fprintf(stderr,
 					"invalid rval format\n");
-- 
1.7.6.5





More information about the Strace-devel mailing list