Skip to content

Commit

Permalink
Attempted mounting read-only after failed permission to read-write
Browse files Browse the repository at this point in the history
If a partition image could not be opened read-write, retry as read-only
  • Loading branch information
Jean-Pierre André committed Aug 22, 2018
1 parent d52b1ca commit 2514ce6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libntfs-3g/unix_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags)
*(int*)dev->d_private = open(dev->d_name, flags);
if (*(int*)dev->d_private == -1) {
err = errno;
/* if permission error and rw, retry read-only */
if ((err == EACCES) && ((flags & O_RDWR) == O_RDWR))
err = EROFS;
goto err_out;
}
#ifdef HAVE_LINUX_FS_H
Expand Down
2 changes: 1 addition & 1 deletion libntfs-3g/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev,
dev->d_name);
goto error_exit;
} else {
ntfs_log_info("Can only open '%s' as read-only\n",
ntfs_log_info("Error opening '%s' read-write\n",
dev->d_name);
NVolSetReadOnly(vol);
}
Expand Down

0 comments on commit 2514ce6

Please sign in to comment.