public RubyFixnum pos(ThreadContext context) {
OpenFile fptr = getOpenFileChecked();
boolean locked = fptr.lock();
try {
long pos = fptr.tell(context);
if (pos < 0 && fptr.errno() != null) throw context.runtime.newErrnoFromErrno(fptr.errno(), fptr.getPath());
pos -= fptr.rbuf.len;
return context.runtime.newFixnum(pos);
} finally {
if (locked) fptr.unlock();