On Mon, Jan 09, 2017 at 09:40:19PM +0800, JingPiao Chen wrote: [...] > +#include "tests.h" > +#include <asm/unistd.h> > + > +#ifdef __NR_ustat > + > +# include <stdio.h> > +# include <sys/stat.h> > +# include <sys/sysmacros.h> > +# include <unistd.h> > +# include <ustat.h> > + > +int > +main(void) > +{ > + kernel_ulong_t magic = (kernel_ulong_t) 0xfacefeedffffffff; > + unsigned int dev = (unsigned int) magic; > + struct ustat *ust = tail_alloc(sizeof(*ust)); > + struct stat st; > + > + long rc = syscall(__NR_ustat, magic, 0); > + printf("ustat(makedev(%u, %u), NULL) = %s\n", major(dev), > + minor(dev), sprintrc(rc));
It'd look nicer if you wrapped the line after the first argument, e.g. printf("ustat(makedev(%u, %u), NULL) = %s\n", major(dev), minor(dev), sprintrc(rc)); > + > + rc = syscall(__NR_ustat, magic, ust); > + printf("ustat(makedev(%u, %u), %p) = %s\n", major(dev), minor(dev), > + ust, sprintrc(rc)); Likewise. > + > + if (stat("/", &st) == -1) > + perror_msg_and_fail("stat"); > + rc = syscall(__NR_ustat, st.st_dev, ust); Please note that sizeof(st.st_dev) might be greater than sizeof(dev). If this is the case, the value of st.st_dev might not be a valid argument for ustat. I suggest assigning st.st_dev to dev with a check that both are equal. If it is the case, you can pass dev on to ustat. > + printf("ustat(makedev(%u, %u), {f_tfree=%llu, f_tinode=%llu}) = %s\n", > + major(st.st_dev), minor(st.st_dev), (unsigned long long) > ust->f_tfree, > + (unsigned long long) ust->f_tinode, sprintrc(rc)); Please note that ustat might be not implemented by the kernel, so one cannot assume that a ustat call succeeds. -- ldv
pgpl9fIrTlWjG.pgp
Description: PGP signature
------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel