oop: improve safety for truncateFile

In order to make truncateFile safer and to avoid any confusion on its
behavior:

* a new comment has been added mentioning O_TRUNC and "w" to avoid any
  future mistake in this area
* a new test has been added to check the expected outcomes
* the "w" mode has been removed from truncateFile (used in os.fdopen)
  to prevent any future reconversion to open(path, "w")
* the risk of a file descriptor leak (for a failing os.fdopen call)
  has been removed using the relevant posix calls

Change-Id: Ib71b53498c7bc4ea7a1ab725feb18bc5929f8c85
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/20046
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
Reviewed-by: Sergey Gotliv <sgotliv@redhat.com>
Reviewed-by: Dan Kenigsberg <danken@redhat.com>