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..cc6ed67 100644
a
|
b
|
typedef struct identify_cookie {
|
48 | 48 | char label[256]; |
49 | 49 | } identify_cookie; |
50 | 50 | |
| 51 | status_t |
| 52 | check_read_only(const char *dev) |
| 53 | { |
| 54 | status_t check = B_OK; // NO ERROR during READ_ONLY check |
| 55 | int fd = open(dev, O_RDONLY | O_NOCACHE); |
| 56 | if (fd < 0) |
| 57 | check = errno; |
| 58 | |
| 59 | if (fd >= 0) { |
| 60 | // opening succeeded |
| 61 | device_geometry geometry; |
| 62 | |
| 63 | if (!ioctl(fd, B_GET_GEOMETRY, &geometry)) { |
| 64 | if (geometry.read_only) { |
| 65 | check = B_READ_ONLY_DEVICE; // READ_ONLY device |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // close the descriptor |
| 70 | close(fd); |
| 71 | } |
| 72 | return check; // go the default way |
| 73 | } |
51 | 74 | |
52 | 75 | static status_t |
53 | 76 | get_node_type(ntfs_inode* ni, int* _type) |
… |
… |
fs_mount(fs_volume *_vol, const char *device, ulong flags, const char *args,
|
204 | 227 | void *handle; |
205 | 228 | unsigned long mountFlags = 0; |
206 | 229 | status_t result = B_NO_ERROR; |
| 230 | status_t rd_only_check; |
207 | 231 | |
208 | 232 | TRACE("fs_mount - ENTER\n"); |
209 | 233 | |
… |
… |
fs_mount(fs_volume *_vol, const char *device, ulong flags, const char *args,
|
234 | 258 | "true"), "true") == 0; |
235 | 259 | unload_driver_settings(handle); |
236 | 260 | |
237 | | if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0) { |
| 261 | // checking whether the device is READ_ONLY or not |
| 262 | rd_only_check = check_read_only(device); |
| 263 | |
| 264 | // check for the read only status if the device |
| 265 | if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0 || rd_only_check == B_READ_ONLY_DEVICE) { |
238 | 266 | mountFlags |= MS_RDONLY; |
239 | 267 | ns->flags |= B_FS_IS_READONLY; |
240 | 268 | } |
241 | | |
242 | | // TODO: this does not take read-only volumes into account! |
| 269 | |
243 | 270 | ns->ntvol = utils_mount_volume(device, mountFlags, true); |
244 | 271 | if (ns->ntvol != NULL) |
245 | 272 | result = B_NO_ERROR; |