Ikruglov/sysread implementation

Fix issues noticed by Pavel Shaydo in the maillist