]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/dquot.c
2 * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
47 static int dquot_f(int argc
, char **argv
);
48 static void dquot_help(void);
50 static const cmdinfo_t dquot_cmd
=
51 { "dquot", NULL
, dquot_f
, 1, 2, 1, "[gid|uid]",
52 "set current address to group or user quota block", dquot_help
};
54 const field_t dqblk_hfld
[] = {
55 { "", FLDT_DQBLK
, OI(0), C1
, 0, TYP_NONE
},
59 #define DDOFF(f) bitize(offsetof(xfs_dqblk_t, dd_ ## f))
60 #define DDSZC(f) szcount(xfs_dqblk_t, dd_ ## f)
61 const field_t dqblk_flds
[] = {
62 { "diskdq", FLDT_DISK_DQUOT
, OI(DDOFF(diskdq
)), C1
, 0, TYP_NONE
},
63 { "fill", FLDT_CHARS
, OI(DDOFF(fill
)), CI(DDSZC(fill
)), FLD_SKIPALL
,
68 #define DOFF(f) bitize(offsetof(xfs_disk_dquot_t, d_ ## f))
69 const field_t disk_dquot_flds
[] = {
70 { "magic", FLDT_UINT16X
, OI(DOFF(magic
)), C1
, 0, TYP_NONE
},
71 { "version", FLDT_UINT8X
, OI(DOFF(version
)), C1
, 0, TYP_NONE
},
72 { "flags", FLDT_UINT8X
, OI(DOFF(flags
)), C1
, 0, TYP_NONE
},
73 { "id", FLDT_DQID
, OI(DOFF(id
)), C1
, 0, TYP_NONE
},
74 { "blk_hardlimit", FLDT_QCNT
, OI(DOFF(blk_hardlimit
)), C1
, 0,
76 { "blk_softlimit", FLDT_QCNT
, OI(DOFF(blk_softlimit
)), C1
, 0,
78 { "ino_hardlimit", FLDT_QCNT
, OI(DOFF(ino_hardlimit
)), C1
, 0,
80 { "ino_softlimit", FLDT_QCNT
, OI(DOFF(ino_softlimit
)), C1
, 0,
82 { "bcount", FLDT_QCNT
, OI(DOFF(bcount
)), C1
, 0, TYP_NONE
},
83 { "icount", FLDT_QCNT
, OI(DOFF(icount
)), C1
, 0, TYP_NONE
},
84 { "itimer", FLDT_INT32D
, OI(DOFF(itimer
)), C1
, 0, TYP_NONE
},
85 { "btimer", FLDT_INT32D
, OI(DOFF(btimer
)), C1
, 0, TYP_NONE
},
86 { "iwarns", FLDT_QWARNCNT
, OI(DOFF(iwarns
)), C1
, 0, TYP_NONE
},
87 { "bwarns", FLDT_QWARNCNT
, OI(DOFF(bwarns
)), C1
, 0, TYP_NONE
},
88 { "pad0", FLDT_INT32D
, OI(DOFF(pad0
)), C1
, FLD_SKIPALL
, TYP_NONE
},
89 { "rtb_hardlimit", FLDT_QCNT
, OI(DOFF(rtb_hardlimit
)), C1
, 0,
91 { "rtb_softlimit", FLDT_QCNT
, OI(DOFF(rtb_softlimit
)), C1
, 0,
93 { "rtbcount", FLDT_QCNT
, OI(DOFF(rtbcount
)), C1
, 0, TYP_NONE
},
94 { "rtbtimer", FLDT_INT32D
, OI(DOFF(rtbtimer
)), C1
, 0, TYP_NONE
},
95 { "rtbwarns", FLDT_QWARNCNT
, OI(DOFF(rtbwarns
)), C1
, 0, TYP_NONE
},
96 { "pad", FLDT_UINT16X
, OI(DOFF(pad
)), C1
, FLD_SKIPALL
, TYP_NONE
},
123 while ((c
= getopt(argc
, argv
, "gu")) != EOF
) {
132 dbprintf("bad option for dquot command\n");
136 s
= dogrp
? "group" : "user";
137 if (optind
!= argc
- 1) {
138 dbprintf("dquot command requires one %s id argument\n", s
);
141 ino
= dogrp
? mp
->m_sb
.sb_gquotino
: mp
->m_sb
.sb_uquotino
;
142 if (ino
== 0 || ino
== NULLFSINO
) {
143 dbprintf("no %s quota inode present\n", s
);
146 id
= (xfs_dqid_t
)strtol(argv
[optind
], &p
, 0);
148 dbprintf("bad %s id for dquot %s\n", s
, argv
[optind
]);
151 perblock
= (int)(mp
->m_sb
.sb_blocksize
/ sizeof(xfs_dqblk_t
));
152 qbno
= (xfs_fileoff_t
)(id
/ perblock
);
153 qoff
= (int)(id
% perblock
);
157 bmap(qbno
, 1, XFS_DATA_FORK
, &nex
, &bm
);
160 dbprintf("no %s quota data for id %d\n", s
, id
);
163 set_cur(&typtab
[TYP_DQBLK
], XFS_FSB_TO_DADDR(mp
, bm
.startblock
), blkbb
,
165 off_cur(qoff
* (int)sizeof(xfs_dqblk_t
), sizeof(xfs_dqblk_t
));
173 add_command(&dquot_cmd
);