patch-2.1.48 linux/fs/proc/link.c

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

diff -u --recursive --new-file v2.1.47/linux/fs/proc/link.c linux/fs/proc/link.c
@@ -138,15 +138,18 @@
 	if (!IS_ERR(dentry)) {
 		error = -ENOENT;
 		if (dentry) {
-			char * tmp = (char*)__get_free_page(GFP_KERNEL);
-			int len = d_path(dentry, current->fs->root, tmp);
-			int min = buflen<PAGE_SIZE ? buflen : PAGE_SIZE;
-			if(len <= min)
-				min = len+1;
+			char * tmp = (char*)__get_free_page(GFP_KERNEL), *path;
+			int len;
+
+			path = d_path(dentry, tmp, PAGE_SIZE);
+			len = tmp + PAGE_SIZE - path;
+
+			if (len < buflen)
+				buflen = len;
 			dput(dentry);
-			copy_to_user(buffer, tmp, min);
+			copy_to_user(buffer, path, buflen);
 			free_page((unsigned long)tmp);
-			error = len;
+			error = buflen;
 		}
 	}
 	return error;

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