[PATCH master] fs: align truncate return codes with POSIX
m.felsch at pengutronix.de
Thu Feb 2 05:12:16 PST 2023
thanks for the patch.
On 23-02-02, Ahmad Fatoum wrote:
> Writing past end of a file results in a cryptic error code:
> barebox at board:/ cp /dev/zero /dev/mmc0.part
> write: Operation not permitted
> cp: Operation not permitted
> Because the cdev's truncate is not implemented and as such partition
> can't be increased in size. POSIX specifies EPERM as the correct return
> code for truncate(2) in such a situation, but for write(2) it is ENOSPC.
> Thus most truncate callbacks in barebox instead return ENOSPC, when
> according to POSIX, EPERM would have been the correct error code to
> Switching all truncate drivers is a bit more involved, so for now let's
> treat EPERM and ENOSPC instead when truncate fails to enlarge a file.
> Reported-by: Marco Felsch <m.felsch at pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Reviewed-by: Marco Felsch <m.felsch at pengutronix.de>
More information about the barebox