首页天道酬勤exfat怎么格式化,NTFS FILE SYSTEM

exfat怎么格式化,NTFS FILE SYSTEM

张世龙 05-12 13:37 13次浏览

另一方面,前言最近客户反馈的问题是,在Android系统的机顶盒中插入exfat格式的USB内存后,无法得到UUID这一信息。

/system/vold/中已经添加了对exfat格式USB内存的支持,可以看到通过df命令挂载了USB内存,但运行blkid时,不会显示exfat格式的USB内存信息。

二、问题分析运行blkid /dev/block/sda1命令(sda1为USB内存挂载点),USB内存格式为vfat时可以正常显示。 USB存储器格式为exfat时,无法显示。 问题是blkid命令不完整导致的,需要添加一些代码才能显示。 三、解决方法需要修改的代码位于external/e2fsprogs/lib/blkid路径下。 e2fsprogs是Ext2(和Ext3/4 )文件系统工具(Ext2文件系统实用程序),包含创建、修复、配置和调试Ext2文件系统等标准工具。 e2fsprogs是开源软件,符合GPLv2或LGPLv2标准。 代码China提供了e2fsprogs的开放源代码,其中已经添加了对exfat的适当支持。 您可以在此处搜索并同步相应的修改。 其中主要修改了两个文件: probe.c和probe.h。 四、代码修改以下为对exfat格式设备的修改,代码如下:

from 05 cf6cbb 92b F6 d65 ef 0480053 ddcc 4a 625 f0e 86 bmonsep 1700336003360002001 from : amosstandate 3360 tue, 6 jul 2021163360023360380800 subject : [ patch ] AAA----外部/E2 fsprogs/lib/bl kid/probe.c|131外部/E2 172安装(diff-- gita/external/E2 fsprogs/lib/bl kid/probe.CB/external/E2 fsprogs/lib/bl kid/probe 2 lib/bl kid/probe.c @-1158、61158、38 @ @ staticvoidunnid } staticvoidunicode _ 16le _ to _ u utf8 (unsigned char * ssto ) for(I=j=0; i 2=in_len; i =2) c=(buf[I1]8)| buf[i]; if(c==0) { str[j]='\0 '; 布雷克; }elseif(c0x80 ) if ) j1=out_len ) break; str [ j ]=(不一致char ) c; }elseif(c0x800 ) if ) J2=out_len ) break; str[j]=(unsignedchar )0xc0| (C6 ); str [ j ]=(未指定char )0x 80|(c0x3f ); }else{if(J3=out_Len ) break; str[j]=(unsignedchar )0x E0|(c12 ); str [ j ]=(未指定的char ) (0x80|) (0x3f ) ); str [ j ]=(未指定char )0x 80|(c0x3f ); } } str[j]='\0 '; } staticintprobe _ HFS (structblkid _ probe * probe _ bl kid _ attr () unused )、structblkid _ magic * id _ bl u u u u u u u u u u u u u u u u u u u u u u u u unsid }静态uint 64 _ tex fat _ block _ to _ offset (conststructexfat _ super _ block * sb,u

int64_t block)+{+ return block << sb->block_bits;+}++static uint64_t exfat_cluster_to_block(const struct exfat_super_block *sb,+ uint32_t cluster)+{+ return sb->cluster_block_start ++ ((uint64_t)(cluster - EXFAT_FIRST_DATA_CLUSTER) << sb->bpc_bits);+}++static uint64_t exfat_cluster_to_offset(const struct exfat_super_block *sb,+ uint32_t cluster)+{+ return exfat_block_to_offset(sb, exfat_cluster_to_block(sb, cluster));+}++static uint32_t exfat_next_cluster(struct blkid_probe *probe,+ const struct exfat_super_block *sb,+ uint32_t cluster)+{+ uint32_t *next;+ uint64_t offset;++ offset = exfat_block_to_offset(sb, sb->fat_block_start)+ + (uint64_t) cluster * sizeof (cluster);+ next = (uint32_t *)get_buffer(probe, offset, sizeof (uint32_t));++ return next ? *next : 0;+}++static struct exfat_entry_label *find_exfat_entry_label(+ struct blkid_probe *probe, const struct exfat_super_block *sb)+{+ uint32_t cluster = sb->rootdir_cluster;+ uint64_t offset = exfat_cluster_to_offset(sb, cluster);+ uint8_t *entry;+ const size_t max_iter = 10000;+ size_t i = 0;++ for (; i < max_iter; ++i) {+ entry = (uint8_t *)get_buffer(probe, offset, EXFAT_ENTRY_SIZE);+ if (!entry)+ return NULL;+ if (entry[0] == EXFAT_ENTRY_EOD)+ return NULL;+ if (entry[0] == EXFAT_ENTRY_LABEL)+ return (struct exfat_entry_label*) entry;++ offset += EXFAT_ENTRY_SIZE;+ if (offset % CLUSTER_SIZE(sb) == 0) {+ cluster = exfat_next_cluster(probe, sb, cluster);+ if (cluster < EXFAT_FIRST_DATA_CLUSTER)+ return NULL;+ if (cluster > EXFAT_LAST_DATA_CLUSTER)+ return NULL;+ offset = exfat_cluster_to_offset(sb, cluster);+ }+ }++ return NULL;+}++static int probe_exfat(struct blkid_probe *probe,+ struct blkid_magic *id __BLKID_ATTR((unused)),+ unsigned char *buf)+{+ struct exfat_super_block *sb;+ struct exfat_entry_label *label;+ char uuid[40];++ sb = (struct exfat_super_block *)buf;+ if (!sb || CLUSTER_SIZE(sb) == 0) {+ DBG(DEBUG_PROBE, printf("bad exfat superblock.\n"));+ return errno ? - errno : 1;+ }++ label = find_exfat_entry_label(probe, sb);+ if (label) {+ unsigned char utf8_label[128];+ unicode_16le_to_utf8(utf8_label, sizeof(utf8_label), label->name, label->length * 2);+ blkid_set_tag(probe->dev, "LABEL", (char *) utf8_label, 0);+ } else {+ blkid_set_tag(probe->dev, "LABEL", "disk", 4);+ }++ memset(uuid, 0, sizeof (uuid));+ snprintf(uuid, sizeof (uuid), "%02hhX%02hhX-%02hhX%02hhX",+ sb->volume_serial[3], sb->volume_serial[2],+ sb->volume_serial[1], sb->volume_serial[0]);+ blkid_set_tag(probe->dev, "UUID", uuid, strlen(uuid));++ return 0;+}+ /* * Various filesystem magics that we can check for. Note that kboff and * sboff are in kilobytes and bytes respectively. All magics are in@@ -1482,6 +1612,7 @@ static struct blkid_magic type_array[] = { { "lvm2pv", 1, 0x018, 8, "LVM2 001",probe_lvm2 }, { "lvm2pv", 1, 0x218, 8, "LVM2 001",probe_lvm2 }, { "btrfs", 64, 0x40, 8, "_BHRfS_M",probe_btrfs },+ { "exfat", 0, 3, 8, "EXFAT ", probe_exfat }, { NULL, 0, 0, 0, NULL,NULL } }; diff --git a/external/e2fsprogs/lib/blkid/probe.h b/external/e2fsprogs/lib/blkid/probe.hindex 37fc9c0..2c6acea 100644--- a/external/e2fsprogs/lib/blkid/probe.h+++ b/external/e2fsprogs/lib/blkid/probe.h@@ -14,6 +14,8 @@ #ifndef _BLKID_PROBE_H #define _BLKID_PROBE_H +#include <stdint.h>+ #include <blkid/blkid_types.h> struct blkid_magic;@@ -725,6 +727,45 @@ struct btrfs_super_block { __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; } __attribute__ ((__packed__)); +struct exfat_super_block {+ uint8_t jump[3];+ uint8_t oem_name[8];+ uint8_t __unused1[53];+ uint64_t block_start;+ uint64_t block_count;+ uint32_t fat_block_start;+ uint32_t fat_block_count;+ uint32_t cluster_block_start;+ uint32_t cluster_count;+ uint32_t rootdir_cluster;+ uint8_t volume_serial[4];+ struct {+ uint8_t vermin;+ uint8_t vermaj;+ } version;+ uint16_t volume_state;+ uint8_t block_bits;+ uint8_t bpc_bits;+ uint8_t fat_count;+ uint8_t drive_no;+ uint8_t allocated_percent;+} __attribute__ ((__packed__));++struct exfat_entry_label {+ uint8_t type;+ uint8_t length;+ uint8_t name[30];+} __attribute__ ((__packed__));++#define BLOCK_SIZE(sb) (1 << (sb)->block_bits)+#define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)++#define EXFAT_FIRST_DATA_CLUSTER 2+#define EXFAT_LAST_DATA_CLUSTER 0xffffff6+#define EXFAT_ENTRY_SIZE 32++#define EXFAT_ENTRY_EOD 0x00+#define EXFAT_ENTRY_LABEL 0x83 /* * Byte swap functions */-- 2.17.1

codechina上的提交id号:

AOSP: blkid: add support to recognize exfat to blkid.
I870e59a14b6bcd8b45562cdd02c2502d60a9eeffAOSP: blkid: Resolve to the exFAT uuid change on reboot.
I376ed9fe1ba1b7f3d367d78cc5e2bb8ea9cc2d13AOSP: blkid: Correct the label name for exfat
Ib16204c75c2cdf675d480e9c66f484bb3c51108e
可根据上面的修改来同步到自己的代码上。
if函数与mid函数的嵌套使用,blkid命令