我正在尝试从 C++ 程序中安装 ecryptfs。通过在提示符下发出以下命令,我绝对可以安装它而无需提问:
sudo mount -t ecryptfs -o "rw,key=passphrase:passphrase_passwd=geoff,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=n,ecryptfs_enable_filename_crypto=n,no_sig_cache" ~/source/ ~/target/
请注意,实际上,我正在传递一条完整的规范路径,以防万一。
但是在程序中我errno=EINVAL
尝试使用mount()
具有相同参数的函数后失败了:
mount("~/source/", "~/target/", "ecryptfs", MS_NODEV, "rw,key=passphrase:passphrase_passwd=geoff,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=n,ecryptfs_enable_filename_crypto=n,no_sig_cache")
该程序确实以root
特权启动,并且我检查了我是否有 CAP_SYS_ADMIN。
该mount()
函数返回-1
并设置errno
为EINVAL
。
我的论点正确吗?这可能是特权问题吗?
编辑:我通过在外部执行 mount via 让它工作system()
,但由于某些原因仍想使用该功能。