sizeof(*inode));
}
+static inline ext2_filsys fuse2fs_start(struct fuse2fs *ff)
+{
+ pthread_mutex_lock(&ff->bfl);
+ return ff->fs;
+}
+
#ifdef CONFIG_MMP
static bool fuse2fs_mmp_wanted(const struct fuse2fs *ff)
{
{
struct fuse2fs *ff = data;
- pthread_mutex_lock(&ff->bfl);
+ fuse2fs_start(ff);
if (fuse2fs_mmp_wanted(ff) && !bthread_cancelled(ff->mmp_thread))
fuse2fs_mmp_touch(ff, false);
pthread_mutex_unlock(&ff->bfl);
FUSE2FS_CHECK_CONTEXT_DESTROY(ff);
- pthread_mutex_lock(&ff->bfl);
- fs = ff->fs;
+ fs = fuse2fs_start(ff);
dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name);
if (fs->flags & EXT2_FLAG_RW) {
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
ret = fuse2fs_file_ino(ff, path, fi, &ino);
if (ret)
goto out;
FUSE2FS_CHECK_CONTEXT(ff);
dbg_printf(ff, "%s: path=%s\n", __func__, path);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino);
if (err || ino == 0) {
ret = translate_error(fs, 0, err);
a = *node_name;
*node_name = 0;
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_can_allocate(ff, 2)) {
ret = -ENOSPC;
goto out2;
a = *node_name;
*node_name = 0;
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_can_allocate(ff, 1)) {
ret = -ENOSPC;
goto out2;
int ret;
FUSE2FS_CHECK_CONTEXT(ff);
- pthread_mutex_lock(&ff->bfl);
+ fuse2fs_start(ff);
ret = __op_unlink(ff, path);
pthread_mutex_unlock(&ff->bfl);
return ret;
int ret;
FUSE2FS_CHECK_CONTEXT(ff);
- pthread_mutex_lock(&ff->bfl);
+ fuse2fs_start(ff);
ret = __op_rmdir(ff, path);
pthread_mutex_unlock(&ff->bfl);
return ret;
a = *node_name;
*node_name = 0;
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_can_allocate(ff, 1)) {
ret = -ENOSPC;
goto out2;
FUSE2FS_CHECK_CONTEXT(ff);
dbg_printf(ff, "%s: renaming %s to %s\n", __func__, from, to);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_can_allocate(ff, 5)) {
ret = -ENOSPC;
goto out;
a = *node_name;
*node_name = 0;
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_can_allocate(ff, 2)) {
ret = -ENOSPC;
goto out2;
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
ret = fuse2fs_file_ino(ff, path, fi, &ino);
if (ret)
goto out;
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
ret = fuse2fs_file_ino(ff, path, fi, &ino);
if (ret)
goto out;
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- pthread_mutex_lock(&ff->bfl);
+ fuse2fs_start(ff);
ret = fuse2fs_file_ino(ff, path, fi, &ino);
if (ret)
goto out;
int ret;
FUSE2FS_CHECK_CONTEXT(ff);
- pthread_mutex_lock(&ff->bfl);
+ fuse2fs_start(ff);
ret = __op_open(ff, path, fp);
pthread_mutex_unlock(&ff->bfl);
return ret;
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino,
(intmax_t) offset, len);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
err = ext2fs_file_open(fs, fh->ino, fh->open_flags, &efp);
if (err) {
ret = translate_error(fs, fh->ino, err);
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino,
(intmax_t) offset, (intmax_t) len);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_writeable(fs)) {
ret = -EROFS;
goto out;
FUSE2FS_CHECK_CONTEXT(ff);
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if ((fp->flags & O_SYNC) &&
fs_writeable(fs) &&
FUSE2FS_CHECK_CONTEXT(ff);
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
/* For now, flush everything, even if it's slow */
if (fs_writeable(fs) && fh->open_flags & EXT2_FILE_WRITE) {
err = ext2fs_flush2(fs, 0);
FUSE2FS_CHECK_CONTEXT(ff);
dbg_printf(ff, "%s: path=%s\n", __func__, path);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
buf->f_bsize = fs->blocksize;
buf->f_frsize = 0;
return -ENODATA;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!ext2fs_has_feature_xattr(fs->super)) {
ret = -ENOTSUP;
goto out;
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!ext2fs_has_feature_xattr(fs->super)) {
ret = -ENOTSUP;
goto out;
return -EINVAL;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!ext2fs_has_feature_xattr(fs->super)) {
ret = -ENOTSUP;
goto out;
return -ENODATA;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!ext2fs_has_feature_xattr(fs->super)) {
ret = -ENOTSUP;
goto out;
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d offset=%llu\n", __func__, fh->ino,
(unsigned long long)offset);
- i.fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ i.fs = fuse2fs_start(ff);
i.buf = buf;
i.func = fill_func;
err = ext2fs_dir_iterate2(i.fs, fh->ino, 0, NULL, op_readdir_iter, &i);
FUSE2FS_CHECK_CONTEXT(ff);
dbg_printf(ff, "%s: path=%s mask=0x%x\n", __func__, path, mask);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino);
if (err || ino == 0) {
ret = translate_error(fs, 0, err);
a = *node_name;
*node_name = 0;
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_can_allocate(ff, 1)) {
ret = -ENOSPC;
goto out2;
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d len=%jd\n", __func__, fh->ino,
(intmax_t) len);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_writeable(fs)) {
ret = -EROFS;
goto out;
FUSE2FS_CHECK_CONTEXT(ff);
FUSE2FS_CHECK_HANDLE(ff, fh);
dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
ret = stat_inode(fs, fh->ino, statbuf);
pthread_mutex_unlock(&ff->bfl);
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
ret = fuse2fs_file_ino(ff, path, fi, &ino);
if (ret)
goto out;
FUSE2FS_CHECK_CONTEXT(ff);
FUSE2FS_CHECK_HANDLE(ff, fh);
- pthread_mutex_lock(&ff->bfl);
+ fuse2fs_start(ff);
switch ((unsigned long) cmd) {
#ifdef SUPPORT_I_FLAGS
case EXT2_IOC_GETFLAGS:
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino);
if (err) {
ret = translate_error(fs, 0, err);
FUSE2FS_CHECK_CONTEXT(ff);
FUSE2FS_CHECK_HANDLE(ff, fh);
- fs = ff->fs;
- pthread_mutex_lock(&ff->bfl);
+ fs = fuse2fs_start(ff);
if (!fs_writeable(fs)) {
ret = -EROFS;
goto out;