diff --git a/libntfs-3g/volume.c b/libntfs-3g/volume.c index 389acee4..8ec4ba8c 100644 --- a/libntfs-3g/volume.c +++ b/libntfs-3g/volume.c @@ -512,8 +512,20 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long flags) /* ...->open needs bracketing to compile with glibc 2.7 */ if ((dev->d_ops->open)(dev, NVolReadOnly(vol) ? O_RDONLY: O_RDWR)) { - ntfs_log_perror("Error opening '%s'", dev->d_name); - goto error_exit; + if (!NVolReadOnly(vol) && (errno == EROFS)) { + if ((dev->d_ops->open)(dev, O_RDONLY)) { + ntfs_log_perror("Error opening read-only '%s'", + dev->d_name); + goto error_exit; + } else { + ntfs_log_info("Can only open '%s' as read-only\n", + dev->d_name); + NVolSetReadOnly(vol); + } + } else { + ntfs_log_perror("Error opening '%s'", dev->d_name); + goto error_exit; + } } /* Attach the device to the volume. */ vol->dev = dev; diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c index a923da74..4f0bcd40 100644 --- a/src/lowntfs-3g.c +++ b/src/lowntfs-3g.c @@ -3906,6 +3906,12 @@ int main(int argc, char *argv[]) if (err) goto err_out; + /* Force read-only mount if the device was found read-only */ + if (!ctx->ro && NVolReadOnly(ctx->vol)) { + ctx->ro = TRUE; + if (ntfs_strinsert(&parsed_options, ",ro")) + goto err_out; + } /* We must do this after ntfs_open() to be able to set the blksize */ if (ctx->blkdev && set_fuseblk_options(&parsed_options)) goto err_out; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index b3fa50d6..540ef473 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -3798,6 +3798,12 @@ int main(int argc, char *argv[]) if (err) goto err_out; + /* Force read-only mount if the device was found read-only */ + if (!ctx->ro && NVolReadOnly(ctx->vol)) { + ctx->ro = TRUE; + if (ntfs_strinsert(&parsed_options, ",ro")) + goto err_out; + } /* We must do this after ntfs_open() to be able to set the blksize */ if (ctx->blkdev && set_fuseblk_options(&parsed_options)) goto err_out;