aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2009-12-27 06:26:04 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2009-12-27 06:26:04 +0000
commitc3616249ab23a2cfd4caa843df95aeb9a17ef5b2 (patch)
tree96f562fdb9f921dd2993bd1581a245833a5d132b
parente525d16a80319276894d6737ffb7c4b5a8fda142 (diff)
downloadsrc-c3616249ab23a2cfd4caa843df95aeb9a17ef5b2.tar.gz
src-c3616249ab23a2cfd4caa843df95aeb9a17ef5b2.zip
Minor bugs turned up during conversion of quotacheck.
Notes
Notes: svn path=/projects/quota64/; revision=201037
-rw-r--r--lib/libutil/quotafile.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/libutil/quotafile.c b/lib/libutil/quotafile.c
index 9017c4ecd80b..652d95a290fc 100644
--- a/lib/libutil/quotafile.c
+++ b/lib/libutil/quotafile.c
@@ -118,6 +118,8 @@ quota_open(struct fstab *fs, int quotatype, int openflags)
struct stat st;
int qcmd, serrno;
+ if (strcmp(fs->fs_vfstype, "ufs"))
+ return (NULL);
if ((qf = calloc(1, sizeof(*qf))) == NULL)
return (NULL);
qf->fd = -1;
@@ -176,8 +178,11 @@ quota_open(struct fstab *fs, int quotatype, int openflags)
dqh.dqh_version = htobe32(Q_DQHDR64_VERSION);
dqh.dqh_hdrlen = htobe32(sizeof(struct dqhdr64));
dqh.dqh_reclen = htobe32(sizeof(struct dqblk64));
- if (write(qf->fd, &dqh, sizeof(dqh)) != sizeof(dqh))
+ if (write(qf->fd, &dqh, sizeof(dqh)) != sizeof(dqh)) {
+ /* it was one we created ourselves */
+ unlink(qf->qfname);
goto error;
+ }
grp = getgrnam(QUOTAGROUP);
fchown(qf->fd, 0, grp ? grp->gr_gid : 0);
fchmod(qf->fd, 0640);
@@ -185,12 +190,8 @@ quota_open(struct fstab *fs, int quotatype, int openflags)
error:
serrno = errno;
/* did we have an open file? */
- if (qf->fd != -1) {
- /* was it one we created ourselves? */
- if ((openflags & O_CREAT) == O_CREAT)
- unlink(qf->qfname);
+ if (qf->fd != -1)
close(qf->fd);
- }
free(qf);
errno = serrno;
return (NULL);