From owner-svn-src-projects@FreeBSD.ORG Fri Feb 13 19:57:00 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37A0E1065670; Fri, 13 Feb 2009 19:57:00 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B8B18FC1C; Fri, 13 Feb 2009 19:57:00 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1DJuxkt097925; Fri, 13 Feb 2009 19:56:59 GMT (envelope-from mckusick@svn.freebsd.org) Received: (from mckusick@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1DJuxes097923; Fri, 13 Feb 2009 19:56:59 GMT (envelope-from mckusick@svn.freebsd.org) Message-Id: <200902131956.n1DJuxes097923@svn.freebsd.org> From: Kirk McKusick Date: Fri, 13 Feb 2009 19:56:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188598 - projects/quota64/lib/libutil X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Feb 2009 19:57:00 -0000 Author: mckusick Date: Fri Feb 13 19:56:59 2009 New Revision: 188598 URL: http://svn.freebsd.org/changeset/base/188598 Log: Make hasquota thread safe. Modified: projects/quota64/lib/libutil/libutil.h projects/quota64/lib/libutil/quotafile.c Modified: projects/quota64/lib/libutil/libutil.h ============================================================================== --- projects/quota64/lib/libutil/libutil.h Fri Feb 13 19:49:51 2009 (r188597) +++ projects/quota64/lib/libutil/libutil.h Fri Feb 13 19:56:59 2009 (r188598) @@ -148,7 +148,7 @@ struct quotafile *quota_create(const cha void quota_close(struct quotafile *); int quota_read(struct quotafile *, struct dqblk *, int); int quota_write(struct quotafile *, const struct dqblk *, int); -int hasquota(struct fstab *, int, char **); +int hasquota(struct fstab *, int, char *, int); #endif __END_DECLS Modified: projects/quota64/lib/libutil/quotafile.c ============================================================================== --- projects/quota64/lib/libutil/quotafile.c Fri Feb 13 19:49:51 2009 (r188597) +++ projects/quota64/lib/libutil/quotafile.c Fri Feb 13 19:56:59 2009 (r188598) @@ -280,13 +280,13 @@ quota_write(struct quotafile *qf, const * 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, cha } 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, cha 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); }