Bug 732304 - readlink on empty path is not POSIX compliant anymore
Summary: readlink on empty path is not POSIX compliant anymore
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 15
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2011-08-21 19:49 UTC by Vittorio
Modified: 2011-11-29 20:28 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2011-11-29 20:28:44 UTC

Attachments (Terms of Use)

Description Vittorio 2011-08-21 19:49:41 UTC
Description of problem:
I just installed kernel-

and I found that readlink on an empty path now sets errno to EINVAL.

This is not POSIX compliant, man 3 readlink says that ENOENT should be put 
in errno 
if path is an empty string.

Version-Release number of selected component (if applicable):

How reproducible:
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int main()
char buffer[256];
ssize_t n;
perror("errno from readlink:");
if( errno != ENOENT) printf("n=%d errno=%d\n",n,errno);
return 0;

Steps to Reproduce:
1. Compile
2. Run
Actual results:
Invalid argument

Expected results:
No such file or directory

Additional info:
Until readlink gave the correct errno. 
This is running readlink03 from ltp-full-20110606.

Comment 1 Josh Boyer 2011-08-21 21:01:07 UTC
You should report this upstream.

Comment 2 Chuck Ebbert 2011-08-22 16:33:52 UTC
Looks like this was caused by these two changes:

Before the second change, if path was empty we immediately returned -ENOENT.
Now we fall further into the filesystem code trying to look up the empty path and something there is returning -EINVAL.

Comment 3 Chuck Ebbert 2011-08-25 01:12:56 UTC
The fix for this is now in the -mm tree:

Subject: [stable] + readlinkat-ensure-we-return-enoent-for-the-empty-pathname-for-normal-lookups.patch added to -mm tree

Comment 4 Josh Boyer 2011-11-29 20:28:44 UTC
The patch Chuck highlighted was included in the 3.1.1 release ( in F15)

Note You need to log in before you can comment on or make changes to this bug.