Bug 7097 - Pseudo fails to properly ENOTDIR on stat/lstat
Summary: Pseudo fails to properly ENOTDIR on stat/lstat
Status: RESOLVED FIXED
Alias: None
Product: Pseudo
Classification: Yocto Project Subprojects
Component: pseudo (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 1.8
Assignee: Seebs
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2014-12-23 04:58 UTC by aerial9
Modified: 2015-05-21 17:54 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description aerial9 2014-12-23 04:58:47 UTC
This was causing a bug with a makefile that expected $(wildcard */) to only return directories. Sort of explained by: http://pastie.org/9795375

Steps to reproduce:
$ touch afile
$ stat afile/
stat: cannot stat ‘afile/’: Not a directory
$ LD_PRELOAD="libpsuedo.so" PSEUDO_PREFIX=. stat afile/
  File: ‘afile/’
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
  <etc>
Comment 1 Seebs 2015-01-02 19:04:52 UTC
Huh, that's fascinating! I was not aware of this idiom. Apparently, the stat syscall will take a literal filename of "a/" as meaning the same thing as "a", but will fail with ENOTDIR if a is not a directory. I'd never seen that before, and my initial check of the documentation doesn't actually turn it up, but it's probably possible to implement.
Comment 2 aerial9 2015-01-02 19:40:08 UTC
It seems to be explained in path_resolution(7), specifically:

   Trailing slashes
       If a pathname ends in a '/', that forces resolution of the preceding component as in Step 2: it has to exist and resolve to a directory.  Oth‐
       erwise, a trailing '/' is ignored.  (Or, equivalently, a pathname with a trailing '/' is equivalent to the pathname obtained by appending  '.'
       to it.)
Comment 3 Seebs 2015-05-21 17:54:02 UTC
Oh, whoops. This got fixed a while back, I never updated the bug.