https://bugs.kde.org/show_bug.cgi?id=506928
--- Comment #3 from Mark Wielaard <[email protected]> --- (In reply to Mark Wielaard from comment #2) > (In reply to mcermak from comment #1) > > Please, review the attached patch. > > OK, after lunch :) OK, after dinner... > Subject: [PATCH] Wrap linux specific syscall 22 (ustat) > The ustat syscall comes from pre-git linux history. It is > deprecated in favor of statfs. But in some cases it may > still be used. OK > ustat() returns information about a mounted filesystem. dev > is a device number identifying a device containing a mounted > filesystem. ubuf is a pointer to a ustat structure. Maybe give the whole function signature: int ustat(dev_t dev, struct ustat *ubuf); > Declare a sys_ustat wrapper in priv_syswrap-linux.h and hook > it for {amd64,arm,arm64,mips64,nanomips,ppc32,ppc64,riscv64,\ > s390x,x86}-linux using LINXY with PRE and POST handler in > syswrap-linux.c > https://bugs.kde.org/show_bug.cgi?id=506928 OK. > diff --git a/NEWS b/NEWS > index 796d9716e..e759daf2f 100644 > --- a/NEWS > +++ b/NEWS > @@ -56,6 +56,7 @@ are not entered into bugzilla tend to get forgotten about > or ignored. > 506499 Unhandled syscall 592 (exterrctl - FreeBSD > 506795 Better report which clone flags are problematic > 506930 valgrind allows SIGKILL being reset to SIG_DFL > +506928 Wrap (deprecated) linux specific ustat syscall Please sort on number. Should be before 506930 > diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h > b/coregrind/m_syswrap/priv_syswrap-linux.h > index 9e6cb8981..ce10a35f6 100644 > --- a/coregrind/m_syswrap/priv_syswrap-linux.h > +++ b/coregrind/m_syswrap/priv_syswrap-linux.h > @@ -40,6 +40,7 @@ extern void ML_(call_on_new_stack_0_1) ( Addr stack, Addr > retaddr, > // Linux-specific (but non-arch-specific) syscalls > +DECL_TEMPLATE(linux, sys_ustat); > DECL_TEMPLATE(linux, sys_clone) > DECL_TEMPLATE(linux, sys_mount); > DECL_TEMPLATE(linux, sys_oldumount); OK. > diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c > b/coregrind/m_syswrap/syswrap-amd64-linux.c > index 22989f9fa..c80286f00 100644 > --- a/coregrind/m_syswrap/syswrap-amd64-linux.c > +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c > @@ -633,7 +633,7 @@ static SyscallTableEntry syscall_table[] = { > // (__NR_uselib, sys_uselib), // 134 > LINX_(__NR_personality, sys_personality), // 135 > - // (__NR_ustat, sys_ustat), // 136 > + LINXY(__NR_ustat, sys_ustat), // 136 > GENXY(__NR_statfs, sys_statfs), // 137 > GENXY(__NR_fstatfs, sys_fstatfs), // 138 > // (__NR_sysfs, sys_sysfs), // 139 OK, as are the other arches. > diff --git a/coregrind/m_syswrap/syswrap-linux.c > b/coregrind/m_syswrap/syswrap-linux.c > index 306c3a2f8..c9b2c500a 100644 > --- a/coregrind/m_syswrap/syswrap-linux.c > +++ b/coregrind/m_syswrap/syswrap-linux.c > @@ -63,6 +63,7 @@ > #include "priv_syswrap-linux.h" > #include "priv_syswrap-main.h" > #include "priv_syswrap-xen.h" > +#include <stdint.h> Please don't use stdint.h types. See below. > +PRE(sys_ustat) > +{ > + PRINT("sys_ustat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG2); > + // unsigned int should in practice be good equivalent to u32, but... > + PRE_REG_READ2(long, "ustat", uint32_t, dev, struct vki_ustat *, ubuf); You can use vki_uint32_t or __vki_u32 > + if (ARG2 != 0) { > + PRE_MEM_WRITE( "ustat(ubuf)", ARG2, sizeof(struct vki_ustat) ); > + } > +} Don't need the ARG2 != 0. PRE_MEM_WRITE will warn if ARG2 is NULL, which is what we want. > +POST(sys_ustat) > +{ > + if (ARG2 != 0) { > + POST_MEM_WRITE( ARG1, sizeof(struct vki_ustat) ); > + } > +} You don't need the ARG2 != 0. POST_MEM_WRITE should work on ARG2 (not ARG1). > diff --git a/coregrind/m_syswrap/syswrap-mips64-linux.c > b/coregrind/m_syswrap/syswrap-mips64-linux.c > index 67e5c0b37..8e2dcbe93 100644 > --- a/coregrind/m_syswrap/syswrap-mips64-linux.c > +++ b/coregrind/m_syswrap/syswrap-mips64-linux.c > @@ -216,7 +216,6 @@ SysRes sys_set_tls ( ThreadId tid, Addr tlsptr ) > DECL_TEMPLATE (mips_linux, sys_set_thread_area); > DECL_TEMPLATE (mips_linux, sys_vmsplice); > -DECL_TEMPLATE (mips_linux, sys_ustat); > DECL_TEMPLATE (mips_linux, sys_sysfs); > DECL_TEMPLATE (mips_linux, sys_swapon); > DECL_TEMPLATE (mips_linux, sys_swapoff); > @@ -248,12 +247,6 @@ PRE(sys_sched_rr_get_interval) > *flags |= SfMayBlock; > } > -PRE(sys_ustat) > -{ > - PRINT("sys_ustat ( %#" FMT_REGWORD "x, %#" FMT_REGWORD "x)", ARG1, ARG2); > - PRE_REG_READ2(long, "ustat", int, flags, const void *, path); > -} > - OK, since this is now going into linux-generic. > diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h > index 8c919845b..9072b73e5 100644 > --- a/include/vki/vki-linux.h > +++ b/include/vki/vki-linux.h > @@ -171,6 +171,25 @@ typedef struct { > typedef int __vki_kernel_key_t; > typedef int __vki_kernel_mqd_t; > +//---------------------------------------------------------------------- > +// From pre-git history /include/linux/types.h > +//---------------------------------------------------------------------- > + > +struct vki_ustat { > +#ifdef __mips__ > + long f_tfree; > +#else > + int f_tfree; > +#endif Please use #if defined(VGA_mips64), defined(VGA_mips32) and/or #elif defined(VGA_nanomips) depending on which Valgrind Architecure this holds for. > +#ifdef __s390x__ > + unsigned int f_tinode; > +#else > + unsigned long f_tinode; > +#endif Please use #if defined(VGA_s390x) > + char f_fname[6]; > + char f_fpack[6]; > +}; > + -- You are receiving this mail because: You are watching all bug changes.
