I cannot mount some IMAGE on the MacOSX 10.10 via C function mount().
I use following code
JavaScript
x
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() is failed!", GET_FILE_LINE_FUNC_ARG);
}
And when I start the program I get the error “mount() is failed! Error(Operation not supported by device).”
And image was mounted if I use the following command:
JavaScript
sudo hdiutil attach -mountpoint "${MountPointPath}" "${Image}"
Also, when I use mount() on the Linux – All is OK. Following Linux code:
JavaScript
if(mount(m_IMGName.c_str(), m_TargetPath.c_str(), m_FSType.c_str(), 0, m_Opts.c_str())){
throw SysCallTestExeption(errno, "mount() is failed!", GET_FILE_LINE_FUNC_ARG);
}
Advertisement
Answer
There is no hfs+
type in
JavaScript
mount("hfs+", m_TargetPath.c_str(), MNT_RDONLY, &data)
You should use hfs
to handle both HFS and HFS+. Look for example at mount_hfs command source:
JavaScript
#define HFS_MOUNT_TYPE "hfs"