qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Desnogues <laurent.desnogues@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [7118] linux-user: prefer glibc over direct syscalls
Date: Tue, 21 Apr 2009 09:56:12 +0200	[thread overview]
Message-ID: <761ea48b0904210056w37100e85tcf71162c84e961d1@mail.gmail.com> (raw)
In-Reply-To: <E1Lu7ig-0007Ez-1h@cvs.savannah.gnu.org>

On Wed, Apr 15, 2009 at 6:12 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> Revision: 7118
>          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7118
> Author:   aurel32
> Date:     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 <riku.voipio@iki.fi>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>
> Modified Paths:
> --------------
>    trunk/configure
>    trunk/linux-user/syscall.c
[...]
> +int
> +main(void)
> +{
> +       /* try to unlink nonexisting file */
> +       return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
> +}
> +EOF
> +  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
> +    atfile=yes
> +  fi
> +fi
[...]
> Modified: trunk/linux-user/syscall.c
> ===================================================================
> --- trunk/linux-user/syscall.c  2009-04-15 16:12:06 UTC (rev 7117)
> +++ trunk/linux-user/syscall.c  2009-04-15 16:12:13 UTC (rev 7118)
[...]
> +#ifdef CONFIG_ATFILE
> +/*
> + * Host system seems to have atfile syscall stubs available.  We
> + * 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)
> +{
> +  return (faccessat(dirfd, pathname, mode, flags));
> +}
> +#endif
> +#ifdef TARGET_NR_fchmodat
> +static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode, int flags)
> +{
> +  return (fchmodat(dirfd, pathname, mode, flags));
> +}
> +#endif
> +#ifdef TARGET_NR_fchownat
> +static int sys_fchownat(int dirfd, const char *pathname, uid_t owner,
> +    gid_t group, int flags)
> +{
> +  return (fchownat(dirfd, pathname, owner, group, flags));
> +}
> +#endif
> +#ifdef __NR_fstatat64
> +static int sys_fstatat64(int dirfd, const char *pathname, struct stat *buf,
> +    int flags)
> +{
> +  return (fstatat(dirfd, pathname, buf, flags));
> +}
> +#endif
> +#ifdef __NR_newfstatat
> +static int sys_newfstatat(int dirfd, const char *pathname, struct stat *buf,
> +    int flags)
> +{
> +  return (fstatat(dirfd, pathname, buf, flags));
> +}
> +#endif
> +#ifdef TARGET_NR_futimesat
> +static int sys_futimesat(int dirfd, const char *pathname,
> +    const struct timeval times[2])
> +{
> +  return (futimesat(dirfd, pathname, times));
> +}
> +#endif
> +#ifdef TARGET_NR_linkat
> +static int sys_linkat(int olddirfd, const char *oldpath,
> +    int newdirfd, const char *newpath, int flags)
> +{
> +  return (linkat(olddirfd, oldpath, newdirfd, newpath, flags));
> +}
> +#endif
> +#ifdef TARGET_NR_mkdirat
> +static int sys_mkdirat(int dirfd, const char *pathname, mode_t mode)
> +{
> +  return (mkdirat(dirfd, pathname, mode));
> +}
> +#endif
> +#ifdef TARGET_NR_mknodat
> +static int sys_mknodat(int dirfd, const char *pathname, mode_t mode,
> +    dev_t dev)
> +{
> +  return (mknodat(dirfd, pathname, mode, dev));
> +}
> +#endif
> +#ifdef TARGET_NR_openat
> +static int sys_openat(int dirfd, const char *pathname, int flags, ...)
> +{
> +  /*
> +   * open(2) has extra parameter 'mode' when called with
> +   * flag O_CREAT.
> +   */
> +  if ((flags & O_CREAT) != 0) {
> +      va_list ap;
> +      mode_t mode;
> +
> +      /*
> +       * Get the 'mode' parameter and translate it to
> +       * host bits.
> +       */
> +      va_start(ap, flags);
> +      mode = va_arg(ap, mode_t);
> +      mode = target_to_host_bitmask(mode, fcntl_flags_tbl);
> +      va_end(ap);
> +
> +      return (openat(dirfd, pathname, flags, mode));
> +  }
> +  return (openat(dirfd, pathname, flags));
> +}
> +#endif
> +#ifdef TARGET_NR_readlinkat
> +static int sys_readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz)
> +{
> +  return (readlinkat(dirfd, pathname, buf, bufsiz));
> +}
> +#endif
> +#ifdef TARGET_NR_renameat
> +static int sys_renameat(int olddirfd, const char *oldpath,
> +    int newdirfd, const char *newpath)
> +{
> +  return (renameat(olddirfd, oldpath, newdirfd, newpath));
> +}
> +#endif
> +#ifdef TARGET_NR_symlinkat
> +static int sys_symlinkat(const char *oldpath, int newdirfd, const char *newpath)
> +{
> +  return (symlinkat(oldpath, newdirfd, newpath));
> +}
> +#endif
> +#ifdef TARGET_NR_unlinkat
> +static int sys_unlinkat(int dirfd, const char *pathname, int flags)
> +{
> +  return (unlinkat(dirfd, pathname, flags));
> +}
> +#endif
> +#ifdef TARGET_NR_utimensat
> +static int sys_utimensat(int dirfd, const char *pathname,
> +    const struct timespec times[2], int flags)
> +{
> +  return (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

  parent reply	other threads:[~2009-04-21  7:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-15 16:12 [Qemu-devel] [7118] linux-user: prefer glibc over direct syscalls Aurelien Jarno
2009-04-15 19:21 ` Stefan Weil
2009-04-15 19:48   ` Aurelien Jarno
2009-04-16 15:25 ` Laurent Desnogues
2009-04-16 16:47   ` Riku Voipio
2009-04-17 13:51     ` Aurelien Jarno
2009-04-17  0:16 ` Paul Brook
2009-04-17  8:03   ` Riku Voipio
2009-04-21  7:56 ` Laurent Desnogues [this message]
2009-04-21  8:36   ` Arnaud Patard
2009-04-21  8:35     ` Laurent Desnogues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=761ea48b0904210056w37100e85tcf71162c84e961d1@mail.gmail.com \
    --to=laurent.desnogues@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).