ntfs: takes read only volumes into account #8449

* initial patch from kag_anil fixed by myself
* fix log message in fs_write_attrib()
This commit is contained in:
Jérôme Duval
2012-07-12 21:07:19 +02:00
parent 826e58d886
commit 5e4a2efb47
2 changed files with 20 additions and 3 deletions
@@ -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;
+19 -2
View File
@@ -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;