Mark Salyzyn | 4599627 | 2017-05-02 14:44:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* Miniature version of a header-only keyutils.h (no library required) */ |
| 18 | |
| 19 | #ifndef _INIT_KEYUTILS_H_ |
| 20 | #define _INIT_KEYUTILS_H_ |
| 21 | |
| 22 | #ifndef KEYUTILS_H /* walk away if the _real_ one exists */ |
| 23 | |
| 24 | #include <linux/keyctl.h> |
| 25 | #include <stdarg.h> |
| 26 | #include <sys/syscall.h> |
| 27 | #include <unistd.h> |
| 28 | |
| 29 | static inline long keyctl(int cmd, ...) { |
| 30 | va_list va; |
| 31 | unsigned long arg2, arg3, arg4, arg5; |
| 32 | |
| 33 | va_start(va, cmd); |
| 34 | arg2 = va_arg(va, unsigned long); |
| 35 | arg3 = va_arg(va, unsigned long); |
| 36 | arg4 = va_arg(va, unsigned long); |
| 37 | arg5 = va_arg(va, unsigned long); |
| 38 | va_end(va); |
| 39 | return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); |
| 40 | } |
| 41 | |
| 42 | #endif |
| 43 | |
| 44 | #endif |