diff options
author | des <des@FreeBSD.org> | 2009-01-30 13:54:03 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2009-01-30 13:54:03 +0000 |
commit | 604db9f61a0640dd95d3f93b517db0e54b17f090 (patch) | |
tree | f6bcaa578ebaec30009182705f8c54ba76d1e4c0 /libexec/rpc.rquotad | |
parent | c5677e5d7ad2e7b7122f55bc89be13fcb3f7128d (diff) | |
download | FreeBSD-src-604db9f61a0640dd95d3f93b517db0e54b17f090.zip FreeBSD-src-604db9f61a0640dd95d3f93b517db0e54b17f090.tar.gz |
WIP
Diffstat (limited to 'libexec/rpc.rquotad')
-rw-r--r-- | libexec/rpc.rquotad/Makefile | 4 | ||||
-rw-r--r-- | libexec/rpc.rquotad/rquotad.c | 28 |
2 files changed, 9 insertions, 23 deletions
diff --git a/libexec/rpc.rquotad/Makefile b/libexec/rpc.rquotad/Makefile index feacce5..fb3f38bc 100644 --- a/libexec/rpc.rquotad/Makefile +++ b/libexec/rpc.rquotad/Makefile @@ -6,7 +6,7 @@ MAN = rpc.rquotad.8 WARNS ?= 6 -DPADD= ${LIBRPCSVC} -LDADD= -lrpcsvc +DPADD= ${LIBRPCSVC} ${LIBUTIL} +LDADD= -lrpcsvc -lutil .include <bsd.prog.mk> diff --git a/libexec/rpc.rquotad/rquotad.c b/libexec/rpc.rquotad/rquotad.c index 559a57a..63bb0c7 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> @@ -247,9 +248,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); @@ -265,32 +267,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); } |