Репозитории ALT
S: | 0.8.7-alt4 |
5.1: | 0.8.7-alt2.M51.1 |
4.1: | 0.8.5-alt2 |
4.0: | 0.8.5-alt2 |
3.0: | |
+backports: | 0.8.3-alt1.M30.1 |
Группа :: Система/Ядро и оборудование
Пакет: fuse-smb
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: fuse-smb-ResFix-RenameFix-WriteSpeedIncr.patch
Скачать
Скачать
diff -uNr fusesmb-orig-0.8.7/fusesmb.c fusesmb-0.8.7/fusesmb.c
--- fusesmb-orig-0.8.7/fusesmb.c 2010-01-05 09:55:02.000000000 +0200
+++ fusesmb-0.8.7/fusesmb.c 2011-05-23 11:35:12.441837108 +0300
@@ -53,8 +53,7 @@
*/
static pthread_mutex_t ctx_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t rwd_ctx_mutex = PTHREAD_MUTEX_INITIALIZER;
-static SMBCCTX *ctx, *rwd_ctx;
+static SMBCCTX *ctx;
pthread_t cleanup_thread;
/*
@@ -131,9 +130,6 @@
ctx->callbacks.purge_cached_fn(ctx);
pthread_mutex_unlock(&ctx_mutex);
- pthread_mutex_lock(&rwd_ctx_mutex);
- rwd_ctx->callbacks.purge_cached_fn(rwd_ctx);
- pthread_mutex_unlock(&rwd_ctx_mutex);
/*
* Look every minute in the notfound cache for items that are
* no longer used
@@ -205,10 +201,6 @@
pthread_mutex_lock(&ctx_mutex);
ctx->timeout = opts.global_timeout * 1000;
pthread_mutex_unlock(&ctx_mutex);
-
- pthread_mutex_lock(&rwd_ctx_mutex);
- rwd_ctx->timeout = opts.global_timeout * 1000;
- pthread_mutex_unlock(&rwd_ctx_mutex);
}
@@ -536,22 +528,23 @@
// return -ENOENT;
strcat(smb_path, stripworkgroup(path));
- pthread_mutex_lock(&rwd_ctx_mutex);
- file = rwd_ctx->open(rwd_ctx, smb_path, fi->flags, 0);
+ pthread_mutex_lock(&ctx_mutex);
+ file = ctx->open(ctx, smb_path, fi->flags, 0);
if (file == NULL)
{
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
fi->fh = (unsigned long)file;
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return 0;
}
static int fusesmb_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
{
+
SMBCFILE *file;
char smb_path[MY_MAXPATHLEN] = "smb:/";
@@ -563,11 +556,11 @@
int tries = 0; //For number of retries before failing
ssize_t ssize; //Returned by ctx->read
- pthread_mutex_lock(&rwd_ctx_mutex);
+ pthread_mutex_lock(&ctx_mutex);
/* Ugly goto but it works ;) But IMHO easiest solution for error handling here */
goto seek;
reopen:
- if ((file = rwd_ctx->open(rwd_ctx, smb_path, fi->flags, 0)) == NULL)
+ if ((file = ctx->open(ctx, smb_path, fi->flags, 0)) == NULL)
{
/* Trying to reopen when out of memory */
if (errno == ENOMEM)
@@ -575,7 +568,7 @@
tries++;
if (tries > 4)
{
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
goto reopen;
@@ -583,14 +576,14 @@
/* Other errors from docs cannot be recovered from so returning the error */
else
{
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
}
fi->fh = (unsigned long)file;
seek:
- if (rwd_ctx->lseek(rwd_ctx, (SMBCFILE *)fi->fh, offset, SEEK_SET) == (off_t) - 1)
+ if (ctx->lseek(ctx, (SMBCFILE *)fi->fh, offset, SEEK_SET) == (off_t) - 1)
{
/* Bad file descriptor try to reopen */
if (errno == EBADF)
@@ -600,11 +593,11 @@
else
{
//SMB Init failed
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
}
- if ((ssize = rwd_ctx->read(rwd_ctx, (SMBCFILE *)fi->fh, buf, size)) < 0)
+ if ((ssize = ctx->read(ctx, (SMBCFILE *)fi->fh, buf, size)) < 0)
{
/* Bad file descriptor try to reopen */
if (errno == EBADF)
@@ -614,11 +607,11 @@
/* Tried opening a directory / or smb_init failed */
else
{
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
}
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return (size_t) ssize;
}
@@ -632,11 +625,12 @@
int tries = 0; //For number of retries before failing
ssize_t ssize; //Returned by ctx->read
- pthread_mutex_lock(&rwd_ctx_mutex);
+ pthread_mutex_lock(&ctx_mutex);
/* Ugly goto but it works ;) But IMHO easiest solution for error handling here */
goto seek;
+
reopen:
- if (NULL == (file = rwd_ctx->open(rwd_ctx, smb_path, fi->flags, 0)))
+ if (NULL == (file = ctx->open(ctx, smb_path, fi->flags, 0)))
{
/* Trying to reopen when out of memory */
if (errno == ENOMEM)
@@ -644,20 +638,20 @@
tries++;
if (tries > 4)
{
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
goto reopen;
}
/* Other errors from docs cannot be recovered from so returning the error */
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
fi->fh = (unsigned long)file;
- seek:
- if (rwd_ctx->lseek(rwd_ctx, (SMBCFILE *)fi->fh, offset, SEEK_SET) == (off_t) - 1)
+ seek:
+ if (ctx->lseek(ctx, (SMBCFILE *)fi->fh, offset, SEEK_SET) == (off_t) - 1)
{
/* Bad file descriptor try to reopen */
if (errno == EBADF)
@@ -667,11 +661,11 @@
else
{
//SMB Init failed
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
}
- if ((ssize = rwd_ctx->write(rwd_ctx, (SMBCFILE *)fi->fh, (void *) buf, size)) < 0)
+ if ((ssize = ctx->write(ctx, (SMBCFILE *)fi->fh, (void *) buf, size)) < 0)
{
/* Bad file descriptor try to reopen */
if (errno == EBADF)
@@ -681,24 +675,24 @@
/* Tried opening a directory / or smb_init failed */
else
{
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return -errno;
}
}
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return (size_t) ssize;
}
static int fusesmb_release(const char *path, struct fuse_file_info *fi)
{
(void)path;
- pthread_mutex_lock(&rwd_ctx_mutex);
+ pthread_mutex_lock(&ctx_mutex);
#ifdef HAVE_LIBSMBCLIENT_CLOSE_FN
- rwd_ctx->close_fn(rwd_ctx, (SMBCFILE *)fi->fh);
+ ctx->close_fn(ctx, (SMBCFILE *)fi->fh);
#else
- rwd_ctx->close(rwd_ctx, (SMBCFILE *)fi->fh);
+ ctx->close(ctx, (SMBCFILE *)fi->fh);
#endif
- pthread_mutex_unlock(&rwd_ctx_mutex);
+ pthread_mutex_unlock(&ctx_mutex);
return 0;
}
@@ -812,7 +806,7 @@
return -errno;
}
pthread_mutex_unlock(&ctx_mutex);
-
+
/* Clear item from notfound_cache */
if (slashcount(path) == 4)
{
@@ -888,7 +882,6 @@
static int fusesmb_truncate(const char *path, off_t size)
{
-
debug("path: %s, size: %lld", path, size);
char smb_path[MY_MAXPATHLEN] = "smb:/";
if (slashcount(path) <= 3)
@@ -951,6 +944,23 @@
return -errno;
}
pthread_mutex_unlock(&ctx_mutex);
+
+ /* Clear item from notfound_cache */
+ if (slashcount(new_path) == 4)
+ {
+ pthread_mutex_lock(¬found_cache_mutex);
+ hnode_t *node = hash_lookup(notfound_cache, new_path);
+ if (node != NULL)
+ {
+ const void *key = hnode_getkey(node);
+ void *data = hnode_get(node);
+ hash_delete_free(notfound_cache, node);
+ free((void *)key);
+ free(data);
+ }
+ pthread_mutex_unlock(¬found_cache_mutex);
+ }
+
return 0;
}
@@ -1003,7 +1013,6 @@
#endif
};
-
int main(int argc, char *argv[])
{
/* Workaround for bug in libsmbclient:
@@ -1099,23 +1108,20 @@
if (my_argv == NULL)
exit(EXIT_FAILURE);
- /* libsmbclient doesn't work with reads bigger than 32k */
- char *max_read = "-omax_read=32768";
-
for (i = 0; i < argc; i++)
{
my_argv[i] = argv[i];
my_argc++;
}
- my_argv[my_argc++] = max_read;
+ /* libsmbclient doesn't work with reads bigger than 32k */
+ my_argv[my_argc++] = "-o";
+ my_argv[my_argc++] = "max_read=32768,big_writes,max_write=32768";
options_read(&cfg, &opts);
ctx = fusesmb_new_context(&cfg, &cfg_mutex);
- rwd_ctx = fusesmb_new_context(&cfg, &cfg_mutex);
- if (ctx == NULL || rwd_ctx == NULL)
- exit(EXIT_FAILURE);
+ if (ctx == NULL) exit(EXIT_FAILURE);
notfound_cache = hash_create(HASHCOUNT_T_MAX, NULL, NULL);
if (notfound_cache == NULL)
@@ -1124,7 +1130,6 @@
fuse_main(my_argc, my_argv, &fusesmb_oper);
smbc_free_context(ctx, 1);
- smbc_free_context(rwd_ctx, 1);
options_free(&opts);
config_free(&cfg);