diff options
| author | Jérôme Duval <jerome.duval@gmail.com> | 2012-07-12 21:03:17 +0200 |
|---|---|---|
| committer | Jérôme Duval <jerome.duval@gmail.com> | 2012-07-12 21:07:19 +0200 |
| commit | 5e4a2efb479d3b3957f89fd3d318996541f00aeb (patch) | |
| tree | f5563e6eec76c557c8efeea159ecb9102fdedae0 | |
| parent | 826e58d886baacc4352177cae94c11c409e09fb7 (diff) | |
* initial patch from kag_anil fixed by myself
* fix log message in fs_write_attrib()
| -rw-r--r-- | src/add-ons/kernel/file_systems/ntfs/attributes.c | 2 | ||||
| -rw-r--r-- | src/add-ons/kernel/file_systems/ntfs/fs_func.c | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/add-ons/kernel/file_systems/ntfs/attributes.c b/src/add-ons/kernel/file_systems/ntfs/attributes.c index 2d5aa4d304..c6fe2a56c8 100644 --- a/src/add-ons/kernel/file_systems/ntfs/attributes.c +++ b/src/add-ons/kernel/file_systems/ntfs/attributes.c @@ -582,7 +582,7 @@ fs_write_attrib(fs_volume *_vol, fs_vnode *_node, void *_cookie,off_t pos, ERROR("%s - ntfs_attr_pwrite returned less bytes than "
"requested.\n", __FUNCTION__);
if (bytesWritten <= 0) {
- ERROR(("%s - ntfs_attr_pwrite()<=0\n", __FUNCTION__));
+ ERROR("%s - ntfs_attr_pwrite()<=0\n", __FUNCTION__);
*_length = 0;
result = EINVAL;
goto exit;
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 aee6569949..82736afb99 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fs_func.c +++ b/src/add-ons/kernel/file_systems/ntfs/fs_func.c @@ -49,6 +49,23 @@ typedef struct identify_cookie { } identify_cookie; +static bool +is_device_read_only(const char *device) +{ + bool isReadOnly = false; + device_geometry geometry; + int fd = open(device, O_RDONLY | O_NOCACHE); + if (fd < 0) + return false; + + if (ioctl(fd, B_GET_GEOMETRY, &geometry) == 0) + isReadOnly = geometry.read_only; + + close(fd); + return isReadOnly; +} + + static status_t get_node_type(ntfs_inode* ni, int* _type) { @@ -234,12 +251,12 @@ fs_mount(fs_volume *_vol, const char *device, ulong flags, const char *args, "true"), "true") == 0; unload_driver_settings(handle); - if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0) { + if (ns->ro || (flags & B_MOUNT_READ_ONLY) != 0 + || is_device_read_only(device)) { mountFlags |= MS_RDONLY; ns->flags |= B_FS_IS_READONLY; } - // TODO: this does not take read-only volumes into account! ns->ntvol = utils_mount_volume(device, mountFlags, true); if (ns->ntvol != NULL) result = B_NO_ERROR; |
