Remove support for extended attributes
This commit is contained in:
parent
d61383d148
commit
f5e14315d4
105
src/cache.c
105
src/cache.c
@ -100,7 +100,6 @@ enum {
|
|||||||
CTIME,
|
CTIME,
|
||||||
SMTIME,
|
SMTIME,
|
||||||
ETAG,
|
ETAG,
|
||||||
MIME,
|
|
||||||
LOCK_EXPIRE,
|
LOCK_EXPIRE,
|
||||||
DIRTY,
|
DIRTY,
|
||||||
REMOTE_EXISTS,
|
REMOTE_EXISTS,
|
||||||
@ -124,7 +123,6 @@ static const char* const type[] = {
|
|||||||
[CTIME] = "ctime",
|
[CTIME] = "ctime",
|
||||||
[SMTIME] = "smtime",
|
[SMTIME] = "smtime",
|
||||||
[ETAG] = "etag",
|
[ETAG] = "etag",
|
||||||
[MIME] = "mime",
|
|
||||||
[LOCK_EXPIRE] = "lock_expire",
|
[LOCK_EXPIRE] = "lock_expire",
|
||||||
[DIRTY] = "dirty",
|
[DIRTY] = "dirty",
|
||||||
[REMOTE_EXISTS] = "remote_exists",
|
[REMOTE_EXISTS] = "remote_exists",
|
||||||
@ -764,7 +762,7 @@ dav_tidy_cache(void)
|
|||||||
set_execute = 1;
|
set_execute = 1;
|
||||||
int ret = dav_put(node->path, node->cache_path, &node->remote_exists,
|
int ret = dav_put(node->path, node->cache_path, &node->remote_exists,
|
||||||
&node->lock_expire, &node->etag, &node->smtime,
|
&node->lock_expire, &node->etag, &node->smtime,
|
||||||
&node->mime_type, set_execute);
|
set_execute);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
node->utime = time(NULL);
|
node->utime = time(NULL);
|
||||||
node->dirty = 0;
|
node->dirty = 0;
|
||||||
@ -857,7 +855,7 @@ dav_close(dav_node *node, int fd, int flags, pid_t pid, pid_t pgid)
|
|||||||
set_execute = 1;
|
set_execute = 1;
|
||||||
int ret = dav_put(node->path, node->cache_path, &node->remote_exists,
|
int ret = dav_put(node->path, node->cache_path, &node->remote_exists,
|
||||||
&node->lock_expire, &node->etag, &node->smtime,
|
&node->lock_expire, &node->etag, &node->smtime,
|
||||||
&node->mime_type, set_execute);
|
set_execute);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
node->utime = time(NULL);
|
node->utime = time(NULL);
|
||||||
node->dirty = 0;
|
node->dirty = 0;
|
||||||
@ -930,8 +928,7 @@ dav_create(dav_node **nodep, dav_node *parent, const char *name, uid_t uid,
|
|||||||
if (!ret) {
|
if (!ret) {
|
||||||
(*nodep)->smtime = (*nodep)->mtime;
|
(*nodep)->smtime = (*nodep)->mtime;
|
||||||
if (!is_created(*nodep))
|
if (!is_created(*nodep))
|
||||||
dav_head((*nodep)->path, &(*nodep)->etag, &(*nodep)->smtime, NULL,
|
dav_head((*nodep)->path, &(*nodep)->etag, &(*nodep)->smtime, NULL);
|
||||||
&(*nodep)->mime_type);
|
|
||||||
(*nodep)->utime = (*nodep)->smtime;
|
(*nodep)->utime = (*nodep)->smtime;
|
||||||
delete_cache_file(parent);
|
delete_cache_file(parent);
|
||||||
parent->mtime = (*nodep)->mtime;
|
parent->mtime = (*nodep)->mtime;
|
||||||
@ -973,58 +970,6 @@ dav_getattr(dav_node *node, uid_t uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
dav_getxattr(dav_node *node, const char *name, char *buf, size_t *size,
|
|
||||||
uid_t uid)
|
|
||||||
{
|
|
||||||
if (!is_valid(node))
|
|
||||||
return ENOENT;
|
|
||||||
if (debug)
|
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "getxattr %s", node->path);
|
|
||||||
if (node->parent != NULL && !has_permission(node->parent, uid, X_OK | R_OK))
|
|
||||||
return EACCES;
|
|
||||||
if (strcmp(name, "user.mime_type") != 0 || !node->mime_type)
|
|
||||||
return ENOTSUP;
|
|
||||||
|
|
||||||
if (*size == 0) {
|
|
||||||
*size = strlen(node->mime_type);
|
|
||||||
} else if (strlen(node->mime_type) > *size) {
|
|
||||||
return ERANGE;
|
|
||||||
} else {
|
|
||||||
*size = strlen(node->mime_type);
|
|
||||||
strncpy(buf, node->mime_type, *size);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
dav_listxattr(dav_node *node, char *buf, size_t *size, uid_t uid)
|
|
||||||
{
|
|
||||||
if (!is_valid(node))
|
|
||||||
return ENOENT;
|
|
||||||
if (debug)
|
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "listxattr %s", node->path);
|
|
||||||
if (node->parent != NULL && !has_permission(node->parent, uid, X_OK | R_OK))
|
|
||||||
return EACCES;
|
|
||||||
if (!node->mime_type)
|
|
||||||
return ENOTSUP;
|
|
||||||
|
|
||||||
if (*size == 0) {
|
|
||||||
*size = strlen("user.mime_type") + 1;
|
|
||||||
} else if (strlen("user.mime_type") > *size) {
|
|
||||||
return ERANGE;
|
|
||||||
} else {
|
|
||||||
*size = strlen("user.mime_type") + 1;
|
|
||||||
strncpy(buf, "user.mime_type", *size - 1);
|
|
||||||
*(buf + *size - 1) = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
dav_lookup(dav_node **nodep, dav_node *parent, const char *name, uid_t uid)
|
dav_lookup(dav_node **nodep, dav_node *parent, const char *name, uid_t uid)
|
||||||
{
|
{
|
||||||
@ -1487,7 +1432,7 @@ dav_setattr(dav_node *node, uid_t uid, int sm, mode_t mode, int so,
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
time_t smtime = 0;
|
time_t smtime = 0;
|
||||||
char *etag = NULL;
|
char *etag = NULL;
|
||||||
dav_head(node->path, &etag, &smtime, NULL, NULL);
|
dav_head(node->path, &etag, &smtime, NULL);
|
||||||
if (etag && node->etag && strcmp(etag, node->etag) != 0)
|
if (etag && node->etag && strcmp(etag, node->etag) != 0)
|
||||||
err = EIO;
|
err = EIO;
|
||||||
if (smtime && smtime > node->smtime)
|
if (smtime && smtime > node->smtime)
|
||||||
@ -1499,8 +1444,7 @@ dav_setattr(dav_node *node, uid_t uid, int sm, mode_t mode, int so,
|
|||||||
}
|
}
|
||||||
dav_set_execute(node->path, set_execute);
|
dav_set_execute(node->path, set_execute);
|
||||||
if (is_dirty(node))
|
if (is_dirty(node))
|
||||||
dav_head(node->path, &node->etag, &node->smtime, NULL,
|
dav_head(node->path, &node->etag, &node->smtime, NULL);
|
||||||
&node->mime_type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node->mode = (node->mode & ~DAV_A_MASK) | mode;
|
node->mode = (node->mode & ~DAV_A_MASK) | mode;
|
||||||
@ -1678,8 +1622,6 @@ backup_node(dav_node *orig)
|
|||||||
node->name = xstrdup(orig->cache_path + strlen(cache_dir) +1);
|
node->name = xstrdup(orig->cache_path + strlen(cache_dir) +1);
|
||||||
node->cache_path = orig->cache_path;
|
node->cache_path = orig->cache_path;
|
||||||
orig->cache_path = NULL;
|
orig->cache_path = NULL;
|
||||||
node->mime_type = orig->mime_type;
|
|
||||||
orig->mime_type = NULL;
|
|
||||||
orig->dirty = 0;
|
orig->dirty = 0;
|
||||||
node->size = orig->size;
|
node->size = orig->size;
|
||||||
node->uid = default_uid;
|
node->uid = default_uid;
|
||||||
@ -1746,8 +1688,7 @@ clean_tree(dav_node *node, int upload)
|
|||||||
set_execute = 1;
|
set_execute = 1;
|
||||||
int ret = dav_put(node->path, node->cache_path,
|
int ret = dav_put(node->path, node->cache_path,
|
||||||
&node->remote_exists, &node->lock_expire,
|
&node->remote_exists, &node->lock_expire,
|
||||||
&node->etag, &node->smtime,
|
&node->etag, &node->smtime, set_execute);
|
||||||
&node->mime_type, set_execute);
|
|
||||||
if (is_locked(node))
|
if (is_locked(node))
|
||||||
dav_unlock(node->path, &node->lock_expire);
|
dav_unlock(node->path, &node->lock_expire);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
@ -1786,8 +1727,6 @@ delete_node(dav_node *node)
|
|||||||
delete_cache_file(node);
|
delete_cache_file(node);
|
||||||
if (node->etag)
|
if (node->etag)
|
||||||
free(node->etag);
|
free(node->etag);
|
||||||
if (node->mime_type)
|
|
||||||
free(node->mime_type);
|
|
||||||
while (node->handles) {
|
while (node->handles) {
|
||||||
dav_handle *tofree = node->handles;
|
dav_handle *tofree = node->handles;
|
||||||
node->handles = node->handles->next;
|
node->handles = node->handles->next;
|
||||||
@ -1923,7 +1862,7 @@ move_no_remote(dav_node *src, dav_node *dst, dav_node *dst_parent,
|
|||||||
src->smtime = time(NULL);
|
src->smtime = time(NULL);
|
||||||
|
|
||||||
if (!is_created(src))
|
if (!is_created(src))
|
||||||
dav_head(src->path, &src->etag, &src->smtime, NULL, &src->mime_type);
|
dav_head(src->path, &src->etag, &src->smtime, NULL);
|
||||||
src->utime = time(NULL);
|
src->utime = time(NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1958,7 +1897,7 @@ move_reg(dav_node *src, dav_node *dst, dav_node *dst_parent,
|
|||||||
dav_lock(dst_path, &src->lock_expire, &src->remote_exists);
|
dav_lock(dst_path, &src->lock_expire, &src->remote_exists);
|
||||||
}
|
}
|
||||||
if (is_cached(src))
|
if (is_cached(src))
|
||||||
dav_head(dst_path, &src->etag, &src->smtime, NULL, &src->mime_type);
|
dav_head(dst_path, &src->etag, &src->smtime, NULL);
|
||||||
if (dst) {
|
if (dst) {
|
||||||
remove_from_tree(dst);
|
remove_from_tree(dst);
|
||||||
remove_from_changed(dst);
|
remove_from_changed(dst);
|
||||||
@ -2015,7 +1954,6 @@ new_node(dav_node *parent, mode_t mode)
|
|||||||
node->name = NULL;
|
node->name = NULL;
|
||||||
node->cache_path = NULL;
|
node->cache_path = NULL;
|
||||||
node->etag = NULL;
|
node->etag = NULL;
|
||||||
node->mime_type = NULL;
|
|
||||||
node->handles = NULL;
|
node->handles = NULL;
|
||||||
node->size = 0;
|
node->size = 0;
|
||||||
|
|
||||||
@ -2614,8 +2552,7 @@ update_cache_file(dav_node *node)
|
|||||||
if (get_upload_time(node) >= time(NULL))
|
if (get_upload_time(node) >= time(NULL))
|
||||||
return 0;
|
return 0;
|
||||||
ret = dav_put(node->path, node->cache_path, &node->remote_exists,
|
ret = dav_put(node->path, node->cache_path, &node->remote_exists,
|
||||||
&node->lock_expire, &node->etag, &node->smtime,
|
&node->lock_expire, &node->etag, &node->smtime, -1);
|
||||||
&node->mime_type, -1);
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
node->utime = time(NULL);
|
node->utime = time(NULL);
|
||||||
node->dirty = 0;
|
node->dirty = 0;
|
||||||
@ -2643,7 +2580,7 @@ update_cache_file(dav_node *node)
|
|||||||
int modified = 0;
|
int modified = 0;
|
||||||
off_t old_size = node->size;
|
off_t old_size = node->size;
|
||||||
ret = dav_get_file(node->path, node->cache_path, &node->size,
|
ret = dav_get_file(node->path, node->cache_path, &node->size,
|
||||||
&node->etag, &node->smtime, &node->mime_type,
|
&node->etag, &node->smtime,
|
||||||
&modified);
|
&modified);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
@ -2660,7 +2597,7 @@ update_cache_file(dav_node *node)
|
|||||||
time_t smtime = 0;
|
time_t smtime = 0;
|
||||||
char *etag = NULL;
|
char *etag = NULL;
|
||||||
ret = dav_get_file(node->path, node->cache_path, &node->size, &etag,
|
ret = dav_get_file(node->path, node->cache_path, &node->size, &etag,
|
||||||
&smtime, &node->mime_type, NULL);
|
&smtime, NULL);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
node->etag = etag;
|
node->etag = etag;
|
||||||
if (smtime) {
|
if (smtime) {
|
||||||
@ -2994,12 +2931,6 @@ write_node(dav_node *node, FILE *file, const char *indent)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_reg(node) && node->mime_type != NULL) {
|
|
||||||
if (fprintf(file, "%s<d:%s><![CDATA[%s]]></d:%s>\n", ind, type[MIME],
|
|
||||||
node->mime_type, type[MIME]) < 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_reg(node)) {
|
if (is_reg(node)) {
|
||||||
if (fprintf(file, "%s<d:%s>%lli</d:%s>\n", ind, type[SIZE],
|
if (fprintf(file, "%s<d:%s>%lli</d:%s>\n", ind, type[SIZE],
|
||||||
(long long int) node->size, type[SIZE]) < 0)
|
(long long int) node->size, type[SIZE]) < 0)
|
||||||
@ -3318,7 +3249,7 @@ xml_end_reg(void *userdata, int state, const char *nspace, const char *name)
|
|||||||
|
|
||||||
/* Finishes the creation of the root directory. userdata must be equal to root,
|
/* Finishes the creation of the root directory. userdata must be equal to root,
|
||||||
or the complete tree will be deleted.
|
or the complete tree will be deleted.
|
||||||
Members path, name, cache_path,etag and mime_type will be NULL.
|
Members path, name, cache_path and etag will be NULL.
|
||||||
return value : allways 0. */
|
return value : allways 0. */
|
||||||
static int
|
static int
|
||||||
xml_end_root(void *userdata, int state, const char *nspace, const char *name)
|
xml_end_root(void *userdata, int state, const char *nspace, const char *name)
|
||||||
@ -3341,10 +3272,6 @@ xml_end_root(void *userdata, int state, const char *nspace, const char *name)
|
|||||||
free(dir->etag);
|
free(dir->etag);
|
||||||
dir->etag = NULL;
|
dir->etag = NULL;
|
||||||
}
|
}
|
||||||
if (dir->mime_type) {
|
|
||||||
free(dir->mime_type);
|
|
||||||
dir->mime_type = NULL;
|
|
||||||
}
|
|
||||||
dir->size = 0;
|
dir->size = 0;
|
||||||
dir->smtime = 0;
|
dir->smtime = 0;
|
||||||
|
|
||||||
@ -3405,9 +3332,6 @@ xml_end_string(void *userdata, int state, const char *nspace, const char *name)
|
|||||||
case ETAG:
|
case ETAG:
|
||||||
(*((dav_node **) userdata))->etag = xml_data;
|
(*((dav_node **) userdata))->etag = xml_data;
|
||||||
break;
|
break;
|
||||||
case MIME:
|
|
||||||
(*((dav_node **) userdata))->mime_type = xml_data;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
free(xml_data);
|
free(xml_data);
|
||||||
xml_data = NULL;
|
xml_data = NULL;
|
||||||
@ -3442,9 +3366,6 @@ xml_end_string_old(void *userdata, int state, const char *nspace,
|
|||||||
case ETAG:
|
case ETAG:
|
||||||
(*((dav_node **) userdata))->etag = xml_data;
|
(*((dav_node **) userdata))->etag = xml_data;
|
||||||
break;
|
break;
|
||||||
case MIME:
|
|
||||||
(*((dav_node **) userdata))->mime_type = xml_data;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
free(xml_data);
|
free(xml_data);
|
||||||
xml_data = NULL;
|
xml_data = NULL;
|
||||||
@ -3686,8 +3607,6 @@ xml_start_string(void *userdata, int parent, const char *nspace,
|
|||||||
ret = CACHE_PATH;
|
ret = CACHE_PATH;
|
||||||
} else if (strcmp(name, type[ETAG]) == 0) {
|
} else if (strcmp(name, type[ETAG]) == 0) {
|
||||||
ret = ETAG;
|
ret = ETAG;
|
||||||
} else if (strcmp(name, type[MIME]) == 0) {
|
|
||||||
ret = MIME;
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
19
src/cache.h
19
src/cache.h
@ -83,8 +83,6 @@ struct dav_node {
|
|||||||
changed remotely. If present it overrides information from the
|
changed remotely. If present it overrides information from the
|
||||||
Last-Modified time (smtime). */
|
Last-Modified time (smtime). */
|
||||||
char *etag;
|
char *etag;
|
||||||
/* The media-type as in HTTP-header Content-Type. */
|
|
||||||
char *mime_type;
|
|
||||||
/* A linked list of handles for open files. */
|
/* A linked list of handles for open files. */
|
||||||
dav_handle *handles;
|
dav_handle *handles;
|
||||||
/* Size of the contents of the node.
|
/* Size of the contents of the node.
|
||||||
@ -287,23 +285,6 @@ int
|
|||||||
dav_getattr(dav_node *node, uid_t uid);
|
dav_getattr(dav_node *node, uid_t uid);
|
||||||
|
|
||||||
|
|
||||||
/* Checks whether node exists and uid has permissions. The value of
|
|
||||||
extended attribute name is copied into buf. If its size is greater
|
|
||||||
than size, EOVERFLOW is returned.
|
|
||||||
Permissions:
|
|
||||||
uid must have execute permission for parent and all of its ancestors, as
|
|
||||||
well as read permission for parent. */
|
|
||||||
int
|
|
||||||
dav_getxattr(dav_node *node, const char *name, char *buf, size_t *size,
|
|
||||||
uid_t uid);
|
|
||||||
|
|
||||||
|
|
||||||
/* Returns the list of supported extended attributes. This is just
|
|
||||||
user.mime_type. */
|
|
||||||
int
|
|
||||||
dav_listxattr(dav_node *node, char *buf, size_t *size, uid_t uid);
|
|
||||||
|
|
||||||
|
|
||||||
/* Searches for a node with name name in the directory parent and returns the
|
/* Searches for a node with name name in the directory parent and returns the
|
||||||
node in nodep.
|
node in nodep.
|
||||||
Permissions:
|
Permissions:
|
||||||
|
@ -128,15 +128,9 @@ fuse_create(void);
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
fuse_getattr(void);
|
fuse_getattr(void);
|
||||||
|
|
||||||
static uint32_t
|
|
||||||
fuse_getxattr(void);
|
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
fuse_init(void);
|
fuse_init(void);
|
||||||
|
|
||||||
static uint32_t
|
|
||||||
fuse_listxattr(void);
|
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
fuse_lookup(void);
|
fuse_lookup(void);
|
||||||
|
|
||||||
@ -385,15 +379,21 @@ dav_run_msgloop(volatile int *keep_on_running)
|
|||||||
break;
|
break;
|
||||||
case FUSE_SETXATTR:
|
case FUSE_SETXATTR:
|
||||||
if (debug)
|
if (debug)
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_GETXATTR:");
|
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_SETXATTR:");
|
||||||
oh->error = -ENOSYS;
|
oh->error = -ENOSYS;
|
||||||
oh->len = sizeof(struct fuse_out_header);
|
oh->len = sizeof(struct fuse_out_header);
|
||||||
break;
|
break;
|
||||||
case FUSE_GETXATTR:
|
case FUSE_GETXATTR:
|
||||||
oh->len = fuse_getxattr();
|
if (debug)
|
||||||
|
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_GETXATTR:");
|
||||||
|
oh->error = -ENOSYS;
|
||||||
|
oh->len = sizeof(struct fuse_out_header);
|
||||||
break;
|
break;
|
||||||
case FUSE_LISTXATTR:
|
case FUSE_LISTXATTR:
|
||||||
oh->len = fuse_listxattr();
|
if (debug)
|
||||||
|
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_LISTXATTR:");
|
||||||
|
oh->error = -ENOSYS;
|
||||||
|
oh->len = sizeof(struct fuse_out_header);
|
||||||
break;
|
break;
|
||||||
case FUSE_REMOVEXATTR:
|
case FUSE_REMOVEXATTR:
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -603,50 +603,6 @@ fuse_getattr(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint32_t
|
|
||||||
fuse_getxattr(void)
|
|
||||||
{
|
|
||||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
|
||||||
struct fuse_getxattr_in *in = (struct fuse_getxattr_in *)
|
|
||||||
(buf + sizeof(struct fuse_in_header));
|
|
||||||
char *name = (char *) (buf + sizeof(struct fuse_in_header)
|
|
||||||
+ sizeof(struct fuse_getxattr_in));
|
|
||||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
|
||||||
struct fuse_getxattr_out *out = (struct fuse_getxattr_out *)
|
|
||||||
(buf + sizeof(struct fuse_out_header));
|
|
||||||
char *value = (char *) (buf + sizeof(struct fuse_out_header));
|
|
||||||
if (debug) {
|
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_GETXATTR:");
|
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, %s, %i",
|
|
||||||
(unsigned long long) ih->nodeid, name, in->size);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size = in->size;
|
|
||||||
if (size == 0) {
|
|
||||||
oh->error = dav_getxattr((dav_node *) ((size_t) ih->nodeid), name,
|
|
||||||
value, &size, ih->uid);
|
|
||||||
if (oh->error) {
|
|
||||||
oh->error *= -1;
|
|
||||||
return sizeof(struct fuse_out_header);
|
|
||||||
}
|
|
||||||
out->size = size;
|
|
||||||
out->padding = 0;
|
|
||||||
return sizeof(struct fuse_out_header)
|
|
||||||
+ sizeof(struct fuse_getxattr_out);
|
|
||||||
} else {
|
|
||||||
if (size > (buf_size - sizeof(struct fuse_out_header)))
|
|
||||||
size = buf_size - sizeof(struct fuse_out_header);
|
|
||||||
oh->error = dav_getxattr((dav_node *) ((size_t) ih->nodeid), name,
|
|
||||||
value, &size, ih->uid);
|
|
||||||
if (oh->error) {
|
|
||||||
oh->error *= -1;
|
|
||||||
return sizeof(struct fuse_out_header);
|
|
||||||
}
|
|
||||||
return sizeof(struct fuse_out_header) + size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
fuse_init(void)
|
fuse_init(void)
|
||||||
{
|
{
|
||||||
@ -685,48 +641,6 @@ fuse_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint32_t
|
|
||||||
fuse_listxattr(void)
|
|
||||||
{
|
|
||||||
struct fuse_in_header *ih = (struct fuse_in_header *) buf;
|
|
||||||
struct fuse_getxattr_in *in = (struct fuse_getxattr_in *)
|
|
||||||
(buf + sizeof(struct fuse_in_header));
|
|
||||||
struct fuse_out_header *oh = (struct fuse_out_header *) buf;
|
|
||||||
struct fuse_getxattr_out *out = (struct fuse_getxattr_out *)
|
|
||||||
(buf + sizeof(struct fuse_out_header));
|
|
||||||
char *value = (char *) (buf + sizeof(struct fuse_out_header));
|
|
||||||
if (debug) {
|
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "FUSE_LISTXATTR:");
|
|
||||||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " n 0x%llx, %i",
|
|
||||||
(unsigned long long) ih->nodeid, in->size);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size = in->size;
|
|
||||||
if (size == 0) {
|
|
||||||
oh->error = dav_listxattr((dav_node *) ((size_t) ih->nodeid), value,
|
|
||||||
&size, ih->uid);
|
|
||||||
if (oh->error) {
|
|
||||||
oh->error *= -1;
|
|
||||||
return sizeof(struct fuse_out_header);
|
|
||||||
}
|
|
||||||
out->size = size;
|
|
||||||
out->padding = 0;
|
|
||||||
return sizeof(struct fuse_out_header)
|
|
||||||
+ sizeof(struct fuse_getxattr_out);
|
|
||||||
} else {
|
|
||||||
if (size > (buf_size - sizeof(struct fuse_out_header)))
|
|
||||||
size = buf_size - sizeof(struct fuse_out_header);
|
|
||||||
oh->error = dav_listxattr((dav_node *) ((size_t) ih->nodeid), value,
|
|
||||||
&size, ih->uid);
|
|
||||||
if (oh->error) {
|
|
||||||
oh->error *= -1;
|
|
||||||
return sizeof(struct fuse_out_header);
|
|
||||||
}
|
|
||||||
return sizeof(struct fuse_out_header) + size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
fuse_lookup(void)
|
fuse_lookup(void)
|
||||||
{
|
{
|
||||||
|
35
src/webdav.c
35
src/webdav.c
@ -680,7 +680,7 @@ dav_get_webdav_error()
|
|||||||
|
|
||||||
int
|
int
|
||||||
dav_get_file(const char *path, const char *cache_path, off_t *size,
|
dav_get_file(const char *path, const char *cache_path, off_t *size,
|
||||||
char **etag, time_t *mtime, char **mime, int *modified)
|
char **etag, time_t *mtime, int *modified)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@ -733,13 +733,6 @@ dav_get_file(const char *path, const char *cache_path, off_t *size,
|
|||||||
if (*etag) free(*etag);
|
if (*etag) free(*etag);
|
||||||
*etag = normalize_etag(ne_get_response_header(req, "ETag"));
|
*etag = normalize_etag(ne_get_response_header(req, "ETag"));
|
||||||
}
|
}
|
||||||
|
|
||||||
value = ne_get_response_header(req, "Content-Type");
|
|
||||||
if (mime && value) {
|
|
||||||
if (*mime)
|
|
||||||
free(*mime);
|
|
||||||
*mime = xstrdup(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ne_request_destroy(req);
|
ne_request_destroy(req);
|
||||||
@ -753,8 +746,7 @@ dav_get_file(const char *path, const char *cache_path, off_t *size,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
dav_head(const char *path, char **etag, time_t *mtime, off_t *length,
|
dav_head(const char *path, char **etag, time_t *mtime, off_t *length)
|
||||||
char **mime)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@ -784,13 +776,6 @@ dav_head(const char *path, char **etag, time_t *mtime, off_t *length,
|
|||||||
if (!ret && length && value)
|
if (!ret && length && value)
|
||||||
*length = strtol(value, NULL, 10);
|
*length = strtol(value, NULL, 10);
|
||||||
|
|
||||||
value = ne_get_response_header(req, "Content-Type");
|
|
||||||
if (!ret && mime && value) {
|
|
||||||
if (*mime)
|
|
||||||
free(*mime);
|
|
||||||
*mime = xstrdup(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ne_request_destroy(req);
|
ne_request_destroy(req);
|
||||||
free(spath);
|
free(spath);
|
||||||
return ret;
|
return ret;
|
||||||
@ -816,7 +801,7 @@ dav_lock(const char *path, time_t *expire, int *exists)
|
|||||||
#else /* NE_VERSION_MINOR == 25 */
|
#else /* NE_VERSION_MINOR == 25 */
|
||||||
if (precheck && !*exists) {
|
if (precheck && !*exists) {
|
||||||
#endif /* NE_VERSION_MINOR == 25 */
|
#endif /* NE_VERSION_MINOR == 25 */
|
||||||
if (dav_head(path, NULL, NULL, NULL, NULL) == 0) {
|
if (dav_head(path, NULL, NULL, NULL) == 0) {
|
||||||
return EEXIST;
|
return EEXIST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -942,7 +927,7 @@ dav_move(const char *src, const char *dst)
|
|||||||
|
|
||||||
int
|
int
|
||||||
dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
||||||
char **etag, time_t *mtime, char **mime, int execute)
|
char **etag, time_t *mtime, int execute)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@ -956,7 +941,7 @@ dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
|||||||
char *r_etag = NULL;
|
char *r_etag = NULL;
|
||||||
time_t r_mtime = 0;
|
time_t r_mtime = 0;
|
||||||
off_t r_length = 0;
|
off_t r_length = 0;
|
||||||
ret = dav_head(path, &r_etag, &r_mtime, &r_length, NULL);
|
ret = dav_head(path, &r_etag, &r_mtime, &r_length);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (!*exists && r_length) {
|
if (!*exists && r_length) {
|
||||||
ret = EEXIST;
|
ret = EEXIST;
|
||||||
@ -1072,14 +1057,6 @@ dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mime) {
|
|
||||||
value = ne_get_response_header(req, "Content-Type");
|
|
||||||
if (value) {
|
|
||||||
if (*mime)
|
|
||||||
free(*mime);
|
|
||||||
*mime = xstrdup(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ne_request_destroy(req);
|
ne_request_destroy(req);
|
||||||
@ -1090,7 +1067,7 @@ dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
|||||||
if (execute == 1)
|
if (execute == 1)
|
||||||
dav_set_execute(path, execute);
|
dav_set_execute(path, execute);
|
||||||
if (need_head)
|
if (need_head)
|
||||||
dav_head(path, etag, mtime, NULL, mime);
|
dav_head(path, etag, mtime, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
13
src/webdav.h
13
src/webdav.h
@ -141,16 +141,13 @@ dav_get_collection(const char *path, dav_props **props);
|
|||||||
mtime : Points to the Last-Modified value of the cached version. Will
|
mtime : Points to the Last-Modified value of the cached version. Will
|
||||||
be updated if a new version of the file is retrieved.
|
be updated if a new version of the file is retrieved.
|
||||||
May be NULL.
|
May be NULL.
|
||||||
mime : Points to the mime_type string of the cached version. Will
|
|
||||||
be updated by the value of the Content-Type header, if any.
|
|
||||||
May be NULL;
|
|
||||||
modified : Points to a flag that will be set 1 if the file cache_path
|
modified : Points to a flag that will be set 1 if the file cache_path
|
||||||
has been replaced by a new version. May be NULL.
|
has been replaced by a new version. May be NULL.
|
||||||
return value : 0 on success; an appropriate file error code otherwise.
|
return value : 0 on success; an appropriate file error code otherwise.
|
||||||
Not-Modified counts as success. */
|
Not-Modified counts as success. */
|
||||||
int
|
int
|
||||||
dav_get_file(const char *path, const char *cache_path, off_t *size,
|
dav_get_file(const char *path, const char *cache_path, off_t *size,
|
||||||
char **etag, time_t *mtime, char **mime, int *modified);
|
char **etag, time_t *mtime, int *modified);
|
||||||
|
|
||||||
|
|
||||||
/* Returns the error string from the last WebDAV request.
|
/* Returns the error string from the last WebDAV request.
|
||||||
@ -168,12 +165,10 @@ dav_get_webdav_error(void);
|
|||||||
etag : Points to the Etag; will be updated on success. May be NULL.
|
etag : Points to the Etag; will be updated on success. May be NULL.
|
||||||
mtime : Points to mtime; will be updated on success. May be NULL.
|
mtime : Points to mtime; will be updated on success. May be NULL.
|
||||||
length: Points to length; will be updated on success. May be NULL.
|
length: Points to length; will be updated on success. May be NULL.
|
||||||
mime : Points to mime_type; will be updated on success. May be NULL.
|
|
||||||
return value : 0 if the file exists; an appropriate file error code
|
return value : 0 if the file exists; an appropriate file error code
|
||||||
otherwise. */
|
otherwise. */
|
||||||
int
|
int
|
||||||
dav_head(const char *path, char **etag, time_t *mtime, off_t *length,
|
dav_head(const char *path, char **etag, time_t *mtime, off_t *length);
|
||||||
char **mime);
|
|
||||||
|
|
||||||
|
|
||||||
/* Locks the file path on the server with an excluse write lock and updates
|
/* Locks the file path on the server with an excluse write lock and updates
|
||||||
@ -238,13 +233,11 @@ dav_move(const char *src, const char *dst);
|
|||||||
Updated on success. May be NULL.
|
Updated on success. May be NULL.
|
||||||
mtime : The Last_Modified value used to check for changes on the
|
mtime : The Last_Modified value used to check for changes on the
|
||||||
server. Updated on success. May be NULL.
|
server. Updated on success. May be NULL.
|
||||||
mime : The value of mime_type. Updated on successMay be NULL.
|
|
||||||
If a mime_type is set, the Content-Type header will be sent.
|
|
||||||
execute : if 1 set execute property, else no change of execute property.
|
execute : if 1 set execute property, else no change of execute property.
|
||||||
return value : 0 on success; an appropriate file error code otherwise. */
|
return value : 0 on success; an appropriate file error code otherwise. */
|
||||||
int
|
int
|
||||||
dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
dav_put(const char *path, const char *cache_path, int *exists, time_t *expire,
|
||||||
char **etag, time_t *mtime, char **mime, int execute);
|
char **etag, time_t *mtime, int execute);
|
||||||
|
|
||||||
/* Makes a PROPFIND request for path to get quota information (RFC 4331)
|
/* Makes a PROPFIND request for path to get quota information (RFC 4331)
|
||||||
and places them in total and used.
|
and places them in total and used.
|
||||||
|
Loading…
Reference in New Issue
Block a user