3 * Checking routines for old VFS quota format
17 #include "quotaio_v1.h"
18 #include "quotacheck.h"
20 /* Load all other dquot structures */
21 static void load_dquots(char *filename, int fd, int type)
23 struct v1_disk_dqblk ddqblk;
24 struct util_dqblk *udq;
29 lseek(fd, 0, SEEK_SET);
30 while ((err = read(fd, &ddqblk, sizeof(ddqblk)))) {
32 die(1, _("Cannot read entry for id %u from quotafile %s: %s\n"), (uint) id,
33 filename, strerror(errno));
34 if (err != sizeof(ddqblk)) {
35 errstr(_("Entry for id %u is truncated.\n"),
39 if (ddqblk.dqb_bhardlimit == 0
40 && ddqblk.dqb_bsoftlimit == 0
41 && ddqblk.dqb_ihardlimit == 0
42 && ddqblk.dqb_isoftlimit == 0) {
46 dquot = add_dquot(id, type);
48 udq->dqb_bhardlimit = ddqblk.dqb_bhardlimit;
49 udq->dqb_bsoftlimit = ddqblk.dqb_bsoftlimit;
50 udq->dqb_ihardlimit = ddqblk.dqb_ihardlimit;
51 udq->dqb_isoftlimit = ddqblk.dqb_isoftlimit;
52 udq->dqb_btime = ddqblk.dqb_btime;
53 udq->dqb_itime = ddqblk.dqb_itime;
58 /* Load first structure - get grace times */
59 static int check_info(char *filename, int fd, int type)
61 struct v1_disk_dqblk ddqblk;
64 debug(FL_DEBUG, _("Loading first quota entry with grace times.\n"));
65 lseek(fd, 0, SEEK_SET);
66 err = read(fd, &ddqblk, sizeof(ddqblk));
68 die(1, _("Cannot read first entry from quotafile %s: %s\n"), filename,
70 if (err != sizeof(ddqblk)) {
72 _("WARNING - Quotafile %s was probably truncated. Cannot save quota settings...\n"),
76 old_info[type].dqi_bgrace = ddqblk.dqb_btime;
77 old_info[type].dqi_igrace = ddqblk.dqb_itime;
78 debug(FL_DEBUG, _("First entry loaded.\n"));
82 int v1_buffer_file(char *filename, int fd, int type)
84 old_info[type].dqi_bgrace = MAX_DQ_TIME;
85 old_info[type].dqi_igrace = MAX_IQ_TIME;
86 if (flags & FL_NEWFILE)
88 if (check_info(filename, fd, type) < 0)
90 load_dquots(filename, fd, type);