kempniu / yafut

Yet Another File UTility
GNU General Public License v2.0
4 stars 3 forks source link

Check output file type before calling fchmod() #28

Closed kempniu closed 5 months ago

kempniu commented 5 months ago

When copying a file from a Yaffs file system to a host-mounted file system, Yafut tries to also copy file permissions. Calling fchmod() is expected to always work for standard output and regular files, but not necessarily for other objects that can be represented by a file descriptor (e.g. the /dev/null character device). Since Yafut's primary role is copying file contents and any fchmod() errors cause the program's exit code to become non-zero, only call fchmod() when it is expected to succeed and report success without calling fchmod() otherwise.