I'm not being able to understand it, aren't we supposed to have SEEK_CUR / SEEK_SET or SEEK_END in the whence? Why does it have 2 and how does it work like this?
SEEK_SET
/SEEK_CUR
/SEEK_END
are 0/1/2 respectively, you can use the number or definition.
See definitions here: http://unix.superglobalmegacorp.com/BSD4.4/newsrc/sys/unistd.h.html
/* whence values for lseek(2) */
#define SEEK_SET 0 /* set file offset to offset */
#define SEEK_CUR 1 /* set file offset to current plus offset */
#define SEEK_END 2 /* set file offset to EOF plus offset */
Of course, it is bad practice to directly use these numbers as it may change in future implementations (not likely though)