quotacheck.c (166458) | quotacheck.c (166485) |
---|---|
1/* 2 * Copyright (c) 1980, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Robert Elz at The University of Melbourne. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41static char sccsid[] = "@(#)quotacheck.c 8.3 (Berkeley) 1/29/94"; 42#endif /* not lint */ 43#endif 44#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1980, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Robert Elz at The University of Melbourne. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41static char sccsid[] = "@(#)quotacheck.c 8.3 (Berkeley) 1/29/94"; 42#endif /* not lint */ 43#endif 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sbin/quotacheck/quotacheck.c 166458 2007-02-03 11:20:28Z mpp $"); | 45__FBSDID("$FreeBSD: head/sbin/quotacheck/quotacheck.c 166485 2007-02-04 06:33:15Z mpp $"); |
46 47/* 48 * Fix up / report on disk quotas & usage 49 */ 50#include <sys/param.h> 51#include <sys/disklabel.h> | 46 47/* 48 * Fix up / report on disk quotas & usage 49 */ 50#include <sys/param.h> 51#include <sys/disklabel.h> |
52#include <sys/mount.h> |
|
52#include <sys/stat.h> 53 54#include <ufs/ufs/dinode.h> 55#include <ufs/ufs/quota.h> 56#include <ufs/ffs/fs.h> 57 58#include <err.h> 59#include <errno.h> --- 522 unchanged lines hidden (view full) --- 582int 583hasquota(fs, type, qfnamep) 584 struct fstab *fs; 585 int type; 586 char **qfnamep; 587{ 588 char *opt; 589 char *cp; | 53#include <sys/stat.h> 54 55#include <ufs/ufs/dinode.h> 56#include <ufs/ufs/quota.h> 57#include <ufs/ffs/fs.h> 58 59#include <err.h> 60#include <errno.h> --- 522 unchanged lines hidden (view full) --- 583int 584hasquota(fs, type, qfnamep) 585 struct fstab *fs; 586 int type; 587 char **qfnamep; 588{ 589 char *opt; 590 char *cp; |
591 struct statfs sfb; |
|
590 static char initname, usrname[100], grpname[100]; 591 static char buf[BUFSIZ]; 592 593 if (!initname) { | 592 static char initname, usrname[100], grpname[100]; 593 static char buf[BUFSIZ]; 594 595 if (!initname) { |
594 (void)snprintf(usrname, sizeof(usrname), 595 "%s%s", qfextension[USRQUOTA], qfname); 596 (void)snprintf(grpname, sizeof(grpname), 597 "%s%s", qfextension[GRPQUOTA], qfname); | 596 (void)snprintf(usrname, sizeof(usrname), "%s%s", 597 qfextension[USRQUOTA], qfname); 598 (void)snprintf(grpname, sizeof(grpname), "%s%s", 599 qfextension[GRPQUOTA], qfname); |
598 initname = 1; 599 } 600 strcpy(buf, fs->fs_mntops); 601 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 602 if ((cp = index(opt, '=')) != NULL) 603 *cp++ = '\0'; 604 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 605 break; 606 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 607 break; 608 } 609 if (!opt) 610 return (0); 611 if (cp) 612 *qfnamep = cp; 613 else { | 600 initname = 1; 601 } 602 strcpy(buf, fs->fs_mntops); 603 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 604 if ((cp = index(opt, '=')) != NULL) 605 *cp++ = '\0'; 606 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 607 break; 608 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 609 break; 610 } 611 if (!opt) 612 return (0); 613 if (cp) 614 *qfnamep = cp; 615 else { |
614 (void)snprintf(buf, sizeof(buf), 615 "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); | 616 (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file, 617 qfname, qfextension[type]); |
616 *qfnamep = buf; 617 } | 618 *qfnamep = buf; 619 } |
620 if (statfs(fs->fs_file, &sfb) != 0) { 621 warn("cannot statfs mount point %s", fs->fs_file); 622 return (0); 623 } 624 if (strcmp(fs->fs_file, sfb.f_mntonname)) { 625 warnx("%s not mounted for %s quotas", fs->fs_file, 626 type == USRQUOTA ? "user" : "group"); 627 return (0); 628 } |
|
618 return (1); 619} 620 621/* 622 * Routines to manage the file usage table. 623 * 624 * Lookup an id of a specific type. 625 */ --- 197 unchanged lines hidden --- | 629 return (1); 630} 631 632/* 633 * Routines to manage the file usage table. 634 * 635 * Lookup an id of a specific type. 636 */ --- 197 unchanged lines hidden --- |