Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1283 - block info returns additional charactes in FAT32 label name #5793

Closed
openwrt-bot opened this issue Jan 19, 2018 · 9 comments
Closed
Labels

Comments

@openwrt-bot
Copy link

fleskalebas:

On several devices (ar71xx, ipq806x, mvebu) and with several versions of LEDE (all since 17.01.0) and even OpenWRT versions, block info returns not only the label name but it seems that also some random character in memory is added to the label name.

Expected:
root@router:~# block info
/dev/sda1: UUID="91f1-f7ed" LABEL="DATA" VERSION="FAT32" TYPE="vfat"

Current result:
root@router:~# block info
/dev/sda1: UUID="91f1-f7ed" LABEL="DATA â-'" VERSION="FAT32" TYPE="vfat"

Above character is the ANSI equivalent of the UTF-8 character that is returned. Sometimes (on mvebu devices for example) I got the following results:
/dev/sda1: UUID="91f1-f7ed" LABEL="DATA 1" VERSION="FAT32" TYPE="vfat"
/dev/sda1: UUID="91f1-f7ed" LABEL="DATA A" VERSION="FAT32" TYPE="vfat"
/dev/sda1: UUID="91f1-f7ed" LABEL="DATA Z" VERSION="FAT32" TYPE="vfat"

Somehow block info adds spaces and the extra character (even when I label the disk with a 12-character label name).

@openwrt-bot
Copy link
Author

fleskalebas:

The spaces in the label name are truncated above, in reality there are multiple spaces instead of just one.

@openwrt-bot
Copy link
Author

john:

are you able to build your own image if i provide a test patch ?

@openwrt-bot
Copy link
Author

fleskalebas:

Yes, no problem :)

@openwrt-bot
Copy link
Author

john:

try this patch please

@openwrt-bot
Copy link
Author

fleskalebas:

Thanks, end of this week I'm going to build a new image and report asap.

@openwrt-bot
Copy link
Author

fleskalebas:

After applying the patch, no extra character appends in the LABEL name.

However, when I name the disk with a label shorter than 11 characters, block info still pads the label name with spaces until the name is 11 characters long. A label with exactly 11 characters will work to avoid spaces.

In the bug report I accidentally stated that the label name must be 12 characters. This is wrong, the max size of a fat32 label is 11 characters. However, the patch still works.

@openwrt-bot
Copy link
Author

jow-:

Hm I guess that other implemenations right-trim the spaces from the label for convenience reasons. I do recall that FAT labels are sometimes displayed as "foo" and sometimes as "foo " by various tools and operating systems.

For maximal compatibility we likely should trim both user provided and blkid provided fat labels before working with them.

@openwrt-bot
Copy link
Author

fleskalebas:

The use case for me is mounting by LABEL name instead of device name (since sda might sometimes become sdb) To ensure that it works, I use a 11-character name to avoid errors because of the spaces, but maybe the mounting ignores the spaces too, then it's all fixed by the patch.

@openwrt-bot
Copy link
Author

mirko:

As a follow up - the following patch truncates the filesystem label and replaces the first occurrence of a blank (0x20) with a \0-byte:
https://pb.nanl.de/show.php?id=44995&hash=15878593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant