Fix file mode calculation

Since 9da0627, file mode calculation is incorrect. For example when `umask` is `0077`, file mode is `0611` instead of `0600`.

See 898a38b / #7196.