Skip to contentSkip to conversation

lseek(fd, n, SEEK_END) does *not* go to eof - n

pile of bugs Al Viro 1 participant 1 message Jun 16, 2013

Subsystems (6)
lore
Share & tools
lore

Al Viro

author
#0 lore raw

When you copy some code, you are supposed to read it. If nothing else, there's a chance to spot and fix an obvious bug instead of sharing it...

X-Song: "I Got It From Agnes", by Tom Lehrer

---

drivers/net/ethernet/brocade/bna/bnad_debugfs.c +1 -1
index 6e8bc9d..94d957d 100644
@@ -244,7 +244,7 @@ bnad_debugfs_lseek(struct file *file, loff_t offset, int orig)
 		file->f_pos += offset;
 		break;
 	case 2:
-		file->f_pos = debug->buffer_len - offset;
+		file->f_pos = debug->buffer_len + offset;
 		break;
 	default:
 		return -EINVAL;
drivers/scsi/bfa/bfad_debugfs.c +1 -1
index 439c012..b63d534 100644
@@ -186,7 +186,7 @@ bfad_debugfs_lseek(struct file *file, loff_t offset, int orig)
 		file->f_pos += offset;
 		break;
 	case 2:
-		file->f_pos = debug->buffer_len - offset;
+		file->f_pos = debug->buffer_len + offset;
 		break;
 	default:
 		return -EINVAL;
drivers/scsi/fnic/fnic_debugfs.c +1 -1
index adc1f7f..85e1ffd 100644
@@ -174,7 +174,7 @@ static loff_t fnic_trace_debugfs_lseek(struct file *file,
 		pos = file->f_pos + offset;
 		break;
 	case 2:
-		pos = fnic_dbg_prt->buffer_len - offset;
+		pos = fnic_dbg_prt->buffer_len + offset;
 	}
 	return (pos < 0 || pos > fnic_dbg_prt->buffer_len) ?
 			  -EINVAL : (file->f_pos = pos);
drivers/scsi/lpfc/lpfc_debugfs.c +1 -1
index f63f5ff..f525ecb 100644
@@ -1178,7 +1178,7 @@ lpfc_debugfs_lseek(struct file *file, loff_t off, int whence)
 		pos = file->f_pos + off;
 		break;
 	case 2:
-		pos = debug->len - off;
+		pos = debug->len + off;
 	}
 	return (pos < 0 || pos > debug->len) ? -EINVAL : (file->f_pos = pos);
 }