MCPcopy Create free account
hub / github.com/F-Stack/f-stack / hasquota

Function hasquota

tools/libutil/quotafile.c:67–112  ·  view source on GitHub ↗

* Check to see if a particular quota is to be enabled. */

Source from the content-addressed store, hash-verified

65 * Check to see if a particular quota is to be enabled.
66 */
67static int
68hasquota(struct fstab *fs, int type, char *qfnamep, int qfbufsize)
69{
70 char *opt;
71 char *cp;
72 struct statfs sfb;
73 char buf[BUFSIZ];
74 static char initname, usrname[100], grpname[100];
75
76 /*
77 * 1) we only need one of these
78 * 2) fstab may specify a different filename
79 */
80 if (!initname) {
81 (void)snprintf(usrname, sizeof(usrname), "%s%s",
82 qfextension[USRQUOTA], QUOTAFILENAME);
83 (void)snprintf(grpname, sizeof(grpname), "%s%s",
84 qfextension[GRPQUOTA], QUOTAFILENAME);
85 initname = 1;
86 }
87 strcpy(buf, fs->fs_mntops);
88 for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
89 if ((cp = strchr(opt, '=')))
90 *cp++ = '\0';
91 if (type == USRQUOTA && strcmp(opt, usrname) == 0)
92 break;
93 if (type == GRPQUOTA && strcmp(opt, grpname) == 0)
94 break;
95 }
96 if (!opt)
97 return (0);
98 /*
99 * Ensure that the filesystem is mounted.
100 */
101 if (statfs(fs->fs_file, &sfb) != 0 ||
102 strcmp(fs->fs_file, sfb.f_mntonname)) {
103 return (0);
104 }
105 if (cp) {
106 strlcpy(qfnamep, cp, qfbufsize);
107 } else {
108 (void)snprintf(qfnamep, qfbufsize, "%s/%s.%s", fs->fs_file,
109 QUOTAFILENAME, qfextension[type]);
110 }
111 return (1);
112}
113
114struct quotafile *
115quota_open(struct fstab *fs, int quotatype, int openflags)

Callers 1

quota_openFunction · 0.85

Calls 6

snprintfFunction · 0.85
strtokFunction · 0.85
strchrFunction · 0.85
strcmpFunction · 0.85
statfsClass · 0.70
strlcpyFunction · 0.50

Tested by

no test coverage detected