]> git.pld-linux.org Git - packages/quota.git/blob - quota-sparc.patch
- fixes for quota 3.00
[packages/quota.git] / quota-sparc.patch
1 From davem@piglet.twiddle.net  Tue Apr 13 03:50:39 1999
2 Return-Path: <davem@piglet.twiddle.net>
3 Received: from lacrosse.redhat.com (root@lacrosse.redhat.com [207.175.42.154])
4         by devserv.devel.redhat.com (8.8.7/8.8.7) with ESMTP id DAA25723;
5         Tue, 13 Apr 1999 03:50:37 -0400
6 Received: from mail.redhat.com (mail.redhat.com [199.183.24.239])
7         by lacrosse.redhat.com (8.8.7/8.8.7) with ESMTP id DAA21788;
8         Tue, 13 Apr 1999 03:50:36 -0400
9 Received: from piglet.twiddle.net (davem@piglet.twiddle.net [207.104.6.26])
10         by mail.redhat.com (8.8.7/8.8.7) with ESMTP id DAA09990;
11         Tue, 13 Apr 1999 03:50:34 -0400
12 Received: (from davem@localhost)
13         by piglet.twiddle.net (8.8.7/8.8.7) id AAA27448;
14         Tue, 13 Apr 1999 00:50:34 -0700
15 Date: Tue, 13 Apr 1999 00:50:34 -0700
16 Message-Id: <199904130750.AAA27448@piglet.twiddle.net>
17 X-Authentication-Warning: piglet.twiddle.net: davem set sender to davem@piglet.twiddle.net using -f
18 From: David Miller <davem@twiddle.net>
19 To: gafton@redhat.com
20 CC: jbj@redhat.com, msw@redhat.com
21 Subject: [PATCH] fix for sparc64 quotas
22 Reply-To: davem@redhat.com
23 Status: RO
24 Content-Length: 15353
25 Lines: 485
26
27
28 Please add this patch to the quota package, it fixes
29 BugZilla BugID 2147.  I verified it on sparc and sparc64
30 RH6.0 machines, it should work just fine on other systems as well as
31 the changed behavior is controlled by ifdef __sparc__ checks.
32
33 I will close that BugID when this goes into a build and I re-verify
34 that it is indeed fixed.
35
36 --- quota-1.66/utils/dqblk.h.~1~        Tue Apr 13 07:22:43 1999
37 +++ quota-1.66/utils/dqblk.h    Tue Apr 13 07:30:59 1999
38 @@ -0,0 +1,61 @@
39 +#if !defined(__sparc__) || defined(__sparc_v9__)
40 +/* We don't want any of this crap on anything other than 32bit sparc userland. */
41 +#define ondisk_dqblk dqblk
42 +#define CONVERT_TO_USER_DQUOT(__d, __s) memcpy((__d), (__s), sizeof(*(__d)))
43 +#define CONVERT_TO_KERNEL_DQUOT(__d, __s) memcpy((__d), (__s), sizeof(*(__d)))
44 +#define DQUOT_CONVERT_INIT() do { } while(0)
45 +#define ondisk_dqblk_size sizeof(struct dqblk)
46 +/* Leave dqoff as is... */
47 +#else
48 +
49 +#include <sys/utsname.h>
50 +
51 +extern int need_dquot_convert;
52 +
53 +#define DQUOT_CONVERT_INIT() \
54 +do {   struct utsname name; \
55 +       int ret; \
56 +       need_dquot_convert = 0; \
57 +       ret = uname(&name); \
58 +       if(ret == 0) { \
59 +               if(name.machine[5] != '\0') \
60 +                       need_dquot_convert = 1; \
61 +       } \
62 +} while(0)
63 +
64 +struct ondisk_dqblk {
65 +       u_int32_t dqb_bhardlimit;       /* absolute limit on disk blks alloc */
66 +       u_int32_t dqb_bsoftlimit;       /* preferred limit on disk blks */
67 +       u_int32_t dqb_curblocks;        /* current block count */
68 +       u_int32_t dqb_ihardlimit;       /* maximum # allocated inodes */
69 +       u_int32_t dqb_isoftlimit;       /* preferred inode limit */
70 +       u_int32_t dqb_curinodes;        /* current # allocated inodes */
71 +       u_int64_t dqb_btime;            /* time limit for excessive disk use */
72 +       u_int64_t dqb_itime;            /* time limit for excessive files */
73 +};
74 +
75 +#define ondisk_dqblk_size \
76 +       (need_dquot_convert ? \
77 +        sizeof(struct ondisk_dqblk) : \
78 +         sizeof(struct dqblk))
79 +
80 +#undef dqoff
81 +#define dqoff(__id)    ((loff_t) ((__id) * ondisk_dqblk_size))
82 +
83 +#define CONVERT_TO_USER_DQUOT(__d, __s) \
84 +do {   memcpy((__d), (__s), sizeof(struct dqblk)); \
85 +       if(need_dquot_convert != 0) { \
86 +               (__d)->dqb_btime = (time_t) (__s)->dqb_btime; \
87 +               (__d)->dqb_itime = (time_t) (__s)->dqb_itime; \
88 +       } \
89 +} while(0)
90 +
91 +#define CONVERT_TO_KERNEL_DQUOT(__d, __s) \
92 +do {   memcpy((__d), (__s), ondisk_dqblk_size); \
93 +       if(need_dquot_convert != 0) { \
94 +               (__d)->dqb_btime = (u_int64_t) (__s)->dqb_btime; \
95 +               (__d)->dqb_itime = (u_int64_t) (__s)->dqb_itime; \
96 +       } \
97 +} while(0)
98 +
99 +#endif
100 --- quota-1.66/utils/quota.c.~1~        Tue Apr 13 04:02:15 1999
101 +++ quota-1.66/utils/quota.c    Tue Apr 13 07:28:09 1999
102 @@ -62,6 +62,10 @@
103  #include "rquota.h"
104  #endif
105  
106 +#include "dqblk.h"
107 +
108 +int need_dquot_convert;
109 +
110  extern char *qfextension[];
111  
112  struct quotause {
113 @@ -110,6 +114,8 @@
114     extern char *optarg;
115     extern int optind, errno;
116  
117 +   DQUOT_CONVERT_INIT();
118 +
119     while ((ch = getopt(argc, argv, "ugvqV")) != EOF) {
120        switch (ch) {
121           case 'g':
122 @@ -472,7 +478,7 @@
123         * Initialize unix authentication
124         */
125        clnt->cl_auth = authunix_create_default();
126 -      clnt_control(clnt, CLSET_TIMEOUT, &timeout);
127 +      clnt_control(clnt, CLSET_TIMEOUT, (char *) &timeout);
128  
129        result = rquotaproc_getquota_2(&args.ext_arg, clnt);
130        if (result != NULL && result->status == Q_OK) {
131 @@ -498,7 +504,7 @@
132               * Initialize unix authentication
133               */
134              clnt->cl_auth = authunix_create_default();
135 -            clnt_control(clnt, CLSET_TIMEOUT, &timeout);
136 +            clnt_control(clnt, CLSET_TIMEOUT, (char *) &timeout);
137  
138              result = rquotaproc_getquota_1(&args.arg, clnt);
139              if (result != NULL && result->status == Q_OK) {
140 @@ -545,6 +551,8 @@
141  
142        if (strcmp(mnt->mnt_type, MNTTYPE_NFS)) {
143           if (quotactl(qcmd, mnt->mnt_fsname, id, (caddr_t)&qup->dqblk) != 0) {
144 +           struct ondisk_dqblk od_dqblk;
145 +
146              if (errno == ENOSYS || errno == ESRCH )
147                 continue;
148              if ((fd = open(qfpathname, O_RDONLY)) < 0) {
149 @@ -553,7 +561,7 @@
150                 continue;
151              }
152              lseek(fd, (long) dqoff(id), L_SET);
153 -            switch (read(fd, &qup->dqblk, sizeof(struct dqblk))) {
154 +            switch (read(fd, &od_dqblk, ondisk_dqblk_size)) {
155                 case 0:/* EOF */
156                    /*
157                     * Convert implicit 0 quota (EOF) into an
158 @@ -561,7 +569,8 @@
159                     */
160                    memset((caddr_t)&qup->dqblk, 0, sizeof(struct dqblk));
161                    break;
162 -               case sizeof(struct dqblk):   /* OK */
163 +              case sizeof(struct ondisk_dqblk):   /* OK */
164 +                 CONVERT_TO_USER_DQUOT(&qup->dqblk, &od_dqblk);
165                    break;
166                 default:   /* ERROR */
167                    fprintf(stderr, "quota: read error");
168 --- quota-1.66/utils/edquota.c.~1~      Tue Apr 13 04:02:15 1999
169 +++ quota-1.66/utils/edquota.c  Tue Apr 13 07:27:52 1999
170 @@ -61,6 +61,10 @@
171  #include <unistd.h>
172  #include "pathnames.h"
173  
174 +#include "dqblk.h"
175 +
176 +int need_dquot_convert;
177 +
178  extern char *qfextension[];
179  char *quotagroup = QUOTAGROUP;
180  char tmpfil[] = _PATH_TMP;
181 @@ -85,6 +89,8 @@
182     char *protoname, ch;
183     int tflag = 0, pflag = 0;
184  
185 +   DQUOT_CONVERT_INIT();
186 +
187     if (argc < 2)
188        usage();
189  
190 @@ -241,6 +247,7 @@
191        }
192  
193        if (quotactl(qcmd, mnt->mnt_fsname, id, (caddr_t) &qup->dqblk) != 0) {
194 +         struct ondisk_dqblk od_dqblk;
195           if ((errno == EOPNOTSUPP || errno == ENOSYS || errno == ENOPKG) && !warned) {
196              warned++;
197              fprintf(stderr, "Warning: %s\n",
198 @@ -261,8 +268,8 @@
199              (void) fchmod(fd, 0640);
200           }
201  
202 -         lseek(fd, (long) (id * sizeof(struct dqblk)), L_SET);
203 -         switch (read(fd, &qup->dqblk, sizeof(struct dqblk))) {
204 +         lseek(fd, (long) dqoff(id), L_SET);
205 +         switch (read(fd, &od_dqblk, ondisk_dqblk_size)) {
206              case 0:/* EOF */
207                 /*
208                  * Convert implicit 0 quota (EOF) into an
209 @@ -271,7 +278,8 @@
210                 bzero((caddr_t) & qup->dqblk,
211                       sizeof(struct dqblk));
212                 break;
213 -            case sizeof(struct dqblk):   /* OK */
214 +           case sizeof(struct ondisk_dqblk):   /* OK */
215 +              CONVERT_TO_USER_DQUOT(&qup->dqblk, &od_dqblk);
216                 break;
217              default:   /* ERROR */
218                 fprintf(stderr, "edquota: read error in ");
219 @@ -311,9 +319,12 @@
220        if ((fd = open(qup->qfname, O_WRONLY)) < 0) {
221           perror(qup->qfname);
222        } else {
223 -         lseek(fd, (long) id * (long) sizeof(struct dqblk), 0);
224 -         if (write(fd, &qup->dqblk, sizeof(struct dqblk)) !=
225 -             sizeof(struct dqblk)) {
226 +         struct ondisk_dqblk od_dqblk;
227 +
228 +        CONVERT_TO_KERNEL_DQUOT(&od_dqblk, &qup->dqblk);
229 +         lseek(fd, (long) dqoff(id), 0);
230 +         if (write(fd, &od_dqblk, ondisk_dqblk_size) !=
231 +             ondisk_dqblk_size) {
232              fprintf(stderr, "edquota: ");
233              perror(qup->qfname);
234           }
235 --- quota-1.66/utils/repquota.c.~1~     Tue Apr 13 04:02:15 1999
236 +++ quota-1.66/utils/repquota.c Tue Apr 13 06:59:57 1999
237 @@ -54,6 +54,10 @@
238  #include <stdio.h>
239  #include <errno.h>
240  
241 +#include "dqblk.h"
242 +
243 +int need_dquot_convert;
244 +
245  extern char *qfextension[];
246  
247  struct fileusage {
248 @@ -84,6 +88,8 @@
249     extern int optind;
250     char ch, *qfnp;
251  
252 +   DQUOT_CONVERT_INIT();
253 +
254     while ((ch = getopt(argc, argv, "aguv")) != EOF) {
255        switch (ch) {
256           case 'a':
257 @@ -165,6 +171,7 @@
258     register struct fileusage *fup;
259     FILE *qf;
260     u_long id;
261 +   struct ondisk_dqblk od_dqblk;
262     struct dqblk dqbuf;
263     char *timeprt();
264     static struct dqblk zerodqblk;
265 @@ -188,9 +195,10 @@
266        return (1);
267     }
268     for (id = 0;; id++) {
269 -      fread(&dqbuf, sizeof(struct dqblk), 1, qf);
270 +      fread(&od_dqblk, ondisk_dqblk_size, 1, qf);
271        if (feof(qf))
272           break;
273 +      CONVERT_TO_USER_DQUOT(&dqbuf, &od_dqblk);
274        if (dqbuf.dqb_curinodes == 0 && dqbuf.dqb_curblocks == 0)
275           continue;
276        if ((fup = lookup(id, type)) == 0)
277 --- quota-1.66/utils/quotacheck.c.~1~   Tue Apr 13 04:02:15 1999
278 +++ quota-1.66/utils/quotacheck.c       Tue Apr 13 07:13:01 1999
279 @@ -38,6 +38,10 @@
280  #include <ext2fs/ext2fs.h>
281  #endif
282  
283 +#include "dqblk.h"
284 +
285 +int need_dquot_convert;
286 +
287  #define DEF_BLOCKSIZE 1024
288  #define NODQUOT (struct dquot *)NULL
289  
290 @@ -201,6 +205,8 @@
291     char *usr_qfnp, *grp_qfnp;
292     register struct mntent *mnt;
293  
294 +   DQUOT_CONVERT_INIT();
295 +
296     while ((ch = getopt(argc, argv, "avugdR")) != EOF) {
297        switch (ch) {
298           case 'a':
299 @@ -609,6 +615,7 @@
300   */
301  void dump_to_file(char *fsname, char *quotafile, int type)
302  {
303 +   struct ondisk_dqblk od_dqblk;
304     struct dqblk dq_dqb;
305     struct dquot *dquot;
306     struct stat st;
307 @@ -635,15 +642,16 @@
308      * quotafile. Only dump new gracetimes when creating a new 
309      * quotafile.
310      */
311 -   if (read(fd, &dq_dqb, sizeof(struct dqblk)) <= 0) {
312 +   if (read(fd, &od_dqblk, ondisk_dqblk_size) <= 0) {
313        memset((caddr_t *)&dq_dqb, 0, sizeof(struct dqblk));
314        dq_dqb.dqb_btime = MAX_DQ_TIME;
315        dq_dqb.dqb_itime = MAX_IQ_TIME;
316 -      write(fd, &dq_dqb, sizeof(struct dqblk));
317 +      CONVERT_TO_KERNEL_DQUOT(&od_dqblk, &dq_dqb);
318 +      write(fd, &od_dqblk, ondisk_dqblk_size);
319     }
320  
321     if (fstat(fd, &st) == 0) {
322 -      max_id = (st.st_size / sizeof(struct dqblk)) - 1;
323 +      max_id = (st.st_size / ondisk_dqblk_size) - 1;
324        if (max_id < highestid[type])
325           max_id = highestid[type];
326     } else
327 @@ -652,9 +660,10 @@
328     for (id = 0; id <= max_id; id++) {
329        memset((caddr_t)&dq_dqb, 0, sizeof(struct dqblk));
330  
331 -      if (lseek(fd, dqoff(id), SEEK_SET) == dqoff(id))
332 -         read(fd, &dq_dqb, sizeof(struct dqblk));
333 -
334 +      if (lseek(fd, dqoff(id), SEEK_SET) == dqoff(id)) {
335 +         read(fd, &od_dqblk, ondisk_dqblk_size);
336 +        CONVERT_TO_USER_DQUOT(&dq_dqb, &od_dqblk);
337 +      }
338        if ((dquot = lookup_dquot(id, type)) != NODQUOT) {
339           dq_curinodes = dquot->dq_curinodes;
340           dq_curblocks = dquot->dq_curblocks;
341 @@ -680,8 +689,10 @@
342           if (quotactl(QCMD(Q_SETUSE, type), fsname, id, (caddr_t)&dq_dqb) == 0)
343              continue;
344  
345 -      if (lseek(fd, dqoff(id), SEEK_SET) == dqoff(id))
346 -         write(fd, &dq_dqb, sizeof(struct dqblk));
347 +      if (lseek(fd, dqoff(id), SEEK_SET) == dqoff(id)) {
348 +         CONVERT_TO_KERNEL_DQUOT(&od_dqblk, &dq_dqb);
349 +         write(fd, &od_dqblk, ondisk_dqblk_size);
350 +      }
351     }
352     flock(fd, LOCK_UN);
353     close(fd);
354 --- quota-1.66/utils/rquota_server.c.~1~        Tue Apr 13 04:02:15 1999
355 +++ quota-1.66/utils/rquota_server.c    Tue Apr 13 07:28:21 1999
356 @@ -29,6 +29,8 @@
357  #include <mntent.h>
358  #include <stdio.h>
359  
360 +#include "dqblk.h"
361 +
362  #define TYPE_EXTENDED  0x01
363  #define ACTIVE         0x02
364  
365 @@ -106,6 +108,7 @@
366        ext_getquota_args *ext_args;
367     } arguments;
368     FILE *fp;
369 +   struct ondisk_dqblk od_dqblk;
370     struct dqblk dq_dqb;
371     struct mntent *mnt;
372     char *pathname, *devicename, *qfpathname;
373 @@ -162,7 +165,7 @@
374              if ((fd = open(qfpathname, O_RDONLY)) < 0)
375                 continue;
376              lseek(fd, (long) dqoff(id), L_SET);
377 -            switch (read(fd, &dq_dqb, sizeof(struct dqblk))) {
378 +            switch (read(fd, &od_dqblk, ondisk_dqblk_size)) {
379                 case 0:/* EOF */
380                    /*
381                     * Convert implicit 0 quota (EOF) into an
382 @@ -170,7 +173,8 @@
383                     */
384                    memset((caddr_t)&dq_dqb, 0, sizeof(struct dqblk));
385                    break;
386 -               case sizeof(struct dqblk):   /* OK */
387 +              case sizeof(struct ondisk_dqblk):   /* OK */
388 +                  CONVERT_TO_USER_DQUOT(&dq_dqb, &od_dqblk);
389                    break;
390                 default:   /* ERROR */
391                    close(fd);
392 --- quota-1.66/utils/rquota_svc.c.~1~   Sun Nov 17 08:59:46 1996
393 +++ quota-1.66/utils/rquota_svc.c       Tue Apr 13 07:03:30 1999
394 @@ -28,6 +28,10 @@
395  #include <netinet/in.h>
396  #include <syslog.h>
397  
398 +#include "dqblk.h"
399 +
400 +int need_dquot_convert;
401 +
402  #ifdef __STDC__
403  #define SIG_PF void(*)(int)
404  #endif
405 @@ -181,6 +185,8 @@
406  int main(int argc, char **argv)
407  {
408     register SVCXPRT *transp;
409 +
410 +   DQUOT_CONVERT_INIT();
411  
412     (void) pmap_unset(RQUOTAPROG, RQUOTAVERS);
413     (void) pmap_unset(RQUOTAPROG, EXT_RQUOTAVERS);
414 --- quota-1.66/utils/warnquota.c.~1~    Tue Apr 13 04:02:15 1999
415 +++ quota-1.66/utils/warnquota.c        Tue Apr 13 07:10:14 1999
416 @@ -31,6 +31,10 @@
417  #include <pwd.h>
418  #include <string.h>
419  
420 +#include "dqblk.h"
421 +
422 +int need_dquot_convert;
423 +
424  #define MAIL_CMD "/usr/lib/sendmail -t"
425  #define FROM     "support@localhost"
426  #define SUBJECT  "Disk Quota usage on system"
427 @@ -134,6 +138,7 @@
428  void read_quotafile(char *qfilename, char *devicename)
429  {
430     int fd, id = 0;
431 +   struct ondisk_dqblk od_dqblk;
432     struct dqblk dq_dqb;
433  
434     if ((fd = open(qfilename, O_RDONLY)) < 0) {
435 @@ -141,10 +146,12 @@
436        exit(1);
437     }
438  
439 -   while (read(fd, &dq_dqb, sizeof(struct dqblk)) == sizeof(struct dqblk)) {
440 +   while (read(fd, &od_dqblk, ondisk_dqblk_size) == ondisk_dqblk_size) {
441        if ((dq_bsoftlimit && dq_curblocks >= dq_bsoftlimit) ||
442 -          (dq_isoftlimit && dq_curinodes >= dq_isoftlimit))
443 +          (dq_isoftlimit && dq_curinodes >= dq_isoftlimit)) {
444 +         CONVERT_TO_USER_DQUOT(&dq_dqb, &od_dqblk);
445           add_offence(id, devicename, &dq_dqb);
446 +      }
447        id++;
448     }
449     close(fd);
450 @@ -300,5 +307,7 @@
451  
452  main(int argc, char **argv)
453  {
454 +   DQUOT_CONVERT_INIT();
455 +
456     warn_quota();
457  }
458 --- quota-1.66/utils/rquota_clnt.c.~1~  Thu Jul 20 11:27:40 1995
459 +++ quota-1.66/utils/rquota_clnt.c      Tue Apr 13 07:19:19 1999
460 @@ -12,7 +12,11 @@
461         static getquota_rslt res;
462  
463         bzero((char *)&res, sizeof(res));
464 -       if (clnt_call(clnt, RQUOTAPROC_GETQUOTA, xdr_getquota_args, argp, xdr_getquota_rslt, &res, TIMEOUT) != RPC_SUCCESS) {
465 +       if (clnt_call(clnt, RQUOTAPROC_GETQUOTA,
466 +                     (xdrproc_t) xdr_getquota_args,
467 +                     (caddr_t) argp,
468 +                     (xdrproc_t) xdr_getquota_rslt,
469 +                     (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
470                 return (NULL);
471         }
472         return (&res);
473 @@ -27,7 +31,11 @@
474         static getquota_rslt res;
475  
476         bzero((char *)&res, sizeof(res));
477 -       if (clnt_call(clnt, RQUOTAPROC_GETACTIVEQUOTA, xdr_getquota_args, argp, xdr_getquota_rslt, &res, TIMEOUT) != RPC_SUCCESS) {
478 +       if (clnt_call(clnt, RQUOTAPROC_GETACTIVEQUOTA,
479 +                     (xdrproc_t) xdr_getquota_args,
480 +                     (caddr_t) argp,
481 +                     (xdrproc_t) xdr_getquota_rslt,
482 +                     (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
483                 return (NULL);
484         }
485         return (&res);
486 @@ -42,7 +50,11 @@
487         static getquota_rslt res;
488  
489         bzero((char *)&res, sizeof(res));
490 -       if (clnt_call(clnt, RQUOTAPROC_GETQUOTA, xdr_ext_getquota_args, argp, xdr_getquota_rslt, &res, TIMEOUT) != RPC_SUCCESS) {
491 +       if (clnt_call(clnt, RQUOTAPROC_GETQUOTA,
492 +                     (xdrproc_t) xdr_ext_getquota_args,
493 +                     (caddr_t) argp,
494 +                     (xdrproc_t) xdr_getquota_rslt,
495 +                     (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
496                 return (NULL);
497         }
498         return (&res);
499 @@ -57,7 +69,11 @@
500         static getquota_rslt res;
501  
502         bzero((char *)&res, sizeof(res));
503 -       if (clnt_call(clnt, RQUOTAPROC_GETACTIVEQUOTA, xdr_ext_getquota_args, argp, xdr_getquota_rslt, &res, TIMEOUT) != RPC_SUCCESS) {
504 +       if (clnt_call(clnt, RQUOTAPROC_GETACTIVEQUOTA,
505 +                     (xdrproc_t) xdr_ext_getquota_args,
506 +                     (caddr_t) argp,
507 +                     (xdrproc_t) xdr_getquota_rslt,
508 +                     (caddr_t) &res, TIMEOUT) != RPC_SUCCESS) {
509                 return (NULL);
510         }
511         return (&res);
512
This page took 0.114561 seconds and 3 git commands to generate.