1 #if defined(USE_QUOTAS)
6 /*----------------------------------------------------------------------
7 Return space left in disk quota on file system which given path is in.
9 Args: path - Path name of file or directory on file system of concern
10 over - pointer to flag that is set if the user is over quota
12 Returns: If *over = 0, the number of bytes free in disk quota as per
14 If *over = 1, the number of bytes *over* quota.
15 -1 is returned on an error looking up quota
16 0 is returned if there is no quota
18 BUG: If there's more than 2.1Gb free this function will break
21 disk_quota(path, over)
25 static int no_quota = 0;
31 return(0L); /* If no quota the first time, then none the second,
32 Also Ultrix seems to give the wrong answer the second
35 dprint(5, (debugfile, "quota_check path: %s\n", path ? path : "?"));
36 if(stat(path, &statx) < 0) {
43 dprint(7, (debugfile, "Quota check: UID:%d stat: %d %x\n",
44 getuid(), statx.st_dev, statx.st_dev));
45 memset((void *)"ax, 0, sizeof(struct dqblk));
46 if(quota(Q_GETDLIM, getuid(), statx.st_dev, "ax) < 0) {
47 dprint(5, (debugfile, "Quota failed : %s\n",
48 error_description(errno)));
51 return(0L); /* No limit */
53 return(-1L); /* Some thing went wrong */
57 dprint(5,(debugfile,"Quota: bsoftlimit:%d bhardlimit:%d curblock:%d\n",
58 quotax.dqb_bsoftlimit, quotax.dqb_bhardlimit, quotax.dqb_curblocks));
60 /* Some confusion on the type of bsoftlimit. The include file says
61 unsigned, but -1 seems to indicate no quota */
62 if(quotax.dqb_bsoftlimit == 0 || (long)quotax.dqb_bsoftlimit == -1) {
67 q = (quotax.dqb_bsoftlimit - quotax.dqb_curblocks) * 1024;
73 dprint(5, (debugfile, "disk_quota returning :%d, over:%d\n", q, *over));
76 #endif /* USE_QUOTAS */