"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cache.c" between
davfs2-1.6.1.tar.gz and davfs2-1.7.0.tar.gz

About: davfs2 is a file system driver that allows you to mount a WebDAV server as a disk drive.

cache.c  (davfs2-1.6.1):cache.c  (davfs2-1.7.0)
skipping to change at line 26 skipping to change at line 26
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with davfs2; if not, write to the Free Software Foundation, along with davfs2; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
#include "config.h" #include "config.h"
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
#include <dirent.h> #include <dirent.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include <error.h>
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#include <grp.h> #include <grp.h>
#ifdef HAVE_LIBINTL_H #ifdef HAVE_LIBINTL_H
#include <libintl.h> #include <libintl.h>
#endif #endif
#include <pwd.h> #include <pwd.h>
#ifdef HAVE_STDINT_H #ifdef HAVE_STDINT_H
#include <stdint.h> #include <stdint.h>
skipping to change at line 60 skipping to change at line 59
#ifdef HAVE_UTIME_H #ifdef HAVE_UTIME_H
#include <utime.h> #include <utime.h>
#endif #endif
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#include <sys/xattr.h>
#include <ne_alloc.h> #include <ne_alloc.h>
#include <ne_string.h> #include <ne_string.h>
#include <ne_xml.h> #include <ne_xml.h>
#include "defaults.h" #include "defaults.h"
#include "mount_davfs.h" #include "mount_davfs.h"
#include "webdav.h" #include "webdav.h"
#include "cache.h" #include "cache.h"
#include "util.h"
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
#define _(String) gettext(String) #define _(String) gettext(String)
#else #else
#define _(String) String #define _(String) String
#endif #endif
/* Private constants */ /* Private constants */
/*===================*/ /*===================*/
skipping to change at line 646 skipping to change at line 645
clean_cache(); clean_cache();
next_minimize = 0; next_minimize = 0;
int ret = update_directory(root, 0); int ret = update_directory(root, 0);
if (ret == EAGAIN) { if (ret == EAGAIN) {
root->utime = 0; root->utime = 0;
ret = update_directory(root, 0); ret = update_directory(root, 0);
} }
if (ret == EAGAIN) { if (ret == EAGAIN) {
error(0, 0, _("connection timed out two times;\n" WARN(_("connection timed out two times;\n"
"trying one last time")); "trying one last time"));
root->utime = 0; root->utime = 0;
ret = update_directory(root, 0); ret = update_directory(root, 0);
if (!ret) if (!ret)
printf(_("Last try succeeded.\n")); printf(_("Last try succeeded.\n"));
} }
if (ret == EAGAIN) { if (ret == EAGAIN) {
error(0, 0, _("server temporarily unreachable;\n" WARN(_("server temporarily unreachable;\n"
"mounting anyway")); "mounting anyway"));
} else if (ret) { } else if (ret) {
error(EXIT_FAILURE, 0, _("Mounting failed.\n%s"), ERR(_("Mounting failed.\n%s"), dav_get_webdav_error());
dav_get_webdav_error());
} else { } else {
dav_statfs(); dav_statfs();
} }
} }
void void
dav_close_cache(volatile int *got_sigterm) dav_close_cache(volatile int *got_sigterm)
{ {
if (debug) if (debug)
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Closing cache"); syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Closing cache");
skipping to change at line 1009 skipping to change at line 1007
if (!*nodep) { if (!*nodep) {
update_directory(parent, file_refresh); update_directory(parent, file_refresh);
*nodep = get_child(parent, name); *nodep = get_child(parent, name);
} }
if (!*nodep) if (!*nodep)
return ENOENT; return ENOENT;
if (is_dir(*nodep)) { if (is_dir(*nodep)) {
if (!(*nodep)->utime) if (!(*nodep)->utime)
update_directory(*nodep, retry); update_directory(*nodep, retry);
} else if (is_open(*nodep)) { } else {
attr_from_cache_file(*nodep);
if (is_open(*nodep))
attr_from_cache_file(*nodep);
else if (!is_dirty(*nodep)) {
int ret;
dav_props *props = NULL;
ret = dav_get_collection((*nodep)->path, &props);
if (ret == 0) {
if ((*nodep)->size != props->size) {
(*nodep)->size = props->size;
delete_cache_file(*nodep);
}
dav_delete_props(props);
}
}
} }
return 0; return 0;
} }
int int
dav_mkdir(dav_node **nodep, dav_node *parent, const char *name, uid_t uid, dav_mkdir(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
mode_t mode) mode_t mode)
{ {
if (!is_valid(parent)) if (!is_valid(parent))
skipping to change at line 2248 skipping to change at line 2262
add_node(node->parent, props); add_node(node->parent, props);
remove_node(node); remove_node(node);
return 1; return 1;
} else { } else {
dav_delete_props(props); dav_delete_props(props);
return ret; return ret;
} }
} }
if (is_cached(node)) { if (is_cached(node)) {
if ((!node->etag && props->mtime > node->smtime) if ((!props->etag && props->mtime > node->smtime)
|| (node->etag && props->etag || (node->etag && props->etag
&& strcmp(node->etag, props->etag) != 0)) { && strcmp(node->etag, props->etag) != 0)) {
if (is_open(node)) { if (is_open(node)) {
node->utime = 0; node->utime = 0;
dav_delete_props(props); dav_delete_props(props);
return ret; return ret;
} else if (is_dirty(node)) { } else if (is_dirty(node)) {
add_node(node->parent, props); add_node(node->parent, props);
remove_node(node); remove_node(node);
return 1; return 1;
skipping to change at line 2694 skipping to change at line 2708
dir : The top level cache directory. dir : The top level cache directory.
host : Domain name of the server. host : Domain name of the server.
path : Path of the resource onthe server. path : Path of the resource onthe server.
mpoint : Mount point. */ mpoint : Mount point. */
static void static void
check_cache_dir(const char *dir, const char *host, const char *path, check_cache_dir(const char *dir, const char *host, const char *path,
const char *mpoint) const char *mpoint)
{ {
struct passwd *pw = getpwuid(default_uid); struct passwd *pw = getpwuid(default_uid);
if (!pw || !pw->pw_name) if (!pw || !pw->pw_name)
error(EXIT_FAILURE, 0, _("can't read user data base")); ERR(_("can't read user data base"));
char *dir_name = ne_concat(host, path, mpoint + 1, "+", pw->pw_name, NULL); char *dir_name = ne_concat(host, path, mpoint + 1, "+", pw->pw_name, NULL);
*(dir_name + strlen(host) + strlen(path) - 1) = '+'; *(dir_name + strlen(host) + strlen(path) - 1) = '+';
char *pos = strchr(dir_name, '/'); char *pos = strchr(dir_name, '/');
while (pos) { while (pos) {
*pos = '-'; *pos = '-';
pos = strchr(pos, '/'); pos = strchr(pos, '/');
} }
DIR *tl_dir = opendir(dir); DIR *tl_dir = opendir(dir);
if (!tl_dir) if (!tl_dir)
error(EXIT_FAILURE, 0, _("can't open cache directory %s"), dir); ERR(_("can't open cache directory %s"), dir);
struct dirent *de = readdir(tl_dir); struct dirent *de = readdir(tl_dir);
while (de && !cache_dir) { while (de && !cache_dir) {
if (strcmp(de->d_name, dir_name) == 0) { if (strcmp(de->d_name, dir_name) == 0) {
cache_dir = ne_concat(dir, "/", de->d_name, NULL); cache_dir = ne_concat(dir, "/", de->d_name, NULL);
} }
de = readdir(tl_dir); de = readdir(tl_dir);
} }
closedir(tl_dir); closedir(tl_dir);
if (!cache_dir) { if (!cache_dir) {
cache_dir = ne_concat(dir, "/", dir_name, NULL); cache_dir = ne_concat(dir, "/", dir_name, NULL);
if (mkdir(cache_dir, S_IRWXU) != 0) if (mkdir(cache_dir, S_IRWXU) != 0)
error(EXIT_FAILURE, 0, _("can't create cache directory %s"), ERR(_("can't create cache directory %s"),
cache_dir); cache_dir);
} }
free(dir_name); free(dir_name);
struct stat st; struct stat st;
if (stat(cache_dir, &st) != 0) if (stat(cache_dir, &st) != 0)
error(EXIT_FAILURE, 0, _("can't access cache directory %s"), ERR(_("can't access cache directory %s"), cache_dir);
cache_dir);
if (st.st_uid != geteuid()) if (st.st_uid != geteuid())
error(EXIT_FAILURE, 0, _("wrong owner of cache directory %s"), ERR(_("wrong owner of cache directory %s"), cache_dir);
cache_dir);
if ((DAV_A_MASK & st.st_mode) != S_IRWXU) if ((DAV_A_MASK & st.st_mode) != S_IRWXU)
error(EXIT_FAILURE, 0, ERR(_("wrong permissions set for cache directory %s"), cache_dir);
_("wrong permissions set for cache directory %s"), cache_dir);
} }
/* Searches cache for orphaned files and puts them into backup. */ /* Searches cache for orphaned files and puts them into backup. */
static void static void
clean_cache(void) clean_cache(void)
{ {
DIR *dir = opendir(cache_dir); DIR *dir = opendir(cache_dir);
if (!dir) if (!dir)
return; return;
 End of changes. 14 change blocks. 
20 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)