1
0

openat2.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  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. /* openat2 definition. Linux specific.
  17. Copyright (C) 2025-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. #ifndef _FCNTL_H
  31. # error "Never use <bits/openat2.h> directly; include <fcntl.h> instead."
  32. #endif
  33. #ifndef __glibc_has_open_how
  34. /* Arguments for how openat2 should open the target path. */
  35. struct open_how
  36. {
  37. __uint64_t flags;
  38. __uint64_t mode;
  39. __uint64_t resolve;
  40. };
  41. #endif
  42. /* how->resolve flags for openat2. */
  43. #ifndef RESOLVE_NO_XDEV
  44. # define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings
  45. (includes bind-mounts). */
  46. #endif
  47. #ifndef RESOLVE_NO_MAGICLINKS
  48. # define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style
  49. "magic-links". */
  50. #endif
  51. #ifndef RESOLVE_NO_SYMLINKS
  52. # define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks. */
  53. #endif
  54. #ifndef RESOLVE_BENEATH
  55. # define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like
  56. "..", symlinks, and absolute
  57. paths which escape the dirfd. */
  58. #endif
  59. #ifndef RESOLVE_IN_ROOT
  60. # define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".."
  61. be scoped inside the dirfd
  62. (similar to chroot). */
  63. #endif
  64. #ifndef RESOLVE_CACHED
  65. # define RESOLVE_CACHED 0x20 /* Only complete if resolution can be
  66. completed through cached lookup. May
  67. return -EAGAIN if that's not
  68. possible. */
  69. #endif