From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LwAq2-0006IT-SH for qemu-devel@nongnu.org; Tue, 21 Apr 2009 03:56:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LwAq1-0006IH-E8 for qemu-devel@nongnu.org; Tue, 21 Apr 2009 03:56:17 -0400 Received: from [199.232.76.173] (port=55785 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LwAq1-0006IE-86 for qemu-devel@nongnu.org; Tue, 21 Apr 2009 03:56:17 -0400 Received: from mx20.gnu.org ([199.232.41.8]:53134) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LwAq0-0006zN-HZ for qemu-devel@nongnu.org; Tue, 21 Apr 2009 03:56:16 -0400 Received: from fg-out-1718.google.com ([72.14.220.155]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LwApy-00047m-Qy for qemu-devel@nongnu.org; Tue, 21 Apr 2009 03:56:15 -0400 Received: by fg-out-1718.google.com with SMTP id l27so565875fgb.8 for ; Tue, 21 Apr 2009 00:56:12 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 21 Apr 2009 09:56:12 +0200 Message-ID: <761ea48b0904210056w37100e85tcf71162c84e961d1@mail.gmail.com> Subject: Re: [Qemu-devel] [7118] linux-user: prefer glibc over direct syscalls From: Laurent Desnogues Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Wed, Apr 15, 2009 at 6:12 PM, Aurelien Jarno wrot= e: > Revision: 7118 > =A0 =A0 =A0 =A0 =A0http://svn.sv.gnu.org/viewvc/?view=3Drev&root=3Dqemu&r= evision=3D7118 > Author: =A0 aurel32 > Date: =A0 =A0 2009-04-15 16:12:13 +0000 (Wed, 15 Apr 2009) > Log Message: > ----------- > linux-user: prefer glibc over direct syscalls > > The openat/*at syscalls are incredibly common with modern coreutils, > calling them directly via syscalls breaks for example fakeroot. Use > glibc stubs whenever directly available and provide old syscall > calling for people still using older libc. > > Patch originally from Mika Westerberg, Adapted to > apply to current trunk and cleaned up by Riku Voipio. > > Signed-off-by: Riku Voipio > Signed-off-by: Aurelien Jarno > > Modified Paths: > -------------- > =A0 =A0trunk/configure > =A0 =A0trunk/linux-user/syscall.c [...] > +int > +main(void) > +{ > + =A0 =A0 =A0 /* try to unlink nonexisting file */ > + =A0 =A0 =A0 return (unlinkat(AT_FDCWD, "nonexistent_file", 0)); > +} > +EOF > + =A0if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then > + =A0 =A0atfile=3Dyes > + =A0fi > +fi [...] > Modified: trunk/linux-user/syscall.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- trunk/linux-user/syscall.c =A02009-04-15 16:12:06 UTC (rev 7117) > +++ trunk/linux-user/syscall.c =A02009-04-15 16:12:13 UTC (rev 7118) [...] > +#ifdef CONFIG_ATFILE > +/* > + * Host system seems to have atfile syscall stubs available. =A0We > + * now enable them one by one as specified by target syscall_nr.h. > + */ > + > +#ifdef TARGET_NR_faccessat > +static int sys_faccessat(int dirfd, const char *pathname, int mode, int = flags) > +{ > + =A0return (faccessat(dirfd, pathname, mode, flags)); > +} > +#endif > +#ifdef TARGET_NR_fchmodat > +static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, in= t flags) > +{ > + =A0return (fchmodat(dirfd, pathname, mode, flags)); > +} > +#endif > +#ifdef TARGET_NR_fchownat > +static int sys_fchownat(int dirfd, const char *pathname, uid_t owner, > + =A0 =A0gid_t group, int flags) > +{ > + =A0return (fchownat(dirfd, pathname, owner, group, flags)); > +} > +#endif > +#ifdef __NR_fstatat64 > +static int sys_fstatat64(int dirfd, const char *pathname, struct stat *b= uf, > + =A0 =A0int flags) > +{ > + =A0return (fstatat(dirfd, pathname, buf, flags)); > +} > +#endif > +#ifdef __NR_newfstatat > +static int sys_newfstatat(int dirfd, const char *pathname, struct stat *= buf, > + =A0 =A0int flags) > +{ > + =A0return (fstatat(dirfd, pathname, buf, flags)); > +} > +#endif > +#ifdef TARGET_NR_futimesat > +static int sys_futimesat(int dirfd, const char *pathname, > + =A0 =A0const struct timeval times[2]) > +{ > + =A0return (futimesat(dirfd, pathname, times)); > +} > +#endif > +#ifdef TARGET_NR_linkat > +static int sys_linkat(int olddirfd, const char *oldpath, > + =A0 =A0int newdirfd, const char *newpath, int flags) > +{ > + =A0return (linkat(olddirfd, oldpath, newdirfd, newpath, flags)); > +} > +#endif > +#ifdef TARGET_NR_mkdirat > +static int sys_mkdirat(int dirfd, const char *pathname, mode_t mode) > +{ > + =A0return (mkdirat(dirfd, pathname, mode)); > +} > +#endif > +#ifdef TARGET_NR_mknodat > +static int sys_mknodat(int dirfd, const char *pathname, mode_t mode, > + =A0 =A0dev_t dev) > +{ > + =A0return (mknodat(dirfd, pathname, mode, dev)); > +} > +#endif > +#ifdef TARGET_NR_openat > +static int sys_openat(int dirfd, const char *pathname, int flags, ...) > +{ > + =A0/* > + =A0 * open(2) has extra parameter 'mode' when called with > + =A0 * flag O_CREAT. > + =A0 */ > + =A0if ((flags & O_CREAT) !=3D 0) { > + =A0 =A0 =A0va_list ap; > + =A0 =A0 =A0mode_t mode; > + > + =A0 =A0 =A0/* > + =A0 =A0 =A0 * Get the 'mode' parameter and translate it to > + =A0 =A0 =A0 * host bits. > + =A0 =A0 =A0 */ > + =A0 =A0 =A0va_start(ap, flags); > + =A0 =A0 =A0mode =3D va_arg(ap, mode_t); > + =A0 =A0 =A0mode =3D target_to_host_bitmask(mode, fcntl_flags_tbl); > + =A0 =A0 =A0va_end(ap); > + > + =A0 =A0 =A0return (openat(dirfd, pathname, flags, mode)); > + =A0} > + =A0return (openat(dirfd, pathname, flags)); > +} > +#endif > +#ifdef TARGET_NR_readlinkat > +static int sys_readlinkat(int dirfd, const char *pathname, char *buf, si= ze_t bufsiz) > +{ > + =A0return (readlinkat(dirfd, pathname, buf, bufsiz)); > +} > +#endif > +#ifdef TARGET_NR_renameat > +static int sys_renameat(int olddirfd, const char *oldpath, > + =A0 =A0int newdirfd, const char *newpath) > +{ > + =A0return (renameat(olddirfd, oldpath, newdirfd, newpath)); > +} > +#endif > +#ifdef TARGET_NR_symlinkat > +static int sys_symlinkat(const char *oldpath, int newdirfd, const char *= newpath) > +{ > + =A0return (symlinkat(oldpath, newdirfd, newpath)); > +} > +#endif > +#ifdef TARGET_NR_unlinkat > +static int sys_unlinkat(int dirfd, const char *pathname, int flags) > +{ > + =A0return (unlinkat(dirfd, pathname, flags)); > +} > +#endif > +#ifdef TARGET_NR_utimensat > +static int sys_utimensat(int dirfd, const char *pathname, > + =A0 =A0const struct timespec times[2], int flags) > +{ > + =A0return (utimensat(dirfd, pathname, times, flags)); > +} > +#endif Just to point that my system has all *at functions except for utimensat. This breaks compilation. Shouldn't all *at functions be tested in the configure script? For the record I am running CentOS 5.3 x86_64. Laurent