关于fuse的常用启动参数

1、启动fuse用户态守护进程

   参数比较多,一般正常使用需要的命令类似下面即可
   /myfuseexe 源挂载路径 目的挂载路径  -o allow_other -o auto_unmount
   例如:
   /myfuseexe /src /data/src -o allow_other -o auto_unmount
   把/src目录挂载到/data/src下
   参数说明:
   (1)allow_other     
   “allow access by all users” 一般是需要加上的,否认挂载的目录只能root访问,其他用户权限不能访问
   (2)auto_unmount    
   “auto unmount on process termination”
   开发的fuse用户态进程,可能存在异常,添加这个参数,当守护进程异常退出后,会自动卸载挂载的路径。
   也可以不添加这个参数,程序异常退出后就需要手动umount挂载的路径。
   注意:使用这个参数,环境上要有libfuse发布代码util里提供的fusermount命令,这个命令完成异常后的卸载操作。

2、启动的问题,高版本3.0以后,需要在"/etc/fuse.conf“ 配置,才能使能allow_other

cat ./util/fuse.conf
# The file /etc/fuse.conf allows for the following parameters:
#
# user_allow_other - Using the allow_other mount option works fine as root, in
# order to have it work as user you need user_allow_other in /etc/fuse.conf as
# well. (This option allows users to use the allow_other option.) You need
# allow_other if you want users other than the owner to access a mounted fuse.
# This option must appear on a line by itself. There is no value, just the
# presence of the option.

#user_allow_other    //打开才能使用 -o allow_other


# mount_max = n - this option sets the maximum number of mounts.
# Currently (2014) it must be typed exactly as shown
# (with a single space before and after the equals sign).

#mount_max = 1000

3、debug执行

/myfuseexe 源挂载路径 目的挂载路径  -d  -f  -o allow_other -o auto_unmount &
-d:使能debug

-f:前台运行。

添加这两个参数就可以启动默认控制台输出日志信息。

高版本提供了fuse.log文件,用户可封装自定义日志接口,方便信息记录
static void default_log_func(
        __attribute__(( unused )) enum fuse_log_level level,
        const char *fmt, va_list ap)
{
    vfprintf(stderr, fmt, ap);
}

static fuse_log_func_t log_func = default_log_func;

void fuse_set_log_func(fuse_log_func_t func)
{
    if (!func)
        func = default_log_func;

    log_func = func;
}

void fuse_log(enum fuse_log_level level, const char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
    log_func(level, fmt, ap);
    va_end(ap);
}
使用fuse_set_log_func就可以重新设置自定义日志接口。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值