Deleted Added
full compact
repquota.c (139043) repquota.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[] = "@(#)repquota.c 8.1 (Berkeley) 6/6/93";
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[] = "@(#)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 139043 2004-12-19 18:02:45Z maxim $");
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>
46
47/*
48 * Quota report
49 */
50#include <sys/param.h>
51#include <sys/mount.h>
51#include <ufs/ufs/quota.h>
52#include <err.h>
53#include <errno.h>
54#include <fstab.h>
55#include <grp.h>
56#include <pwd.h>
57#include <stdio.h>
58#include <stdlib.h>

--- 224 unchanged lines hidden (view full) ---

283 return (-1);
284}
285
286/*
287 * Check to see if a particular quota is to be enabled.
288 */
289int
290hasquota(fs, type, qfnamep)
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)
291 register struct fstab *fs;
292 struct fstab *fs;
292 int type;
293 char **qfnamep;
294{
293 int type;
294 char **qfnamep;
295{
295 register char *opt;
296 char *opt;
296 char *cp;
297 char *cp;
298 struct statfs sfb;
297 static char initname, usrname[100], grpname[100];
298 static char buf[BUFSIZ];
299
300 if (!initname) {
299 static char initname, usrname[100], grpname[100];
300 static char buf[BUFSIZ];
301
302 if (!initname) {
301 sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname);
302 sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname);
303 (void)snprintf(usrname, sizeof(usrname), "%s%s",
304 qfextension[USRQUOTA], qfname);
305 (void)snprintf(grpname, sizeof(grpname), "%s%s",
306 qfextension[GRPQUOTA], qfname);
303 initname = 1;
304 }
305 strcpy(buf, fs->fs_mntops);
306 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
307 if ((cp = index(opt, '=')))
308 *cp++ = '\0';
309 if (type == USRQUOTA && strcmp(opt, usrname) == 0)
310 break;
311 if (type == GRPQUOTA && strcmp(opt, grpname) == 0)
312 break;
313 }
314 if (!opt)
315 return (0);
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);
316 if (cp) {
320 if (cp)
317 *qfnamep = cp;
321 *qfnamep = cp;
318 return (1);
322 else {
323 (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file,
324 qfname, qfextension[type]);
325 *qfnamep = buf;
319 }
326 }
320 (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);
321 *qfnamep = buf;
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 }
322 return (1);
323}
324
325/*
326 * Routines to manage the file usage table.
327 *
328 * Lookup an id of a specific type.
329 */

--- 79 unchanged lines hidden ---
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 ---