diff --git a/include/ntfs/layout.h b/include/ntfs/layout.h index f9f3ea7c..d2fa1a41 100644 --- a/include/ntfs/layout.h +++ b/include/ntfs/layout.h @@ -524,7 +524,7 @@ typedef enum { * unistr.c::ntfs_collate_names() and unistr.c::legal_ansi_char_array[] * for what I mean but COLLATION_UNICODE_STRING would not give any special * treatment to any characters at all, but this is speculation. - * COLLATION_NTOFS_ULONG - Sorting is done according to ascending u32 key + * COLLATION_NTOFS_ULONG - Sorting is done according to ascending u32 key * values. E.g. used for $SII index in FILE_Secure, which sorts by * security_id (u32). * COLLATION_NTOFS_SID - Sorting is done according to ascending SID values. diff --git a/libntfs/unix_io.c b/libntfs/unix_io.c index 5cfbeee0..ee8d35db 100644 --- a/libntfs/unix_io.c +++ b/libntfs/unix_io.c @@ -90,9 +90,11 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags) return -1; /* * Open the device/file obtaining the file descriptor for exclusive - * access. + * access (but only if mounting r/w). */ - *(int*)dev->d_private = open(dev->d_name, flags | O_EXCL); + if ((flags & O_RDWR) == O_RDWR) + flags |= O_EXCL; + *(int*)dev->d_private = open(dev->d_name, flags); if (*(int*)dev->d_private == -1) { err = errno; goto err_out;