gpt4 book ai didi

linux - 显示fat32 usb盘的卷标?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:34:57 26 4
gpt4 key购买 nike

在我的例子中,我将一个fat32 usb盘的卷标修改为“usb磁盘”(带有中文字符)。

然后我把U盘插到ubuntu(13.04)上,

ls /dev/disk/by-label

显示“USB\x20\xb4\xc5\xc5\xcc”。

或者,我使用 udev 规则在 angstrom beaglebone 上自动挂载外部 USB 磁盘。

IMPORT{program}="/sbin/blkid -o udev -p %N"
ENV{ID_FS_LABEL}!="", ENV{mount_point}="/media/%E{ID_FS_LABEL}"
ACTION=="add", RUN+="/bin/mkdir -p %E{mount_point}", RUN+="/bin/mount -o iocharset=utf8 /dev/%k %E{mount_point}"

我得到一个“/media/USB___”挂载点。

如何获得正确的卷标?

测试一个ntfs和ext3的u盘没问题。

最佳答案

FAT、VFAT 和 FAT32 似乎不使用 unicode 文件名——至少在我看来是这样。他们可以使用“OEM”代码页(我不完全理解)中的大多数字符,但即便如此,仍有许多字符无法显示。

Microsoft 页面对此进行了解释: http://msdn.microsoft.com/en-us/library/windows/desktop/dd317748%28v=vs.85%29.aspx

"NTFS stores file names in Unicode. In contrast, the older FAT12, FAT16, and FAT32 file systems use the OEM character set. For more information, see Code Pages.

"Non-Unicode applications that create FAT files sometimes have to use the standard C runtime library conversion functions to translate between the Windows code page character set and the OEM code page character set. With Unicode implementations of the file system functions, it is not necessary to perform such translations.

"Your application can use generic string types, as described in Windows Data Types for Strings. The application can also use generic function prototypes using techniques described in Conventions for Function Prototypes. For either generic string types or generic function prototypes, your application can use a single source file to compile either a Unicode or a non-Unicode version. To allow for this, the application provides macros for functions that are not invoked when compiling for Unicode.

"In both NTFS and FAT file systems, the special file name characters are: '\', '/', '.', '?', and '*'. On OEM code pages, these special characters are in the ASCII range of characters (0x00 through 0x7F). Their Unicode equivalents are the same values in a 2-byte form, 0x0000 through 0x007F.

"Caution Windows code page and OEM code page character sets used on Japanese-language operating systems contain the Yen symbol (¥) instead of a backslash (\). Thus, the Yen symbol is a prohibited character for NTFS and FAT file systems. When mapping Unicode to a Japanese-language code page, WideCharToMultiByte and other conversion functions map both backslash (U+005C) and the normal Unicode Yen symbol (U+00A5) to this same character. For security reasons, your applications should not typically allow the character U+00A5 in a Unicode string that might be converted for use as a FAT file name. For more information, see Security Considerations: International Features."

这个维基百科页面: http://en.wikipedia.org/wiki/Comparison_of_file_systems让它更清晰一些

"Any byte except for values 0-31, 127 (DEL) and: " * / : < > ? \ | + , . ; = [] (lowcase a-z are stored as A-Z). With VFAT LFN any Unicode except NUL"

希望这对您有所帮助。

关于linux - 显示fat32 usb盘的卷标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20969668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com