#include #include #include #include int digital_lstat(const char *path, struct stat *buffer ) { struct attr_timbuf mytimbuf; int myfd=-1; int lstatres=0; TRACE(2,"in digital_lstat (vers_ts.cpp ) \"%s\".",path); lstatres= lstat (path, buffer); if (lstatres >= 0) { myfd = open (path, O_RDONLY); if (myfd != -1) { TRACE(2,"OPEN succesful ( digital_lstat )."); if (fcntl(myfd,F_GETTIMES,&mytimbuf)!=-1) { TRACE(2,"FCNTL succesful ( digital_lstat )."); buffer->st_mtime=mytimbuf.mtime.tv_sec; buffer->st_atime=mytimbuf.atime.tv_sec; buffer->st_ctime=mytimbuf.ctime.tv_sec; } else TRACE(2,"FCNTL unsuccesful ( digital_lstat )."); close(myfd); myfd=-1; } else { TRACE(2,"OPEN unsuccesful ( digital_lstat ). err=%d \"%s\"",errno,strerror(errno)); TRACE(2,"try and chmod and then open"); chmod(path, 666); myfd = open (path, O_RDONLY); if (myfd != -1) { TRACE(2,"OPEN succesful ( digital_lstat )."); if (fcntl(myfd,F_GETTIMES,&mytimbuf)!=-1) { TRACE(2,"FCNTL succesful ( digital_lstat )."); buffer->st_mtime=mytimbuf.mtime.tv_sec; buffer->st_atime=mytimbuf.atime.tv_sec; buffer->st_ctime=mytimbuf.ctime.tv_sec; } else TRACE(2,"FCNTL unsuccesful ( digital_lstat )."); close(myfd); myfd=-1; } } } else TRACE(2,"LSTAT unsuccesful ( digital_lstat )."); return lstatres; }