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[] = "@(#)repquota.c 8.1 (Berkeley) 6/6/93"; 42#endif /* not lint */ 43#endif 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/usr.sbin/repquota/repquota.c 166485 2007-02-04 06:33:15Z mpp $"); |
46 47/* 48 * Quota report 49 */ 50#include <sys/param.h> |
51#include <sys/mount.h> |
52#include <ufs/ufs/quota.h> 53#include <err.h> 54#include <errno.h> 55#include <fstab.h> 56#include <grp.h> 57#include <pwd.h> 58#include <stdio.h> 59#include <stdlib.h> --- 224 unchanged lines hidden (view full) --- 284 return (-1); 285} 286 287/* 288 * Check to see if a particular quota is to be enabled. 289 */ 290int 291hasquota(fs, type, qfnamep) |
292 struct fstab *fs; |
293 int type; 294 char **qfnamep; 295{ |
296 char *opt; |
297 char *cp; |
298 struct statfs sfb; |
299 static char initname, usrname[100], grpname[100]; 300 static char buf[BUFSIZ]; 301 302 if (!initname) { |
303 (void)snprintf(usrname, sizeof(usrname), "%s%s", 304 qfextension[USRQUOTA], qfname); 305 (void)snprintf(grpname, sizeof(grpname), "%s%s", 306 qfextension[GRPQUOTA], qfname); |
307 initname = 1; 308 } 309 strcpy(buf, fs->fs_mntops); 310 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 311 if ((cp = index(opt, '='))) 312 *cp++ = '\0'; 313 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 314 break; 315 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 316 break; 317 } 318 if (!opt) 319 return (0); |
320 if (cp) |
321 *qfnamep = cp; |
322 else { 323 (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file, 324 qfname, qfextension[type]); 325 *qfnamep = buf; |
326 } |
327 if (statfs(fs->fs_file, &sfb) != 0) { 328 warn("cannot statfs mount point %s", fs->fs_file); 329 return (0); 330 } 331 if (strcmp(fs->fs_file, sfb.f_mntonname)) { 332 warnx("%s not mounted for %s quotas", fs->fs_file, 333 type == USRQUOTA ? "user" : "group"); 334 return (0); 335 } |
336 return (1); 337} 338 339/* 340 * Routines to manage the file usage table. 341 * 342 * Lookup an id of a specific type. 343 */ --- 79 unchanged lines hidden --- |