libmount: check writing to a file was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
include: add close_fd() for noticing write errors before close()

Essentially this helper function is similar to close_stream(), but for
file descriptors.

When a file descriptors are close()'d status of write is often
overlooked.  The close_fd() will try to determine what happen to writes
with fsync() before closing the file descriptor.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
fdformat: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
partx: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
resizepart: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
cfdisk: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sfdisk: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
wdctl: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
fsck.cramfs: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
fsck.minix: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
mkfs.bfs: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
mkfs.cramfs: unify write check to a file descriptor

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
mkfs.minix: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
mkswap: unify write check to a file descriptor

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
swaplabel: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
fallocate: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
setpriv: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
swapon: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
wall: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>