{"id":2486,"date":"2026-06-28T17:00:00","date_gmt":"2026-06-28T09:00:00","guid":{"rendered":"https:\/\/www.zhiwanyuzhou.com\/?p=2486"},"modified":"2026-07-22T17:10:11","modified_gmt":"2026-07-22T09:10:11","slug":"010%e6%a8%a1%e6%9d%bf-jffs2%e6%96%87%e4%bb%b6%e7%b3%bb%e7%bb%9f","status":"publish","type":"post","link":"https:\/\/www.zhiwanyuzhou.com\/index.php\/2026\/06\/28\/010%e6%a8%a1%e6%9d%bf-jffs2%e6%96%87%e4%bb%b6%e7%b3%bb%e7%bb%9f\/","title":{"rendered":"010\u6a21\u677f-JFFS2\u6587\u4ef6\u7cfb\u7edf"},"content":{"rendered":"\n<h2>\u4e00\u3001\u524d\u8a00<\/h2>\n\n\n\n<p>010 Editor\u7684\u6a21\u677f\u529f\u80fd\u662f\u4e00\u9879\u4e13\u4e1a\u7ea7\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u89e3\u6790\u4e0e\u7f16\u8f91\u673a\u5236\u3002\u5b83\u901a\u8fc7\u7ed3\u6784\u5316\u7684\u65b9\u5f0f\u5bf9\u539f\u59cb\u5341\u516d\u8fdb\u5236\u6570\u636e\u8fdb\u884c\u8bed\u4e49\u5c42\u9762\u7684\u6620\u5c04\uff0c\u5c06\u5b57\u8282\u5e8f\u5217\u8f6c\u5316\u4e3a\u5177\u6709\u660e\u786e\u5b57\u6bb5\u542b\u4e49\u7684\u6570\u636e\u7ed3\u6784\u6811\uff0c\u4ece\u800c\u663e\u8457\u63d0\u5347\u4e86\u4e8c\u8fdb\u5236\u5185\u5bb9\u7684\u53ef\u8bfb\u6027\u4e0e\u53ef\u7f16\u8f91\u6027\u3002<\/p>\n\n\n\n<p>\u8be5\u529f\u80fd\u4e0d\u4ec5\u5185\u7f6e\u4e86\u8986\u76d6\u5e38\u89c1\u6587\u4ef6\u683c\u5f0f\u7684\u4e30\u5bcc\u6a21\u677f\u5e93\uff0c\u8fd8\u652f\u6301\u7528\u6237\u6839\u636e\u7279\u5b9a\u683c\u5f0f\u9700\u6c42\u8fdb\u884c\u81ea\u5b9a\u4e49\u5f00\u53d1\uff0c\u5e76\u53ef\u7ed3\u5408\u811a\u672c\u5b9e\u73b0\u89e3\u6790\u3001\u4fee\u6539\u4e0e\u6821\u9a8c\u7b49\u6d41\u7a0b\u7684\u81ea\u52a8\u5316\u3002\u5728\u9006\u5411\u5de5\u7a0b\u3001\u534f\u8bae\u5206\u6790\u53ca\u56fa\u4ef6\u7814\u7a76\u7b49\u4e13\u4e1a\u9886\u57df\u4e2d\uff0c\u6a21\u677f\u529f\u80fd\u4f5c\u4e3a\u8fde\u63a5\u5e95\u5c42\u6570\u636e\u4e0e\u4e0a\u5c42\u903b\u8f91\u7684\u5173\u952e\u6865\u6881\uff0c\u53d1\u6325\u7740\u91cd\u8981\u7684\u6280\u672f\u652f\u6491\u4f5c\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-1.png\" alt=\"\" class=\"wp-image-2488\" width=\"747\" height=\"633\" srcset=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-1.png?v=1784710827 870w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-1-300x254.png?v=1784710827 300w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-1-768x651.png?v=1784710827 768w\" sizes=\"(max-width: 747px) 100vw, 747px\" \/><\/figure>\n\n\n\n<h2>\u4e8c\u3001JFFS2\u6587\u4ef6<\/h2>\n\n\n\n<p>\u53c2\u8003\u4e4b\u524d\u5199\u7684\u300a<a href=\"https:\/\/www.zhiwanyuzhou.com\/index.php\/2022\/03\/19\/jffs2%e6%96%87%e4%bb%b6%e7%b3%bb%e7%bb%9f\/\">JFFS2\u6587\u4ef6\u7cfb\u7edf<\/a>\u300b\uff0c\u521b\u5efa\u4e00\u4e2ajffs2\u7684\u6587\u4ef6\uff0c\u518d\u4f7f\u7528010Editor\u6253\u5f00\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-palette-color-8-background-color has-text-color has-background\"><code>mkfs.jffs2 -r rootfs -o rootfs.jffs2<\/code><\/pre>\n\n\n\n<p>\u67e5\u627e\u6a21\u677f\uff0c\u53d1\u73b0\u4e0d\u652f\u6301jffs2\uff0c\u6240\u4ee5\u9700\u8981\u81ea\u5df1\u6839\u636ejffs2\u7684\u683c\u5f0f\u53bb\u7f16\u5199\u6a21\u677f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"863\" height=\"756\" src=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-5.png\" alt=\"\" class=\"wp-image-2495\" srcset=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-5.png?v=1784711339 863w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-5-300x263.png?v=1784711339 300w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-5-768x673.png?v=1784711339 768w\" sizes=\"(max-width: 863px) 100vw, 863px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h2>\u4e09\u3001010\u6a21\u677f<\/h2>\n\n\n\n<p>\u5c06\u4ee5\u4e0b\u4ee3\u7801\u4fdd\u5b58\u4e3a\u6a21\u677f\u6587\u4ef6jffs2.bt\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-palette-color-8-background-color has-text-color has-background\"><code>\/\/ ---------- \u8282\u70b9\u7c7b\u578b\u5e38\u91cf ----------\nconst uint16 JFFS2_MAGIC              = 0x1985;\nconst uint16 NODETYPE_PADDING         = 0x2004;\nconst uint16 NODETYPE_DIRENT          = 0xE001;\nconst uint16 NODETYPE_INODE           = 0xE002;\nconst uint16 NODETYPE_CLEANMARKER     = 0x2003;\nconst uint16 NODETYPE_SUMMARY         = 0x2006;\nconst uint16 NODETYPE_XATTR           = 0xE008;\nconst uint16 NODETYPE_XREF            = 0xE009;\n\n\/\/ ---------- CRC-32 ----------\nuint32 MtdCrc(uint64 pos, uint64 len) {\n    local uint64 crc;\n    local uint64 i, j;\n    local uint32 b;\n\n    \/\/ Jefferson's mtd_crc is CRC32 with an effective zero seed and no final XOR.\n    crc = 0;\n\n    for (i = 0; i &lt; len; i = i + 1) {\n        b = ((uint32)ReadByte(pos + i)) &amp; 0xFFu;\n        crc = crc ^ (uint64)b;\n        for (j = 0; j &lt; 8; j = j + 1) {\n            if ((crc &amp; 1u) != 0u) {\n                crc = (crc &gt;&gt; 1) ^ 0xEDB88320u;\n            }\n            else {\n                crc = crc &gt;&gt; 1;\n            }\n        }\n    }\n    return (uint32)crc;\n}\n\nstring TypeName(uint16 t) {\n    switch (t) {\n        case NODETYPE_DIRENT:      return \"DIRENT\";\n        case NODETYPE_INODE:       return \"INODE\";\n        case NODETYPE_PADDING:     return \"PADDING\";\n        case NODETYPE_CLEANMARKER: return \"CLEANMARKER\";\n        case NODETYPE_SUMMARY:     return \"SUMMARY\";\n        case NODETYPE_XATTR:       return \"XATTR\";\n        case NODETYPE_XREF:        return \"XREF\";\n        default:                   return Str(\"UNK_0x%04X\", t);\n    }\n}\n\n\/\/ ---------- JFFS2 common header (12 \u5b57\u8282) ----------\ntypedef struct {\n    uint16 magic    &lt;fgcolor=cRed,  comment=\"JFFS2 magic, must be 0x1985\"&gt;;\n    uint16 nodetype &lt;comment=\"Node type\"&gt;;\n    uint32 totlen   &lt;comment=\"Total length (incl. header)\"&gt;;\n    uint32 hdr_crc  &lt;comment=\"CRC of first 8 bytes\"&gt;;\n} Jffs2Header &lt;read=ShowHdr&gt;;\n\nstring ShowHdr(Jffs2Header &amp;h) {\n    if (h.magic != JFFS2_MAGIC) {\n        return Str(\"&#91;bad magic=0x%04X]\", h.magic);\n    }\n    local uint64 p = startof(h);\n    local uint32 calc = MtdCrc(p, 8);\n\n    if (calc == h.hdr_crc) {\n        return Str(\"&#91;OK  %s totlen=%u]\", TypeName(h.nodetype), h.totlen);\n    }\n    if (calc == (~h.hdr_crc &amp; 0xFFFFFFFF)) {\n        return Str(\"&#91;DIRTY %s totlen=%u]\", TypeName(h.nodetype), h.totlen);\n    }\n    return Str(\"&#91;CRC_BAD %s exp=0x%08X got=0x%08X]\",\n               TypeName(h.nodetype), h.hdr_crc, calc);\n}\n\n\/\/ ---------- DIRENT body ----------\n\/\/ Matches struct jffs2_raw_dirent after the common 12-byte header.\ntypedef struct {\n    uint32 pino      &lt;comment=\"parent inode\"&gt;;\n    uint32 version;   \n    uint32 ino       &lt;comment=\"child inode number\"&gt;;\n    uint32 mctime    &lt;comment=\"modification time\"&gt;;\n    uchar  nsize     &lt;comment=\"name length\"&gt;;\n    uchar  type      &lt;comment=\"DT_* directory entry type\"&gt;;\n    uchar  unused&#91;2];\n    uint32 node_crc;\n    uint32 name_crc;\n    char   name&#91;nsize] &lt;fgcolor=cDkGreen&gt;;\n} Jffs2Dirent &lt;read=ShowDirent&gt;;\n\n\/\/ ---------- INODE body ----------\n\/\/ Matches struct jffs2_raw_inode after the common 12-byte header.\ntypedef struct {\n    uint32 ino        &lt;comment=\"inode number\"&gt;;\n    uint32 version;    \n    uint32 mode;\n    uint16 uid;\n    uint16 gid;\n    uint32 isize      &lt;comment=\"file size\"&gt;;\n    uint32 atime;\n    uint32 mtime;\n    uint32 ctime;\n    uint32 offset     &lt;comment=\"data offset within file\"&gt;;\n    uint32 csize      &lt;comment=\"compressed size\"&gt;;\n    uint32 dsize      &lt;comment=\"decompressed size\"&gt;;\n    uchar  compr      &lt;comment=\"compression method\"&gt;;\n    uchar  usercompr;\n    uint16 flags;\n    uint32 data_crc;\n    uint32 node_crc;\n    uchar  data&#91;csize] &lt;comment=\"compressed data (length = csize)\"&gt;;\n} Jffs2Inode &lt;read=ShowInode&gt;;\n\n\/\/ ---------- CRC checks for node bodies ----------\nstring CrcStatus(uint32 calculated, uint32 stored) {\n    if (calculated == stored) {\n        return \"OK\";\n    }\n    return \"BAD\";\n}\n\nstring ShowDirent(Jffs2Dirent &amp;d) {\n    local uint64 p;\n    local uint32 node_calc;\n    local uint32 name_calc;\n\n    \/\/ node_crc covers the header and fixed dirent fields before node_crc.\n    p = startof(d) - 12;\n    node_calc = MtdCrc(p, 32);\n    name_calc = MtdCrc(startof(d) + 28, d.nsize);\n\n    return Str(\"&#91;node_crc=%s calc=0x%08X stored=0x%08X name_crc=%s calc=0x%08X stored=0x%08X]\",\n               CrcStatus(node_calc, d.node_crc), node_calc, d.node_crc,\n               CrcStatus(name_calc, d.name_crc), name_calc, d.name_crc);\n}\n\nstring ShowInode(Jffs2Inode &amp;n) {\n    local uint64 p;\n    local uint32 node_calc;\n    local uint32 data_calc;\n\n    \/\/ node_crc covers the header and inode fields through flags.\n    p = startof(n) - 12;\n    node_calc = MtdCrc(p, 60);\n    data_calc = MtdCrc(startof(n) + 56, n.csize);\n\n    return Str(\"&#91;data_crc=%s calc=0x%08X stored=0x%08X node_crc=%s calc=0x%08X stored=0x%08X]\",\n               CrcStatus(data_calc, n.data_crc), data_calc, n.data_crc,\n               CrcStatus(node_calc, n.node_crc), node_calc, n.node_crc);\n}\n\n\ntypedef struct {\n    Jffs2Header hdr;\n    if (hdr.nodetype == NODETYPE_DIRENT) {\n        Jffs2Dirent body;\n    }\n    else if (hdr.nodetype == NODETYPE_INODE) {\n        Jffs2Inode body;\n    }\n    \/\/ PADDING \/ CLEANMARKER \/ XATTR \/ XREF \/ \u5176\u5b83: \u53ea\u6709 hdr\n} Jffs2Node;\n\n\n\nFSeek(0);\n\n\/\/ JFFS2 magic \u7684\u539f\u59cb\u5b57\u8282\u5e8f\u5217:\n\/\/   85 19 -&gt; little-endian (\u6570\u503c 0x1985)\n\/\/   19 85 -&gt; big-endian    (\u6570\u503c 0x1985)\nif (FileSize() &lt; 2) {\n    Warning(\"\u6587\u4ef6\u592a\u77ed,\u65e0\u6cd5\u8bfb\u53d6 JFFS2 magic\");\n    return -1;\n}\n\nif ((((uint32)ReadByte(0)) &amp; 0xFFu) == 0x85u &amp;&amp;\n    (((uint32)ReadByte(1)) &amp; 0xFFu) == 0x19u) {\n    LittleEndian();\n    Printf(\"JFFS2 byte order: little-endian\\n\");\n}\nelse if ((((uint32)ReadByte(0)) &amp; 0xFFu) == 0x19u &amp;&amp;\n         (((uint32)ReadByte(1)) &amp; 0xFFu) == 0x85u) {\n    BigEndian();\n    Printf(\"JFFS2 byte order: big-endian\\n\");\n}\nelse {\n    Warning(\"\u4e0d\u662f JFFS2 \u955c\u50cf: magic bytes \u4e0d\u5339\u914d\");\n    return -1;\n}\n\nFSeek(0);\n\nwhile (FTell() + 12 &lt;= FileSize() &amp;&amp; ReadShort(FTell()) == JFFS2_MAGIC) {\n    Jffs2Node node;\n    FSeek(startof(node) + ((node.hdr.totlen + 3) \/ 4) * 4);\n}<\/code><\/pre>\n\n\n\n<p>\u6dfb\u52a0\u6a21\u677f<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"951\" height=\"807\" src=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-2.png\" alt=\"\" class=\"wp-image-2489\" srcset=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-2.png?v=1784710976 951w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-2-300x255.png?v=1784710976 300w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-2-768x652.png?v=1784710976 768w\" sizes=\"(max-width: 951px) 100vw, 951px\" \/><\/figure>\n\n\n\n<p>\u52a0\u8f7d\u6a21\u677f<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"445\" height=\"416\" src=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-4.png\" alt=\"\" class=\"wp-image-2491\" srcset=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-4.png?v=1784711040 445w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-4-300x280.png?v=1784711040 300w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/figure>\n\n\n\n<p>\u6700\u540e\u7684\u6548\u679c\u5982\u4e0b\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"684\" src=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-3-1024x684.png?v=1784711015\" alt=\"\" class=\"wp-image-2490\" srcset=\"https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-3-1024x684.png?v=1784711015 1024w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-3-300x200.png?v=1784711015 300w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-3-768x513.png?v=1784711015 768w, https:\/\/www.zhiwanyuzhou.com\/wp-content\/uploads\/2026\/07\/image-3.png?v=1784711015 1454w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00 010 Editor\u7684\u6a21\u677f\u529f\u80fd\u662f\u4e00\u9879\u4e13\u4e1a\u7ea7\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u89e3\u6790\u4e0e\u7f16\u8f91\u673a\u5236\u3002\u5b83\u901a\u8fc7\u7ed3\u6784\u5316\u7684\u65b9\u5f0f\u5bf9\u539f\u59cb\u5341\u516d\u8fdb\u5236\u6570\u636e\u8fdb\u884c\u8bed\u4e49\u5c42\u9762\u7684\u6620\u5c04\uff0c\u5c06\u5b57\u8282\u5e8f\u5217\u8f6c\u5316\u4e3a\u5177\u6709\u660e\u786e\u5b57\u6bb5\u542b\u4e49\u7684\u6570\u636e\u7ed3\u6784\u6811\uff0c\u4ece\u800c\u663e\u8457\u63d0\u5347\u4e86\u4e8c\u8fdb\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"_links":{"self":[{"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2486"}],"collection":[{"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=2486"}],"version-history":[{"count":3,"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2486\/revisions"}],"predecessor-version":[{"id":2496,"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2486\/revisions\/2496"}],"wp:attachment":[{"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=2486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=2486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhiwanyuzhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=2486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}