patch-1.3.48 linux/fs/open.c

Next file: linux/fs/umsdos/inode.c
Previous file: linux/fs/namei.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.47/linux/fs/open.c linux/fs/open.c
@@ -367,6 +367,7 @@
 	struct inode * inode;
 	struct file * file;
 	struct iattr newattrs;
+	int error;
 
 	if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
 		return -EBADF;
@@ -400,7 +401,16 @@
 		newattrs.ia_valid |= ATTR_MODE;
 	}
 	inode->i_dirt = 1;
-	return notify_change(inode, &newattrs);
+	if (inode->i_sb->dq_op) {
+		inode->i_sb->dq_op->initialize(inode, -1);
+		if (inode->i_sb->dq_op->transfer(inode, &newattrs, 0))
+			return -EDQUOT;
+		error = notify_change(inode, &newattrs);
+		if (error)
+			inode->i_sb->dq_op->transfer(inode, &newattrs, 1);
+	} else
+		error = notify_change(inode, &newattrs);
+	return error;
 }
 
 asmlinkage int sys_chown(const char * filename, uid_t user, gid_t group)
@@ -444,7 +454,15 @@
 		newattrs.ia_valid |= ATTR_MODE;
 	}
 	inode->i_dirt = 1;
-	error = notify_change(inode, &newattrs);
+	if (inode->i_sb->dq_op) {
+		inode->i_sb->dq_op->initialize(inode, -1);
+		if (inode->i_sb->dq_op->transfer(inode, &newattrs, 0))
+			return -EDQUOT;
+		error = notify_change(inode, &newattrs);
+		if (error)
+			inode->i_sb->dq_op->transfer(inode, &newattrs, 1);
+	} else
+		error = notify_change(inode, &newattrs);
 	iput(inode);
 	return(error);
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this