mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* vfat creates multiple files with the same filename
@ 2009-06-28 18:26 Marton Balint
  2009-06-30  2:24 ` OGAWA Hirofumi
  0 siblings, 1 reply; 5+ messages in thread
From: Marton Balint @ 2009-06-28 18:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: hirofumi

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1555 bytes --]

Hi, 

If I use vfat with the utf8 mount option, and create a file with an 
invalid utf-8 character in it's name, then the invalid charater gets 
removed from the filename silently. That's probably the expected way of 
operation but the problem is, that this automatic filename sanitization 
can be used to create multiple files with the same filename. Here's an 
example how to do it:

mkdir /mnt/fatfs
FILENAME=`echo -ne "invalidutf8char_\\0341_endofchar"`
echo "Using filename: $FILENAME"
dd if=/dev/zero of=fatfs bs=512 count=128
mkdosfs -F 32 fatfs
mount -o loop,utf8 fatfs /mnt/fatfs
touch "/mnt/fatfs/$FILENAME"
umount /mnt/fatfs
mount -o loop,utf8 fatfs /mnt/fatfs
touch "/mnt/fatfs/$FILENAME"
ls -l /mnt/fatfs
umount /mnt/fatfs

----  And the output is:

Using filename: invalidutf8char_á_endofchar
128+0 records in
128+0 records out
65536 bytes (66 kB) copied, 0.000388118 s, 169 MB/s
mkdosfs 2.11 (12 Mar 2005)
total 0
-rwxr-xr-x 1 root root 0 Jun 28 19:46 invalidutf8char__endofchar
-rwxr-xr-x 1 root root 0 Jun 28 19:46 invalidutf8char__endofchar

I don't know if removing the invalid characters silently instead of 
returning EINVAL is a good practice, but allowing two files with identical 
filenames is definitely wrong. 

Could someone please have a look at the problem? Unfortunately I am not 
qualified enough to track it down...

I've run the testcase on both 2.6.30 and 2.6.31-rc1 kernels, but this bug 
is probably not very new, since I remember having it also in 2.6.27.

Regards,
  Marton

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-07-06 19:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-28 18:26 vfat creates multiple files with the same filename Marton Balint
2009-06-30  2:24 ` OGAWA Hirofumi
2009-07-01  0:02   ` Marton Balint
2009-07-01  0:29     ` OGAWA Hirofumi
2009-07-06 19:11       ` Marton Balint

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®