mirror of https://git.tukaani.org/xz.git
Revert "xz: O_SEARCH cannot be used for fsync()"
This reverts commit 4014e2479c
.
POSIX-conforming O_SEARCH should allow fsync().
This commit is contained in:
parent
4014e2479c
commit
ea92eae122
|
@ -69,6 +69,10 @@ static bool warn_fchown;
|
||||||
# define O_NOCTTY 0
|
# define O_NOCTTY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef O_SEARCH
|
||||||
|
# define O_SEARCH O_RDONLY
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef O_DIRECTORY
|
#ifndef O_DIRECTORY
|
||||||
# define O_DIRECTORY 0
|
# define O_DIRECTORY 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -886,7 +890,7 @@ io_open_dest_real(file_pair *pair)
|
||||||
// to a directory. (We opened the source file
|
// to a directory. (We opened the source file
|
||||||
// already but directories might have been renamed
|
// already but directories might have been renamed
|
||||||
// after the source file was opened.)
|
// after the source file was opened.)
|
||||||
pair->dir_fd = open(dir_name, O_RDONLY | O_DIRECTORY
|
pair->dir_fd = open(dir_name, O_SEARCH | O_DIRECTORY
|
||||||
| O_NOCTTY | O_NONBLOCK);
|
| O_NOCTTY | O_NONBLOCK);
|
||||||
if (pair->dir_fd == -1) {
|
if (pair->dir_fd == -1) {
|
||||||
// Since we did open the source file
|
// Since we did open the source file
|
||||||
|
@ -896,15 +900,12 @@ io_open_dest_real(file_pair *pair)
|
||||||
//
|
//
|
||||||
// In an odd case, the directory has write
|
// In an odd case, the directory has write
|
||||||
// and search permissions but not read
|
// and search permissions but not read
|
||||||
// permission (d-wx------). Then we would be
|
// permission (d-wx------), and O_SEARCH is
|
||||||
// able to create a new file and only the
|
// actually O_RDONLY. Then we would be able
|
||||||
// directory syncing would be impossible. But
|
// to create a new file and only the directory
|
||||||
// let's be strict about syncing and require
|
// syncing would be impossible. But let's be
|
||||||
// users to explicitly disable it if they
|
// strict about syncing and require users to
|
||||||
// don't want it.
|
// explicitly disable it if they don't want it.
|
||||||
//
|
|
||||||
// NOTE: O_SEARCH doesn't allow fsync().
|
|
||||||
// musl maps O_SEARCH to O_PATH.
|
|
||||||
message_error(_("%s: Opening the directory "
|
message_error(_("%s: Opening the directory "
|
||||||
"failed: %s"),
|
"failed: %s"),
|
||||||
tuklib_mask_nonprint(dir_name),
|
tuklib_mask_nonprint(dir_name),
|
||||||
|
|
Loading…
Reference in New Issue