diff --git a/src/add-ons/kernel/file_systems/ntfs/fs_func.c b/src/add-ons/kernel/file_systems/ntfs/fs_func.c
index 166fbbc..2a023fb 100644
a
|
b
|
typedef struct identify_cookie {
|
48 | 48 | char label[256]; |
49 | 49 | } identify_cookie; |
50 | 50 | |
| 51 | bool |
| 52 | is_device_read_only(const char *device) |
| 53 | { |
| 54 | bool isReadOnly = FALSE; |
| 55 | int fd = open(device, O_RDONLY | O_NOCACHE); |
| 56 | |
| 57 | if (fd >= 0) { |
| 58 | device_geometry geometry; |
| 59 | |
| 60 | if (ioctl(fd, B_GET_GEOMETRY, &geometry) == 0) { |
| 61 | if (geometry.read_only) { |
| 62 | isReadOnly = TRUE; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | close(fd); |
| 67 | } |
| 68 | return isReadOnly; |
| 69 | } |
51 | 70 | |
52 | 71 | static status_t |
53 | 72 | get_node_type(ntfs_inode* ni, int* _type) |
… |
… |
fs_mount(fs_volume *_vol, const char *device, ulong flags, const char *args,
|
234 | 253 | "true"), "true") == 0; |
235 | 254 | unload_driver_settings(handle); |
236 | 255 | |
237 | | if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0) { |
| 256 | if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0 || is_device_read_only(device)) { |
238 | 257 | mountFlags |= MS_RDONLY; |
239 | 258 | ns->flags |= B_FS_IS_READONLY; |
240 | 259 | } |
241 | 260 | |
242 | | // TODO: this does not take read-only volumes into account! |
243 | 261 | ns->ntvol = utils_mount_volume(device, mountFlags, true); |
244 | 262 | if (ns->ntvol != NULL) |
245 | 263 | result = B_NO_ERROR; |