baruch / diskscan

Scan disk for bad or near failure sectors, performs disk diagnostics
GNU General Public License v3.0
108 stars 29 forks source link

Minimal support for Darwin (OSX) #56

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi, I tried compiling and porting DiskPatch to OSX, apart from errors in CMAKE and time compatibility with the standard library it appears that under /arch the correct file for this architecture has not been developed. It would be nice to have something like a start. I would really like to help if you know where I can get a good documentation/example. (No clue from developer.apple.com)

baruch commented 8 years ago

I'm currently away and we'll be able to look at it later on but initially you may want to utilize the POSIX interface that is available. I believe that there SCSI interfaces are not supported in Mac OS.

Baruch

On Tue, Aug 23, 2016, 17:21 Mc128k notifications@github.com wrote:

Hi, I tried compiling and porting DiskPatch to OSX, apart from errors in CMAKE and time compatibility with the standard library it appears that under /arch the correct file for this architecture has not been developed. It would be nice to have something like a start. I would really like to help if you know where I can get a good documentation/example. (No clue from developer.apple.com)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/baruch/diskscan/issues/56, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIHShxjHX-XxdA4jXH939XIremh053Tks5qix4WgaJpZM4JrHg1 .

baruch commented 8 years ago

Did you try to utilize the posix interface for Darwin?

ghost commented 8 years ago

OSX is a bit different, and yes, I tried a bit and that didn't work well. One thing I saw for example is that for direct access you have to use /dev/rdisk instead of /dev/disk. This is a diagnostic tool, and having caching between the disk and the program is not quite good

ghost commented 7 years ago

One thing, can you please include this in CMakeLists.txt:

include(CheckFunctionExists)

Otherwise cmake complains about the missing function

ghost commented 7 years ago

Also I notice there are some function calls that seem linux-specific:

  "_disk_dev_mount_state", referenced from:
      _disk_mount_allowed in libdiskscanlib.a(diskscan.c.o)
  "_sched_setscheduler", referenced from:
      _set_realtime in libdiskscanlib.a(diskscan.c.o)
  "_verbose", referenced from:
      _diskscan_cli in cli.c.o
      _print_header in cli.c.o
      _disk_scan in libdiskscanlib.a(diskscan.c.o)
      _latency_bucket_prepare in libdiskscanlib.a(diskscan.c.o)
      _disk_scan_latency_stride in libdiskscanlib.a(diskscan.c.o)
      _latency_bucket_finish in libdiskscanlib.a(diskscan.c.o)
      _conclusion_calc in libdiskscanlib.a(diskscan.c.o)
      ...

setscheduler looks like a GNU Library function, I don't know about verbose. disk_dev_mount_state is not declared in the 'generic' architecture, and the compiler complains about it

baruch commented 7 years ago

I can try to add the cmake bit, no problem.

The rest will actually require some work with Mac OS X to resolve properly. Do you know if there is any method to get a remote shell on a mac for such development? Once upon a time sourceforge would provide different unix boxes to access remotely for porting but I never saw such a thing for Macs.

ghost commented 7 years ago

You can virtualize OSX with VirtualBox. It's a bit complicated to get a good image, but it works. VMware player too. There's a patch around.

Anyway maybe I think I can try to fix them. About direct access there's only to change the device name from /dev/disk3 to /dev/rdisk3 (I'll check the docs), the disk mount state can be asked by invoking a shell command (or maybe there's an API for that), but I'm clueless about the scheduler. What is it for exactly? Is the GNU library really needed?

baruch commented 7 years ago

You can probably skip the scheduler, I dont recall right now what it was for but I doubt it is critical.

ghost commented 7 years ago

I corrected some stuff and created a header for the darwin architecture (a copy of the generic one). The program compiles, but it complains about an invalid number of sectors. I'll try to figure that out and come back to you if I get stuck. Hopefully the source will get documented some time

ghost commented 7 years ago

I think I made it work, the progress bar stays silent, but I can see the activity on the hard disk. Also if I interrupt it the graph works fine.

The code I edited is a mess, still I created a darwin architecture like the others and fixed some issues, if you'd like I can share them as .diff