github_36898934 2016-12-02 01:58 采纳率: 0%
浏览 1326

用mount的api实现mount -t ecryptfs

我想实现"mount -t ecryptfs /test /test"用mount的api来写
代码:
#include
#include
#include
#include

struct DO_MOUNT_t{
char *target;
char *source;
char *ftype;
char *mount_data;
unsigned long mountflags;
};

struct DO_MOUNT_t do_mount = {
.target = "/home/hb/workspace/hb_ecryptfs/src/mountecryptfs",
.source = "/home/hb/workspace/hb_ecryptfs/src/mountecryptfs",
.ftype = "ecryptfs",
.mount_data = "ecryptfs_sig=a72b681d8911efa9,"
"ecryptfs_cipher=aes,"
"ecryptfs_key_bytes=16",
//"ecryptfs_opt_passthrough=n,"
//"ecryptfs_enable_filename_crypto=n",
.mountflags = 0,
};

int main(int argc, char *argv[])
{
int ret;

//printf("111:%s\n", do_mount.mount_data);
ret = mount(do_mount.source, do_mount.target, do_mount.ftype, do_mount.mountflags, do_mount.mount_data);
//ret = sys_mount(do_mount.source, do_mount.target, do_mount.ftype, do_mount.mountflags, do_mount.mount_data);
if( ret < 0 ){
    //if(EBUSY == errno){
        printf("mount failed! error:%s\n", strerror(errno));
    //}
    return -1;  
}

printf("111\n");
//printf("mount %s -> %s success\n", do_mount.source, do_mount.target);
return 0;

}
执行完提示:error:No such file or directory,我猜测是do_mount.data里面的参数没有写对,但是我不知道怎么完善它

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2016-12-31 11:30
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器