diff --git a/checkin_notes b/checkin_notes index 9d2b7cc812..e6b2a35959 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2705,3 +2705,14 @@ David Mar 27 2008 tools/ update_versions version.h + +David Mar 27 2008 + - Library: switch from lstat() back to stat() most places; + this broke some projects' back-end code. + Make a new function (boinc_file_or_symlink_exists()) + for use by the client when clearing out slot dirs + + client/ + sandbox.C + lib/ + filesys.C,h diff --git a/client/sandbox.C b/client/sandbox.C index 7310670eaf..d9f1033627 100644 --- a/client/sandbox.C +++ b/client/sandbox.C @@ -149,12 +149,12 @@ static int delete_project_owned_file_aux(const char* path) { // Delete the file located at path. // If "retry" is set, do retries for 5 sec in case some // other program (e.g. virus checker) has the file locked. -// Don't do this if deleting directories - it can lock up Manager. +// Don't do this if deleting directories - it can lock up the Manager. // int delete_project_owned_file(const char* path, bool retry) { int retval = 0; - if (!boinc_file_exists(path)) { + if (!boinc_file_or_symlink_exists(path)) { return 0; } retval = delete_project_owned_file_aux(path); diff --git a/lib/filesys.C b/lib/filesys.C index 7d8977eb74..ad5a40bcc4 100644 --- a/lib/filesys.C +++ b/lib/filesys.C @@ -74,20 +74,17 @@ using std::string; char boinc_failed_file[256]; -#ifdef _WIN32 -#define lstat(x,y) stat(x,y) -#endif // routines for enumerating the entries in a directory int is_file(const char* path) { struct stat sbuf; - int retval = lstat(path, &sbuf); + int retval = stat(path, &sbuf); return (!retval && (sbuf.st_mode & S_IFREG)); } int is_dir(const char* path) { struct stat sbuf; - int retval = lstat(path, &sbuf); + int retval = stat(path, &sbuf); return (!retval && (sbuf.st_mode & S_IFDIR)); } @@ -287,7 +284,7 @@ int file_size(const char* path, double& size) { struct stat sbuf; int retval; - retval = lstat(path, &sbuf); + retval = stat(path, &sbuf); if (retval) return ERR_NOT_FOUND; size = (double)sbuf.st_size; return 0; @@ -445,8 +442,21 @@ FILE* boinc_fopen(const char* path, const char* mode) { int boinc_file_exists(const char* path) { struct stat buf; + if (stat(path, &buf)) { + return false; // stat() returns zero on success + } + return true; +} +// same, but doesn't traverse symlinks +// +int boinc_file_or_symlink_exists(const char* path) { + struct stat buf; +#ifdef _WIN32 + if (stat(path, &buf)) { +#else if (lstat(path, &buf)) { +#endif return false; // stat() returns zero on success } return true; diff --git a/lib/filesys.h b/lib/filesys.h index f830614055..b807301064 100644 --- a/lib/filesys.h +++ b/lib/filesys.h @@ -59,6 +59,7 @@ extern "C" { extern int is_dir(const char* path); extern int boinc_truncate(const char*, double); extern int boinc_file_exists(const char* path); + extern int boinc_file_or_symlink_exists(const char* path); #ifdef __cplusplus }