summaryrefslogtreecommitdiffstats
path: root/libexec/rpc.rquotad/rquotad.c
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/rpc.rquotad/rquotad.c')
-rw-r--r--libexec/rpc.rquotad/rquotad.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/libexec/rpc.rquotad/rquotad.c b/libexec/rpc.rquotad/rquotad.c
index fe82742..2499c48 100644
--- a/libexec/rpc.rquotad/rquotad.c
+++ b/libexec/rpc.rquotad/rquotad.c
@@ -23,6 +23,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fstab.h>
#include <grp.h>
+#include <libutil.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -245,9 +246,10 @@ initfs(void)
int
getfsquota(long id, char *path, struct dqblk *dqblk)
{
+ struct quotafile *qf;
struct stat st_path;
struct fs_stat *fs;
- int qcmd, fd, ret = 0;
+ int qcmd, ret = 0;
if (stat(path, &st_path) < 0)
return (0);
@@ -263,32 +265,16 @@ getfsquota(long id, char *path, struct dqblk *dqblk)
if (quotactl(fs->fs_file, qcmd, id, dqblk) == 0)
return (1);
- if ((fd = open(fs->qfpathname, O_RDONLY)) < 0) {
+ if ((qf = quota_open(fs->qfpathname)) == NULL) {
syslog(LOG_ERR, "open error: %s: %m", fs->qfpathname);
return (0);
}
- if (lseek(fd, (off_t)(id * sizeof(struct dqblk)), L_SET) == (off_t)-1) {
- close(fd);
- return (1);
- }
- switch (read(fd, dqblk, sizeof(struct dqblk))) {
- case 0:
- /*
- * Convert implicit 0 quota (EOF)
- * into an explicit one (zero'ed dqblk)
- */
- bzero(dqblk, sizeof(struct dqblk));
- ret = 1;
- break;
- case sizeof(struct dqblk): /* OK */
- ret = 1;
- break;
- default: /* ERROR */
+ if (quota_read(qf, dqblk, id) != 0) {
syslog(LOG_ERR, "read error: %s: %m", fs->qfpathname);
- close(fd);
+ quota_close(qf);
return (0);
}
- close(fd);
+ quota_close(qf);
}
return (ret);
}
OpenPOWER on IntegriCloud