1
0

quota.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. /* This just represents the non-kernel parts of <linux/quota.h>.
  17. Copyright (C) 1998-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. /*
  31. * Copyright (c) 1982, 1986 Regents of the University of California.
  32. * All rights reserved.
  33. *
  34. * This code is derived from software contributed to Berkeley by
  35. * Robert Elz at The University of Melbourne.
  36. *
  37. * Redistribution and use in source and binary forms, with or without
  38. * modification, are permitted provided that the following conditions
  39. * are met:
  40. * 1. Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * 2. Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in the
  44. * documentation and/or other materials provided with the distribution.
  45. * 4. Neither the name of the University nor the names of its contributors
  46. * may be used to endorse or promote products derived from this software
  47. * without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. * SUCH DAMAGE.
  60. */
  61. #ifndef _SYS_QUOTA_H
  62. #define _SYS_QUOTA_H 1
  63. #include <features.h>
  64. #include <sys/types.h>
  65. #include <linux/quota.h>
  66. /*
  67. * Convert diskblocks to blocks and the other way around.
  68. * currently only to fool the BSD source. :-)
  69. */
  70. #define dbtob(num) ((num) << 10)
  71. #define btodb(num) ((num) >> 10)
  72. /*
  73. * Convert count of filesystem blocks to diskquota blocks, meant for
  74. * filesystems where i_blksize != 1024.
  75. */
  76. #define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / 1024)
  77. /*
  78. * Definitions for disk quotas imposed on the average user
  79. * (big brother finally hits Linux).
  80. *
  81. * The following constants define the amount of time given a user
  82. * before the soft limits are treated as hard limits (usually resulting
  83. * in an allocation failure). The timer is started when the user crosses
  84. * their soft limit, it is reset when they go below their soft limit.
  85. */
  86. #define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
  87. #define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
  88. #define QUOTAFILENAME "quota"
  89. #define QUOTAGROUP "staff"
  90. #define NR_DQHASH 43 /* Just an arbitrary number any suggestions ? */
  91. #define NR_DQUOTS 256 /* Number of quotas active at one time */
  92. /* Old name for struct if_dqblk. */
  93. struct dqblk
  94. {
  95. __uint64_t dqb_bhardlimit; /* absolute limit on disk quota blocks alloc */
  96. __uint64_t dqb_bsoftlimit; /* preferred limit on disk quota blocks */
  97. __uint64_t dqb_curspace; /* current quota block count */
  98. __uint64_t dqb_ihardlimit; /* maximum # allocated inodes */
  99. __uint64_t dqb_isoftlimit; /* preferred inode limit */
  100. __uint64_t dqb_curinodes; /* current # allocated inodes */
  101. __uint64_t dqb_btime; /* time limit for excessive disk use */
  102. __uint64_t dqb_itime; /* time limit for excessive files */
  103. __uint32_t dqb_valid; /* bitmask of QIF_* constants */
  104. };
  105. /*
  106. * Shorthand notation.
  107. */
  108. #define dq_bhardlimit dq_dqb.dqb_bhardlimit
  109. #define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
  110. #define dq_curspace dq_dqb.dqb_curspace
  111. #define dq_valid dq_dqb.dqb_valid
  112. #define dq_ihardlimit dq_dqb.dqb_ihardlimit
  113. #define dq_isoftlimit dq_dqb.dqb_isoftlimit
  114. #define dq_curinodes dq_dqb.dqb_curinodes
  115. #define dq_btime dq_dqb.dqb_btime
  116. #define dq_itime dq_dqb.dqb_itime
  117. #define dqoff(UID) ((__loff_t)((UID) * sizeof (struct dqblk)))
  118. /* Old name for struct if_dqinfo. */
  119. struct dqinfo
  120. {
  121. __uint64_t dqi_bgrace;
  122. __uint64_t dqi_igrace;
  123. __uint32_t dqi_flags;
  124. __uint32_t dqi_valid;
  125. };
  126. __BEGIN_DECLS
  127. extern int quotactl (int __cmd, const char *__special, int __id,
  128. __caddr_t __addr) __THROW;
  129. __END_DECLS
  130. #endif /* sys/quota.h */