c - How to mount image using mount(2) -
i cannot mount image on macosx 10.10 via c function mount().
i use following code
... char imgpath[m_imgname.size() + 1]; memcpy(imgpath, m_imgname.c_str(), m_imgname.size() + 1); struct hfs_mount_args data; data.fspec = imgpath; if(mount("hfs+", m_targetpath.c_str(), mnt_rdonly, &data)){ throw syscalltestexeption(errno, "mount() failed!", get_file_line_func_arg); } ...
and when start program error "mount() failed! error(operation not supported device)."
and image mounted if use following command:
sudo hdiutil attach -mountpoint "${mountpointpath}" "${image}"
also, when use mount() on linux - ok. following linux code:
... if(mount(m_imgname.c_str(), m_targetpath.c_str(), m_fstype.c_str(), 0, m_opts.c_str())){ throw syscalltestexeption(errno, "mount() failed!", get_file_line_func_arg); } ...
there no hfs+
type in
mount("hfs+", m_targetpath.c_str(), mnt_rdonly, &data)
you should use hfs
handle both hfs , hfs+. example @ mount_hfs command source:
#define hfs_mount_type "hfs"
Comments
Post a Comment