Skip to content

Commit

Permalink
[xrdCeph] properly return ENOENT when file does not exist in open for…
Browse files Browse the repository at this point in the history
… read

The open was so far successful, leading to successful reading of non existing files, as if they were 0 size
  • Loading branch information
root committed Mar 16, 2017
1 parent e9423c3 commit 4f43e75
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/XrdCeph/XrdCephPosix.cc
Expand Up @@ -604,12 +604,17 @@ int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode
insertOpenForWrite(fr.name);
}
// in case of O_CREAT and O_EXCL, we should complain if the file exists
if ((flags & O_CREAT) && (flags & O_EXCL)) {
// in case of O_READ, the file has to exist
if (((flags & O_CREAT) && (flags & O_EXCL)) || ((flags&O_ACCMODE) == O_RDONLY)) {
libradosstriper::RadosStriper *striper = getRadosStriper(fr);
if (0 == striper) return -EINVAL;
struct stat buf;
int rc = striper->stat(fr.name, (uint64_t*)&(buf.st_size), &(buf.st_atime));
if (rc != -ENOENT) {
if ((flags&O_ACCMODE) == O_RDONLY) {
if (rc) {
return rc;
}
} else if (rc != -ENOENT) {
if (0 == rc) return -EEXIST;
return rc;
}
Expand Down

0 comments on commit 4f43e75

Please sign in to comment.