[net.bugs.4bsd] 4.2 disk quota bug setting quotas for logged in users

kre@mulga.OZ (Robert Elz) (10/01/84)

Index: sys/quota_sys.c 4.2bsd FIX

Description:
	If you attempt to set a new disk quota on a user who
	has recently deleted some files, the system will
	quite likely soon panic with "maknode: dquot".
	This has been known to appear as if the problem is
	setting disk quotas of a user who is logged in.

Repeat-By:
	Find some user who has no quotas, have him log in &
	delete some files (create them first if necessary)
	then set quotas on that filesystem (the one that
	files were deleted on).  Have the user create the
	files again (any contents, or none).  Unless you're
	very lucky, you will get a panic("maknode: dquot").
	(Of course, the system may have panic'd because of
	some other user creating a file before you get a chance).

Fix:
	The following diff is to sys/quota_sys.c, the line numbers
	are most probably way out, but its right near the end of
	function setdlim() (last 10 lines).  First piece of text
	is the old (buggy) version, second is the fixed one.

*** /tmp/quota_sys.c	Mon Oct  1 05:27:25 1984
--- quota_sys.c	Sun Jul 15 07:13:23 1984
***************
*** 171,177
  	if (dq == odq)
  		return (error);
  	for (ip = inode; ip < inodeNINODE; ip++)
! 		if (ip->i_uid == q->q_uid && ip->i_dev == dev) {
  			if (dq == NODQUOT)
  				dqrele(ip->i_dquot);
  			else

--- 171,177 -----
  	if (dq == odq)
  		return (error);
  	for (ip = inode; ip < inodeNINODE; ip++)
! 		if (ip->i_uid == q->q_uid && ip->i_dev == dev && ip->i_mode) {
  			if (dq == NODQUOT)
  				dqrele(ip->i_dquot);
  			else

Robert Elz					decvax!mulga!kre