Raise the maximum F2FS label size to 127 characters (!29)

Fix to make mkfs.f2fs properly handle labels longer than 16 characters
was included in f2fs-tools 1.2.0 [1].  The oldest supported
distributions now include this release:
  Distro             EOL        f2fs-tools
- Debian 8           2020-Jun   1.4.0
- RHEL / CentOS 7    2024-Jun   1.4.1
- SLES 12            2027-Oct   Unknown
- Ubuntu 14.04 LTS   2019-Apr   1.2.0

Note that on Ubuntu 14.04 LTS blkid from util-linux 2.20.1 is too old to
recognise F2FS file systems, as 2.23 is required for F2FS support [2].

mkfs.f2fs claims the maximum label length is less than 512 characters,
but actually accepts 512 characters.

    # label=`head -c 1024 < /dev/zero | tr '\0' 'A'`
    # mkfs.f2fs -l `echo -n "$label" | cut -c1-513` /dev/sdb10

            F2FS-tools: mkfs.f2fs Ver: 1.4.0 (2014-09-18)

    Error: Volume Label should be less than      512 characters

    Usage: mkfs.f2fs [options] device [sectors]
    [options]:
      -a heap-based allocation [default:1]
      -d debug level [default:0]
      -e [extension list] e.g. "mp3,gif,mov"
      -l label
      -o overprovision ratio [default:5]
      -s # of segments per section [default:1]
      -z # of sections per zone [default:1]
      -t 0: nodiscard, 1: discard [default:1]
    sectors: number of sectors. [default: determined by device size]
    # echo $?
    1

    # mkfs.f2fs -l `echo -n "$label" | cut -c1-512` /dev/sdb10

            F2FS-tools: mkfs.f2fs Ver: 1.4.0 (2014-09-18)

    Info: Label = AAAAAAAAAAAA...[trimmed from 512 "A"s]...AAAAAAAAAAAA
    Info: sector size = 512
    Info: total sectors = 1048576 (in 512bytes)
    Info: zone aligned segment0 blkaddr: 256
    Info: Discarding device
    Info: This device doesn't support TRIM
    Info: format successful
    # echo $?
    0

    # blkid -V
    blkid from util-linux 2.25.2  (libblkid 2.25.0, 24-Oct-2014)
    # blkid /dev/sdb
    /dev/sdb10: LABEL="AAAAAAAAAAAA...[only 127 "A"s]...AAAAAAAAAAAA"
    UUID="f47f3fdc-dd91-4616-bb6d-0d643a884265" TYPE="f2fs"
    PARTUUID="3bb4bef8-9494-4e82-8dda-5d8edd9c60d9"

As blkid only reports the first 127 characters and is the only command
used for reading the label of an F2FS file system, use this as the new
increased limit.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/commit/?id=9799d6364dc93e1fd259d812d4a50ed984a6456b
    mkfs: handle labels longer than 16 characters

[2] https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.23/v2.23-ReleaseNotes
    "add Flash-Friendly File System (f2fs) support  [Alejandro Martinez
    Ruiz]"

Closes !29 - Enhance F2FS support
This commit is contained in:
Mike Fleetwood 2019-03-17 13:40:45 +00:00
parent afbf56c1c2
commit c9f47403b8
1 changed files with 3 additions and 5 deletions

View File

@ -198,11 +198,9 @@ int Utils::get_filesystem_label_maxlength( FSType filesystem )
case FS_EXT2 : return 16 ;
case FS_EXT3 : return 16 ;
case FS_EXT4 : return 16 ;
//mkfs.f2fs says that it can create file systems with labels up to 512
// characters, but it core dumps with labels of 29 characters or larger!
// Also blkid only correctly displays labels up to 19 characters.
// (Suspect it is all part of a memory corruption bug in mkfs.f2fs).
case FS_F2FS : return 19 ;
// mkfs.f2fs supports labels up to 512 characters, however only blkid is
// used to read the label and that only displays the first 127 characters.
case FS_F2FS : return 127;
case FS_FAT16 : return 11 ;
case FS_FAT32 : return 11 ;
//mkfs.hfsplus can create hfs and hfs+ file systems with labels up to 255