Debian Codegraph @

contrib/aix_jfs2_class/jfs2class.xs

raw
1 /*
2 * Perl interface to quota classes on JFS2 (AIX 5.3)
3 *
4 * This code is untested by me and reportedly not functional yet.
5 * It's just provided as possible basis for further development.
6 *
7 * Copyright (C) 2007 Tom Zoerner.
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it either under the terms of the Perl Artistic License or the GNU
11 * General Public License as published by the Free Software Foundation.
12 * (Either version 2 of the GPL, or any later version.)
13 * For a copy of these licenses see <http://www.opensource.org/licenses/>.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * Perl Artistic License or GNU General Public License for more details.
19 */
20
21 MODULE = Quota PACKAGE = Quota::JFS2CLASS
22
23 void
24 jfs2_getlimit(dev,class)
25 char * dev
26 int class
27 PPCODE:
28 #if defined(HAVE_JFS2)
29 if (strncmp(dev, "(JFS2)", 6) == 0) {
30 j2qlimit_t j2q;
31 int retval;
32
33 memset(&j2q, 0, sizeof(j2q));
34 retval = quotactl (dev + 6, Q_J2GETLIMIT, class, (caddr_t)&j2q);
35 if (retval == 0) {
36 EXTEND(sp, 8);
37 PUSHs(sv_2mortal(newSViv(j2q.ql_bsoft)));
38 PUSHs(sv_2mortal(newSViv(j2q.ql_bhard)));
39 PUSHs(sv_2mortal(newSViv(j2q.ql_btime)));
40
41 PUSHs(sv_2mortal(newSViv(j2q.ql_isoft)));
42 PUSHs(sv_2mortal(newSViv(j2q.ql_ihard)));
43 PUSHs(sv_2mortal(newSViv(j2q.ql_itime)));
44 }
45 } else
46 #endif /* HAVE_JFS2 */
47 {
48 errno = ENOENT;
49 }
50
51 int
52 jfs2_putlimit(dev,class,bs,bh,bt,fs,fh,ft)
53 char * dev
54 int class
55 int bs
56 int bh
57 int bt
58 int fs
59 int fh
60 int ft
61 CODE:
62 #if defined(HAVE_JFS2)
63 if (strncmp(dev, "(JFS2)", 6) == 0) {
64 j2qlimit_t j2q;
65 memset(&j2q, 0, sizeof(j2q));
66 j2q.ql_bsoft = bs;
67 j2q.ql_bhard = bh;
68 j2q.ql_btime = bt;
69
70 j2q.ql_isoft = fs;
71 j2q.ql_ihard = fh;
72 j2q.ql_itime = ft;
73 RETVAL = quotactl (dev + 6, Q_J2PUTLIMIT, class, (caddr_t)&j2q);
74 } else
75 #endif /* HAVE_JFS2 */
76 {
77 RETVAL = -1;
78 errno = ENOENT;
79 }
80 OUTPUT:
81 RETVAL
82
83 void
84 jfs2_newlimit(dev,bs,bh,bt,fs,fh,ft)
85 char * dev
86 int bs
87 int bh
88 int bt
89 int fs
90 int fh
91 int ft
92 PPCODE:
93 #if defined(HAVE_JFS2)
94 if (strncmp(dev, "(JFS2)", 6) == 0) {
95 j2qlimit_t j2q;
96 uid_t class;
97 int retval;
98
99 memset(&j2q, 0, sizeof(j2q));
100 j2q.ql_bsoft = bs;
101 j2q.ql_bhard = bh;
102 j2q.ql_btime = bt;
103
104 j2q.ql_isoft = fs;
105 j2q.ql_ihard = fh;
106 j2q.ql_itime = ft;
107
108 retval = quotactl (dev + 6, Q_J2NEWLIMIT, 0, (caddr_t)&j2q);
109 if (retval == 0) {
110 EXTEND(sp, 1);
111 class = *( (uid_t*) &j2q );
112 PUSHs(sv_2mortal(newSViv(class)));
113 }
114 } else
115 #endif /* HAVE_JFS2 */
116 {
117 errno = ENOENT;
118 }
119
120 int
121 jfs2_rmvlimit(dev,class)
122 char * dev
123 int class
124 CODE:
125 #if defined(HAVE_JFS2)
126 if (strncmp(dev, "(JFS2)", 6) == 0) {
127 RETVAL = quotactl (dev + 6, Q_J2RMVLIMIT, class, NULL);
128 } else
129 #endif /* HAVE_JFS2 */
130 {
131 RETVAL = -1;
132 errno = ENOENT;
133 }
134 OUTPUT:
135 RETVAL
136
137 int
138 jfs2_deflimit(dev,class)
139 char * dev
140 int class
141 CODE:
142 #if defined(HAVE_JFS2)
143 if (strncmp(dev, "(JFS2)", 6) == 0) {
144 RETVAL = quotactl (dev + 6, Q_J2DEFLIMIT, class, NULL);
145 } else
146 #endif /* HAVE_JFS2 */
147 {
148 RETVAL = -1;
149 errno = ENOENT;
150 }
151 OUTPUT:
152 RETVAL
153
154 int
155 jfs2_uselimit(dev,class,uid=getuid(),kind=0)
156 char * dev
157 int class
158 int uid
159 int kind
160 CODE:
161 #if defined(HAVE_JFS2)
162 if (strncmp(dev, "(JFS2)", 6) == 0) {
163 uid_t id_buf = uid;
164 RETVAL = quotactl (dev + 6, QCMD(Q_J2USELIMIT, ((kind != 0) ? GRPQUOTA : USRQUOTA)), class, (caddr_t)&id_buf);
165 } else
166 #endif /* HAVE_JFS2 */
167 {
168 RETVAL = -1;
169 errno = ENOENT;
170 }
171 OUTPUT:
172 RETVAL
173
174 void
175 jfs2_getnextq(dev,class)
176 char * dev
177 int class
178 PPCODE:
179 #if defined(HAVE_JFS2)
180 if (strncmp(dev, "(JFS2)", 6) == 0) {
181 uid_t id_buf = 0;
182 int retval;
183
184 //retval = quotactl (dev + 6, QCMD(Q_J2GETNEXTQ,USRQUOTA), class, (caddr_t) &id_buf);
185 retval = quotactl (dev + 6, Q_J2GETNEXTQ, class, (caddr_t) &id_buf);
186 printf("Q_J2GETNEXTQ(%s,%d)=%d ID=%d\n",dev+6,class,retval,id_buf);
187 if (retval == 0) {
188 EXTEND(sp, 1);
189 PUSHs(sv_2mortal(newSViv(id_buf)));
190 }
191 } else
192 #endif /* HAVE_JFS2 */
193 {
194 errno = ENOENT;
195 }
196