Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4038552rwb; Sun, 30 Jul 2023 23:28:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlERUmWSHdOETFe1ay2tmeDVUbnEIW8c5d0jJqDm2PqF1YGYblB48c6jZ2A4LB9txq4oisak X-Received: by 2002:a05:6a00:a84:b0:668:97bf:5ed7 with SMTP id b4-20020a056a000a8400b0066897bf5ed7mr12106022pfl.22.1690784898776; Sun, 30 Jul 2023 23:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690784898; cv=none; d=google.com; s=arc-20160816; b=ASBK2tpzG/78xZ/4h3g6fBncSDxrsl6cHabbYQa/s15o8LcLUwNWm10fL1Jjr+VDBu PVMvU396izOKjloGk+zyVTiahd6E5TIL7Y/WvOmmMqERSTDkdu6n1ZyMN95efqmOMy1s U7Jqk2rlOoaCFX2yvZ0h+g9e2K66djz4G6iKPe56DToCplkp2f1rLVyzMPRSGVsxbXnp +5Fpe596hXiZyFwg7c0QUl2itqMojrwJ9H4QRMpeNZGS69Kg1mF5ngXfa8RI/OMAYunz shCNzmhO2ja1Z4CtOtSr5N2IemjPrjvhDxZAR7E/mH8xUYXFX3g3ElWQ45DczHzennrI lkCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ieF276YL7HT0gGGHoKO90ryHoiIiAVp5S/Cx1Rhnja4=; fh=v7F5bNzsq4Q4LGdZjJa1EmtnJ311Jq3MTg3/MHRPaPI=; b=zSD0sGja3tfA83qVZW2kIAvh6u2trDB+Kfuj3pGk2PH1h7dviAuvr46SYO6j9E/KR7 V1WBTQRfWJb08QSN0KU1qb80a5G0rjBiNr3Px0ASEAl+MqWc33hf4lAg6Jvp7kCvj6xd ZlBnfutnyt12RZixt8yZM2L08UX8swMoBYrEN3QSYfSxwCgv8B3cy8zRhY5Sw2eRPZCV PPhzv0kW3Ux3TDK1mEZiGO8EoW3BQL04idekitNyMwIChQEJ6fZ3w9IY6G2KwpulW5ZW gtq015ufNpearKcAdcL9+b9M68lVv38DcfZ8e3rwWJ3ZYQtWN5Tixp+8fsX0OReX2Yui YVkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=dT5hcPdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a63f54a000000b00563eda6a8f8si6667505pgk.239.2023.07.30.23.28.06; Sun, 30 Jul 2023 23:28:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=dT5hcPdN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229889AbjGaFzw (ORCPT + 99 others); Mon, 31 Jul 2023 01:55:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbjGaFzt (ORCPT ); Mon, 31 Jul 2023 01:55:49 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28A9AE78 for ; Sun, 30 Jul 2023 22:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1690782940; bh=5QtzLncJjPW1Z/AkFRqT4LJ0AxsIBfsBfMzg9sLfXXk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dT5hcPdNviYg1RTXNOZr9ggglMMLfYCZ0Jgd8l71USkoTJGPL2oyYHZbnc13fZsW3 WegPenPnplrg7Rjfidz2L45ijqgSdjclkGlKLyFdoAYmR5hbgw+l1Ih2zTy93x0lcn 1E9gZ9DOUYnc4PPlRBtBHJ60odnmBXtbe/3WQYfk= Date: Mon, 31 Jul 2023 07:55:39 +0200 From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: tjcw@cantab.net Cc: linux-kernel@vger.kernel.org Subject: Re: vfat file system does not allow a space at the end of a directory name Message-ID: <196f7191-5820-4480-99d3-e7ffc66e9c98@t-8ch.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chris, On 2023-07-30 23:33:03+0100, Chris Ward wrote: > I had a zip file (from downloading pictures from Google Photos) where > some of the directory names had a space at the end. This unzipped fine > on an ext4 file system, but gave errors when unpacking onto a USB key > which had a FAT file system. > > On further investigation, file names have the same problem. On my USB key, I get > > tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ touch 'aab ' > touch: setting times of 'aab ': No such file or directory > tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ echo ok >'aab ' > bash: aab : Invalid argument > tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ touch 'aab' > tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ echo ok >'aab' > tjcw@tjcw-OptiPlex-7010:/media/tjcw/Photos$ > > Is this as expected, or is it a bug in the kernel's handling of FAT > file systems ? Probably the next step is to check the behaviour under > Microsoft Windows. AFAIK this is a limitation in the FAT filesystem itself. The problem is that FAT stores filenames in fixed width fields. Unused space in these fields is filled with ' '. This means that storing "foo", "foo " or "foo ". would all result in the exact same result and it will be impossible to figure out the correct one afterwards. From Wikipedia [0]: trailing spaces in either the base name or the extension are considered to be padding and not a part of the file name From fs/fat/namei_vfat.c vfat_is_used_badchars(): last character cannot be space [0] https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system