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:
@@ -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 "
|
ERROR("%s - ntfs_attr_pwrite returned less bytes than "
|
||||||
"requested.\n", __FUNCTION__);
|
"requested.\n", __FUNCTION__);
|
||||||
if (bytesWritten <= 0) {
|
if (bytesWritten <= 0) {
|
||||||
ERROR(("%s - ntfs_attr_pwrite()<=0\n", __FUNCTION__));
|
ERROR("%s - ntfs_attr_pwrite()<=0\n", __FUNCTION__);
|
||||||
*_length = 0;
|
*_length = 0;
|
||||||
result = EINVAL;
|
result = EINVAL;
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|||||||
@@ -49,6 +49,23 @@ typedef struct identify_cookie {
|
|||||||
} 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
|
static status_t
|
||||||
get_node_type(ntfs_inode* ni, int* _type)
|
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;
|
"true"), "true") == 0;
|
||||||
unload_driver_settings(handle);
|
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;
|
mountFlags |= MS_RDONLY;
|
||||||
ns->flags |= B_FS_IS_READONLY;
|
ns->flags |= B_FS_IS_READONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this does not take read-only volumes into account!
|
|
||||||
ns->ntvol = utils_mount_volume(device, mountFlags, true);
|
ns->ntvol = utils_mount_volume(device, mountFlags, true);
|
||||||
if (ns->ntvol != NULL)
|
if (ns->ntvol != NULL)
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user