Skip to content

Commit

Permalink
Fixed handling of O_TRUNC on ceph file opening
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Ponce committed Mar 5, 2015
1 parent a548543 commit 81dcefe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/XrdCeph/XrdCephPosix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ void ceph_posix_set_logfunc(void (*logfunc) (char *, va_list argp)) {
g_logfunc = logfunc;
};

static int ceph_posix_internal_truncate(const CephFile &file, unsigned long long size);

int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode) {
logwrapper((char*)"ceph_open : fd %d associated to %s", g_nextCephFd, pathname);
CephFileRef fr = getCephFileRef(pathname, env, flags, mode, 0);
Expand All @@ -448,6 +450,10 @@ int ceph_posix_open(XrdOucEnv* env, const char *pathname, int flags, mode_t mode
if (flags & (O_WRONLY|O_RDWR)) {
g_filesOpenForWrite.insert(fr.name);
}
// in case of O_TRUNC, we should truncate the file
if (flags & O_TRUNC) {
ceph_posix_internal_truncate(fr, 0);
}
return g_nextCephFd-1;
}

Expand Down

0 comments on commit 81dcefe

Please sign in to comment.