From mboxrd@z Thu Jan 1 00:00:00 1970 From: Damian Stewart Subject: PROBLEM: hfsplus filesystem allows opendir() on plain files Date: Tue, 02 Dec 2008 16:26:56 +0100 Message-ID: <493553C0.2090407@frey.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit To: linux-fsdevel@vger.kernel.org Return-path: Received: from ip-72-55-185-114.static.privatedns.com ([72.55.185.114]:41443 "EHLO webhost.wanderingmonster.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787AbYLBP5D (ORCPT ); Tue, 2 Dec 2008 10:57:03 -0500 Received: from [192.168.1.105] (91-113-127-42.adsl.highway.telekom.at [91.113.127.42]) by webhost.wanderingmonster.co.nz (Postfix) with ESMTP id 656BB1465D for ; Wed, 3 Dec 2008 04:27:05 +1300 (NZDT) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 1. hfsplus filesystem allows opendir() on plain files. 2. When opendir() is called on a plain file stored in an hfsplus filesystem, opendir() fails to return 0 and set errno to ENOTDIR. 3. filesystem, hfsplus 4. Linux version 2.6.27-7-generic (buildd@palmer) (gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) ) #1 SMP Tue Nov 4 19:33:20 UTC 2008 5. unknown 6. n/a 7. Try the following program on files and directories first under a mountpoint for an ext3 partition then under a mountpoint for an hfsplus partition. /////////////////////////////////// #include #include #include // usage: opendir_test | int main( int argc, char** argv ) { DIR* result = opendir( argv[1] ); printf("ENOTDIR is 0x%x\n", ENOTDIR ); printf("opendir '%s' returned 0x%x, errno 0x%x\n", argv[1], result, errno ); return 0; } ////////////////////////////////// I get the following output: damian@damian-laptop:~/code/opendir$ mkdir test_directory damian@damian-laptop:~/code/opendir$ echo hello > test_file.txt damian@damian-laptop:~/code/opendir$ ./opendir_test test_directory ENOTDIR is 0x14 opendir 'test_directory' returned 0x88f6008, errno 0x0 damian@damian-laptop:~/code/opendir$ ./opendir_test test_file.txt ENOTDIR is 0x14 opendir 'test_file.txt' returned 0x0, errno 0x14 # /osx is an HFSPLUS mountpoint damian@damian-laptop:~/code/opendir$ cd /media/osx # mkdir test_directory && echo hello > test_file.txt performed in OSX damian@damian-laptop:/media/osx$ ./opendir_test test_directory ENOTDIR is 0x14 opendir 'test_directory' returned 0x919d008, errno 0x0 # erroneous result follows damian@damian-laptop:/media/osx$ ./opendir_test test_file.txt ENOTDIR is 0x14 opendir 'test_file.txt' returned 0x9a23008, errno 0x0 damian@damian-laptop:/media/osx$ 8. If some fields are empty or look unusual you may have an old version. Compare to the current minimal requirements in Documentation/Changes. Linux damian-laptop 2.6.27-7-generic #1 SMP Tue Nov 4 19:33:20 UTC 2008 i686 GNU/Linux Gnu C 4.3.2-1ubuntu11) Gnu make 3.81 binutils Binutils util-linux 2.14 mount support module-init-tools 3.3-pre11 e2fsprogs 1.41.3 reiserfsprogs 3.6.19 pcmciautils 014 Linux C Library 2.8.90 Dynamic linker (ldd) 2.8.90 Procps 3.2.7 Net-tools 1.60 Kbd 1.14.1 Sh-utils 6.10 udev 124 wireless-tools 29 Modules Loaded ipv6 aes_i586 aes_generic nls_utf8 hfsplus i915 drm af_packet binfmt_misc btusb sco bridge stp bnep rfcomm l2cap bluetooth ppdev acpi_cpufreq cpufreq_stats cpufreq_powersave cpufreq_conservative cpufreq_userspace cpufreq_ondemand freq_table container wmi pci_slot sbs sbshc iptable_filter ip_tables x_tables sbp2 parport_pc lp parport joydev snd_hda_intel arc4 snd_pcm_oss snd_mixer_oss iTCO_wdt ecb crypto_blkcipher iTCO_vendor_support snd_pcm ath9k evdev appleir pcspkr appletouch snd_seq_dummy mac80211 snd_seq_oss cfg80211 snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq video snd_timer snd_seq_device output battery snd ac intel_agp button soundcore agpgart shpchp pci_hotplug snd_page_alloc ext3 jbd mbcache sd_mod crc_t10dif sr_mod cdrom sg ata_generic ata_piix usbhid hid pata_acpi ohci1394 libata ieee1394 scsi_mod ehci_hcd uhci_hcd dock usbcore sky2 thermal processor fan fbcon tileblit font bitblit softcursor fuse thanks d -- damian stewart | skype: damiansnz | damian@frey.co.nz frey | live art with machines | http://www.frey.co.nz