Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2196215/?format=api
{ "id": 2196215, "url": "http://patchwork.ozlabs.org/api/patches/2196215/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260213053719.2590474-1-varadarajan.narayanan@oss.qualcomm.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260213053719.2590474-1-varadarajan.narayanan@oss.qualcomm.com>", "list_archive_url": null, "date": "2026-02-13T05:37:19", "name": "[v4] fs: fat: Handle 'FAT sector size mismatch'", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "6a5b19a8cd2ef6a8c2d70fc78077ad7cc72ebfb0", "submitter": { "id": 92283, "url": "http://patchwork.ozlabs.org/api/people/92283/?format=api", "name": "Varadarajan Narayanan", "email": "varadarajan.narayanan@oss.qualcomm.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260213053719.2590474-1-varadarajan.narayanan@oss.qualcomm.com/mbox/", "series": [ { "id": 492059, "url": "http://patchwork.ozlabs.org/api/series/492059/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=492059", "date": "2026-02-13T05:37:19", "name": "[v4] fs: fat: Handle 'FAT sector size mismatch'", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/492059/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2196215/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2196215/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=pnG3UOGr;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=QFsuvUsh;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=oss.qualcomm.com", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com\n header.b=\"pnG3UOGr\";\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.b=\"QFsuvUsh\";\n\tdkim-atps=neutral", "phobos.denx.de; dmarc=none (p=none dis=none)\n header.from=oss.qualcomm.com", "phobos.denx.de; spf=pass\n smtp.mailfrom=varadarajan.narayanan@oss.qualcomm.com" ], "Received": [ "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fC1CY6Ymbz1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 16:37:45 +1100 (AEDT)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 2926783015;\n\tFri, 13 Feb 2026 06:37:37 +0100 (CET)", "by phobos.denx.de (Postfix, from userid 109)\n id C13D383936; Fri, 13 Feb 2026 06:37:36 +0100 (CET)", "from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n [205.220.180.131])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 77A6F80FA1\n for <u-boot@lists.denx.de>; Fri, 13 Feb 2026 06:37:30 +0100 (CET)", "from pps.filterd (m0279869.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 61D2dcjg2093478\n for <u-boot@lists.denx.de>; Fri, 13 Feb 2026 05:37:29 GMT", "from mail-pj1-f72.google.com (mail-pj1-f72.google.com\n [209.85.216.72])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4c9k6y2aeg-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <u-boot@lists.denx.de>; Fri, 13 Feb 2026 05:37:28 +0000 (GMT)", "by mail-pj1-f72.google.com with SMTP id\n 98e67ed59e1d1-35678f99c6eso495470a91.1\n for <u-boot@lists.denx.de>; Thu, 12 Feb 2026 21:37:28 -0800 (PST)", "from hu-varada-blr.qualcomm.com\n (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-356a88ac286sm451394a91.14.2026.02.12.21.37.23\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 12 Feb 2026 21:37:25 -0800 (PST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED,\n SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:date:from:message-id:mime-version\n :subject:to; s=qcppdkim1; bh=quBYJELYFuehbmaI2bclFr8PEeMx/V28VKB\n N0j3ZhaM=; b=pnG3UOGrB2VZkggtZl0l5/13uNM5cq8AwiDi9h1gOh8cHwDECB3\n QqkmPRoknQaXacy+U1TwdiPZbh20whgIGQGJm3SwaPuagqnmXg1Ih7zRw/A340lO\n 3F++QJsr1jM+sD4eJFfhk3IodO0GcQJK0Dia+l8xNAIyWNg0BrA3O3PhfHWwJhDs\n VP8GW4fbvNIiuCZtYUXDCHKNqFcBi3xaxgTMCVzM57PWiI8ZrV0b1j02/yGTy+MN\n U6sPIbEdNegw1nWVeutC3QHrpwu9JmZIuLjouHhSsnqM1uu6xm6gf5zoGYGr/EYb\n 3ShOr4haWQc/EqIl2tY+zuiGZqmSKgfVlAQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1770961048; x=1771565848; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=quBYJELYFuehbmaI2bclFr8PEeMx/V28VKBN0j3ZhaM=;\n b=QFsuvUshhwcV/4t1GwAPwVVOwXCG+KqSIEfxGE0MyF5CF+zALCw+MhFa4ZX2ZuVKx6\n l/zuSuBPMmB9hJKYk88hVW55B44DotTUTNYA8JUSoLuyGXWS/dh2+vvDGxgFEy0HnszG\n +oJIzE8E521Gy4VKJV6fD7NaQfMbpyZmQbAmG7q7FsyvzeZtrxuKp5mqT9u/g627Im3W\n ql+8+yWwr0gO+2WzCo0Rrw6tmlzdaUWz9Y2/95PTTNMxi4Us66zATeRTntwgSKjwST5f\n QO36bNzxNRJerl1jiOU0ByNZeHnoCxdvP7AK6ckgwvsfZSzzw2bOvkrFqJ/sEXuuvftB\n yIPQ==" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770961048; x=1771565848;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=quBYJELYFuehbmaI2bclFr8PEeMx/V28VKBN0j3ZhaM=;\n b=ed76Q9jP+PYa7uqVHsdN34Lc8xloPCE7C6wqBSOOJlWzvECr7q3lNHbNIrzJdpjqhr\n /crQe02TPFsrlxlDCaURcQwCihEwFGu1U6t1TQr4QYVb9AWXOBVpB0o72tbSrz6AywFd\n Gnmz6MGSvJraz8mxazwSDdByxuWajjVVUYdNo5oONpuEzk8EPBWw0WFH6cWfnyQ/FFgS\n OTpCNwOVS1T0UX69Nq8N+osPe1NPd+f8EHyCEJF9rTnsTStuse2nDLypgzix0YvR7enn\n /UKr1qx8KkElOGicbtnZ3vgC9/fYubkm80KWl6QKVFr2/1C6WB0CtD8JlLla30/yvUL+\n ismQ==", "X-Forwarded-Encrypted": "i=1;\n AJvYcCXdOKrdwaNljXDKcIFvti8VniXckKvVjdatvFF53M/etPlXgQAdgeeGVwbNzg+Di8Up9OS45dY=@lists.denx.de", "X-Gm-Message-State": "AOJu0YwJIOFzIkwlQk5BPq1AEnhQkk2PRLw3CFPEZ3WpjleL1xOF0Daa\n +l6FBrVQjJETeeLFf5r7pth7lVg/mKMrXN6G1UWES10sTAETMB/Kso7WnkJXTeArz2cWeKZqsSH\n 53iX8rpgU7hhrMcBfH/Vh8As4K2mxLIOxXk/0dkmz3oeJYb8ABmKKDezE", "X-Gm-Gg": "AZuq6aIKFWqjkmjCaJJA36TQ1syj4B7bV+RPi5rwJMoxTwqfxZFHpD46fNm7AUmhc4y\n 9+qdBThCdxmHPunGGhrWWcEELv8nKGCCOvgj4N+QlTnSB+AllO9S0OKfLoffldxeTZ43a9lkzZ+\n LlsGAqBLF7MO87e086KoYXOYlIJ+C/MPNyfi50F47ldGm0sIcxP6TjS9gEMQ9b51/Ybl8ZtIMCx\n E7xSjNpGxx9mKwyAFoFbzrKx5ygmjUkr51KdOqUJ1AkOR1GQPgW0e90z5uCj2yRoNCJrkLtXmY/\n 61W0WPjbuEVrNAnj5fIa7PyaDFSBqm2Pv9TJb9orNiF5O1kF603e6p5xrT78jlX91/VsABYN5m7\n olbEpE65RQUvRgA6OnKWUCAPm28slDLj9j7m9m8sXBFywgbQK9T/xAU/Cn8xRjVxQ3gHH5Wj3VJ\n SWBt+kJVRvgGcawRmI3qPZsDL4QRmDiPjmj90j76X3NuiG3HzozSA=", "X-Received": [ "by 2002:a17:90b:4c92:b0:356:1edc:b64 with SMTP id\n 98e67ed59e1d1-356aab9a342mr778796a91.8.1770961046868;\n Thu, 12 Feb 2026 21:37:26 -0800 (PST)", "by 2002:a17:90b:4c92:b0:356:1edc:b64 with SMTP id\n 98e67ed59e1d1-356aab9a342mr778760a91.8.1770961045855;\n Thu, 12 Feb 2026 21:37:25 -0800 (PST)" ], "From": "Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>", "To": "trini@konsulko.com, gabriel.dalimonte@gmail.com, u-boot@lists.denx.de", "Cc": "caleb.connolly@linaro.org, balaji.selvanathan@oss.qualcomm.com,\n Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>", "Subject": "[PATCH v4] fs: fat: Handle 'FAT sector size mismatch'", "Date": "Fri, 13 Feb 2026 11:07:19 +0530", "Message-Id": "<20260213053719.2590474-1-varadarajan.narayanan@oss.qualcomm.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Authority-Analysis": "v=2.4 cv=NsTcssdJ c=1 sm=1 tr=0 ts=698eb898 cx=c_pps\n a=RP+M6JBNLl+fLTcSJhASfg==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17\n a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=YfCOm-DyAAAA:8\n a=5p_tG3gqAAAA:8 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=COk6AnOGAAAA:8\n a=NdH2wwV_UUrT48UC1CkA:9 a=iS9zxrgQBfv6-_F4QbHw:22 a=zQLMK8awuJ6_Hvp-_9Ux:22\n a=TjNXssC_j7lpFel5tvFf:22", "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMjEzMDA0MCBTYWx0ZWRfX68b6xP8blFc2\n 04EGCYSfDM8bbdKz05XXRc1AhC51K9158PX/Ga6MdPaRJJfIx3hVd4kalLGWk20whOU7pmXONU9\n YwaUeGe1Pg3bmwG1DeQSIY+0BL4Q+b10rRUnslCw/BKkobsTDEhvymV8xJwFxC469imlHMEVAtm\n LT58JM15Q84S/gmaVqogjP5OK+mDB+yDRU9IAvlja2oKOkOh4jzcWDzByAIPWKnIpXcuJ/n65GL\n 1BxJrBvxFGSWqfNgXOGDCkoxSuMeWS0CRbFXN7ZFvfP6HJN7Btv3Lb9S1CedXDxQFIOTZDlb3vy\n J+FM4tyyv7J5Qb+BgFB2POi1aolzWhXyUXAH0CkUU1qw7vJxPfQV4swxHQem4fUSD/FL5rW9mvc\n TVvFW3ws2UTZbk3HiA1iiY9911+oHAT8snZrITCid6fiH53p7qKRsdLvgD92FHPu32b7K4M+B6u\n 7rL394ZyTfk82gMjEdw==", "X-Proofpoint-GUID": "DiXLsOtW8vl7IbEeymkcvPpZ3zuZ5gtc", "X-Proofpoint-ORIG-GUID": "DiXLsOtW8vl7IbEeymkcvPpZ3zuZ5gtc", "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-02-12_05,2026-02-12_03,2025-10-01_01", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n bulkscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501\n lowpriorityscore=0 adultscore=0 phishscore=0 malwarescore=0 clxscore=1015\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602130040", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "Do FAT read and write based on the device sector size\ninstead of the size recorded in the FAT meta data.\n\nFAT code issues i/o in terms of the sector size. Convert that to\ndevice sector size before doing the actual i/o. Additionally,\nhandle leading/trailing blocks when the meta data based block\nno and i/o size is not an exact multiple of the device sector\nsize or vice versa.\n\nTested on UFS device with sector size 4096 and meta data recorded\nsector size 512.\n\nSigned-off-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>\n---\nChanges in v4:\n- Fix clang warning reported in https://source.denx.de/u-boot/u-boot/-/jobs/1365316\n- Remove unused function 'size_to_blocks()'\n- Triggered CI, it fails with this error https://dev.azure.com/u-boot/u-boot/_build/results?buildId=12817&view=logs&j=a007cd84-3be0-5a02-8a7a-a34fb3052485&t=216c79d4-eaff-5600-0b8f-3a63c01a45d6&l=405. But that seems to be seen on top-of-tree without this change also.\n- Link to v3: https://lore.kernel.org/u-boot/20260122063442.2622684-1-balaji.selvanathan@oss.qualcomm.com/\n\nChanges in v3:\n- Respin, no changes\n- Link to v2: https://lore.kernel.org/u-boot/20241125085213.460723-1-quic_varada@quicinc.com/\n\nChanges in v2:\n- fat_sect_size is declared as static\n- The else block in disk_write() function has been removed\n- The commit message has additional details about testing\n- Link to v1: https://lore.kernel.org/u-boot/20241119073048.3469260-1-quic_varada@quicinc.com/\n---\n fs/fat/fat.c | 213 ++++++++++++++++++++++++++++++++++++++++++---\n fs/fat/fat_write.c | 19 ----\n 2 files changed, 200 insertions(+), 32 deletions(-)", "diff": "diff --git a/fs/fat/fat.c b/fs/fat/fat.c\nindex 9ce5df59f9b..af66cf7c98d 100644\n--- a/fs/fat/fat.c\n+++ b/fs/fat/fat.c\n@@ -45,24 +45,209 @@ static void downcase(char *str, size_t len)\n \n static struct blk_desc *cur_dev;\n static struct disk_partition cur_part_info;\n+static int fat_sect_size;\n \n #define DOS_BOOT_MAGIC_OFFSET\t0x1fe\n #define DOS_FS_TYPE_OFFSET\t0x36\n #define DOS_FS32_TYPE_OFFSET\t0x52\n \n-static int disk_read(__u32 block, __u32 nr_blocks, void *buf)\n+static inline __u32 sect_to_block(__u32 sect, __u32 *off)\n {\n-\tulong ret;\n+\t*off = 0;\n+\tif (fat_sect_size && fat_sect_size < cur_part_info.blksz) {\n+\t\tint div = cur_part_info.blksz / fat_sect_size;\n+\n+\t\t*off = sect % div;\n+\t\treturn sect / div;\n+\t} else if (fat_sect_size && (fat_sect_size > cur_part_info.blksz)) {\n+\t\treturn sect * (fat_sect_size / cur_part_info.blksz);\n+\t}\n \n-\tif (!cur_dev)\n-\t\treturn -1;\n+\treturn sect;\n+}\n \n-\tret = blk_dread(cur_dev, cur_part_info.start + block, nr_blocks, buf);\n+static int disk_read(__u32 sect, __u32 nr_sect, void *buf)\n+{\n+\tint ret;\n+\t__u8 *block = NULL;\n+\t__u32 rem, size;\n+\t__u32 s, n;\n \n-\tif (ret != nr_blocks)\n-\t\treturn -1;\n+\trem = nr_sect * fat_sect_size;\n+\t/*\n+\t * block N block N + 1 block N + 2\n+\t * +-+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n+\t * | | | | |s|e|c|t|o|r| | |s|e|c|t|o|r| | |s|e|c|t|o|r| | | | |\n+\t * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n+\t * . . . | | | | . . .\n+\t * ------+---------------+---------------+---------------+------\n+\t * |<--- FAT reads in sectors --->|\n+\t *\n+\t * | part 1 | part 2 | part 3 |\n+\t *\n+\t */\n \n-\treturn ret;\n+\t/* Do part 1 */\n+\tif (fat_sect_size) {\n+\t\t__u32 offset;\n+\n+\t\t/* Read one block and copy out the leading sectors */\n+\t\tblock = malloc_cache_aligned(cur_dev->blksz);\n+\t\tif (!block) {\n+\t\t\tprintf(\"Error: allocating block: %lu\\n\", cur_dev->blksz);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\ts = sect_to_block(sect, &offset);\n+\t\toffset = offset * fat_sect_size;\n+\n+\t\tret = blk_dread(cur_dev, cur_part_info.start + s, 1, block);\n+\t\tif (ret != 1) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t}\n+\n+\t\tif (rem > (cur_part_info.blksz - offset))\n+\t\t\tsize = cur_part_info.blksz - offset;\n+\t\telse\n+\t\t\tsize = rem;\n+\n+\t\tmemcpy(buf, block + offset, size);\n+\t\trem -= size;\n+\t\tbuf += size;\n+\t\ts++;\n+\t} else {\n+\t\t/*\n+\t\t * fat_sect_size not being set implies, this is the first read\n+\t\t * to partition. The first sector is being read to get the\n+\t\t * FS meta data. The FAT sector size is got from this meta data.\n+\t\t */\n+\t\tret = blk_dread(cur_dev, cur_part_info.start + s, 1, buf);\n+\t\tif (ret != 1)\n+\t\t\treturn -1;\n+\t}\n+\n+\t/* Do part 2, read directly into the given buffer */\n+\tif (rem > cur_part_info.blksz) {\n+\t\tn = rem / cur_part_info.blksz;\n+\t\tret = blk_dread(cur_dev, cur_part_info.start + s, n, buf);\n+\t\tif (ret != n) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t}\n+\t\tbuf += n * cur_part_info.blksz;\n+\t\trem = rem % cur_part_info.blksz;\n+\t\ts += n;\n+\t}\n+\n+\t/* Do part 3, read a block and copy the trailing sectors */\n+\tif (rem) {\n+\t\tret = blk_dread(cur_dev, cur_part_info.start + s, 1, block);\n+\t\tif (ret != 1) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t} else {\n+\t\t\tmemcpy(buf, block, rem);\n+\t\t}\n+\t}\n+exit:\n+\tif (block)\n+\t\tfree(block);\n+\n+\treturn (ret == -1) ? -1 : nr_sect;\n+}\n+\n+int disk_write(__u32 sect, __u32 nr_sect, void *buf)\n+{\n+\tint ret;\n+\t__u8 *block = NULL;\n+\t__u32 rem, size;\n+\t__u32 s, n;\n+\n+\trem = nr_sect * fat_sect_size;\n+\t/*\n+\t * block N block N + 1 block N + 2\n+\t * +-+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n+\t * | | | | |s|e|c|t|o|r| | |s|e|c|t|o|r| | |s|e|c|t|o|r| | | | |\n+\t * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n+\t * . . . | | | | . . .\n+\t * ------+---------------+---------------+---------------+------\n+\t * |<--- FAT reads in sectors --->|\n+\t *\n+\t * | part 1 | part 2 | part 3 |\n+\t *\n+\t */\n+\n+\t/* Do part 1 */\n+\tif (fat_sect_size) {\n+\t\t__u32 offset;\n+\n+\t\t/* Read one block and overwrite the leading sectors */\n+\t\tblock = malloc_cache_aligned(cur_dev->blksz);\n+\t\tif (!block) {\n+\t\t\tprintf(\"Error: allocating block: %lu\\n\", cur_dev->blksz);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\ts = sect_to_block(sect, &offset);\n+\t\toffset = offset * fat_sect_size;\n+\n+\t\tret = blk_dread(cur_dev, cur_part_info.start + s, 1, block);\n+\t\tif (ret != 1) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t}\n+\n+\t\tif (rem > (cur_part_info.blksz - offset))\n+\t\t\tsize = cur_part_info.blksz - offset;\n+\t\telse\n+\t\t\tsize = rem;\n+\n+\t\tmemcpy(block + offset, buf, size);\n+\t\tret = blk_dwrite(cur_dev, cur_part_info.start + s, 1, block);\n+\t\tif (ret != 1) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t}\n+\n+\t\trem -= size;\n+\t\tbuf += size;\n+\t\ts++;\n+\t}\n+\n+\t/* Do part 2, write directly from the given buffer */\n+\tif (rem > cur_part_info.blksz) {\n+\t\tn = rem / cur_part_info.blksz;\n+\t\tret = blk_dwrite(cur_dev, cur_part_info.start + s, n, buf);\n+\t\tif (ret != n) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t}\n+\t\tbuf += n * cur_part_info.blksz;\n+\t\trem = rem % cur_part_info.blksz;\n+\t\ts += n;\n+\t}\n+\n+\t/* Do part 3, read a block and copy the trailing sectors */\n+\tif (rem) {\n+\t\tret = blk_dread(cur_dev, cur_part_info.start + s, 1, block);\n+\t\tif (ret != 1) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t} else {\n+\t\t\tmemcpy(block, buf, rem);\n+\t\t}\n+\t\tret = blk_dwrite(cur_dev, cur_part_info.start + s, 1, block);\n+\t\tif (ret != 1) {\n+\t\t\tret = -1;\n+\t\t\tgoto exit;\n+\t\t}\n+\t}\n+exit:\n+\tif (block)\n+\t\tfree(block);\n+\n+\treturn (ret == -1) ? -1 : nr_sect;\n }\n \n int fat_set_blk_dev(struct blk_desc *dev_desc, struct disk_partition *info)\n@@ -581,6 +766,8 @@ read_bootsectandvi(boot_sector *bs, volume_info *volinfo, int *fatsize)\n \t\treturn -1;\n \t}\n \n+\tfat_sect_size = 0;\n+\n \tif (disk_read(0, 1, block) < 0) {\n \t\tdebug(\"Error: reading block\\n\");\n \t\tret = -1;\n@@ -651,12 +838,12 @@ static int get_fs_info(fsdata *mydata)\n \tmydata->rootdir_sect = mydata->fat_sect + mydata->fatlength * bs.fats;\n \n \tmydata->sect_size = get_unaligned_le16(bs.sector_size);\n+\tfat_sect_size = mydata->sect_size;\n \tmydata->clust_size = bs.cluster_size;\n-\tif (mydata->sect_size != cur_part_info.blksz) {\n-\t\tlog_err(\"FAT sector size mismatch (fs=%u, dev=%lu)\\n\",\n-\t\t\tmydata->sect_size, cur_part_info.blksz);\n-\t\treturn -1;\n-\t}\n+\tif (mydata->sect_size != cur_part_info.blksz)\n+\t\tlog_info(\"FAT sector size mismatch (fs=%u, dev=%lu)\\n\",\n+\t\t\t mydata->sect_size, cur_part_info.blksz);\n+\n \tif (mydata->clust_size == 0) {\n \t\tlog_err(\"FAT cluster size not set\\n\");\n \t\treturn -1;\ndiff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c\nindex 0b924541187..b686afd32c6 100644\n--- a/fs/fat/fat_write.c\n+++ b/fs/fat/fat_write.c\n@@ -192,25 +192,6 @@ out:\n }\n \n static int total_sector;\n-static int disk_write(__u32 block, __u32 nr_blocks, void *buf)\n-{\n-\tulong ret;\n-\n-\tif (!cur_dev)\n-\t\treturn -1;\n-\n-\tif (cur_part_info.start + block + nr_blocks >\n-\t\tcur_part_info.start + total_sector) {\n-\t\tprintf(\"error: overflow occurs\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\tret = blk_dwrite(cur_dev, cur_part_info.start + block, nr_blocks, buf);\n-\tif (nr_blocks && ret == 0)\n-\t\treturn -1;\n-\n-\treturn ret;\n-}\n \n /*\n * Write fat buffer into block device\n", "prefixes": [ "v4" ] }