[Bug 435192] Re: Automatic mounting of read only ntfs partition on usb device fails

Martin Pitt martin.pitt at ubuntu.com
Fri Sep 7 06:32:25 UTC 2012

Reported ntfs-3g bug to Debian, as I can't for the live of it find an
upstream bug tracker.

I'll add the -ro workaround to Debian, but not the part that modifies
explicit mount options. Thanks!

** Bug watch added: Debian Bug tracker #686914

** Also affects: ntfs-3g (Debian) via
   Importance: Unknown
       Status: Unknown

** Changed in: udisks2 (Ubuntu Quantal)
       Status: Confirmed => In Progress

** Changed in: udisks2 (Ubuntu Quantal)
     Assignee: (unassigned) => Martin Pitt (pitti)

You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to ntfs-3g in Ubuntu.

  Automatic mounting of read only ntfs partition on usb device fails

Status in OEM Priority Project:
  In Progress
Status in OEM Priority Project precise series:
  In Progress
Status in abstraction for enumerating and managing block devices:
Status in “ntfs-3g” package in Ubuntu:
Status in “udisks” package in Ubuntu:
Status in “udisks2” package in Ubuntu:
  In Progress
Status in “ntfs-3g” source package in Precise:
Status in “udisks” source package in Precise:
Status in “ntfs-3g” source package in Quantal:
Status in “udisks” source package in Quantal:
Status in “udisks2” source package in Quantal:
  In Progress
Status in “ntfs-3g” package in Debian:

Bug description:
  OEM customers raise this issue, thinking that the error message can be misleading to inexperienced users.


  fixed by below patch:

  diff --git a/precise/src/device.c b/precise/src/device.c
  index a7f8880..8b48612 100644
  --- a/precise/src/device.c
  +++ b/precise/src/device.c
  @@ -6407,6 +6407,7 @@ device_filesystem_mount_authorized_cb (Daemon *daemon,
     const FSMountOptions *fsmo;
     char **options;
     char uid_buf[32];
  +  int access_changed;
     fstype = NULL;
     options = NULL;
  @@ -6414,6 +6415,7 @@ device_filesystem_mount_authorized_cb (Daemon *daemon,
     mount_point = NULL;
     remove_dir_on_unmount = FALSE;
     error = NULL;
  +  access_changed = 0;
     /* If the user requests the filesystem type, error out unless the
      * filesystem type is
  @@ -6516,6 +6518,7 @@ device_filesystem_mount_authorized_cb (Daemon *daemon,
     for (n = 0; options[n] != NULL; n++)
         const char *option = options[n];
  +      char *start;
         /* avoid attacks like passing "shortname=lower,uid=0" as a single mount option */
         if (strstr (option, ",") != NULL)
  @@ -6533,9 +6536,23 @@ device_filesystem_mount_authorized_cb (Daemon *daemon,
             goto out;
  +      if (start = strstr(option, "rw")) {
  +	if (device->priv->device_is_read_only) {
  +			start[1]  = 'o';
  +			access_changed = 1;
  +	}
  +      }
         g_string_append_c (s, ',');
         g_string_append (s, option);
  +    if (!access_changed && device->priv->device_is_read_only)
  +    {
  +      g_string_append_c (s, ',');
  +      g_string_append (s, "ro");
  +    }
     mount_options = g_string_free (s, FALSE);
     g_print ("**** USING MOUNT OPTIONS '%s' FOR DEVICE %s\n", mount_options, device->priv->device_file);

  [Test Case]
  Format a SD card with NTFS, lock the SD card as write-protected, insert the card into the SD card slot. If the card is mounted as read-only, the bug is fixed.

  [Regression Potential]

  The fix posted looks shouldn't cause regression.

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

  I believe this should be mounted as read-only instead of an error

  Mounting by hand with the "-o ro" argument works as expected.
  Architecture: i386
  DistroRelease: Ubuntu 10.04
  NonfreeKernelModules: fglrx
  Package: mountall 2.15
  PackageArchitecture: i386
   PATH=(custom, user)
  ProcVersionSignature: Ubuntu 2.6.32-24.39-generic
  Tags: lucid
  Uname: Linux 2.6.32-24-generic i686
  UserGroups: adm admin audio cdrom dialout dip fax fuse lpadmin netdev plugdev sambashare tape video

To manage notifications about this bug go to:

More information about the foundations-bugs mailing list