mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-07 00:50:50 +00:00
Make hasquota thread safe.
This commit is contained in:
parent
909d0c906f
commit
a88984f248
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/quota64/; revision=188598
|
@ -148,7 +148,7 @@ struct quotafile *quota_create(const char *);
|
|||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue