SCCS-vsn: usr.bin/quota/quota.c 5.10
int quotatype;
{
register struct fstab *fs;
int quotatype;
{
register struct fstab *fs;
- char qfilename[MAXPATHLEN + 1];
register struct quotause *qup, *quptail;
struct quotause *quphead;
register struct quotause *qup, *quptail;
struct quotause *quphead;
int qcmd, fd;
setfsent();
quphead = (struct quotause *)0;
qcmd = QCMD(Q_GETQUOTA, quotatype);
while (fs = getfsent()) {
int qcmd, fd;
setfsent();
quphead = (struct quotause *)0;
qcmd = QCMD(Q_GETQUOTA, quotatype);
while (fs = getfsent()) {
- if (!hasquota(fs->fs_mntops, quotatype))
+ if (strcmp(fs->fs_vfstype, "ufs"))
- sprintf(qfilename, "%s/%s.%s", fs->fs_file, qfname,
- qfextension[quotatype]);
- if ((fd = open(qfilename, O_RDONLY)) < 0) {
- perror(qfilename);
+ if (!hasquota(fs, quotatype, &qfpathname))
if ((qup = (struct quotause *)malloc(sizeof *qup)) == NULL) {
fprintf(stderr, "quota: out of memory\n");
exit(2);
}
if ((qup = (struct quotause *)malloc(sizeof *qup)) == NULL) {
fprintf(stderr, "quota: out of memory\n");
exit(2);
}
- if (quotactl(qfilename, qcmd, id, &qup->dqblk) != 0) {
+ if (quotactl(fs->fs_file, qcmd, id, &qup->dqblk) != 0) {
+ if ((fd = open(qfpathname, O_RDONLY)) < 0) {
+ perror(qfpathname);
+ free(qup);
+ continue;
+ }
lseek(fd, (long)(id * sizeof(struct dqblk)), L_SET);
switch (read(fd, &qup->dqblk, sizeof(struct dqblk))) {
case 0: /* EOF */
lseek(fd, (long)(id * sizeof(struct dqblk)), L_SET);
switch (read(fd, &qup->dqblk, sizeof(struct dqblk))) {
case 0: /* EOF */
default: /* ERROR */
fprintf(stderr, "quota: read error");
default: /* ERROR */
fprintf(stderr, "quota: read error");
close(fd);
free(qup);
continue;
}
close(fd);
free(qup);
continue;
}
strcpy(qup->fsname, fs->fs_file);
if (quphead == NULL)
quphead = qup;
strcpy(qup->fsname, fs->fs_file);
if (quphead == NULL)
quphead = qup;
/*
* Check to see if a particular quota is to be enabled.
*/
/*
* Check to see if a particular quota is to be enabled.
*/
-hasquota(options, type)
- char *options;
+hasquota(fs, type, qfnamep)
+ register struct fstab *fs;
- char buf[BUFSIZ];
- char *strtok();
+ char *cp, *index(), *strtok();
static char initname, usrname[100], grpname[100];
static char initname, usrname[100], grpname[100];
+ static char buf[BUFSIZ];
if (!initname) {
sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname);
sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname);
initname = 1;
}
if (!initname) {
sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname);
sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname);
initname = 1;
}
+ strcpy(buf, fs->fs_mntops);
for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
+ if (cp = index(opt, '='))
+ *cp++ = '\0';
if (type == USRQUOTA && strcmp(opt, usrname) == 0)
if (type == USRQUOTA && strcmp(opt, usrname) == 0)
if (type == GRPQUOTA && strcmp(opt, grpname) == 0)
if (type == GRPQUOTA && strcmp(opt, grpname) == 0)
+ if (!opt)
+ return (0);
+ if (cp) {
+ *qfnamep = cp;
+ return (1);
+ }
+ (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);
+ *qfnamep = buf;
+ return (1);