svn commit: r201037 - projects/quota64/lib/libutil
Kirk McKusick
mckusick at FreeBSD.org
Sun Dec 27 06:26:04 UTC 2009
Author: mckusick
Date: Sun Dec 27 06:26:04 2009
New Revision: 201037
URL: http://svn.freebsd.org/changeset/base/201037
Log:
Minor bugs turned up during conversion of quotacheck.
Modified:
projects/quota64/lib/libutil/quotafile.c
Modified: projects/quota64/lib/libutil/quotafile.c
==============================================================================
--- projects/quota64/lib/libutil/quotafile.c Sun Dec 27 06:25:03 2009 (r201036)
+++ projects/quota64/lib/libutil/quotafile.c Sun Dec 27 06:26:04 2009 (r201037)
@@ -118,6 +118,8 @@ quota_open(struct fstab *fs, int quotaty
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 quotaty
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 quotaty
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);
More information about the svn-src-projects
mailing list