• 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: testing exchangedata
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: testing exchangedata


  • Subject: Re: testing exchangedata
  • From: glenn andreas <email@hidden>
  • Date: Tue, 4 Oct 2005 16:38:14 -0500


On Oct 4, 2005, at 3:39 PM, Gerriet M. Denkmann wrote:

This is not a big problem, because exchangedata sets errno to ENOTSUP in this case.


... and so if exchangedata sets errno EINVAL (or whatever) you should
be able to handle it as well.


Yes. But I want to know whether exchangedata will work (because the file saving machinery of NSDocument will be calling it).

Basically, as near as I can tell, you can't.

Very few kernel functions have "preflighting" versions. You could certainly try to make various user calls that funnel through the various checks that the kernel calls use (in this case, there is "vnode_authorize" plus some other sanity and error handling check) but ultimately it's up to VNOP_EXCHANGE to determine if it is possible or not.

In case it will not work, I want to put up some panel, or do some other actions.

Currently I do:
returnCode = exchangedata( my_file, some_dummy_file);
if ( returnCode == 0 ) exchangedata( some_dummy_file, my_file);
(if all is fine - which is the most probable case - I do two useless exchanges; also I think the dummy file is very ugly - and the idea that something bad might happen between these two exchanges makes me uneasy)
if ( returnCode != 0 && errno == EINVAL ) do something here
(another problem: EINVAL gets set for hard links, but also for other errors)


What I want is:
returnCode = thisIsAHardLink( my_file );
if ( returnCode != 0 ) do something here.


So what happens when this is changed in 10.4.5 (or some other later release) - suddenly your code no longer works.


Not to mention you'll also have to check the volume to make sure that it supports VNOP_EXCHANGE (though that's somewhat easier, but strangely enough, the 10.4 version of the code doesn't check that like the earlier code does - probably was easier to just call VNOP_EXCHANGE and let it return "no").

Maybe fsctl could help me? The man page mentions that requests are filesystem-specific but does not say what request one might make.
Do you have any further information on this?


What about getattrlist()?It has a rather overwhelming man page.

While I'm all in favor of preflighting conditions for various critical/resource intense routines, I'm not convinced that you can do it here, and you've got to handle the fallback of it not working (for other volumes) anyway. I'd take a few steps back, have some tequila, and take a look at your whole strategy here - otherwise you get bogged down on how to build a boat to cross a river when there may be a bridge a mile to the left (or maybe you can just go around the lake instead).



Glenn Andreas email@hidden <http://www.gandreas.com/> wicked fun! Widgetarium | the quickest path to widgets

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


References: 
 >Re: testing exchangedata (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Optimizing PDFKit
  • Next by Date: Asynchronous use of NSPrinter, NSPrintInfo
  • Previous by thread: Re: testing exchangedata
  • Next by thread: SenTestingKit and debugging UnitTests
  • Index(es):
    • Date
    • Thread