@@ -720,29 +720,32 @@ fhandler_base::open (int flags, mode_t mode)
720720 goto done;
721721 }
722722
723- /* Fix up file attributes, they are desperately needed later.
724-
725- Originally we only did that in the FILE_CREATED case below, but that's
726- insufficient:
727-
728- If two threads try to create the same file at the same time, it's
729- possible that path_conv::check returns the file as non-existant, i. e.,
730- pc.file_attributes () returns INVALID_FILE_ATTRIBUTES, 0xffffffff.
731- However, one of the NtCreateFile will beat the other, so only one of
732- them returns with FILE_CREATED.
733-
734- The other fhandler_base::open() will instead run into the O_TRUNC
735- conditional (further below), blindly check for the SPARSE attribute
736- and remove that bit. The result is that the attributes will be
737- 0xfffffdff, i.e., everything but SPARSE. Most annoying is that
738- pc.isdir() will return TRUE. Hilarity ensues.
739-
740- Note that we use a different IO_STATUS_BLOCK, so as not to overwrite
741- io.Information... */
742- if (!NT_SUCCESS (NtQueryInformationFile (fh, &io_bi, &fbi, sizeof fbi,
743- FileBasicInformation)))
744- fbi.FileAttributes = file_attributes | FILE_ATTRIBUTE_ARCHIVE;
745- pc.file_attributes (fbi.FileAttributes );
723+ if (get_device () == FH_FS)
724+ {
725+ /* Fix up file attributes, they are desperately needed later.
726+
727+ Originally we only did that in the FILE_CREATED case below, but that's
728+ insufficient:
729+
730+ If two threads try to create the same file at the same time, it's
731+ possible that path_conv::check returns the file as non-existant, i. e.,
732+ pc.file_attributes () returns INVALID_FILE_ATTRIBUTES, 0xffffffff.
733+ However, one of the NtCreateFile will beat the other, so only one of
734+ them returns with FILE_CREATED.
735+
736+ The other fhandler_base::open() will instead run into the O_TRUNC
737+ conditional (further below), blindly check for the SPARSE attribute
738+ and remove that bit. The result is that the attributes will be
739+ 0xfffffdff, i.e., everything but SPARSE. Most annoying is that
740+ pc.isdir() will return TRUE. Hilarity ensues.
741+
742+ Note that we use a different IO_STATUS_BLOCK, so as not to overwrite
743+ io.Information... */
744+ if (!NT_SUCCESS (NtQueryInformationFile (fh, &io_bi, &fbi, sizeof fbi,
745+ FileBasicInformation)))
746+ fbi.FileAttributes = file_attributes | FILE_ATTRIBUTE_ARCHIVE;
747+ pc.file_attributes (fbi.FileAttributes );
748+ }
746749
747750 if (io.Information == FILE_CREATED)
748751 {
0 commit comments