Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
| 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 6 | * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org> |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * 3. The name of the author may not be used to endorse or promote products |
| 18 | * derived from this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
| 32 | #include "defs.h" |
| 33 | |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 34 | #define SUBCMDMASK 0x00ff |
| 35 | #define SUBCMDSHIFT 8 |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 36 | #define QCMD_CMD(cmd) ((uint32_t)(cmd) >> SUBCMDSHIFT) |
| 37 | #define QCMD_TYPE(cmd) ((uint32_t)(cmd) & SUBCMDMASK) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 38 | |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 39 | #define OLD_CMD(cmd) ((uint32_t)(cmd) << SUBCMDSHIFT) |
| 40 | #define NEW_CMD(cmd) ((uint32_t)(cmd) | 0x800000) |
| 41 | #define XQM_CMD(cmd) ((uint32_t)(cmd) | ('X' << SUBCMDSHIFT)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 42 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 43 | #include "xlat/quotacmds.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 44 | #include "xlat/quotatypes.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 45 | #include "xlat/quota_formats.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 46 | #include "xlat/xfs_quota_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 47 | #include "xlat/xfs_dqblk_flags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 48 | #include "xlat/if_dqblk_valid.h" |
Dmitry V. Levin | 60d4892 | 2016-01-19 02:10:23 +0000 | [diff] [blame] | 49 | #include "xlat/if_dqinfo_flags.h" |
Dmitry V. Levin | 2105a97 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 50 | #include "xlat/if_dqinfo_valid.h" |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 51 | |
| 52 | struct if_dqblk |
| 53 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 54 | uint64_t dqb_bhardlimit; |
| 55 | uint64_t dqb_bsoftlimit; |
| 56 | uint64_t dqb_curspace; |
| 57 | uint64_t dqb_ihardlimit; |
| 58 | uint64_t dqb_isoftlimit; |
| 59 | uint64_t dqb_curinodes; |
| 60 | uint64_t dqb_btime; |
| 61 | uint64_t dqb_itime; |
| 62 | uint32_t dqb_valid; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 63 | }; |
| 64 | |
Dmitry V. Levin | cca2e53 | 2016-03-29 01:15:24 +0000 | [diff] [blame] | 65 | struct if_nextdqblk { |
| 66 | uint64_t dqb_bhardlimit; |
| 67 | uint64_t dqb_bsoftlimit; |
| 68 | uint64_t dqb_curspace; |
| 69 | uint64_t dqb_ihardlimit; |
| 70 | uint64_t dqb_isoftlimit; |
| 71 | uint64_t dqb_curinodes; |
| 72 | uint64_t dqb_btime; |
| 73 | uint64_t dqb_itime; |
| 74 | uint32_t dqb_valid; |
| 75 | uint32_t dqb_id; |
| 76 | }; |
| 77 | |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 78 | struct v1_dqblk |
| 79 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 80 | uint32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */ |
| 81 | uint32_t dqb_bsoftlimit; /* preferred limit on disk blks */ |
| 82 | uint32_t dqb_curblocks; /* current block count */ |
| 83 | uint32_t dqb_ihardlimit; /* maximum # allocated inodes */ |
| 84 | uint32_t dqb_isoftlimit; /* preferred inode limit */ |
| 85 | uint32_t dqb_curinodes; /* current # allocated inodes */ |
| 86 | time_t dqb_btime; /* time limit for excessive disk use */ |
| 87 | time_t dqb_itime; /* time limit for excessive files */ |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | struct v2_dqblk |
| 91 | { |
| 92 | unsigned int dqb_ihardlimit; |
| 93 | unsigned int dqb_isoftlimit; |
| 94 | unsigned int dqb_curinodes; |
| 95 | unsigned int dqb_bhardlimit; |
| 96 | unsigned int dqb_bsoftlimit; |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 97 | uint64_t dqb_curspace; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 98 | time_t dqb_btime; |
| 99 | time_t dqb_itime; |
| 100 | }; |
| 101 | |
| 102 | struct xfs_dqblk |
| 103 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 104 | int8_t d_version; /* version of this structure */ |
| 105 | int8_t d_flags; /* XFS_{USER,PROJ,GROUP}_QUOTA */ |
| 106 | uint16_t d_fieldmask; /* field specifier */ |
| 107 | uint32_t d_id; /* user, project, or group ID */ |
| 108 | uint64_t d_blk_hardlimit; /* absolute limit on disk blks */ |
| 109 | uint64_t d_blk_softlimit; /* preferred limit on disk blks */ |
| 110 | uint64_t d_ino_hardlimit; /* maximum # allocated inodes */ |
| 111 | uint64_t d_ino_softlimit; /* preferred inode limit */ |
| 112 | uint64_t d_bcount; /* # disk blocks owned by the user */ |
| 113 | uint64_t d_icount; /* # inodes owned by the user */ |
| 114 | int32_t d_itimer; /* zero if within inode limits */ |
| 115 | int32_t d_btimer; /* similar to above; for disk blocks */ |
| 116 | uint16_t d_iwarns; /* # warnings issued wrt num inodes */ |
| 117 | uint16_t d_bwarns; /* # warnings issued wrt disk blocks */ |
| 118 | int32_t d_padding2; /* padding2 - for future use */ |
| 119 | uint64_t d_rtb_hardlimit; /* absolute limit on realtime blks */ |
| 120 | uint64_t d_rtb_softlimit; /* preferred limit on RT disk blks */ |
| 121 | uint64_t d_rtbcount; /* # realtime blocks owned */ |
| 122 | int32_t d_rtbtimer; /* similar to above; for RT disk blks */ |
| 123 | uint16_t d_rtbwarns; /* # warnings issued wrt RT disk blks */ |
| 124 | int16_t d_padding3; /* padding3 - for future use */ |
| 125 | char d_padding4[8]; /* yet more padding */ |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 128 | struct if_dqinfo |
| 129 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 130 | uint64_t dqi_bgrace; |
| 131 | uint64_t dqi_igrace; |
| 132 | uint32_t dqi_flags; |
| 133 | uint32_t dqi_valid; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | struct v2_dqinfo |
| 137 | { |
| 138 | unsigned int dqi_bgrace; |
| 139 | unsigned int dqi_igrace; |
| 140 | unsigned int dqi_flags; |
| 141 | unsigned int dqi_blocks; |
| 142 | unsigned int dqi_free_blk; |
| 143 | unsigned int dqi_free_entry; |
| 144 | }; |
| 145 | |
| 146 | struct v1_dqstats |
| 147 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 148 | uint32_t lookups; |
| 149 | uint32_t drops; |
| 150 | uint32_t reads; |
| 151 | uint32_t writes; |
| 152 | uint32_t cache_hits; |
| 153 | uint32_t allocated_dquots; |
| 154 | uint32_t free_dquots; |
| 155 | uint32_t syncs; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | struct v2_dqstats |
| 159 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 160 | uint32_t lookups; |
| 161 | uint32_t drops; |
| 162 | uint32_t reads; |
| 163 | uint32_t writes; |
| 164 | uint32_t cache_hits; |
| 165 | uint32_t allocated_dquots; |
| 166 | uint32_t free_dquots; |
| 167 | uint32_t syncs; |
| 168 | uint32_t version; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | typedef struct fs_qfilestat |
| 172 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 173 | uint64_t qfs_ino; /* inode number */ |
| 174 | uint64_t qfs_nblks; /* number of BBs 512-byte-blks */ |
| 175 | uint32_t qfs_nextents; /* number of extents */ |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 176 | } fs_qfilestat_t; |
| 177 | |
| 178 | struct xfs_dqstats |
| 179 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 180 | int8_t qs_version; /* version number for future changes */ |
| 181 | uint16_t qs_flags; /* XFS_QUOTA_{U,P,G}DQ_{ACCT,ENFD} */ |
| 182 | int8_t qs_pad; /* unused */ |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 183 | fs_qfilestat_t qs_uquota; /* user quota storage information */ |
| 184 | fs_qfilestat_t qs_gquota; /* group quota storage information */ |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 185 | uint32_t qs_incoredqs; /* number of dquots incore */ |
| 186 | int32_t qs_btimelimit; /* limit for blks timer */ |
| 187 | int32_t qs_itimelimit; /* limit for inodes timer */ |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 188 | int32_t qs_rtbtimelimit; /* limit for rt blks timer */ |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 189 | uint16_t qs_bwarnlimit; /* limit for num warnings */ |
| 190 | uint16_t qs_iwarnlimit; /* limit for num warnings */ |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 191 | }; |
| 192 | |
Dmitry V. Levin | ed22711 | 2016-01-19 21:48:59 +0000 | [diff] [blame] | 193 | struct fs_qfilestatv { |
| 194 | uint64_t qfs_ino, qfs_nblks; |
| 195 | uint32_t qfs_nextents, qfs_pad; |
| 196 | }; |
| 197 | |
| 198 | struct fs_quota_statv { |
| 199 | int8_t qs_version; |
| 200 | uint8_t qs_pad1; |
| 201 | uint16_t qs_flags; |
| 202 | uint32_t qs_incoredqs; |
| 203 | struct fs_qfilestatv qs_uquota; |
| 204 | struct fs_qfilestatv qs_gquota; |
| 205 | struct fs_qfilestatv qs_pquota; |
| 206 | int32_t qs_btimelimit; |
| 207 | int32_t qs_itimelimit; |
| 208 | int32_t qs_rtbtimelimit; |
| 209 | uint16_t qs_bwarnlimit; |
| 210 | uint16_t qs_iwarnlimit; |
| 211 | uint64_t qs_pad2[8]; |
| 212 | }; |
| 213 | |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 214 | static int |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 215 | decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 216 | { |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 217 | switch (cmd) { |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 218 | case Q_GETQUOTA: |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 219 | if (entering(tcp)) |
| 220 | return 0; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 221 | case Q_SETQUOTA: |
| 222 | { |
| 223 | struct if_dqblk dq; |
| 224 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 225 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 226 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 227 | tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit); |
| 228 | tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit); |
| 229 | tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace); |
| 230 | tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit); |
| 231 | tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit); |
| 232 | tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes); |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 233 | if (!abbrev(tcp)) { |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 234 | tprintf("btime=%" PRIu64 ", ", dq.dqb_btime); |
| 235 | tprintf("itime=%" PRIu64 ", ", dq.dqb_itime); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 236 | tprints("valid="); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 237 | printflags(if_dqblk_valid, |
| 238 | dq.dqb_valid, "QIF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 239 | tprints("}"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 240 | } else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 241 | tprints("...}"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 242 | break; |
| 243 | } |
Dmitry V. Levin | cca2e53 | 2016-03-29 01:15:24 +0000 | [diff] [blame] | 244 | case Q_GETNEXTQUOTA: |
| 245 | { |
| 246 | struct if_nextdqblk dq; |
| 247 | |
| 248 | if (entering(tcp)) |
| 249 | return 0; |
| 250 | if (umove_or_printaddr(tcp, data, &dq)) |
| 251 | break; |
| 252 | tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit); |
| 253 | tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit); |
| 254 | tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace); |
| 255 | tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit); |
| 256 | tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit); |
| 257 | tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes); |
| 258 | if (!abbrev(tcp)) { |
| 259 | tprintf("btime=%" PRIu64 ", ", dq.dqb_btime); |
| 260 | tprintf("itime=%" PRIu64 ", ", dq.dqb_itime); |
| 261 | tprints("valid="); |
| 262 | printflags(if_dqblk_valid, |
| 263 | dq.dqb_valid, "QIF_???"); |
| 264 | tprintf(", id=%u}", dq.dqb_id); |
| 265 | } else |
| 266 | tprintf("id=%u, ...}", dq.dqb_id); |
| 267 | break; |
| 268 | } |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 269 | case Q_V1_GETQUOTA: |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 270 | if (entering(tcp)) |
| 271 | return 0; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 272 | case Q_V1_SETQUOTA: |
| 273 | { |
| 274 | struct v1_dqblk dq; |
| 275 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 276 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 277 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 278 | tprintf("{bhardlimit=%u, ", dq.dqb_bhardlimit); |
| 279 | tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit); |
| 280 | tprintf("curblocks=%u, ", dq.dqb_curblocks); |
| 281 | tprintf("ihardlimit=%u, ", dq.dqb_ihardlimit); |
| 282 | tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit); |
| 283 | tprintf("curinodes=%u, ", dq.dqb_curinodes); |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 284 | tprintf("btime=%lu, ", (long) dq.dqb_btime); |
| 285 | tprintf("itime=%lu}", (long) dq.dqb_itime); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 286 | break; |
| 287 | } |
| 288 | case Q_V2_GETQUOTA: |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 289 | if (entering(tcp)) |
| 290 | return 0; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 291 | case Q_V2_SETQUOTA: |
| 292 | { |
| 293 | struct v2_dqblk dq; |
| 294 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 295 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 296 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 297 | tprintf("{ihardlimit=%u, ", dq.dqb_ihardlimit); |
| 298 | tprintf("isoftlimit=%u, ", dq.dqb_isoftlimit); |
| 299 | tprintf("curinodes=%u, ", dq.dqb_curinodes); |
| 300 | tprintf("bhardlimit=%u, ", dq.dqb_bhardlimit); |
| 301 | tprintf("bsoftlimit=%u, ", dq.dqb_bsoftlimit); |
| 302 | tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace); |
H.J. Lu | 0b315b6 | 2012-02-03 10:16:03 -0800 | [diff] [blame] | 303 | tprintf("btime=%lu, ", (long) dq.dqb_btime); |
| 304 | tprintf("itime=%lu}", (long) dq.dqb_itime); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 305 | break; |
| 306 | } |
| 307 | case Q_XGETQUOTA: |
Dmitry V. Levin | cca2e53 | 2016-03-29 01:15:24 +0000 | [diff] [blame] | 308 | case Q_XGETNEXTQUOTA: |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 309 | if (entering(tcp)) |
| 310 | return 0; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 311 | case Q_XSETQLIM: |
| 312 | { |
| 313 | struct xfs_dqblk dq; |
| 314 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 315 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 316 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 317 | tprintf("{version=%d, ", dq.d_version); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 318 | tprints("flags="); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 319 | printflags(xfs_dqblk_flags, |
Dmitry V. Levin | f77ca9c | 2016-05-16 22:28:31 +0000 | [diff] [blame] | 320 | (uint8_t) dq.d_flags, "XFS_???_QUOTA"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 321 | tprintf(", fieldmask=%#x, ", dq.d_fieldmask); |
| 322 | tprintf("id=%u, ", dq.d_id); |
| 323 | tprintf("blk_hardlimit=%" PRIu64 ", ", dq.d_blk_hardlimit); |
| 324 | tprintf("blk_softlimit=%" PRIu64 ", ", dq.d_blk_softlimit); |
| 325 | tprintf("ino_hardlimit=%" PRIu64 ", ", dq.d_ino_hardlimit); |
| 326 | tprintf("ino_softlimit=%" PRIu64 ", ", dq.d_ino_softlimit); |
| 327 | tprintf("bcount=%" PRIu64 ", ", dq.d_bcount); |
| 328 | tprintf("icount=%" PRIu64 ", ", dq.d_icount); |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 329 | if (!abbrev(tcp)) { |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 330 | tprintf("itimer=%d, ", dq.d_itimer); |
| 331 | tprintf("btimer=%d, ", dq.d_btimer); |
| 332 | tprintf("iwarns=%u, ", dq.d_iwarns); |
| 333 | tprintf("bwarns=%u, ", dq.d_bwarns); |
| 334 | tprintf("rtbcount=%" PRIu64 ", ", dq.d_rtbcount); |
| 335 | tprintf("rtbtimer=%d, ", dq.d_rtbtimer); |
| 336 | tprintf("rtbwarns=%u}", dq.d_rtbwarns); |
| 337 | } else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 338 | tprints("...}"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 339 | break; |
| 340 | } |
| 341 | case Q_GETFMT: |
| 342 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 343 | uint32_t fmt; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 344 | |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 345 | if (entering(tcp)) |
| 346 | return 0; |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 347 | if (umove_or_printaddr(tcp, data, &fmt)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 348 | break; |
Dmitry V. Levin | 6a9ac96 | 2016-01-18 21:34:42 +0000 | [diff] [blame] | 349 | tprints("["); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 350 | printxval(quota_formats, fmt, "QFMT_VFS_???"); |
Dmitry V. Levin | 6a9ac96 | 2016-01-18 21:34:42 +0000 | [diff] [blame] | 351 | tprints("]"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 352 | break; |
| 353 | } |
| 354 | case Q_GETINFO: |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 355 | if (entering(tcp)) |
| 356 | return 0; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 357 | case Q_SETINFO: |
| 358 | { |
| 359 | struct if_dqinfo dq; |
| 360 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 361 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 362 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 363 | tprintf("{bgrace=%" PRIu64 ", ", dq.dqi_bgrace); |
| 364 | tprintf("igrace=%" PRIu64 ", ", dq.dqi_igrace); |
Dmitry V. Levin | 60d4892 | 2016-01-19 02:10:23 +0000 | [diff] [blame] | 365 | tprints("flags="); |
| 366 | printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???"); |
| 367 | tprints(", valid="); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 368 | printflags(if_dqinfo_valid, dq.dqi_valid, "IIF_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 369 | tprints("}"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 370 | break; |
| 371 | } |
| 372 | case Q_V2_GETINFO: |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 373 | if (entering(tcp)) |
| 374 | return 0; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 375 | case Q_V2_SETINFO: |
| 376 | { |
| 377 | struct v2_dqinfo dq; |
| 378 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 379 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 380 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 381 | tprintf("{bgrace=%u, ", dq.dqi_bgrace); |
| 382 | tprintf("igrace=%u, ", dq.dqi_igrace); |
Dmitry V. Levin | 60d4892 | 2016-01-19 02:10:23 +0000 | [diff] [blame] | 383 | tprints("flags="); |
| 384 | printflags(if_dqinfo_flags, dq.dqi_flags, "DQF_???"); |
| 385 | tprintf(", blocks=%u, ", dq.dqi_blocks); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 386 | tprintf("free_blk=%u, ", dq.dqi_free_blk); |
| 387 | tprintf("free_entry=%u}", dq.dqi_free_entry); |
| 388 | break; |
| 389 | } |
| 390 | case Q_V1_GETSTATS: |
| 391 | { |
| 392 | struct v1_dqstats dq; |
| 393 | |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 394 | if (entering(tcp)) |
| 395 | return 0; |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 396 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 397 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 398 | tprintf("{lookups=%u, ", dq.lookups); |
| 399 | tprintf("drops=%u, ", dq.drops); |
| 400 | tprintf("reads=%u, ", dq.reads); |
| 401 | tprintf("writes=%u, ", dq.writes); |
| 402 | tprintf("cache_hits=%u, ", dq.cache_hits); |
| 403 | tprintf("allocated_dquots=%u, ", dq.allocated_dquots); |
| 404 | tprintf("free_dquots=%u, ", dq.free_dquots); |
| 405 | tprintf("syncs=%u}", dq.syncs); |
| 406 | break; |
| 407 | } |
| 408 | case Q_V2_GETSTATS: |
| 409 | { |
| 410 | struct v2_dqstats dq; |
| 411 | |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 412 | if (entering(tcp)) |
| 413 | return 0; |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 414 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 415 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 416 | tprintf("{lookups=%u, ", dq.lookups); |
| 417 | tprintf("drops=%u, ", dq.drops); |
| 418 | tprintf("reads=%u, ", dq.reads); |
| 419 | tprintf("writes=%u, ", dq.writes); |
| 420 | tprintf("cache_hits=%u, ", dq.cache_hits); |
| 421 | tprintf("allocated_dquots=%u, ", dq.allocated_dquots); |
| 422 | tprintf("free_dquots=%u, ", dq.free_dquots); |
| 423 | tprintf("syncs=%u, ", dq.syncs); |
| 424 | tprintf("version=%u}", dq.version); |
| 425 | break; |
| 426 | } |
| 427 | case Q_XGETQSTAT: |
| 428 | { |
| 429 | struct xfs_dqstats dq; |
| 430 | |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 431 | if (entering(tcp)) |
| 432 | return 0; |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 433 | if (umove_or_printaddr(tcp, data, &dq)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 434 | break; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 435 | tprintf("{version=%d, ", dq.qs_version); |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 436 | if (abbrev(tcp)) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 437 | tprints("...}"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 438 | break; |
| 439 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 440 | tprints("flags="); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 441 | printflags(xfs_quota_flags, |
| 442 | dq.qs_flags, "XFS_QUOTA_???"); |
| 443 | tprintf(", incoredqs=%u, ", dq.qs_incoredqs); |
| 444 | tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino); |
| 445 | tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks); |
| 446 | tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents); |
| 447 | tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino); |
| 448 | tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks); |
| 449 | tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents); |
| 450 | tprintf("btimelimit=%d, ", dq.qs_btimelimit); |
| 451 | tprintf("itimelimit=%d, ", dq.qs_itimelimit); |
| 452 | tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit); |
| 453 | tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit); |
| 454 | tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit); |
| 455 | break; |
| 456 | } |
Dmitry V. Levin | ed22711 | 2016-01-19 21:48:59 +0000 | [diff] [blame] | 457 | case Q_XGETQSTATV: |
| 458 | { |
| 459 | struct fs_quota_statv dq; |
| 460 | |
| 461 | if (entering(tcp)) |
| 462 | return 0; |
| 463 | if (umove_or_printaddr(tcp, data, &dq)) |
| 464 | break; |
| 465 | tprintf("{version=%d, ", dq.qs_version); |
| 466 | if (abbrev(tcp)) { |
| 467 | tprints("...}"); |
| 468 | break; |
| 469 | } |
| 470 | tprints("flags="); |
| 471 | printflags(xfs_quota_flags, |
| 472 | dq.qs_flags, "XFS_QUOTA_???"); |
| 473 | tprintf(", incoredqs=%u, ", dq.qs_incoredqs); |
| 474 | tprintf("u_ino=%" PRIu64 ", ", dq.qs_uquota.qfs_ino); |
| 475 | tprintf("u_nblks=%" PRIu64 ", ", dq.qs_uquota.qfs_nblks); |
| 476 | tprintf("u_nextents=%u, ", dq.qs_uquota.qfs_nextents); |
| 477 | tprintf("g_ino=%" PRIu64 ", ", dq.qs_gquota.qfs_ino); |
| 478 | tprintf("g_nblks=%" PRIu64 ", ", dq.qs_gquota.qfs_nblks); |
| 479 | tprintf("g_nextents=%u, ", dq.qs_gquota.qfs_nextents); |
| 480 | tprintf("p_ino=%" PRIu64 ", ", dq.qs_pquota.qfs_ino); |
| 481 | tprintf("p_nblks=%" PRIu64 ", ", dq.qs_pquota.qfs_nblks); |
| 482 | tprintf("p_nextents=%u, ", dq.qs_pquota.qfs_nextents); |
| 483 | tprintf("btimelimit=%d, ", dq.qs_btimelimit); |
| 484 | tprintf("itimelimit=%d, ", dq.qs_itimelimit); |
| 485 | tprintf("rtbtimelimit=%d, ", dq.qs_rtbtimelimit); |
| 486 | tprintf("bwarnlimit=%u, ", dq.qs_bwarnlimit); |
| 487 | tprintf("iwarnlimit=%u}", dq.qs_iwarnlimit); |
| 488 | break; |
| 489 | } |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 490 | case Q_XQUOTAON: |
Dmitry V. Levin | 7ea48d6 | 2016-01-18 21:41:22 +0000 | [diff] [blame] | 491 | case Q_XQUOTAOFF: |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 492 | { |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 493 | uint32_t flag; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 494 | |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 495 | if (umove_or_printaddr(tcp, data, &flag)) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 496 | break; |
Dmitry V. Levin | 6a9ac96 | 2016-01-18 21:34:42 +0000 | [diff] [blame] | 497 | tprints("["); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 498 | printflags(xfs_quota_flags, flag, "XFS_QUOTA_???"); |
Dmitry V. Levin | 6a9ac96 | 2016-01-18 21:34:42 +0000 | [diff] [blame] | 499 | tprints("]"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 500 | break; |
| 501 | } |
| 502 | default: |
Dmitry V. Levin | 0564623 | 2015-07-17 17:35:07 +0000 | [diff] [blame] | 503 | printaddr(data); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 504 | break; |
| 505 | } |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 506 | return RVAL_DECODED; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 509 | SYS_FUNC(quotactl) |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 510 | { |
| 511 | /* |
| 512 | * The Linux kernel only looks at the low 32 bits of command and id |
| 513 | * arguments, but on some 64-bit architectures (s390x) this word |
| 514 | * will have been sign-extended when we see it. The high 1 bits |
| 515 | * don't mean anything, so don't confuse the output with them. |
| 516 | */ |
Dmitry V. Levin | 0894194 | 2016-01-16 22:50:09 +0000 | [diff] [blame] | 517 | uint32_t qcmd = tcp->u_arg[0]; |
| 518 | uint32_t cmd = QCMD_CMD(qcmd); |
| 519 | uint32_t type = QCMD_TYPE(qcmd); |
| 520 | uint32_t id = tcp->u_arg[2]; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 521 | |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 522 | if (entering(tcp)) { |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 523 | printxval(quotacmds, cmd, "Q_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 524 | tprints("|"); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 525 | printxval(quotatypes, type, "???QUOTA"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 526 | tprints(", "); |
Dmitry V. Levin | 7943966 | 2012-10-26 23:43:13 +0000 | [diff] [blame] | 527 | printpath(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 528 | tprints(", "); |
Denys Vlasenko | 7b609d5 | 2011-06-22 14:32:43 +0200 | [diff] [blame] | 529 | switch (cmd) { |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 530 | case Q_QUOTAON: |
Dmitry V. Levin | b176920 | 2016-01-18 21:53:54 +0000 | [diff] [blame] | 531 | case Q_V1_QUOTAON: |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 532 | printxval(quota_formats, id, "QFMT_VFS_???"); |
Dmitry V. Levin | b176920 | 2016-01-18 21:53:54 +0000 | [diff] [blame] | 533 | tprints(", "); |
| 534 | printpath(tcp, tcp->u_arg[3]); |
| 535 | return RVAL_DECODED; |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 536 | } |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 537 | tprintf("%u, ", id); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 538 | } |
Dmitry V. Levin | c02fd61 | 2016-01-19 01:15:49 +0000 | [diff] [blame] | 539 | return decode_cmd_data(tcp, cmd, tcp->u_arg[3]); |
Dmitry V. Levin | ef5c3d6 | 2006-10-16 00:26:47 +0000 | [diff] [blame] | 540 | } |