Bug 845419 - mount does not pass sizelimit to losetup correctly, for loopback mounting hfsplus
Summary: mount does not pass sizelimit to losetup correctly, for loopback mounting hfs...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 17
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-03 03:42 UTC by Hin-Tak Leung
Modified: 2013-04-15 09:15 UTC (History)
3 users (show)

Fixed In Version: util-linux-2.23-0.5
Clone Of:
Environment:
Last Closed: 2013-04-15 09:15:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
LIBMOUNT_DEBUG=0xffff ... &> mountlog as requested. (10.58 KB, text/plain)
2012-08-03 08:12 UTC, Hin-Tak Leung
no flags Details

Description Hin-Tak Leung 2012-08-03 03:42:50 UTC
Description of problem:
mount -o ...sizelimit=... does not get passed to hfsplus loopback.

Version-Release number of selected component (if applicable):
util-linux-2.21.2-2.fc17.x86_64

How reproducible:
always

Steps to Reproduce:
1. Obtain the xcode 4.3.3 image from apple devel web site (free registration required) - some other image may work, if one knows how to calculate the offset.
2. mount -t hfsplus -o loop,offset=33280,sizelimit=1975387136,ro xcode_4.3.3_for_lion.dmg /mnt
  
Actual results:
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

[10679.677225] hfs: invalid secondary volume header
[10679.677240] hfs: unable to find HFS+ superblock

Expected results:
Should mount correctly, and dmesg should show:

[12194.322495] SELinux: initialized (dev loop0, type hfsplus), uses genfs_contexts

Additional info:
This works, so the offset/sizelimit parameters are correct:

losetup --sizelimit 1975387136 --offset 33280 /dev/loop0 xcode_4.3.3_for_lion.dmg
mount -o ro /dev/loop0 /mnt

I am filing this as it should be possible to do it in a single mount command, according to the documentation.

$ ls -l xcode_4.3.3_for_lion.dmg 
-rw-------. 1 Hin-Tak Hin-Tak 1975427679 Jul 24 03:51 xcode_4.3.3_for_lion.dmg
$ md5sum xcode_4.3.3_for_lion.dmg
d6b3a2983320cb11d0ea3f1541323a03  xcode_4.3.3_for_lion.dmg

Comment 1 Karel Zak 2012-08-03 07:36:57 UTC
Please, try

LIBMOUNT_DEBUG=0xffff mount -t hfsplus -o loop,offset=33280,sizelimit=1975387136,ro xcode_4.3.3_for_lion.dmg /mnt &> log

and add the 'log' file to bugzilla. Thanks.

Comment 2 Hin-Tak Leung 2012-08-03 08:12:30 UTC
Created attachment 602082 [details]
LIBMOUNT_DEBUG=0xffff   ... &> mountlog as requested.

LIBMOUNT_DEBUG=0xffff   ... &> mountlog
as requested.

Comment 3 Hin-Tak Leung 2012-08-03 08:18:32 UTC
caveat: I am guessing the end of image (sizelimit) is not passed along correctly, since the error message
"hfs: invalid secondary volume header"
comes from checking the HFS+ 2nd volume header, which is located at the end of byte-range.

For most other partition types (FAT, etc), there is no need to set sizelimit since there is no important information at the end of the partition.

I read something about default blocksize of the loopback device also... but in any case, "mount ... -o <loop-options> ..." should work the same way as "losetup <loop-options> /dev/loop0" + "mount /dev/loop0...".

Comment 4 Karel Zak 2012-08-03 13:46:12 UTC
The mount works the same way as losetup, it's the same code which is shared between losetup and mount. I don't see anything wrog in the debug output.

BTW, in comment #1 you do not use '-t hfsplus' in the your losetup+mount example, can you try it for the alone mount? I mean:

 # mount -o offset=33280,sizelimit=1975387136,ro xcode_4.3.3_for_lion.dmg /mnt

thanks.

Comment 5 Hin-Tak Leung 2012-08-03 14:21:19 UTC
(In reply to comment #4)
> The mount works the same way as losetup, it's the same code which is shared
> between losetup and mount. I don't see anything wrog in the debug output.
> 
> BTW, in comment #1 you do not use '-t hfsplus' in the your losetup+mount
> example, can you try it for the alone mount? I mean:
> 
>  # mount -o offset=33280,sizelimit=1975387136,ro xcode_4.3.3_for_lion.dmg
> /mnt
> 
> thanks.

# mount -o offset=33280,sizelimit=1975387136,ro xcode_4.3.3_for_lion.dmg /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

# dmesg | tail -2
[100532.597545] hfs: invalid secondary volume header
[100532.597564] hfs: unable to find HFS+ superblock

Same parameters, two-step process still works:

# losetup --offset 33280 --sizelimit 1975387136 /dev/loop0 xcode_4.3.3_for_lion.dmg 
# mount  /dev/loop0 /mnt
# dmesg | tail -1
[100601.738595] SELinux: initialized (dev loop0, type hfsplus), uses genfs_contexts

Comment 6 Karel Zak 2013-04-15 09:15:08 UTC
I guess it's already fixed in util-linux >= 2.23-rc2 (-0.5 in Fedora 19).

Upstream commit:

commit 293714c0d157ae04d08bb587e800c70f05cc4a29
Author: Jeff Mahoney <jeffm>
Date:   Tue Apr 9 14:32:50 2013 +0200

    loopdev: sync capacity after setting it


Note You need to log in before you can comment on or make changes to this bug.