edquota.c (166480) | edquota.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 --- 29 unchanged lines hidden (view full) --- 38#endif /* not lint */ 39 40#ifndef lint 41static char sccsid[] = "@(#)edquota.c 8.1 (Berkeley) 6/6/93"; 42#endif /* not lint */ 43#endif 44 45#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 --- 29 unchanged lines hidden (view full) --- 38#endif /* not lint */ 39 40#ifndef lint 41static char sccsid[] = "@(#)edquota.c 8.1 (Berkeley) 6/6/93"; 42#endif /* not lint */ 43#endif 44 45#include <sys/cdefs.h> |
46__FBSDID("$FreeBSD: head/usr.sbin/edquota/edquota.c 166480 2007-02-04 01:41:32Z mpp $"); | 46__FBSDID("$FreeBSD: head/usr.sbin/edquota/edquota.c 166485 2007-02-04 06:33:15Z mpp $"); |
47 48/* 49 * Disk quota editor. 50 */ 51 52#include <sys/param.h> 53#include <sys/stat.h> 54#include <sys/file.h> | 47 48/* 49 * Disk quota editor. 50 */ 51 52#include <sys/param.h> 53#include <sys/stat.h> 54#include <sys/file.h> |
55#include <sys/mount.h> |
|
55#include <sys/wait.h> 56#include <ufs/ufs/quota.h> 57#include <ctype.h> 58#include <err.h> 59#include <errno.h> 60#include <fstab.h> 61#include <grp.h> 62#include <pwd.h> --- 801 unchanged lines hidden (view full) --- 864 return (1); 865} 866 867/* 868 * Check to see if a particular quota is to be enabled. 869 */ 870int 871hasquota(fs, type, qfnamep) | 56#include <sys/wait.h> 57#include <ufs/ufs/quota.h> 58#include <ctype.h> 59#include <err.h> 60#include <errno.h> 61#include <fstab.h> 62#include <grp.h> 63#include <pwd.h> --- 801 unchanged lines hidden (view full) --- 865 return (1); 866} 867 868/* 869 * Check to see if a particular quota is to be enabled. 870 */ 871int 872hasquota(fs, type, qfnamep) |
872 register struct fstab *fs; | 873 struct fstab *fs; |
873 int type; 874 char **qfnamep; 875{ | 874 int type; 875 char **qfnamep; 876{ |
876 register char *opt; | 877 char *opt; |
877 char *cp; | 878 char *cp; |
879 struct statfs sfb; |
|
878 static char initname, usrname[100], grpname[100]; 879 static char buf[BUFSIZ]; 880 881 if (!initname) { | 880 static char initname, usrname[100], grpname[100]; 881 static char buf[BUFSIZ]; 882 883 if (!initname) { |
882 sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname); 883 sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname); | 884 (void)snprintf(usrname, sizeof(usrname), "%s%s", 885 qfextension[USRQUOTA], qfname); 886 (void)snprintf(grpname, sizeof(grpname), "%s%s", 887 qfextension[GRPQUOTA], qfname); |
884 initname = 1; 885 } 886 strcpy(buf, fs->fs_mntops); 887 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 888 if ((cp = index(opt, '='))) 889 *cp++ = '\0'; 890 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 891 break; 892 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 893 break; 894 } 895 if (!opt) 896 return (0); | 888 initname = 1; 889 } 890 strcpy(buf, fs->fs_mntops); 891 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { 892 if ((cp = index(opt, '='))) 893 *cp++ = '\0'; 894 if (type == USRQUOTA && strcmp(opt, usrname) == 0) 895 break; 896 if (type == GRPQUOTA && strcmp(opt, grpname) == 0) 897 break; 898 } 899 if (!opt) 900 return (0); |
897 if (cp) { | 901 if (cp) |
898 *qfnamep = cp; | 902 *qfnamep = cp; |
899 return (1); | 903 else { 904 (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file, 905 qfname, qfextension[type]); 906 *qfnamep = buf; |
900 } | 907 } |
901 (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); 902 *qfnamep = buf; | 908 if (statfs(fs->fs_file, &sfb) != 0) { 909 warn("cannot statfs mount point %s", fs->fs_file); 910 return (0); 911 } 912 if (strcmp(fs->fs_file, sfb.f_mntonname)) { 913 warnx("%s not mounted for %s quotas", fs->fs_file, 914 type == USRQUOTA ? "user" : "group"); 915 sleep(3); 916 return (0); 917 } |
903 return (1); 904} | 918 return (1); 919} |