patch-2.1.57 linux/fs/readdir.c

Next file: linux/fs/select.c
Previous file: linux/fs/proc/mem.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.56/linux/fs/readdir.c linux/fs/readdir.c
@@ -87,7 +87,13 @@
 	if (!file->f_op || !file->f_op->readdir)
 		goto out;
 
+	/*
+	 * Get the inode's semaphore to prevent changes
+	 * to the directory while we read it.
+	 */
+	down(&inode->i_sem);
 	error = file->f_op->readdir(file, &buf, fillonedir);
+	up(&inode->i_sem);
 	if (error < 0)
 		goto out;
 	error = buf.count;
@@ -173,7 +179,13 @@
 	if (!file->f_op || !file->f_op->readdir)
 		goto out;
 
+	/*
+	 * Get the inode's semaphore to prevent changes
+	 * to the directory while we read it.
+	 */
+	down(&inode->i_sem);
 	error = file->f_op->readdir(file, &buf, filldir);
+	up(&inode->i_sem);
 	if (error < 0)
 		goto out;
 	lastdirent = buf.previous;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov