• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to read files from disk directly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read files from disk directly?


  • Subject: Re: How to read files from disk directly?
  • From: Ken Hornstein <email@hidden>
  • Date: Sun, 03 Jul 2011 21:27:49 -0400

>So, the primary question I have is when reading the data from my
>device directly, how can I determine exactly what data belongs with
>what file?

I think most people would tell you that this is a terrible idea and to
forget it.  However, I'm not most people :-)

I will say, upfront, that I don't think it's a great idea.  You're setting
yourself up for a lot of complexity and honestly I don't think you'll really
gain a whole lot in terms of performance.  And I don't think Apple will
make any guarantees that the filesystem format is stable, so you might
find your application not working in the future.

But, hey, if you're REALLY determined to do this, here's what I can
tell you:

- I _was_ going to say that there isn't an userspace API which lets you turn
  a filename into a list of physical block offsets.  But on further
  inspection I realize I was wrong, and there _is_ such an API.
  Specifically, fcntl() has a F_LOG2PHYS option.  But I don't think that
  will help you all that much, because to use that you still have to open()
  a file to get a descriptor for that, and you'd have to do a crapload of
  system calls to get all of the physical block offsets and by that point
  you'd probably be better off just reading the damn file yourself.

- If you want an example of something that does close to what you want,
  look at the source code of fsck_hfs (part of diskdev_cmds).  Specifically
  check out what the -B option of fsck_hfs does.  You're probably going
  to have incorporate a fair amount of dfalib into your application if
  you go that route, though.

- The canonical code to map files into disk offsets can of course be found
  in the xnu source code, specifically in bsd/hfs (look at at the function
  hfs_vnop_blockmap, which from what I remember calls some functions down
  in the hfscommon subdirectory).

--Ken
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to read files from disk directly?
      • From: Eric Gorr <email@hidden>
References: 
 >How to read files from disk directly? (From: Eric Gorr <email@hidden>)

  • Prev by Date: How to read files from disk directly?
  • Next by Date: Re: How to read files from disk directly?
  • Previous by thread: How to read files from disk directly?
  • Next by thread: Re: How to read files from disk directly?
  • Index(es):
    • Date
    • Thread