quota.c (166388) | quota.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 --- 34 unchanged lines hidden (view full) --- 43#ifndef lint 44static const char sccsid[] = "from: @(#)quota.c 8.1 (Berkeley) 6/6/93"; 45#endif /* not lint */ 46 47/* 48 * Disk quota reporting program. 49 */ 50#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 --- 34 unchanged lines hidden (view full) --- 43#ifndef lint 44static const char sccsid[] = "from: @(#)quota.c 8.1 (Berkeley) 6/6/93"; 45#endif /* not lint */ 46 47/* 48 * Disk quota reporting program. 49 */ 50#include <sys/cdefs.h> |
51__FBSDID("$FreeBSD: head/usr.bin/quota/quota.c 166388 2007-02-01 08:37:44Z mpp $"); | 51__FBSDID("$FreeBSD: head/usr.bin/quota/quota.c 166485 2007-02-04 06:33:15Z mpp $"); |
52 53#include <sys/param.h> 54#include <sys/types.h> 55#include <sys/file.h> 56#include <sys/stat.h> 57#include <sys/mount.h> 58#include <sys/socket.h> 59 --- 418 unchanged lines hidden (view full) --- 478} 479 480/* 481 * Check to see if a particular quota is to be enabled. 482 */ 483static int 484ufshasquota(struct fstab *fs, int type, char **qfnamep) 485{ | 52 53#include <sys/param.h> 54#include <sys/types.h> 55#include <sys/file.h> 56#include <sys/stat.h> 57#include <sys/mount.h> 58#include <sys/socket.h> 59 --- 418 unchanged lines hidden (view full) --- 478} 479 480/* 481 * Check to see if a particular quota is to be enabled. 482 */ 483static int 484ufshasquota(struct fstab *fs, int type, char **qfnamep) 485{ |
486 char *opt; 487 char *cp; 488 struct statfs sfb; |
|
486 static char initname, usrname[100], grpname[100]; 487 static char buf[BUFSIZ]; | 489 static char initname, usrname[100], grpname[100]; 490 static char buf[BUFSIZ]; |
488 char *opt, *cp; | |
489 490 if (!initname) { | 491 492 if (!initname) { |
491 sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname); 492 sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname); | 493 (void)snprintf(usrname, sizeof(usrname), "%s%s", 494 qfextension[USRQUOTA], qfname); 495 (void)snprintf(grpname, sizeof(grpname), "%s%s", 496 qfextension[GRPQUOTA], qfname); |
493 initname = 1; 494 } 495 strcpy(buf, fs->fs_mntops); 496 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 497 if ((cp = index(opt, '='))) 498 *cp++ = '\0'; 499 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 500 break; 501 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 502 break; 503 } 504 if (!opt) 505 return (0); | 497 initname = 1; 498 } 499 strcpy(buf, fs->fs_mntops); 500 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 501 if ((cp = index(opt, '='))) 502 *cp++ = '\0'; 503 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 504 break; 505 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 506 break; 507 } 508 if (!opt) 509 return (0); |
506 if (cp) { | 510 if (cp) |
507 *qfnamep = cp; | 511 *qfnamep = cp; |
508 return (1); | 512 else { 513 (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file, 514 qfname, qfextension[type]); 515 *qfnamep = buf; |
509 } | 516 } |
510 (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); 511 *qfnamep = buf; | 517 if (statfs(fs->fs_file, &sfb) != 0) { 518 warn("cannot statfs mount point %s", fs->fs_file); 519 return (0); 520 } 521 if (strcmp(fs->fs_file, sfb.f_mntonname)) { 522 warnx("%s not mounted for %s quotas", fs->fs_file, 523 type == USRQUOTA ? "user" : "group"); 524 return (0); 525 } |
512 return (1); 513} 514 515static int 516getufsquota(struct fstab *fs, struct quotause *qup, long id, int quotatype) 517{ 518 char *qfpathname; 519 int fd, qcmd; --- 167 unchanged lines hidden --- | 526 return (1); 527} 528 529static int 530getufsquota(struct fstab *fs, struct quotause *qup, long id, int quotatype) 531{ 532 char *qfpathname; 533 int fd, qcmd; --- 167 unchanged lines hidden --- |