missing.h revision 9388e99e208a6487b26dcbda86005ee9eba8d93d
fb0951b02ebf51a93acf12721d8857d31ce57ba3Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#pragma once
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers/***
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering This file is part of systemd.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering Copyright 2010 Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering systemd is free software; you can redistribute it and/or modify it
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering under the terms of the GNU Lesser General Public License as published by
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering (at your option) any later version.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering systemd is distributed in the hope that it will be useful, but
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering Lesser General Public License for more details.
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón You should have received a copy of the GNU Lesser General Public License
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón along with systemd; If not, see <http://www.gnu.org/licenses/>.
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón***/
cd4010b37349413db1e553e213e62e654ca28113Lennart Poettering
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón/* Missing glibc definitions to access certain kernel APIs */
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón
4e949c11a1df4547d5f102e4131e07b026369cd7Javier Jardón#include <sys/resource.h>
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#include <sys/syscall.h>
78a825f216d39ee0295b00647b059d45467e1d02Kay Sievers#include <fcntl.h>
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#include <stdlib.h>
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#include <unistd.h>
a80db8bd5f7f15859e8891aab9fc3694ce4cd0bdJavier Jardón#include <linux/oom.h>
a80db8bd5f7f15859e8891aab9fc3694ce4cd0bdJavier Jardón
4db6d587c37c0357d20c79bf1a7c9afd4c7ced61Kay Sievers#ifdef HAVE_AUDIT
907dd1953b7517534d646f5b2777780020c896e2Kay Sievers#include <libaudit.h>
eb7bbee6cd182d5c4eb1e1180631c35158f59379Kay Sievers#endif
6aad7f2cd75c88f990c7857bb173b3e8d0faee0fUmut Tezduyar Lindskog
bbd9b8c2139a70005e4e83d198575e2a10fe1db2Lennart Poettering#include "macro.h"
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#ifdef ARCH_MIPS
22be093ffb403a1c474037939ca9b88b1ee39f77Lennart Poettering#include <asm/sgidefs.h>
d59d0a2b4b41a75eaf618b26b8f8bd1e17de7e2bcee#endif
d59d0a2b4b41a75eaf618b26b8f8bd1e17de7e2bcee
d59d0a2b4b41a75eaf618b26b8f8bd1e17de7e2bcee#ifndef RLIMIT_RTTIME
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#define RLIMIT_RTTIME 15
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers#endif
8666abb452db73d9a11ead61251eec42bc531cceKay Sievers
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#ifndef F_LINUX_SPECIFIC_BASE
5e63ce78b5018ba612e794a610a6f13c5eefade7Cristian Rodríguez#define F_LINUX_SPECIFIC_BASE 1024
3d585edbb14b9705c80183aeb16dfd0a28df0ac9Lennart Poettering#endif
5e63ce78b5018ba612e794a610a6f13c5eefade7Cristian Rodríguez
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera#ifndef F_SETPIPE_SZ
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera#endif
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera#ifndef F_GETPIPE_SZ
1c7dde3e475978c569a982d65fd86d4b4e3caad8Bastien Nocera#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering#endif
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering#ifndef IP_FREEBIND
3ce4fad8f548db9edb19869ea540e3192d2123f4Kay Sievers#define IP_FREEBIND 15
f975e971accc4d50c73ae53167db3df7a7099cf2Lennart Poettering#endif
e9da3678fcfc774b325dc1eaa054d0e00028a1fcLennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#ifndef OOM_SCORE_ADJ_MIN
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#define OOM_SCORE_ADJ_MIN (-1000)
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#endif
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#ifndef OOM_SCORE_ADJ_MAX
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers#define OOM_SCORE_ADJ_MAX 1000
fe1fed02c7637a2c18cd575f78be7fda27972148Zbigniew Jędrzejewski-Szmek#endif
92ec4495f76a7a2a6c31f5bb2a5240f78dcfe1d2Javier Jardón
86b2e20a5e5abf222fb81edcb5d58d012e35cbaaLennart Poettering#ifndef AUDIT_SERVICE_START
86b2e20a5e5abf222fb81edcb5d58d012e35cbaaLennart Poettering#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
b51fc639f01ee6194af3e7e944a79accce474fe1Dave Reisner#endif
86b2e20a5e5abf222fb81edcb5d58d012e35cbaaLennart Poettering
86b2e20a5e5abf222fb81edcb5d58d012e35cbaaLennart Poettering#ifndef AUDIT_SERVICE_STOP
c1c02e07ed87e027a6364c4f4aa2468796ca1c56Dave Reisner#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
96ede2601f27cd5fe52eed96b873bef55cd0ce23Lennart Poettering#endif
edeb68c53f1cdc452016b4c8512586a70b1262e3Tom Gundersen
edeb68c53f1cdc452016b4c8512586a70b1262e3Tom Gundersen#ifndef TIOCVHANGUP
7801356442578ff6e1c65844eb9e65c819af4660Zbigniew Jędrzejewski-Szmek#define TIOCVHANGUP 0x5437
7801356442578ff6e1c65844eb9e65c819af4660Zbigniew Jędrzejewski-Szmek#endif
80a5cbace45a6adbf2f9119edc5a4b10db493064Kay Sievers
b37250d661ed67d07c734630617d73e64f6d7e49Zbigniew Jędrzejewski-Szmek#ifndef IP_TRANSPARENT
b37250d661ed67d07c734630617d73e64f6d7e49Zbigniew Jędrzejewski-Szmek#define IP_TRANSPARENT 19
6581f00f7eabdaccf587a4b6af60ed4696dd2791Zbigniew Jędrzejewski-Szmek#endif
6581f00f7eabdaccf587a4b6af60ed4696dd2791Zbigniew Jędrzejewski-Szmek
92ec4495f76a7a2a6c31f5bb2a5240f78dcfe1d2Javier Jardón#if !HAVE_DECL_PIVOT_ROOT
fe1fed02c7637a2c18cd575f78be7fda27972148Zbigniew Jędrzejewski-Szmekstatic inline int pivot_root(const char *new_root, const char *put_old) {
fe1fed02c7637a2c18cd575f78be7fda27972148Zbigniew Jędrzejewski-Szmek return syscall(SYS_pivot_root, new_root, put_old);
fe1fed02c7637a2c18cd575f78be7fda27972148Zbigniew Jędrzejewski-Szmek}
fe1fed02c7637a2c18cd575f78be7fda27972148Zbigniew Jędrzejewski-Szmek#endif
6e92b23f0d6dd398848376bbaf47e54a90ed3389Kay Sievers
0eaeca1f2373a323b98c86b47561d98e59c67b25Kay Sievers#ifdef __x86_64__
d66ee73a3dd7b5433fc0da3125bbdff740de7745Zbigniew Jędrzejewski-Szmek# ifndef __NR_fanotify_init
d66ee73a3dd7b5433fc0da3125bbdff740de7745Zbigniew Jędrzejewski-Szmek# define __NR_fanotify_init 300
d66ee73a3dd7b5433fc0da3125bbdff740de7745Zbigniew Jędrzejewski-Szmek# endif
3e2147858f21943d5f4a781c60f33ac22c6096edKay Sievers# ifndef __NR_fanotify_mark
ac714a78fdca481488d88f84b6332d28083a4511Martin Jansa# define __NR_fanotify_mark 301
ac714a78fdca481488d88f84b6332d28083a4511Martin Jansa# endif
b62cfcea00862ccbf0e5e297f8a339f70987edefMichael Biebl#elif defined _MIPS_SIM
b62cfcea00862ccbf0e5e297f8a339f70987edefMichael Biebl# if _MIPS_SIM == _MIPS_SIM_ABI32
b62cfcea00862ccbf0e5e297f8a339f70987edefMichael Biebl# ifndef __NR_fanotify_init
9a60da2834074d970ca063c210fe9d2f05c70532Thierry Reding# define __NR_fanotify_init 4336
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# endif
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# ifndef __NR_fanotify_mark
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# define __NR_fanotify_mark 4337
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# endif
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# elif _MIPS_SIM == _MIPS_SIM_NABI32
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# ifndef __NR_fanotify_init
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# define __NR_fanotify_init 6300
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# endif
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# ifndef __NR_fanotify_mark
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# define __NR_fanotify_mark 6301
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# endif
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# elif _MIPS_SIM == _MIPS_SIM_ABI64
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# ifndef __NR_fanotify_init
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek# define __NR_fanotify_init 5295
eb2e280f9c59b66965c9316eadc4c113a13ca744Lucas De Marchi# endif
be1a67d9d63bfdd4a5f8ba9cfc804030f10f5833Lennart Poettering# ifndef __NR_fanotify_mark
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# define __NR_fanotify_mark 5296
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# endif
27765dfc7a32d790badb29e6498b34edb0b60c33Lennart Poettering# endif
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#else
780040dc2a4b08a2c1fe5bd8db3a70e966c2acb3Kay Sievers# ifndef __NR_fanotify_init
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# define __NR_fanotify_init 338
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# endif
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# ifndef __NR_fanotify_mark
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# define __NR_fanotify_mark 339
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering# endif
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#endif
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#ifndef HAVE_FANOTIFY_INIT
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringstatic inline int fanotify_init(unsigned int flags, unsigned int event_f_flags) {
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering return syscall(__NR_fanotify_init, flags, event_f_flags);
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering}
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#endif
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#ifndef HAVE_FANOTIFY_MARK
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poetteringstatic inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t mask,
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering int dfd, const char *pathname) {
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#if defined _MIPS_SIM && _MIPS_SIM == _MIPS_SIM_ABI32 || defined __powerpc__ && !defined __powerpc64__
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering union {
be1a67d9d63bfdd4a5f8ba9cfc804030f10f5833Lennart Poettering uint64_t _64;
be1a67d9d63bfdd4a5f8ba9cfc804030f10f5833Lennart Poettering uint32_t _32[2];
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering } _mask;
be1a67d9d63bfdd4a5f8ba9cfc804030f10f5833Lennart Poettering _mask._64 = mask;
8745297f9853c4a17bac69e1b7e652fe81bc1940Lennart Poettering
d200735e13c52dcfe36c0e066f9f6c2fbfb85a9cMichal Schmidt return syscall(__NR_fanotify_mark, fanotify_fd, flags,
be1a67d9d63bfdd4a5f8ba9cfc804030f10f5833Lennart Poettering _mask._32[0], _mask._32[1], dfd, pathname);
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#else
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
9f64229f9ca69f5652b238a67531432e56108bd6Zbigniew Jędrzejewski-Szmek#endif
9b85fc6a89386582bfe792dba881800b0a093839Gustavo Sverzut Barbieri}
9b85fc6a89386582bfe792dba881800b0a093839Gustavo Sverzut Barbieri#endif
9b85fc6a89386582bfe792dba881800b0a093839Gustavo Sverzut Barbieri
5a45a93627609451784a04366cfa1150d32611d1Lennart Poettering#ifndef BTRFS_IOCTL_MAGIC
c1663b9daf5a43425e54bbe3daf6b10e64578f80Lennart Poettering#define BTRFS_IOCTL_MAGIC 0x94
c1663b9daf5a43425e54bbe3daf6b10e64578f80Lennart Poettering#endif
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek
5a45a93627609451784a04366cfa1150d32611d1Lennart Poettering#ifndef BTRFS_PATH_NAME_MAX
03a170c03cd4a09721369ece48affb70d66c6b90Kay Sievers#define BTRFS_PATH_NAME_MAX 4087
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#endif
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmekstruct btrfs_ioctl_vol_args {
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek int64_t fd;
9e7adc3ae1133fa08a468768a490812299fad030Lucas De Marchi char name[BTRFS_PATH_NAME_MAX + 1];
9e7adc3ae1133fa08a468768a490812299fad030Lucas De Marchi};
9b85fc6a89386582bfe792dba881800b0a093839Gustavo Sverzut Barbieri
9d2d0fe1e3f28a639c26b62391f79cfd1450d91bEvangelos Foutras#ifndef BTRFS_IOC_DEFRAG
5a45a93627609451784a04366cfa1150d32611d1Lennart Poettering#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, struct btrfs_ioctl_vol_args)
5a45a93627609451784a04366cfa1150d32611d1Lennart Poettering#endif
5a45a93627609451784a04366cfa1150d32611d1Lennart Poettering
732bfe09aeffc3cd78b80ee9e20c9c3babd944d6Zbigniew Jędrzejewski-Szmek#ifndef BTRFS_SUPER_MAGIC
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering#define BTRFS_SUPER_MAGIC 0x9123683E
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#endif
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#ifndef MS_MOVE
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#define MS_MOVE 8192
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#endif
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#ifndef MS_PRIVATE
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#define MS_PRIVATE (1 << 18)
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#endif
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#if !HAVE_DECL_GETTID
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmekstatic inline pid_t gettid(void) {
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek return (pid_t) syscall(SYS_gettid);
25ee45f9953c121fc26a54a85ad7bb3a3180152bMichael Biebl}
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#endif
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#ifndef SCM_SECURITY
1864b0e39505cd44a98eee61c97916b86491c0b4Zbigniew Jędrzejewski-Szmek#define SCM_SECURITY 0x03
1864b0e39505cd44a98eee61c97916b86491c0b4Zbigniew Jędrzejewski-Szmek#endif
1864b0e39505cd44a98eee61c97916b86491c0b4Zbigniew Jędrzejewski-Szmek
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#ifndef MS_STRICTATIME
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#define MS_STRICTATIME (1<<24)
1864b0e39505cd44a98eee61c97916b86491c0b4Zbigniew Jędrzejewski-Szmek#endif
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#ifndef PR_SET_NO_NEW_PRIVS
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#define PR_SET_NO_NEW_PRIVS 38
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#endif
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#ifndef PR_SET_CHILD_SUBREAPER
a6c0b31d509f76023d8efbcd5e912863c8fb254cZbigniew Jędrzejewski-Szmek#define PR_SET_CHILD_SUBREAPER 36
f2ec0646aba7c6703a6c79603957e805b74c3befZbigniew Jędrzejewski-Szmek#endif
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#ifndef MAX_HANDLE_SZ
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#define MAX_HANDLE_SZ 128
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek#endif
c937e0d5c579863677e0fcb5508517f7714c332dZbigniew Jędrzejewski-Szmek
afea26ad7d406d8b6c95d2642cb5a1d807b87546Lennart Poettering#ifdef __x86_64__
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sievers# ifndef __NR_name_to_handle_at
4b357e15876b730343db08719c877fdb45b6ad42Michael Marineau# define __NR_name_to_handle_at 303
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sievers# endif
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sievers#else
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sievers# ifndef __NR_name_to_handle_at
85f19d825e7504676f3a80c78c1d9a7ec35a3b3fMichael Biebl# define __NR_name_to_handle_at 341
85f19d825e7504676f3a80c78c1d9a7ec35a3b3fMichael Biebl# endif
85f19d825e7504676f3a80c78c1d9a7ec35a3b3fMichael Biebl#endif
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering
85f19d825e7504676f3a80c78c1d9a7ec35a3b3fMichael Biebl#if !HAVE_DECL_NAME_TO_HANDLE_AT
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sieversstruct file_handle {
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sievers unsigned int handle_bytes;
7959ff9914a6f3a59dbff95c199bcc540b70ac94Kay Sievers int handle_type;
fba1ea06bb5b653e9eb0cc1b6004af8da273a4abShawn Landden unsigned char f_handle[0];
fba1ea06bb5b653e9eb0cc1b6004af8da273a4abShawn Landden};
fba1ea06bb5b653e9eb0cc1b6004af8da273a4abShawn Landden
85f19d825e7504676f3a80c78c1d9a7ec35a3b3fMichael Bieblstatic inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) {
47be870bd83fb3719dffc3ee9348a409ab762a14Lennart Poettering return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags);
9388e99e208a6487b26dcbda86005ee9eba8d93dMichael Olbrich}
4db17f291c627c885de668200ff8cce2e57c933fZbigniew Jędrzejewski-Szmek#endif
9388e99e208a6487b26dcbda86005ee9eba8d93dMichael Olbrich
a8348796c0d39435b1c3d85ce6e95dad1ac85fecLennart Poettering#ifndef HAVE_SECURE_GETENV
9388e99e208a6487b26dcbda86005ee9eba8d93dMichael Olbrich# ifdef HAVE___SECURE_GETENV
9388e99e208a6487b26dcbda86005ee9eba8d93dMichael Olbrich# define secure_getenv __secure_getenv
a8348796c0d39435b1c3d85ce6e95dad1ac85fecLennart Poettering# else
b237ef2cfac7ab0b33170809e8cb64628606207dTollef Fog Heen# error neither secure_getenv nor __secure_getenv are available
a9b5b03212f9c854938483b8901e433c2ba6619bMichael Tremer# endif
d1ab0ca07372649dad70a0348d75e394f254e1b6Lennart Poettering#endif
2270309471213a3c960543e523130627e9cb10e2Kay Sievers