static int sshfs_truncate_workaround(const char *path, off_t size,
struct fuse_file_info *fi);
+static void sshfs_inc_modifver(void)
+{
+ pthread_mutex_lock(&sshfs.lock);
+ sshfs.modifver++;
+ pthread_mutex_unlock(&sshfs.lock);
+}
+
static int sshfs_truncate(const char *path, off_t size)
{
int err;
struct buffer buf;
- sshfs.modifver ++;
+ sshfs_inc_modifver();
if (size == 0 || sshfs.truncate_workaround)
return sshfs_truncate_workaround(path, size, NULL);
static inline int sshfs_file_is_conn(struct sshfs_file *sf)
{
- return sf->connver == sshfs.connver;
+ int ret;
+
+ pthread_mutex_lock(&sshfs.lock);
+ ret = (sf->connver == sshfs.connver);
+ pthread_mutex_unlock(&sshfs.lock);
+
+ return ret;
}
static int sshfs_open_common(const char *path, mode_t mode,
sf->is_seq = 0;
sf->refs = 1;
sf->next_pos = 0;
+ pthread_mutex_lock(&sshfs.lock);
sf->modifver= sshfs.modifver;
sf->connver = sshfs.connver;
+ pthread_mutex_unlock(&sshfs.lock);
buf_init(&buf, 0);
buf_add_path(&buf, path);
buf_add_uint32(&buf, pflags);
chunk->offset = offset;
chunk->size = size;
chunk->refs = 1;
+ pthread_mutex_lock(&sshfs.lock);
chunk->modifver = sshfs.modifver;
+ pthread_mutex_unlock(&sshfs.lock);
sshfs_send_async_read(sf, chunk);
pthread_mutex_lock(&sshfs.lock);
chunk_put(*chunkp);
if (!sshfs_file_is_conn(sf))
return -EIO;
- sshfs.modifver ++;
+ sshfs_inc_modifver();
buf_init(&buf, 0);
buf_add_buf(&buf, handle);
buf_add_uint64(&buf, offset);
if (!sshfs_file_is_conn(sf))
return -EIO;
- sshfs.modifver ++;
+ sshfs_inc_modifver();
if (sshfs.truncate_workaround)
return sshfs_truncate_workaround(path, size, fi);