mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Fix F_GETOWN on some Linux archs.
The syscall conventions on some Linux archs prevented F_GETOWN from working correctly in some situations. This can be rectified when using the new F_GETOWN_EX command.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2000, 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -23,6 +23,40 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <kernel-features.h>
|
||||
|
||||
|
||||
#ifdef __ASSUME_F_GETOWN_EX
|
||||
# define miss_F_GETOWN_EX 0
|
||||
#else
|
||||
static int miss_F_GETOWN_EX;
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
do_fcntl (int fd, int cmd, void *arg)
|
||||
{
|
||||
if (cmd != F_GETOWN || miss_F_GETOWN_EX)
|
||||
return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
|
||||
|
||||
INTERNAL_SYSCALL_DECL (err);
|
||||
struct f_owner_ex fex;
|
||||
int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex);
|
||||
if (!INTERNAL_SYSCALL_ERROR_P (res, err))
|
||||
return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
|
||||
|
||||
#ifndef __ASSUME_F_GETOWN_EX
|
||||
if (INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
|
||||
{
|
||||
res = INLINE_SYSCALL (fcntl, 3, fd, F_GETOWN, arg);
|
||||
miss_F_GETOWN_EX = 1;
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
__set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_CANCELLATION
|
||||
@ -36,7 +70,7 @@ __fcntl_nocancel (int fd, int cmd, ...)
|
||||
arg = va_arg (ap, void *);
|
||||
va_end (ap);
|
||||
|
||||
return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
|
||||
return do_fcntl (fd, cmd, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -52,11 +86,11 @@ __libc_fcntl (int fd, int cmd, ...)
|
||||
va_end (ap);
|
||||
|
||||
if (SINGLE_THREAD_P || cmd != F_SETLKW)
|
||||
return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
|
||||
return do_fcntl (fd, cmd, arg);
|
||||
|
||||
int oldtype = LIBC_CANCEL_ASYNC ();
|
||||
|
||||
int result = INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
|
||||
int result = do_fcntl (fd, cmd, arg);
|
||||
|
||||
LIBC_CANCEL_RESET (oldtype);
|
||||
|
||||
|
Reference in New Issue
Block a user