summaryrefslogtreecommitdiffstats
path: root/lib/libutil/quotafile.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2009-02-13 19:56:59 +0000
committermckusick <mckusick@FreeBSD.org>2009-02-13 19:56:59 +0000
commit987cbdc1c9562a835426a263ddcb2c330666f50c (patch)
tree604aa840a032757c89d2272ab58491491c47038c /lib/libutil/quotafile.c
parent71ad94ecbb545e5a6d3544f912ab8ab0f21253b8 (diff)
downloadFreeBSD-src-987cbdc1c9562a835426a263ddcb2c330666f50c.zip
FreeBSD-src-987cbdc1c9562a835426a263ddcb2c330666f50c.tar.gz
Make hasquota thread safe.
Diffstat (limited to 'lib/libutil/quotafile.c')
-rw-r--r--lib/libutil/quotafile.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/libutil/quotafile.c b/lib/libutil/quotafile.c
index 2520e9f..2b43b65 100644
--- a/lib/libutil/quotafile.c
+++ b/lib/libutil/quotafile.c
@@ -280,13 +280,13 @@ quota_write(struct quotafile *qf, const struct dqblk *dqb, int id)
* Check to see if a particular quota is to be enabled.
*/
int
-hasquota(struct fstab *fs, int type, char **qfnamep)
+hasquota(struct fstab *fs, int type, char *qfnamep, int qfbufsize)
{
char *opt;
char *cp;
struct statfs sfb;
+ char buf[BUFSIZ];
static char initname, usrname[100], grpname[100];
- static char buf[BUFSIZ];
if (!initname) {
(void)snprintf(usrname, sizeof(usrname), "%s%s",
@@ -306,13 +306,6 @@ hasquota(struct fstab *fs, int type, char **qfnamep)
}
if (!opt)
return (0);
- if (cp)
- *qfnamep = cp;
- else {
- (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file,
- QUOTAFILENAME, qfextension[type]);
- *qfnamep = buf;
- }
/*
* Ensure that the filesystem is mounted.
*/
@@ -320,5 +313,11 @@ hasquota(struct fstab *fs, int type, char **qfnamep)
strcmp(fs->fs_file, sfb.f_mntonname)) {
return (0);
}
+ if (cp) {
+ strncpy(qfnamep, cp, qfbufsize);
+ } else {
+ (void)snprintf(qfnamep, qfbufsize, "%s/%s.%s", fs->fs_file,
+ QUOTAFILENAME, qfextension[type]);
+ }
return (1);
}
OpenPOWER on IntegriCloud