Skip to content

Commit a20a7c2

Browse files
bozutafvivier
authored andcommitted
linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS
Socket ioctls SIOCGSTAMP and SIOCGSTAMPNS, used for timestamping the socket connection, are defined in file "ioctls.h" differently from other ioctls. The reason for this difference is explained in the comments above their definition. These ioctls didn't have defined thunk argument types before changes from this patch. They have special handling functions ("do_ioctl_SIOCGSTAMP" and "do_ioctl_SIOCGSTAMPNS") that take care of setting values for approppriate argument types (struct timeval and struct timespec) and thus no thunk argument types were needed for their implementation. But this patch adds those argument type definitions in file "syscall_types.h" and "ioctls.h" as it is needed for printing arguments of these ioctls with strace. Implementation notes: There are two variants of these ioctls: SIOCGSTAMP_OLD/SIOCGSTAM_NEW and SIOCGSTAMPNS_OLD/SIOCGSTAMPNS_NEW. One is the old existing definition and the other is the 2038 safe variant used for 32-bit architectures. Corresponding structure definitions STRUCT_timespec/STRUCT__kernel_timespec and STRUCT_timeval/STRUCT__kernel_sock_timeval were added for these variants. STRUCT_timeval definition was already inside the file as it is used by another implemented ioctl. Two cases were added for definitions STRUCT_timeval/STRUCT__kernel_sock_timeval to manage the case when the "u_sec" field of the timeval structure is of type int. Signed-off-by: Filip Bozuta <[email protected]> Reviewed-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent f4d92c5 commit a20a7c2

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

linux-user/ioctls.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,17 @@
279279
* FIXME: create a macro to define this kind of entry
280280
*/
281281
{ TARGET_SIOCGSTAMP_OLD, TARGET_SIOCGSTAMP_OLD,
282-
"SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP },
282+
"SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP,
283+
{ MK_PTR(MK_STRUCT(STRUCT_timeval)) } },
283284
{ TARGET_SIOCGSTAMPNS_OLD, TARGET_SIOCGSTAMPNS_OLD,
284-
"SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS },
285+
"SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS,
286+
{ MK_PTR(MK_STRUCT(STRUCT_timespec)) } },
285287
{ TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMP_NEW,
286-
"SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP },
288+
"SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP,
289+
{ MK_PTR(MK_STRUCT(STRUCT__kernel_sock_timeval)) } },
287290
{ TARGET_SIOCGSTAMPNS_NEW, TARGET_SIOCGSTAMPNS_NEW,
288-
"SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS },
291+
"SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS,
292+
{ MK_PTR(MK_STRUCT(STRUCT__kernel_timespec)) } },
289293

290294
IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT))
291295
IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT))

linux-user/syscall_types.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,32 @@ STRUCT(snd_timer_params,
137137
TYPE_INT, /* filter */
138138
MK_ARRAY(TYPE_CHAR, 60)) /* reserved */
139139

140+
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
141+
STRUCT(timeval,
142+
TYPE_LONG, /* tv_sec */
143+
TYPE_INT) /* tv_usec */
144+
145+
STRUCT(_kernel_sock_timeval,
146+
TYPE_LONG, /* tv_sec */
147+
TYPE_INT) /* tv_usec */
148+
#else
149+
STRUCT(timeval,
150+
TYPE_LONG, /* tv_sec */
151+
TYPE_LONG) /* tv_usec */
152+
153+
STRUCT(_kernel_sock_timeval,
154+
TYPE_LONGLONG, /* tv_sec */
155+
TYPE_LONGLONG) /* tv_usec */
156+
#endif
157+
140158
STRUCT(timespec,
141159
TYPE_LONG, /* tv_sec */
142160
TYPE_LONG) /* tv_nsec */
143161

162+
STRUCT(_kernel_timespec,
163+
TYPE_LONGLONG, /* tv_sec */
164+
TYPE_LONGLONG) /* tv_nsec */
165+
144166
STRUCT(snd_timer_status,
145167
MK_STRUCT(STRUCT_timespec), /* tstamp */
146168
TYPE_INT, /* resolution */

0 commit comments

Comments
 (0)