Bug 3607

Summary: Unconditional use of LFS64 function in fdisk
Product: Busybox Reporter: bugdal
Component: Standard ComplianceAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: Proposed fix for the issue.

Description bugdal 2011-04-13 16:39:50 UTC
Created attachment 3199 [details]
Proposed fix for the issue.

The fdisk applet uses the lseek64 function to provide support for large disks, under ENABLE_FDISK_SUPPORT_LARGE_DISKS. At first glance this seems correct, but the only time the code using lseek64 is useful is when large file support is not already enabled, and at the configuration level, LFS implies ("selects") CONDIG_FDISK_SUPPORT_LARGE_DISKS. This breaks compiling against musl (http://www.etalabs.net/musl/) which does not provide LFS64 interfaces, but instead always uses 64-bit off_t in the standard interfaces (lseek).

Since the #else case (i.e. !defined(ENABLE_FDISK_SUPPORT_LARGE_DISKS)) will also give fully-working large disk support when LFS is enabled (both cases should generate the exact same code, since the >MAXINT(off_t) should be optimized out as impossible), my proposed fix is to make it so LFS no longer selects CONFIG_FDISK_SUPPORT_LARGE_DISKS, and instead CONFIG_FDISK_SUPPORT_LARGE_DISKS depends on !LFS. This will prevent CONFIG_FDISK_SUPPORT_LARGE_DISKS from getting selected or even appearing in the menu when it's not useful, i.e. when the whole BusyBox already supports 64-bit off_t everywhere, and only show the option for users who have selected a non-LFS build.
Comment 1 Denys Vlasenko 2011-04-16 16:08:37 UTC
Applied to git. Thanks!