freebsd_util.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*-
  2. * Copyright (c) 1991, 1993
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * @(#)queue.h 8.5 (Berkeley) 8/20/94
  30. * $FreeBSD$
  31. */
  32. #define TAILQ_HEAD(name, type) \
  33. struct name { \
  34. struct type *tqh_first; /* first element */ \
  35. struct type **tqh_last; /* addr of last next element */ \
  36. }
  37. #define TAILQ_ENTRY(type) \
  38. struct { \
  39. struct type *tqe_next; /* next element */ \
  40. struct type **tqe_prev; /* address of previous next element */ \
  41. }
  42. #define LIST_HEAD(name, type) \
  43. struct name { \
  44. struct type *lh_first; /* first element */ \
  45. }
  46. #define LIST_ENTRY(type) \
  47. struct { \
  48. struct type *le_next; /* next element */ \
  49. struct type **le_prev; /* address of previous next element */ \
  50. }
  51. typedef uint32_t uid_t; /* user id */
  52. typedef uint32_t gid_t; /* group id */
  53. typedef uint16_t nlink_t; /* link count */
  54. typedef uint16_t mode_t; /* permissions */
  55. typedef int64_t intmax_t; /* FIXME: This should probably be moved to <u.h> or replaced with a spatch */
  56. /*
  57. * User specifiable flags, stored in mnt_flag.
  58. */
  59. #define MNT_RDONLY 0x0000000000000001ULL /* read only filesystem */
  60. /*
  61. * External filesystem command modifier flags.
  62. * Unmount can use the MNT_FORCE flag.
  63. * XXX: These are not STATES and really should be somewhere else.
  64. * XXX: MNT_BYFSID and MNT_NONBUSY collide with MNT_ACLS and MNT_MULTILABEL,
  65. * but because MNT_ACLS and MNT_MULTILABEL are only used for mount(2),
  66. * and MNT_BYFSID and MNT_NONBUSY are only used for unmount(2),
  67. * it's harmless.
  68. */
  69. #define MNT_FORCE 0x0000000000080000ULL /* force unmount or readonly */
  70. /*
  71. * Flags set by internal operations,
  72. * but visible to the user.
  73. * XXX some of these are not quite right.. (I've never seen the root flag set)
  74. */
  75. #define MNT_LOCAL 0x0000000000001000ULL /* filesystem is stored locally */
  76. /*
  77. * Flags for various system call interfaces.
  78. *
  79. * waitfor flags to vfs_sync() and getfsstat()
  80. */
  81. #define MNT_WAIT 1 /* synchronously wait for I/O to complete */
  82. /*
  83. * Error codes used by UFS.
  84. * TODO HARVEY Translate to error strings.
  85. */
  86. #define EPERM 1 /* Operation not permitted */
  87. #define ENOENT 2 /* No such file or directory */
  88. #define EIO 5 /* Input/output error */
  89. #define EINVAL 22 /* Invalid argument */
  90. #define EFBIG 27 /* File too large */
  91. #define ENOSPC 28 /* No space left on device */
  92. #define EOVERFLOW 84 /* Value too large to be stored in data type */
  93. #define EJUSTRETURN (-2) /* don't modify regs, just return */
  94. #define S_IFMT 0170000 /* type of file */
  95. /*
  96. * Super-user changeable flags.
  97. */
  98. #define SF_SNAPSHOT 0x00200000 /* snapshot inode */