- if ((err = quotactl(QCMD(Q_GETQUOTA, type), mnt->mnt_fsname,
- id, (caddr_t)&dq_dqb)) == -1
- && !(flags & ACTIVE)) {
- if ((fd = open(qfpathname, O_RDONLY)) < 0)
- {
- free(qfpathname);
- continue;
- }
- free(qfpathname);
- lseek(fd, (long) dqoff(id), L_SET);
- switch (read(fd, &dq_dqb, sizeof(struct dqblk))) {
- case 0:/* EOF */
- /*
- * Convert implicit 0 quota (EOF) into an
- * explicit one (zero'ed dqblk)
- */
- memset((caddr_t)&dq_dqb, 0, sizeof(struct dqblk));
- break;
- case sizeof(struct dqblk): /* OK */
- break;
- default: /* ERROR */
- close(fd);
- continue;
- }
- close(fd);
- }
+ int fmt;
+ if (quotactl(QCMD(Q_GETFMT, type), mnt->mnt_fsname, 0, (caddr_t)&fmt)==0) {
+ /* new style interface
+ * Don't bother trying to read from the file
+ */
+ err = quotactl(QCMD(Q_GETQUOTA_NEW, type),
+ mnt->mnt_fsname, id, (caddr_t)&dqb);
+ if (err) memset(&dqb, 0, sizeof(dqb));
+ } else {
+ /* old style */
+ struct dqblk dq_dqb;
+
+ if ((err = quotactl(QCMD(Q_GETQUOTA, type), mnt->mnt_fsname,
+ id, (caddr_t)&dq_dqb)) == -1
+ && !(flags & ACTIVE)) {
+ if ((fd = open(qfpathname, O_RDONLY)) < 0)
+ {
+ free(qfpathname);
+ continue;
+ }
+ lseek(fd, (long) dqoff(id), L_SET);
+ switch (read(fd, &dq_dqb, sizeof(struct dqblk))) {
+ case 0:/* EOF */
+ /*
+ * Convert implicit 0 quota (EOF) into an
+ * explicit one (zero'ed dqblk)
+ */
+ memset((caddr_t)&dq_dqb, 0, sizeof(struct dqblk));
+ break;
+ case sizeof(struct dqblk): /* OK */
+ break;
+ default: /* ERROR */
+ close(fd);
+ free(qfpathname);
+ continue;
+ }
+ close(fd);
+ }
+ dqb.dqb_bhardlimit = dq_dqb.dqb_bhardlimit;
+ dqb.dqb_bsoftlimit = dq_dqb.dqb_bsoftlimit;
+ dqb.dqb_curspace = dq_dqb.dqb_curblocks * 1024;
+ dqb.dqb_ihardlimit = dq_dqb.dqb_ihardlimit;
+ dqb.dqb_isoftlimit = dq_dqb.dqb_isoftlimit;
+ dqb.dqb_curinodes = dq_dqb.dqb_curinodes;
+ dqb.dqb_btime = dq_dqb.dqb_btime;
+ dqb.dqb_itime = dq_dqb.dqb_itime;
+ }
+ free(qfpathname);