[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [7118] linux-user: prefer glibc over direct syscalls
From: |
Laurent Desnogues |
Subject: |
Re: [Qemu-devel] [7118] linux-user: prefer glibc over direct syscalls |
Date: |
Tue, 21 Apr 2009 09:56:12 +0200 |
On Wed, Apr 15, 2009 at 6:12 PM, Aurelien Jarno <address@hidden> 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 <address@hidden>
> Signed-off-by: Aurelien Jarno <address@hidden>
>
> 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