{
Inode *in = f->inode.get();
int r;
+ loff_t pos = -1;
switch (whence) {
case SEEK_SET:
- f->pos = offset;
+ pos = offset;
break;
case SEEK_CUR:
- f->pos += offset;
+ pos += offset;
break;
case SEEK_END:
r = _getattr(in, CEPH_STAT_CAP_SIZE, f->actor_perms);
if (r < 0)
return r;
- f->pos = in->size + offset;
+ pos = in->size + offset;
break;
default:
ceph_abort();
}
- ldout(cct, 8) << "_lseek(" << f << ", " << offset << ", " << whence << ") = " << f->pos << dendl;
+ if (pos < 0) {
+ return -EINVAL;
+ } else {
+ f->pos = pos;
+ }
+
+ ldout(cct, 3) << "_lseek(" << f << ", " << offset << ", " << whence << ") = " << f->pos << dendl;
return f->pos;
}