Bug 53237 - [PATCH] Automatic mounting of read-only NTFS partition on USB device fails
Summary: [PATCH] Automatic mounting of read-only NTFS partition on USB device fails
Status: RESOLVED NOTOURBUG
Alias: None
Product: udisks
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: David Zeuthen (not reading bugmail)
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-08 10:29 UTC by Anthony Wong
Modified: 2012-09-10 13:52 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
patch (1.54 KB, patch)
2012-08-08 10:29 UTC, Anthony Wong
Details | Splinter Review
add tests to reproduce this (1.50 KB, patch)
2012-09-06 10:25 UTC, Martin Pitt
Details | Splinter Review

Description Anthony Wong 2012-08-08 10:29:31 UTC
Created attachment 65273 [details] [review]
patch

Mounting of read only NTFS filesystem gives a following error popup:
Cannot mount volume.
Unable to mount the volume '<Volume name>'.
Details:
Error opening '/dev/sdb2': Read-only file system
Failed to mount '/dev/sdb2': Read-only file system

Mounting by hand with the "-o ro" argument works as expected.

This bug can be duplicated by mounting a write-protected (aka locked) SD card with NTFS partition.

Please also see https://bugs.launchpad.net/ubuntu/+source/udisks/+bug/435192

A patch to fix udisks is attached, which is written by Ming Lei <ming.lei@canonical.com>
Comment 1 Martin Pitt 2012-09-06 10:25:07 UTC
Created attachment 66718 [details] [review]
add tests to reproduce this

Confirming with current udisks. I extended the test suite to try mounting read-only devices for all supported file systems, and it indeed works for anything but NTFS.

======================================================================
ERROR: test_ntfs (__main__.FS)
fs: NTFS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "src/tests/integration-test", line 636, in test_ntfs
    self._do_fs_check('ntfs')
  File "src/tests/integration-test", line 758, in _do_fs_check
    self._do_udisks_check(type)
  File "src/tests/integration-test", line 931, in _do_udisks_check
    mount_path = cd_fs.call_mount_sync(no_options, None)
  File "/usr/lib/python3/dist-packages/gi/types.py", line 47, in function
    return info.invoke(*args, **kwargs)
gi._glib.GError: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error mounting /dev/sr1 at /media/root/2FB591B374B26011: Command-line `mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=0,gid=0,dmask=0077,fmask=0177" "/dev/sr1" "/media/root/2FB591B374B26011"' exited with non-zero exit status 18: Error opening '/dev/sr1': Read-only file system
Failed to mount '/dev/sr1': Read-only file system

However, I'd call this a bug in ntfs-3g -- it should automatically default to mounting the device read-only if it is read-only, just as mount does for any other file system.

Unfortunately ntfs-3g does not have a bug tracker. I'll ask the Debian maintainer about how to submit bugs to ntfs3-g.

I don't really like that patch. udisks should not silently modify explicitly given options, i. e. turn "rw" into "ro". I could live with a workaround that appends "ro" if "rw" is not given, and the file system is NTFS, once the bug is reported upstream. David, do you agree?
Comment 2 David Zeuthen (not reading bugmail) 2012-09-06 14:48:41 UTC
(In reply to comment #1)
> I don't really like that patch. udisks should not silently modify explicitly
> given options, i. e. turn "rw" into "ro". I could live with a workaround that
> appends "ro" if "rw" is not given, and the file system is NTFS, once the bug is
> reported upstream. David, do you agree?

As you, I prefer to just get ntfs-3g fixed. As for the patch for appending 'ro' on read-only devices, seems useful for vendors to carry but don't want it upstream...
Comment 3 Martin Pitt 2012-09-07 04:25:18 UTC
I agree, closing. I did commit the test case though, as that seems useful for verification.
Comment 4 Martin Pitt 2012-09-10 13:17:31 UTC
For the record, ntfs-3g has a working bug fix, I forwarded it to http://bugs.debian.org/686914 for the patch (hoping that the Debian maintainer knows how to reach upstream).

BTW, the test case that I committed also uncovers the corresponding problem for reiserfs and xfs. I just didn't have the reiserfs/xfs tools installed when I ran those. I'll file upstream bug reports for those as well, and see to fix those or work around in a distro patch.
Comment 5 Martin Pitt 2012-09-10 13:52:16 UTC
Seems read-only reiserfs and xfs have no (obvious?) workaround; I reported these issues at

   https://github.com/karelzak/util-linux/issues/17
   https://github.com/karelzak/util-linux/issues/18

and pushed a patch to skip testing readonly mounts for these two, to avoid having tests fail for an extended time.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.