hurd: Stop mapping AT_NO_AUTOMOUNT to O_NOTRANS
[glibc.git] / login / getutid_r.c
blob00c078537d40229e4ab7a32383c23cd3771004b0
1 /* Copyright (C) 1996-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <libc-lock.h>
19 #include <errno.h>
20 #include <stdlib.h>
21 #include <utmp.h>
23 #include "utmp-private.h"
26 /* We have to use the lock in getutent_r.c. */
27 __libc_lock_define (extern, __libc_utmp_lock attribute_hidden)
30 int
31 __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
33 int retval;
35 /* Test whether ID has any of the legal types. */
36 if (id->ut_type != RUN_LVL && id->ut_type != BOOT_TIME
37 && id->ut_type != OLD_TIME && id->ut_type != NEW_TIME
38 && id->ut_type != INIT_PROCESS && id->ut_type != LOGIN_PROCESS
39 && id->ut_type != USER_PROCESS && id->ut_type != DEAD_PROCESS)
40 /* No, using '<' and '>' for the test is not possible. */
42 __set_errno (EINVAL);
43 *result = NULL;
44 return -1;
47 __libc_lock_lock (__libc_utmp_lock);
49 retval = __libc_getutid_r (id, buffer, result);
51 __libc_lock_unlock (__libc_utmp_lock);
53 return retval;
55 libc_hidden_def (__getutid_r)
56 weak_alias (__getutid_r, getutid_r)