Like the file objects they are associated with, extended attributes (EAs) can have more than one process accessing them at the same time. This means that one process could be querying EAs for a file object, while another is setting EAs for the same file object.
In addition, operations on EAs are not atomic. That is, a query or set operation might not complete before another query or set operation is performed on the same object. If an error occurs before an entire list of EAs has been set, all, some, or none of them may actually remain set on the file object. This means that EAs may not remain in a consistent state unless the order in which the operations are performed can be guaranteed.
Sharing protection is provided so that unpredictable results do not occur during multiple simultaneous operations on extended attributes. EA manipulation is associated with the access permission to the related file object (file or directory).
Handle-based access permission is controlled by the sharing/access mode of the associated file object:
Path-based access permission is controlled by adding the file object to the sharing set for the duration of the call: an application requires read access and file-sharing permission must be set to deny-write.
Note: The functions that set and query EAs fail if another process holds conflicting sharing rights to the file object.
No explicit EA sharing is performed for DosEnumAttribute. Implicit sharing exists if the caller passes the handle of an open file, since sharing access to the associated file is required to modify its EA. No sharing is performed if the caller passes the path name. This means that if some other process is editing the EAs, and changes them between two calls to DosEnumAttribute, inconsistent results might be returned (for example, the same values might be returned twice, some values might be missed, and so on).
To prevent the modification of EAs for the handle case, the file should be opened in deny-write mode before calling DosEnumAttribute. To prevent the modification of EAs for the path name case, the file should be open in deny-write mode before calling DosEnumAttribute. For the directory name case, no sharing is possible.