首页 > 解决方案 > 在 macOS 上读取引导扇区 CD 驱动器

问题描述

我正在尝试读取 cd 驱动器的引导扇区,以便提取其内容。不幸的是,无论我做什么,我似乎都无法让它工作。我尝试将目录作为文件读取,但访问被拒绝。尝试从 /dev/disk# 直接读取并被锁定。

我也尝试过检查和更改权限,但没有。

在 Windows 中,我会使用 kernel32 中的 CreateFile 和 ReadFile。我只是不确定 macOS 等价物是什么。

public static List<DriveInfo> GetDrives() => DriveInfo.GetDrives().Where(d => d.IsReady && d.DriveType == DriveType.CDRom).ToList();
public static ReadDrives()
{
  var drives = GetDrives()
  foreach(var drive in drives)
  {
    var root = drive.RootDirectory.FullName;
    using (var fp = File.OpenRead(@"/Volumes/Flash - Copy/"))
    {
       //extract boot here
    }

  }
}

标签: c#macos

解决方案


这不是最好的答案,但这对我有用,不需要 sudo。

至少现在是一个解决方案。

var command = $"-c \"umount {inputDisc} && dd if={inputDisc}  of={outputfile} bs=32k  count=1 && mount {inputDisc}\"";
Process.Start("/bin/bash", command);

推荐阅读