关于fuse的常用启动参数

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

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

   参数比较多一般正常使用需要的命令类似下面即可
   /myfuseexe 源挂载路径 目的挂载路径  -o allow_other -o auto_unmount
   例如
   /myfuseexe /src /data/src -o allow_other -o auto_unmount
   把/src目录挂载到/data/src下
   参数说明
   1allow_other     
   “allow access by all users” 一般是需要加上的否认挂载的目录只能root访问其他用户权限不能访问
   2auto_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 auto_unmount


# 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就可以重新设置自定义日志接口。

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6