patch-2.4.19 linux-2.4.19/fs/proc/generic.c

Next file: linux-2.4.19/fs/proc/kcore.c
Previous file: linux-2.4.19/fs/proc/base.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/fs/proc/generic.c linux-2.4.19/fs/proc/generic.c
@@ -138,24 +138,26 @@
 
 
 static loff_t
-proc_file_lseek(struct file * file, loff_t offset, int orig)
+proc_file_lseek(struct file * file, loff_t offset, int origin)
 {
-    switch (orig) {
-    case 0:
-	if (offset < 0)
-	    return -EINVAL;    
-	file->f_pos = offset;
-	return(file->f_pos);
-    case 1:
-	if (offset + file->f_pos < 0)
-	    return -EINVAL;    
-	file->f_pos += offset;
-	return(file->f_pos);
-    case 2:
-	return(-EINVAL);
-    default:
-	return(-EINVAL);
-    }
+	long long retval;
+
+	switch (origin) {
+		case 2:
+			offset += file->f_dentry->d_inode->i_size;
+			break;
+		case 1:
+			offset += file->f_pos;
+	}
+	retval = -EINVAL;
+	if (offset>=0 && offset<=file->f_dentry->d_inode->i_sb->s_maxbytes) {
+		if (offset != file->f_pos) {
+			file->f_pos = offset;
+			file->f_reada = 0;
+		}
+		retval = offset;
+	}
+	return retval;
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)