static ext2_filsys global_fs; /* Try not to use this directly */
-#undef DEBUG
-
-#ifdef DEBUG
-# define dbg_printf(f, a...) do {printf("FUSE2FS-" f, ## a); \
- fflush(stdout); \
-} while (0)
-#else
-# define dbg_printf(f, a...)
-#endif
+#define dbg_printf(fuse2fs, format, ...) \
+ while ((fuse2fs)->debug) { \
+ printf("FUSE2FS (%s): " format, (fuse2fs)->shortdev, ##__VA_ARGS__); \
+ fflush(stdout); \
+ break; \
+ }
#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
# ifdef _IOR
ext2_filsys fs;
pthread_mutex_t bfl;
char *device;
+ char *shortdev;
int ro;
int debug;
int no_default_opts;
ext2_filsys fs = ff->fs;
blk64_t reserved;
- dbg_printf("%s: Asking for %llu; alloc_all=%d total=%llu free=%llu "
+ dbg_printf(ff, "%s: Asking for %llu; alloc_all=%d total=%llu free=%llu "
"rsvd=%llu\n", __func__, num, ff->alloc_all_blocks,
ext2fs_blocks_count(fs->super),
ext2fs_free_blocks_count(fs->super),
return translate_error(fs, ino, err);
perms = inode.i_mode & 0777;
- dbg_printf("access ino=%d mask=e%s%s%s perms=0%o fuid=%d fgid=%d "
+ dbg_printf(ff, "access ino=%d mask=e%s%s%s perms=0%o fuid=%d fgid=%d "
"uid=%d gid=%d\n", ino,
(mask & R_OK ? "r" : ""), (mask & W_OK ? "w" : ""),
(mask & X_OK ? "x" : ""), perms, inode_uid(inode),
return;
}
fs = ff->fs;
- dbg_printf("%s: dev=%s\n", __func__, fs->device_name);
+ dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name);
if (fs->flags & EXT2_FLAG_RW) {
fs->super->s_state |= EXT2_VALID_FS;
if (fs->super->s_error_count)
return NULL;
}
fs = ff->fs;
- dbg_printf("%s: dev=%s\n", __func__, fs->device_name);
+ dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name);
#ifdef FUSE_CAP_IOCTL_DIR
conn->want |= FUSE_CAP_IOCTL_DIR;
#endif
if (err)
translate_error(fs, 0, err);
}
+ if (ff->debug)
+ cfg->debug = 1;
return ff;
}
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s\n", __func__, path);
+ dbg_printf(ff, "%s: path=%s\n", __func__, path);
pthread_mutex_lock(&ff->bfl);
err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino);
if (err) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s\n", __func__, path);
+ dbg_printf(ff, "%s: path=%s\n", __func__, path);
pthread_mutex_lock(&ff->bfl);
err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino);
if (err || ino == 0) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s mode=0%o dev=0x%x\n", __func__, path, mode,
+ dbg_printf(ff, "%s: path=%s mode=0%o dev=0x%x\n", __func__, path, mode,
(unsigned int)dev);
temp_path = strdup(path);
if (!temp_path) {
goto out2;
}
- dbg_printf("%s: create ino=%d/name=%s in dir=%d\n", __func__, child,
+ dbg_printf(ff, "%s: create ino=%d/name=%s in dir=%d\n", __func__, child,
node_name, parent);
err = ext2fs_link(fs, parent, node_name, child, filetype);
if (err == EXT2_ET_DIR_NO_SPACE) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s mode=0%o\n", __func__, path, mode);
+ dbg_printf(ff, "%s: path=%s mode=0%o\n", __func__, path, mode);
temp_path = strdup(path);
if (!temp_path) {
ret = -ENOMEM;
ret = translate_error(fs, 0, err);
goto out2;
}
- dbg_printf("%s: created ino=%d/path=%s in dir=%d\n", __func__, child,
+ dbg_printf(ff, "%s: created ino=%d/path=%s in dir=%d\n", __func__, child,
node_name, parent);
memset(&inode, 0, sizeof(inode));
return ret;
}
-static int unlink_file_by_name(ext2_filsys fs, const char *path)
+static int unlink_file_by_name(struct fuse2fs *ff, const char *path)
{
+ ext2_filsys fs = ff->fs;
errcode_t err;
ext2_ino_t dir;
char *filename = strdup(path);
return ret;
}
- dbg_printf("%s: unlinking name=%s from dir=%d\n", __func__,
+ dbg_printf(ff, "%s: unlinking name=%s from dir=%d\n", __func__,
base_name, dir);
err = ext2fs_unlink(fs, dir, base_name, 0, 0);
free(filename);
ret = translate_error(fs, ino, err);
goto out;
}
- dbg_printf("%s: put ino=%d links=%d\n", __func__, ino,
+ dbg_printf(ff, "%s: put ino=%d links=%d\n", __func__, ino,
inode.i_links_count);
switch (inode.i_links_count) {
goto out;
}
- ret = unlink_file_by_name(fs, path);
+ ret = unlink_file_by_name(ff, path);
if (ret)
goto out;
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: rmdir path=%s ino=%d\n", __func__, path, child);
+ dbg_printf(ff, "%s: rmdir path=%s ino=%d\n", __func__, path, child);
rds.parent = 0;
rds.empty = 1;
goto out;
}
- ret = unlink_file_by_name(fs, path);
+ ret = unlink_file_by_name(ff, path);
if (ret)
goto out;
/* Directories have to be "removed" twice. */
goto out;
if (rds.parent) {
- dbg_printf("%s: decr dir=%d link count\n", __func__,
+ dbg_printf(ff, "%s: decr dir=%d link count\n", __func__,
rds.parent);
err = ext2fs_read_inode_full(fs, rds.parent,
(struct ext2_inode *)&inode,
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: symlink %s to %s\n", __func__, src, dest);
+ dbg_printf(ff, "%s: symlink %s to %s\n", __func__, src, dest);
temp_path = strdup(dest);
if (!temp_path) {
ret = -ENOMEM;
ret = translate_error(fs, 0, err);
goto out2;
}
- dbg_printf("%s: symlinking ino=%d/name=%s to dir=%d\n", __func__,
+ dbg_printf(ff, "%s: symlinking ino=%d/name=%s to dir=%d\n", __func__,
child, node_name, parent);
memset(&inode, 0, sizeof(inode));
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: renaming %s to %s\n", __func__, from, to);
+ dbg_printf(ff, "%s: renaming %s to %s\n", __func__, from, to);
pthread_mutex_lock(&ff->bfl);
if (!fs_can_allocate(ff, 5)) {
ret = -ENOSPC;
goto out2;
}
- dbg_printf("%s: unlinking %s ino=%d\n", __func__,
+ dbg_printf(ff, "%s: unlinking %s ino=%d\n", __func__,
LINUX_S_ISDIR(inode.i_mode) ? "dir" : "file",
to_ino);
if (LINUX_S_ISDIR(inode.i_mode))
}
/* Link in the new file */
- dbg_printf("%s: linking ino=%d/path=%s to dir=%d\n", __func__,
+ dbg_printf(ff, "%s: linking ino=%d/path=%s to dir=%d\n", __func__,
from_ino, cp + 1, to_dir_ino);
err = ext2fs_link(fs, to_dir_ino, cp + 1, from_ino,
ext2_file_type(inode.i_mode));
if (LINUX_S_ISDIR(inode.i_mode)) {
ud.new_dotdot = to_dir_ino;
- dbg_printf("%s: updating .. entry for dir=%d\n", __func__,
+ dbg_printf(ff, "%s: updating .. entry for dir=%d\n", __func__,
to_dir_ino);
err = ext2fs_dir_iterate2(fs, from_ino, 0, NULL,
update_dotdot_helper, &ud);
}
/* Decrease from_dir_ino's links_count */
- dbg_printf("%s: moving linkcount from dir=%d to dir=%d\n",
+ dbg_printf(ff, "%s: moving linkcount from dir=%d to dir=%d\n",
__func__, from_dir_ino, to_dir_ino);
err = ext2fs_read_inode(fs, from_dir_ino, &inode);
if (err) {
goto out2;
/* Remove the old file */
- ret = unlink_file_by_name(fs, from);
+ ret = unlink_file_by_name(ff, from);
if (ret)
goto out2;
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: src=%s dest=%s\n", __func__, src, dest);
+ dbg_printf(ff, "%s: src=%s dest=%s\n", __func__, src, dest);
temp_path = strdup(dest);
if (!temp_path) {
ret = -ENOMEM;
goto out2;
}
- dbg_printf("%s: linking ino=%d/name=%s to dir=%d\n", __func__, ino,
+ dbg_printf(ff, "%s: linking ino=%d/name=%s to dir=%d\n", __func__, ino,
node_name, parent);
err = ext2fs_link(fs, parent, node_name, ino,
ext2_file_type(inode.i_mode));
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: path=%s mode=0%o ino=%d\n", __func__, path, mode, ino);
+ dbg_printf(ff, "%s: path=%s mode=0%o ino=%d\n", __func__, path, mode, ino);
memset(&inode, 0, sizeof(inode));
err = ext2fs_read_inode_full(fs, ino, (struct ext2_inode *)&inode,
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: path=%s owner=%d group=%d ino=%d\n", __func__,
+ dbg_printf(ff, "%s: path=%s owner=%d group=%d ino=%d\n", __func__,
path, owner, group, ino);
memset(&inode, 0, sizeof(inode));
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d len=%jd\n", __func__, ino, len);
+ dbg_printf(ff, "%s: ino=%d len=%jd\n", __func__, ino, len);
ret = check_inum_access(fs, ino, W_OK);
if (ret)
struct fuse2fs_file_handle *file;
int check = 0, ret = 0;
- dbg_printf("%s: path=%s\n", __func__, path);
+ dbg_printf(ff, "%s: path=%s\n", __func__, path);
err = ext2fs_get_mem(sizeof(*file), &file);
if (err)
return translate_error(fs, 0, err);
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d\n", __func__, file->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, file->ino);
ret = check_inum_access(fs, file->ino, check);
if (ret) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset,
+ dbg_printf(ff, "%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset,
len);
pthread_mutex_lock(&ff->bfl);
err = ext2fs_file_open(fs, fh->ino, fh->open_flags, &efp);
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset,
+ dbg_printf(ff, "%s: ino=%d off=%jd len=%jd\n", __func__, fh->ino, offset,
len);
pthread_mutex_lock(&ff->bfl);
if (!fs_writeable(fs)) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
pthread_mutex_lock(&ff->bfl);
if (fs_writeable(fs) && fh->open_flags & EXT2_FILE_WRITE) {
err = ext2fs_flush2(fs, EXT2_FLAG_FLUSH_NO_SYNC);
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
/* For now, flush everything, even if it's slow */
pthread_mutex_lock(&ff->bfl);
if (fs_writeable(fs) && fh->open_flags & EXT2_FILE_WRITE) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s\n", __func__, path);
+ dbg_printf(ff, "%s: path=%s\n", __func__, path);
buf->f_bsize = fs->blocksize;
buf->f_frsize = 0;
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d\n", __func__, ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, ino);
ret = check_inum_access(fs, ino, R_OK);
if (ret)
ret = translate_error(fs, ino, err);
goto out;
}
- dbg_printf("%s: ino=%d\n", __func__, ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, ino);
ret = check_inum_access(fs, ino, R_OK);
if (ret)
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d\n", __func__, ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, ino);
ret = check_inum_access(fs, ino, W_OK);
if (ret == -EACCES) {
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d\n", __func__, ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, ino);
ret = check_inum_access(fs, ino, W_OK);
if (ret)
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
pthread_mutex_lock(&ff->bfl);
i.buf = buf;
i.func = fill_func;
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s mask=0x%x\n", __func__, path, mask);
+ dbg_printf(ff, "%s: path=%s mask=0x%x\n", __func__, path, mask);
pthread_mutex_lock(&ff->bfl);
err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino);
if (err || ino == 0) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
- dbg_printf("%s: path=%s mode=0%o\n", __func__, path, mode);
+ dbg_printf(ff, "%s: path=%s mode=0%o\n", __func__, path, mode);
temp_path = strdup(path);
if (!temp_path) {
ret = -ENOMEM;
goto out2;
}
- dbg_printf("%s: creating ino=%d/name=%s in dir=%d\n", __func__, child,
+ dbg_printf(ff, "%s: creating ino=%d/name=%s in dir=%d\n", __func__, child,
node_name, parent);
err = ext2fs_link(fs, parent, node_name, child, filetype);
if (err == EXT2_ET_DIR_NO_SPACE) {
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d len=%jd\n", __func__, fh->ino, len);
+ dbg_printf(ff, "%s: ino=%d len=%jd\n", __func__, fh->ino, len);
pthread_mutex_lock(&ff->bfl);
if (!fs_writeable(fs)) {
ret = -EROFS;
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
pthread_mutex_lock(&ff->bfl);
ret = stat_inode(fs, fh->ino, statbuf);
pthread_mutex_unlock(&ff->bfl);
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d\n", __func__, ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, ino);
ret = check_inum_access(fs, ino, W_OK);
if (ret)
}
#ifdef SUPPORT_I_FLAGS
-static int ioctl_getflags(ext2_filsys fs, struct fuse2fs_file_handle *fh,
+static int ioctl_getflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
void *data)
{
+ ext2_filsys fs = ff->fs;
errcode_t err;
struct ext2_inode_large inode;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
memset(&inode, 0, sizeof(inode));
err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode,
sizeof(inode));
EXT2_NOATIME_FL | EXT3_JOURNAL_DATA_FL | EXT2_DIRSYNC_FL | \
EXT2_TOPDIR_FL)
-static int ioctl_setflags(ext2_filsys fs, struct fuse2fs_file_handle *fh,
+static int ioctl_setflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
void *data)
{
+ ext2_filsys fs = ff->fs;
errcode_t err;
struct ext2_inode_large inode;
int ret;
__u32 flags = *(__u32 *)data;
struct fuse_context *ctxt = fuse_get_context();
- struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
memset(&inode, 0, sizeof(inode));
err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode,
sizeof(inode));
return 0;
}
-static int ioctl_getversion(ext2_filsys fs, struct fuse2fs_file_handle *fh,
+static int ioctl_getversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
void *data)
{
+ ext2_filsys fs = ff->fs;
errcode_t err;
struct ext2_inode_large inode;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
memset(&inode, 0, sizeof(inode));
err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode,
sizeof(inode));
return 0;
}
-static int ioctl_setversion(ext2_filsys fs, struct fuse2fs_file_handle *fh,
+static int ioctl_setversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
void *data)
{
+ ext2_filsys fs = ff->fs;
errcode_t err;
struct ext2_inode_large inode;
int ret;
__u32 generation = *(__u32 *)data;
struct fuse_context *ctxt = fuse_get_context();
- struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: ino=%d\n", __func__, fh->ino);
+ dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino);
memset(&inode, 0, sizeof(inode));
err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode,
sizeof(inode));
#endif /* SUPPORT_I_FLAGS */
#ifdef FITRIM
-static int ioctl_fitrim(ext2_filsys fs, struct fuse2fs_file_handle *fh,
+static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
void *data)
{
+ ext2_filsys fs = ff->fs;
struct fstrim_range *fr = data;
blk64_t start, end, max_blocks, b, cleared;
errcode_t err = 0;
start = fr->start / fs->blocksize;
end = (fr->start + fr->len - 1) / fs->blocksize;
- dbg_printf("%s: start=%llu end=%llu\n", __func__, start, end);
+ dbg_printf(ff, "%s: start=%llu end=%llu\n", __func__, start, end);
if (start < fs->super->s_first_data_block)
start = fs->super->s_first_data_block;
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
struct fuse2fs_file_handle *fh =
(struct fuse2fs_file_handle *)(uintptr_t)fp->fh;
- ext2_filsys fs;
int ret = 0;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
pthread_mutex_lock(&ff->bfl);
switch ((unsigned long) cmd) {
#ifdef SUPPORT_I_FLAGS
case EXT2_IOC_GETFLAGS:
- ret = ioctl_getflags(fs, fh, data);
+ ret = ioctl_getflags(ff, fh, data);
break;
case EXT2_IOC_SETFLAGS:
- ret = ioctl_setflags(fs, fh, data);
+ ret = ioctl_setflags(ff, fh, data);
break;
case EXT2_IOC_GETVERSION:
- ret = ioctl_getversion(fs, fh, data);
+ ret = ioctl_getversion(ff, fh, data);
break;
case EXT2_IOC_SETVERSION:
- ret = ioctl_setversion(fs, fh, data);
+ ret = ioctl_setversion(ff, fh, data);
break;
#endif
#ifdef FITRIM
case FITRIM:
- ret = ioctl_fitrim(fs, fh, data);
+ ret = ioctl_fitrim(ff, fh, data);
break;
#endif
default:
- dbg_printf("%s: Unknown ioctl %d\n", __func__, cmd);
+ dbg_printf(ff, "%s: Unknown ioctl %d\n", __func__, cmd);
ret = -ENOTTY;
}
pthread_mutex_unlock(&ff->bfl);
ret = translate_error(fs, 0, err);
goto out;
}
- dbg_printf("%s: ino=%d blk=%"PRIu64"\n", __func__, ino, *idx);
+ dbg_printf(ff, "%s: ino=%d blk=%"PRIu64"\n", __func__, ino, *idx);
err = ext2fs_bmap2(fs, ino, NULL, NULL, 0, *idx, 0, (blk64_t *)idx);
if (err) {
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
start = offset / fs->blocksize;
end = (offset + len - 1) / fs->blocksize;
- dbg_printf("%s: ino=%d mode=0x%x start=%jd end=%llu\n", __func__,
+ dbg_printf(ff, "%s: ino=%d mode=0x%x start=%jd end=%llu\n", __func__,
fh->ino, mode, offset / fs->blocksize, end);
if (!fs_can_allocate(ff, len / fs->blocksize))
return -ENOSPC;
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
- dbg_printf("%s: offset=%jd len=%jd\n", __func__, offset, len);
+ dbg_printf(ff, "%s: offset=%jd len=%jd\n", __func__, offset, len);
/* kernel ext4 punch requires this flag to be set */
if (!(mode & FL_KEEP_SIZE_FLAG))
/* Punch out a bunch of blocks */
start = (offset + fs->blocksize - 1) / fs->blocksize;
end = (offset + len - fs->blocksize) / fs->blocksize;
- dbg_printf("%s: ino=%d mode=0x%x start=%llu end=%llu\n", __func__,
+ dbg_printf(ff, "%s: ino=%d mode=0x%x start=%llu end=%llu\n", __func__,
fh->ino, mode, start, end);
memset(&inode, 0, sizeof(inode));
exit(1);
}
+ /* /dev/sda -> sda for reporting */
+ fctx.shortdev = strrchr(fctx.device, '/');
+ if (fctx.shortdev)
+ fctx.shortdev++;
+ else
+ fctx.shortdev = fctx.device;
+
if (fctx.norecovery)
fctx.ro = 1;
if (fctx.ro)
if (fctx.debug) {
int i;
- printf("fuse arguments:");
+ printf("FUSE2FS (%s): fuse arguments:", fctx.shortdev);
for (i = 0; i < args.argc; i++)
printf(" '%s'", args.argv[i]);
printf("\n");
+ fflush(stdout);
}
pthread_mutex_init(&fctx.bfl, NULL);