From owner-freebsd-hackers Thu Apr 11 14: 3:58 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from manor.msen.com (manor.msen.com [148.59.4.66]) by hub.freebsd.org (Postfix) with ESMTP id 9FE6E37B427 for ; Thu, 11 Apr 2002 14:03:25 -0700 (PDT) Received: (from wayne@localhost) by manor.msen.com (8.9.3/8.9.3) id RAA86529 for freebsd-hackers@FreeBSD.ORG; Thu, 11 Apr 2002 17:03:24 -0400 (EDT) (envelope-from wayne) Date: Thu, 11 Apr 2002 17:03:24 -0400 From: "Michael R. Wayne" To: freebsd-hackers@FreeBSD.ORG Subject: Re: quotactl issues Message-ID: <20020411170324.K56996@staff.msen.com> References: <200204101733.NAA65972@manor.msen.com> <20020411132409.J56996@staff.msen.com> <3CB5F6A8.BBD071D@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <3CB5F6A8.BBD071D@mindspring.com>; from tlambert2@mindspring.com on Thu, Apr 11, 2002 at 01:48:40PM -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Apr 11, 2002 at 01:48:40PM -0700, Terry Lambert wrote: > "Michael R. Wayne" wrote: > > No replies on this. Nobody has any ideas? > > Nobody has seen it until now. SOMEbody did - that's why they hacked edquota.c! See code fragment below. > > On Wed, Apr 10, 2002 at 01:33:21PM -0400, Michael R. Wayne wrote: > > > Ported some code that uses quotactl to 4.3 p19 and it fails with EINVAL > > > when trying to: > > > quotactl("var/mail", QCMD(Q_GETQUOTA, USRQUOTA), VALID_UID, &blk) > > > Looked at the source for edquota on 4.5 RELEASE (what I had handy), > > > and ran a copy of it through gdb, it fails with the same error, > > > then it goes in and reads/writes the quota files directly! > > > > > > So, is quotactl just not supported or do the filesystems need to > > > be converted or what? > > 1) Path should be absolute It is in the code. I messed up in the email post. > 2) Path *must* refer to a mount point; you look like you are > treating quotas as if they are more granular than they are. > Quotas are on a per FS basis *only*. /var/mail is a mount point on this box. > 3) Setting a manifest "VALID_UID" doesn't make it valid, just > because you name it that. 8-). OK, I am using 1017 and 1017 is a valid user id on the system. I abstracted in the email. > 4) "[EINVAL] Cmd or the command type is invalid." Right. But the same code works on other BSD systems. > 5) Are you sure that quotas are enables on this FS already? Yes. And edquota (sorta, see below) works OK. > 6) Are you sure blk is a struct dqblk? Yes. > 7) Quota UID and GID ranges are more limited than FreeBSD > otherwise limits UID/GID ranges. Make sure that "VALID_UID" > isn't larger than 65535 or smaller than 0. 1017, which is a valid userid. Now - to re-iterate my point. The code for edquota FAILS IN EXACTLY THE SAME WAY with EINVAL. But edquota IGNORES this error. The reason that edquota works is that, when it gets this failure, it reads and writes the quota file directly. If quotactl works properly, why is there code in edquota.c to read/write the quotactl file directly? /usr/src/usr.sbin/edquota/edquota.c if (quotactl(fs->fs_file, qcmd, id, &qup->dqblk) != 0) { if (errno == EOPNOTSUPP && !warned) { <--- running through gdb errno is EINVAL here. warned++; warnx("warning: quotas are not compiled into this kernel"); sleep(3); } if ((fd = open(qfpathname, O_RDONLY)) < 0) { <--- So, edquota ignores quotactl and does it manually fd = open(qfpathname, O_RDWR|O_CREAT, 0640); if (fd < 0 && errno != ENOENT) { warn("%s", qfpathname); free(qup); continue; } warnx("creating quota file %s", qfpathname); sleep(3); (void) fchown(fd, getuid(), getentry(quotagroup, GRPQUOTA)); (void) fchmod(fd, 0640); } lseek(fd, (long)(id * sizeof(struct dqblk)), L_SET); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message